This commit is contained in:
ridethepig 2023-04-28 17:57:40 +08:00
parent 31bf47eb70
commit 7c226f7d91
2 changed files with 20 additions and 20 deletions

10
.vscode/settings.json vendored
View File

@ -2,5 +2,13 @@
"clangd.arguments": [ "clangd.arguments": [
"--compile-commands-dir=${workspaceFolder}/build" "--compile-commands-dir=${workspaceFolder}/build"
], ],
"cmake.configureOnOpen": true "cmake.configureOnOpen": true,
"antlr4.rrd.saveDir": "${workspaceFolder}/build",
"antlr4.atn.saveDir": "${workspaceFolder}/build",
"antlr4.generation": {
"mode": "internal",
"language": "C++",
"listeners": false,
"visitors": true
}
} }

30
SysY.g4
View File

@ -14,7 +14,7 @@ decl
; ;
constDecl constDecl
: CONST_KW bType constDef (COMMA constDef)* SEMICOLON : CONST_KW bType constDef (COMMA constDef)* ';'
; ;
bType bType
@ -31,7 +31,7 @@ constInitVal
; ;
varDecl varDecl
: bType varDef (COMMA varDef)* SEMICOLON : bType varDef (COMMA varDef)* ';'
; ;
varDef varDef
@ -82,11 +82,11 @@ stmt
; ;
assignStmt assignStmt
: lVal ASSIGN exp SEMICOLON : lVal '=' exp ';'
; ;
expStmt expStmt
: exp? SEMICOLON : exp? ';'
; ;
conditionStmt conditionStmt
@ -98,15 +98,15 @@ whileStmt
; ;
breakStmt breakStmt
: BREAK_KW SEMICOLON : BREAK_KW ';'
; ;
continueStmt continueStmt
: CONTINUE_KW SEMICOLON : CONTINUE_KW ';'
; ;
returnStmt returnStmt
: RETURN_KW (exp)? SEMICOLON : RETURN_KW (exp)? ';'
; ;
exp exp
@ -148,8 +148,8 @@ callee
; ;
unaryOp unaryOp
: PLUS : '+'
| MINUS | '-'
| NOT | NOT
; ;
@ -177,8 +177,8 @@ addExp
; // eliminate left-recursive ; // eliminate left-recursive
addOp addOp
: PLUS : '+'
| MINUS | '-'
; ;
relExp relExp
@ -280,14 +280,6 @@ fragment ESC
: '\\"' | '\\\\' : '\\"' | '\\\\'
; ;
PLUS
: '+'
;
MINUS
: '-'
;
NOT NOT
: '!' : '!'
; ;