Skip to content

Commit 494bcc6

Browse files
committed
🌐 README updated with the new grammar
1 parent 18b152e commit 494bcc6

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

README.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,42 @@ One day hopefully a simple Swift interpreter for the Pascal language inspired by
66
Lexer, parser and interpreter for the following grammar
77

88
````
9-
program : compound_statement DOT
10-
9+
program : PROGRAM variable SEMI block DOT
10+
11+
block : declarations compound_statement
12+
13+
declarations : VAR (variable_declaration SEMI)+
14+
| empty
15+
16+
variable_declaration : ID (COMMA ID)* COLON type_spec
17+
18+
type_spec : INTEGER
19+
1120
compound_statement : BEGIN statement_list END
12-
21+
1322
statement_list : statement
14-
| statement SEMI statement_list
15-
23+
| statement SEMI statement_list
24+
1625
statement : compound_statement
17-
| assignment_statement
18-
| empty
19-
26+
| assignment_statement
27+
| empty
28+
2029
assignment_statement : variable ASSIGN expr
21-
30+
2231
empty :
23-
24-
expr: term ((PLUS | MINUS) term)*
25-
26-
term: factor ((MUL | DIV) factor)*
27-
32+
33+
expr : term ((PLUS | MINUS) term)*
34+
35+
term : factor ((MUL | INTEGER_DIV | FLOAT_DIV) factor)*
36+
2837
factor : PLUS factor
29-
| MINUS factor
30-
| INTEGER
31-
| LPAREN expr RPAREN
32-
| variable
33-
34-
variable: ID
38+
| MINUS factor
39+
| INTEGER_CONST
40+
| REAL_CONST
41+
| LPAREN expr RPAREN
42+
| variable
43+
44+
variable: ID
3545
````
3646

3747
## Try it out

0 commit comments

Comments
 (0)