Browse Source

feat: better statement and binop error messages

master
Garrit Franke 8 months ago
parent
commit
379d8709dc
  1. 5
      src/parser/rules.rs

5
src/parser/rules.rs

@ -229,7 +229,7 @@ impl Parser {
TokenKind::Keyword(Keyword::Struct) => {
Err("Struct definitions inside functions are not allowed".to_string())
}
_ => Err(self.make_error(TokenKind::Unknown, token)),
_ => Err(self.make_error_msg(token.pos, "Failed to parse statement".to_string())),
}
}
@ -581,7 +581,8 @@ impl Parser {
TokenKind::Identifier(_) | TokenKind::Literal(_) | TokenKind::Keyword(_) => {
Ok(Expression::try_from(prev)?)
}
_ => Err(self.make_error(TokenKind::Unknown, prev)),
_ => Err(self
.make_error_msg(prev.pos, "Failed to parse binary operation".to_string())),
}?
}
};

Loading…
Cancel
Save