Minimal typechecking for Binding
This commit is contained in:
parent
59894a1b64
commit
c8d16fc77f
@ -35,9 +35,9 @@
|
|||||||
|
|
||||||
- [x] Parse binding of form `val Type variable = value`
|
- [x] Parse binding of form `val Type variable = value`
|
||||||
- [x] Parse binding of form `Type variable = value`
|
- [x] Parse binding of form `Type variable = value`
|
||||||
- [ ] Infer datatype of `value` in the above for a simple expression
|
- [x] Infer datatype of `value` in the above for a simple expression (minimal)
|
||||||
- [ ] Ensure that the anotated datatype matches the datatype of `value` in the above
|
- [x] Ensure that the anotated datatype matches the datatype of `value` in the above (binding)
|
||||||
- [ ] Infer datatype of a `val variable = value` in the AST: Use the infered datatype
|
- [x] Infer datatype of a `val variable = value` in the AST: Use the infered datatype (binding)
|
||||||
- [x] Formally define the top level constructs
|
- [x] Formally define the top level constructs
|
||||||
- [x] Parse bindings and function declarations as top level constructs
|
- [x] Parse bindings and function declarations as top level constructs
|
||||||
- [x] Parse function declaration arguments (`Type id`)
|
- [x] Parse function declaration arguments (`Type id`)
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -20,7 +20,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thp"
|
name = "thp"
|
||||||
version = "0.0.10"
|
version = "0.0.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"colored",
|
"colored",
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "thp"
|
name = "thp"
|
||||||
version = "0.0.10"
|
version = "0.0.11"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,9 +2,17 @@ use crate::syntax::ast::Expression;
|
|||||||
|
|
||||||
use super::Typed;
|
use super::Typed;
|
||||||
|
|
||||||
|
|
||||||
impl Typed for Expression<'_> {
|
impl Typed for Expression<'_> {
|
||||||
fn get_type(&self) -> String {
|
fn get_type(&self) -> String {
|
||||||
todo!()
|
match self {
|
||||||
|
// TODO: Distinguish between Int & Float
|
||||||
|
Expression::Number(_) => "Int".into(),
|
||||||
|
Expression::String(_) => "String".into(),
|
||||||
|
Expression::Boolean(_) => "Bool".into(),
|
||||||
|
Expression::Identifier(_) => todo!(),
|
||||||
|
Expression::FunctionCall(_) => todo!(),
|
||||||
|
Expression::UnaryOperator(_, _) => todo!(),
|
||||||
|
Expression::BinaryOperator(_, _, _) => todo!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
// This crate provides an interface and implementations
|
// This crate provides an interface and implementations
|
||||||
// for determining the datatypes of the language constructs.
|
// for determining the datatypes of the language constructs.
|
||||||
|
|
||||||
use crate::lexic::token::Token;
|
|
||||||
|
|
||||||
mod expression;
|
mod expression;
|
||||||
|
|
||||||
|
|
||||||
pub trait Typed {
|
pub trait Typed {
|
||||||
fn get_type(&self) -> String;
|
fn get_type(&self) -> String;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user