refactor(lexer, ast): Rewrite decl with c standard grammar of decl

This commit is contained in:
2026-06-12 18:32:13 +08:00
parent 6ff9c804aa
commit 5099bbaab7
4 changed files with 407 additions and 230 deletions
+1 -1
View File
@@ -225,7 +225,7 @@ impl Parser {
self.must_match_token(&TokenValue::LParen, "`(`")?;
let init = if self.peek().value == TokenValue::Semicolon {
None
} else if matches!(self.peek().value, TokenValue::TypeIdent(_)) {
} else if matches!(self.peek().value, TokenValue::Static | TokenValue::TypeIdent(_)) {
Some(ForInit::VarDecl(self.parse_var_decl_stmt_inner(ParseType::MustParse, false)?))
} else {
Some(ForInit::Expr(self.parse_expr()?))