summaryrefslogtreecommitdiff
path: root/Compiler/CGrammar.g4
diff options
context:
space:
mode:
Diffstat (limited to 'Compiler/CGrammar.g4')
-rw-r--r--Compiler/CGrammar.g48
1 files changed, 2 insertions, 6 deletions
diff --git a/Compiler/CGrammar.g4 b/Compiler/CGrammar.g4
index aec4694..484cc90 100644
--- a/Compiler/CGrammar.g4
+++ b/Compiler/CGrammar.g4
@@ -14,11 +14,6 @@ function
: 'int' name=ID '(' ')' block
;
-body
- : statement
- | block
- ;
-
block
: '{' block_item* '}'
;
@@ -30,8 +25,9 @@ block_item
statement
: 'return' expression ';' #returnStatement
- | 'if' '(' expression ')' then=body ('else' else=body) #ifStatement
+ | 'if' '(' expression ')' then=statement ('else' else=statement)? #ifStatement
| expression #expressionStatement
+ | block #blockStatement
;