-
Notifications
You must be signed in to change notification settings - Fork 0
/
description.txt
114 lines (89 loc) · 1.8 KB
/
description.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
Tokens:
ID: [a-z][A-Za-z0-9]*
LP: '('
RP: ')'
INT_LITERAL: [0-9]+|B[0-1]+
STRING_LITERAL: ".*"
BOOL_LITERAL: True|False
INT: Int
BOOL: Bool
STRING: String
FUNC: Func
VAR: Var
ASSIGN: :=
IF: If
ELSE: Else
WHILE: While
LB: '{'
RB: '}'
OR: ||
AND: &&
NOT: !
EQ: ==
NE: /=
LE: <=
LESS: <
GE: >=
GREATER: GE
PLUS: +
MINUS: -
MULT: *
DIV: /
UNARY_MINUS: -
POW: ^
func_call: ID params
params: LP experssion_list RP
| LP void RP
func_decl: FUNC ID type_params_list -> type {statement}
type: BOOL
| INT
| STRING
type_params_list: LP (type ID)*, type ID RP | LP RP
assign_statement: ID ASSIGN expression
decl_statement: VAR Type assign_statement
if_statement: IF LR expression RP {statement} |
IF LR expression RP {statement} else {statement}
while_statement: WHILE LR expression RP {statement}
single_statement: skip;
| expression;
| assign_statement;
| decl_statement;
| while_statement
| if_statement
statement: single_statement statement
| single_statement
literal: INT_LITERAL
| STRING_LITERAL
| BOOL_LITERAL
value: ID
| literal
| func_call
expression: expression1 OR expression
| expression1
expression1: experssion2 AND expression
| expression2
expression2: NOT expression3
| expression3
expression3: expression4 EQ expression4
| expression4 NE expression4
| expression4 LESS expression4
| expression4 LE expression4
| expression4 GREATER expression4
| expression4 GE expression4
| expression4
expression4: expression4 PLUS expression5
| expression4 MINUS expression5
| expression5
expression5: expression5 MULT expression6
| expression5 DIV expression6
| expression6
expression6: UNARY_MINUS expression7
| expression7
expression7: expression7 POW expression8
| expression8
expression8: value
| LP expression RP
start: PROG
PROG = func_decl_sequence
func_decl_sequence = func_decl
| func_dec_sequence func_decl