summaryrefslogtreecommitdiff
path: root/chapter01/docs/01-grammar.md
diff options
context:
space:
mode:
Diffstat (limited to 'chapter01/docs/01-grammar.md')
-rw-r--r--chapter01/docs/01-grammar.md30
1 files changed, 8 insertions, 22 deletions
diff --git a/chapter01/docs/01-grammar.md b/chapter01/docs/01-grammar.md
index 92ed7357..cf947dfc 100644
--- a/chapter01/docs/01-grammar.md
+++ b/chapter01/docs/01-grammar.md
@@ -4,36 +4,22 @@
grammar SimpleLanguage;
program
- : declaration* statement+ EOF
- ;
-
-declaration
- : type IDENTIFIER ';'
- ;
-
-type
- : 'int'
+ : statement EOF
;
statement
- : 'if' '(' expression ')' statement
- | 'if' '(' expression ')' statement 'else' statement
- | 'while' '(' expression ')' statement
- | IDENTIFIER '=' expression ';'
- | '{' declaration* statement+ '}'
- | 'break' ';'
+ : 'return' expression ';'
;
expression
- : primaryExpression # PrimaryExpression_
- | expression ('*' | '/' ) expression # ArithmeticOrLogicalExpression
- | expression ('+' | '-') expression # ArithmeticOrLogicalExpression
+ : primaryExpression
;
primaryExpression
- :
- | INTEGER_LITERAL
- | IDENTIFIER
- | '(' expression ')'
+ : INTEGER_LITERAL
;
+
+INTEGER_LITERAL
+ : [1-9][0-9]*
+ ;
``` \ No newline at end of file