[Compiler] v0.0.4

This commit is contained in:
Araozu 2023-03-28 10:06:23 -05:00
parent 8a72b9308d
commit e28c608788
4 changed files with 13 additions and 6 deletions

View File

@ -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

2
compiler/Cargo.lock generated
View File

@ -313,7 +313,7 @@ dependencies = [
[[package]]
name = "misti"
version = "0.0.3"
version = "0.0.4"
dependencies = [
"chrono",
"clap",

View File

@ -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

View File

@ -76,7 +76,7 @@ pub fn try_parse<'a>(tokens: &'a Vec<Token>, pos: usize) -> Option<SyntaxResult>
/*
* 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<Token>, pos: usize) -> Option<SyntaxResult>
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();