fix(frontend): 规范一下前端实现

This commit is contained in:
jing
2026-03-10 23:03:14 +08:00
parent d2b54a9849
commit c72ffa6e39
8 changed files with 100 additions and 17 deletions

View File

@@ -10,16 +10,24 @@ compUnit
;
funcDef
: Int Main L_PAREN R_PAREN block
: Int Ident L_PAREN R_PAREN block
;
block
: L_BRACE stmt* R_BRACE
: L_BRACE blockItem* R_BRACE
;
blockItem
: decl
| stmt
;
decl
: varDecl
;
stmt
: varDecl
| returnStmt
: returnStmt
;
varDecl
@@ -46,7 +54,6 @@ primary
Int : 'int';
Return : 'return';
Main : 'main';
AddOp : '+';
Assign : '=';