diff --git a/compiler/CHANGELOG.md b/compiler/CHANGELOG.md index f4d0ca5..cd457e3 100644 --- a/compiler/CHANGELOG.md +++ b/compiler/CHANGELOG.md @@ -10,12 +10,16 @@ - [ ] Namespace identifiers in the symbol table - [ ] Stdlib - [ ] Document code -- [ ] Test that the field `position` of the tokens actually points to the start of the token, and not its length + +## v0.0.5 + +- ... ## v0.0.4 - Explicit datatype of variables - Improve error messages when a syntax error is found (show offending line and offending token) +- Show different error messages for val/var binding ## v0.0.3 diff --git a/compiler/Cargo.lock b/compiler/Cargo.lock index 2432e49..2f32110 100644 --- a/compiler/Cargo.lock +++ b/compiler/Cargo.lock @@ -313,7 +313,7 @@ dependencies = [ [[package]] name = "misti" -version = "0.0.3" +version = "0.0.4" dependencies = [ "chrono", "clap", diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index afd5e3c..dc680e0 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "misti" -version = "0.0.3" +version = "0.0.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/compiler/src/syntax/binding.rs b/compiler/src/syntax/binding.rs index 028e708..d573884 100644 --- a/compiler/src/syntax/binding.rs +++ b/compiler/src/syntax/binding.rs @@ -76,7 +76,7 @@ pub fn try_parse<'a>(tokens: &'a Vec, pos: usize) -> Option /* * Equal (=) operator */ - let _equal_operator: &Token = match try_operator(tokens, pos + 2, String::from("=")) { + let equal_operator: &Token = match try_operator(tokens, pos + 2, String::from("=")) { Result3::Ok(t) => t, Result3::Err(t) => { // The parser found a token, but it's not the `=` operator @@ -98,8 +98,11 @@ pub fn try_parse<'a>(tokens: &'a Vec, pos: usize) -> Option let expression = expression::try_parse(tokens, pos + 3); if expression.is_none() { - // TODO: return Error - return None; + return Some(SyntaxResult::Err(SyntaxError { + reason: String::from("Expected an expression after the equal `=` operator"), + error_start: equal_operator.position, + error_end: equal_operator.get_end_position(), + })); } let expression = expression.unwrap();