summaryrefslogtreecommitdiff
path: root/chapter01/docs/01-grammar.md
blob: c5ddae2c8ab41d089cf29363cceae751f5d74ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Grammar for Chapter 1

```antlrv4
grammar SimpleLanguage;

program
    : statement EOF
    ;

statement
    : 'return' expression ';'
    ;

expression
    : primaryExpression
    ;

primaryExpression
    : INTEGER_LITERAL
    ;

INTEGER_LITERAL
    : [1-9][0-9]*
    | [0]
    ;
```