diff --git a/.vscode/settings.json b/.vscode/settings.json index 25afd79..c8e22fd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,13 @@ "clangd.arguments": [ "--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 + } } \ No newline at end of file diff --git a/SysY.g4 b/SysY.g4 index dc1fb33..8320d48 100644 --- a/SysY.g4 +++ b/SysY.g4 @@ -14,7 +14,7 @@ decl ; constDecl - : CONST_KW bType constDef (COMMA constDef)* SEMICOLON + : CONST_KW bType constDef (COMMA constDef)* ';' ; bType @@ -31,7 +31,7 @@ constInitVal ; varDecl - : bType varDef (COMMA varDef)* SEMICOLON + : bType varDef (COMMA varDef)* ';' ; varDef @@ -82,11 +82,11 @@ stmt ; assignStmt - : lVal ASSIGN exp SEMICOLON + : lVal '=' exp ';' ; expStmt - : exp? SEMICOLON + : exp? ';' ; conditionStmt @@ -98,15 +98,15 @@ whileStmt ; breakStmt - : BREAK_KW SEMICOLON + : BREAK_KW ';' ; continueStmt - : CONTINUE_KW SEMICOLON + : CONTINUE_KW ';' ; returnStmt - : RETURN_KW (exp)? SEMICOLON + : RETURN_KW (exp)? ';' ; exp @@ -148,8 +148,8 @@ callee ; unaryOp - : PLUS - | MINUS + : '+' + | '-' | NOT ; @@ -177,8 +177,8 @@ addExp ; // eliminate left-recursive addOp - : PLUS - | MINUS + : '+' + | '-' ; relExp @@ -280,14 +280,6 @@ fragment ESC : '\\"' | '\\\\' ; -PLUS - : '+' - ; - -MINUS - : '-' - ; - NOT : '!' ;