-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths1_bnf.txt
38 lines (35 loc) · 1.22 KB
/
s1_bnf.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
program: (block)*
block: func | ife | ifne | whilee | whilene | statement_list
func: func_name LBR formparams RBR LCBR func_statement_list RCBR
ife: IFE LBR expr RBR LCBR statement_list RCBR
ifne: IFNE LBR expr RBR LCBR statement_list RCBR
whilee: WHIE LBR expr RBR LCBR statement_list RCBR
whilene: WHINE LBR expr RBR LCBR statement_list RCBR
formparams: (var COMMA)* var | EMP
var: ID
func_statement_list: (func_statement | statement)*
statement_list: (statement)*
func_statement: RET expr SEMICOL
statement: block | assign SEMICOL | funcall SEMICOL | LCOMM COMMENT RCOMM | EMP
assign: var ASSIGN expr
funcall: func_name LBR params RBR
func_name: ID
params: (expr COMMA)* expr | EMP
expr: (term (UNION | INTER | DIFF | SYMDIFF))* term
term: funcall | var | set | LBR expr RBR
set: LSBR params RSBR
LBR and RBR - round brackets ( and )
LCBR and RCBR - curly brackets { and }
LCOMM and RCOMM - /* and */
LSBR and RSBR - square brackets [ and ]
IFE - "ife"
IFNE - "ifne"
WHIE - "whilee"
WHINE - "whilene"
RET - "return"
COMMA - comma ,
SEMICOL - semicolon ;
EMP - empty
ID - name of function or variable
ASSIGN - equality sign =
UNION, INTER, DIFF and SYMDIFF - union sign +, intersection sign *, difference sign -, and symmetric difference sign ~