-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar
147 lines (108 loc) · 2.2 KB
/
grammar
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#NON_TERMS
S ATRIB BLOCK BLOCO CMD DECL ESCR EXP_AR EXP_COND SENAO EXP_E EXP_NAO EXP_PAR EXP_SIMPLES FUNC_CALL FUNCT FUNCT_C FUNCT_CC FUNCT_S FUNCT_SC GERAL IDI IF LEIT MAIN MENOSP MUL NUM OPC PAR PARAM PAR_CALL PROT PROT_C PROT_S TOMA TYPE TYPEI
#TERMS
!= % ( ) * + , - / ; < <= = == > >= [ ] char const_char const_num const_real const_str e escreve id int le mainha nada nao ou real se senao tome uai vaza { }
#RULES
S GERAL
GERAL PROT FUNCT MAIN
GERAL PROT MAIN
GERAL FUNCT MAIN
GERAL MAIN
PROT PROT_S
PROT PROT_C
FUNCT FUNCT_S
FUNCT FUNCT_C
PROT_S PROT TYPE id ( ) ;
PROT_S TYPE id ( ) ;
PROT_C PROT TYPE id ( PARAM ) ;
PROT_C TYPE id ( PARAM ) ;
FUNCT_S FUNCT FUNCT_SC
FUNCT_S FUNCT_SC
FUNCT_SC TYPE id ( ) { BLOCK }
FUNCT_SC TYPE id ( ) { }
FUNCT_C FUNCT FUNCT_CC
FUNCT_C FUNCT_CC
FUNCT_CC TYPE id ( PARAM ) { BLOCK }
FUNCT_CC TYPE id ( PARAM ) { }
MAIN int mainha ( ) { BLOCK }
MAIN int mainha ( ) { }
TOMA tome EXP_AR
TOMA tome
BLOCK DECL BLOCO
BLOCK BLOCO
BLOCK DECL
BLOCO BLOCO CMD
BLOCO CMD
CMD IF
CMD uai ( EXP_COND ) { BLOCO }
CMD uai ( EXP_COND ) { }
CMD ATRIB ;
CMD LEIT ;
CMD ESCR ;
CMD TOMA ;
CMD vaza ;
CMD FUNC_CALL ;
IF se ( EXP_COND ) { BLOCO } SENAO
IF se ( EXP_COND ) { BLOCO }
IF se ( EXP_COND ) { } SENAO
IF se ( EXP_COND ) { }
SENAO senao { BLOCO }
SENAO senao { }
ATRIB id = EXP_AR
ATRIB id [ EXP_AR ] = EXP_AR
LEIT le ( id )
LEIT le ( id [ EXP_AR ] )
ESCR escreve ( EXP_AR )
ESCR escreve ( const_str )
DECL DECL TYPEI IDI ;
DECL TYPEI IDI ;
IDI id
IDI id [ EXP_AR ]
IDI id = EXP_AR
PARAM PARAM , PAR
PARAM PAR
PAR TYPEI id
PAR TYPEI id [ ]
TYPE int
TYPE real
TYPE char
TYPE nada
TYPEI int
TYPEI real
TYPEI char
PAR_CALL PAR_CALL , EXP_AR
PAR_CALL EXP_AR
EXP_AR EXP_AR + MUL
EXP_AR EXP_AR - MUL
EXP_AR MUL
MUL MUL * MENOSP
MUL MUL / MENOSP
MUL MUL % MENOSP
MUL MENOSP
MENOSP ( EXP_AR )
MENOSP - ( EXP_AR )
MENOSP - NUM
MENOSP NUM
NUM id
NUM id [ EXP_AR ]
NUM FUNC_CALL
NUM const_num
NUM const_real
NUM const_char
EXP_COND EXP_COND ou EXP_E
EXP_COND EXP_E
EXP_E EXP_E e EXP_NAO
EXP_E EXP_NAO
EXP_NAO nao EXP_NAO
EXP_NAO EXP_PAR
EXP_PAR ( EXP_COND )
EXP_PAR EXP_SIMPLES
EXP_SIMPLES EXP_AR OPC EXP_AR
OPC <
OPC <=
OPC >
OPC >=
OPC ==
OPC !=
FUNC_CALL id ( PAR_CALL )
FUNC_CALL id ( )