-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
183 lines (155 loc) · 2.61 KB
/
main.py
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# <VARS>
def vars(p):
'''
vars : tipo_simple vars_2
| tipo_compuesto vars_2
'''
def vars_2(p):
'''
vars_2 : ID vars_3
'''
def vars_3(p):
'''
vars_3 : vars_comma
| LSQRBRACKET CTEINT RSQRBRACKET vars_semicolon
| vars_semicolon
'''
def vars_comma(p):
'''
vars_comma : vars_2
'''
def vars_semicolon(p):
'''
vars_semicolon : vars
| empty
'''
# <FUNCIONES>
def funciones(p):
'''
funciones : tipo_simple FUNCTION LPAREN param RPAREN LBRACKET vars estatutos RETURN LPAREN expresion RPAREN RBRACKET funciones
| VOID FUNCTION LPAREN param RPAREN LBRACKET vars estatutos RBRACKET funciones
| empty
'''
# <EXP>
def exp(p):
'''
exp : t_exp exp_2
'''
def exp_2(p):
'''
exp_2 : OR exp
| empty
'''
# <T_EXP>
def t_exp(p):
'''
t_exp : g_exp t_exp_2
'''
def t_exp_2(p):
'''
t_exp_2 : AND t_exp
| empty
'''
# <G_EXP>
def g_exp(p):
'''
g_exp : m_exp g_exp_2
'''
def g_exp_2(p):
'''
g_exp_2 : GREATER m_exp
| LESS m_exp
| NOTEQUAL m_exp
| EQUAL m_exp
| empty
'''
# <M_EXP>
def m_exp(p):
'''
m_exp : t m_exp_2
'''
def m_exp_2(p):
'''
m_exp_2 : PLUS m_exp
| MINUS m_exp
| empty
'''
# <T>
def t(p):
'''
t : f t_2
'''
def t(p):
'''
t_2 : TIMES t
| DIVIDE t
| empty
'''
# <F>
def f(p):
'''
f : LPAREN exp RPAREN f_2
| CTEI RPAREN f_2
| CTEF RPAREN f_2
| CTESTRING RPAREN f_2
| variable RPAREN f_2
| llamada RPAREN f_2
| ID DOT ID RPAREN f_2
'''
def f_2(p):
'''
f_2 : empty
'''
# <WRITE>
def write(p):
'''
write : LPAREN write_2
'''
def write_2(p):
'''
write_2 : exp RPAREN write_3
| letrero RPAREN write_3
'''
def write_3(p):
'''
write_3 : COMMA write_2
| empty
'''
# <LOOP_COND>
def loop_cond(p):
'''
loop_cond : L_1 loop_cond_2
'''
def loop_cond_2(p):
'''
loop_cond_2 : OR loop_cond
| empty
'''
# <L_1>
def l_1(p):
'''
l_1 : l_2 l_1_2
'''
def l_1_2(p):
'''
l_1_2 : AND l_1
| empty
'''
# <L_2>
def l_2(p):
'''
l_2 : l_3 l_2_2
'''
def l_2_2(p):
'''
l_2_2 : GREATER l_3
| LESS l_3
| NOTEQUAL l_3
| EQUAL l_3
| empty
'''
def l_3(p):
'''
l_3 : CTEI empty
| LPAREN loop_cond RPAREN empty
'''