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 48f615c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions kclvm/parser/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +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() {
self.sess.struct_span_error(
&format!("unexpected '{:?}'", self.token.kind),
self.token.span,
);
let tok: String = self.token.into();
self.sess
.struct_span_error(&format!("unexpected token '{}'", tok), self.token.span);
self.bump();
}

Expand Down
7 changes: 3 additions & 4 deletions kclvm/parser/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ impl<'a> Parser<'a> {
return Some(stmt);
}

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

None
}
Expand Down

0 comments on commit 48f615c

Please sign in to comment.