Skip to content

Commit

Permalink
refactor: enhance stmt parse errors
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Apr 17, 2024
1 parent 1454ae0 commit 45bcc77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion kclvm/parser/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ impl<'a> Parser<'a> {
/// test: if_expr | simple_expr
pub(crate) fn parse_expr(&mut self) -> NodeRef<Expr> {
if self.token.is_in_recovery_set() {
let tok: String = self.token.into();
self.sess.struct_span_error(
&format!("unexpected '{:?}'", self.token.kind),
&format!("unexpected token '{}'", tok),
self.token.span,
);
self.bump();
Expand Down
3 changes: 2 additions & 1 deletion kclvm/parser/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ impl<'a> Parser<'a> {
return Some(stmt);
}

let tok: String = self.token.into();
self.sess.struct_span_error(
&format!("unexpected '{:?}'", self.token.kind),
&format!("unexpected token '{}'", tok),
self.token.span,
);

Expand Down

0 comments on commit 45bcc77

Please sign in to comment.