-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
39 lines (32 loc) · 1.14 KB
/
grammar.txt
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
27
28
29
30
31
32
33
34
35
36
37
38
39
program -> DECLARE declarations IN commands END
declarations -> declarations pidentifier;
| declarations pidentifier(num:num);
|
commands -> commands command
| command
command -> identifier := expression;
| IF condition THEN commands ELSE commands ENDIF
| IF condition THEN commands ENDIF
| WHILE condition DO commands ENDWHILE
| DO commands WHILE condition ENDDO
| FOR pidentifier FROM value TO value DO commands ENDFOR
| FOR pidentifier FROM value DOWNTO value DO commands ENDFOR
| READ identifier;
| WRITE value;
expression -> value
| value + value
| value - value
| value * value
| value / value
| value % value
condition -> value = value
| value != value
| value < value
| value > value
| value <= value
| value >= value
value -> num
| identifier
identifier -> pidentifier
| pidentifier(pidentifier)
| pidentifier(num)