Esempio n. 1
0
 def p_variable_declaration_noin(self, p):
     """variable_declaration_noin : identifier
                                  | identifier initializer_noin
     """
     if len(p) == 2:
         p[0] = ast.VarDecl(p[1],lineno=p.lineno(1))
     else:
         p[0] = ast.VarDecl(p[1], p[2],lineno=p.lineno(1))
Esempio n. 2
0
 def p_variable_declaration(self, p):
     """variable_declaration : identifier
                             | identifier initializer
     """
     if len(p) == 2:
         p[0] = ast.VarDecl(p[1])
     else:
         p[0] = ast.VarDecl(p[1], p[2])
Esempio n. 3
0
 def p_iteration_statement_5(self, p):
     """
     iteration_statement : \
         FOR LPAREN VAR identifier IN expr RPAREN statement
     """
     p[0] = ast.ForIn(
         item=ast.VarDecl(p[4],lineno=p.lineno(4)),
         iterable=p[6], statement=p[8],lineno=p.lineno(4))
Esempio n. 4
0
 def p_iteration_statement_6(self, p):
     """
     iteration_statement \
       : FOR LPAREN VAR identifier initializer_noin IN expr RPAREN statement
     """
     p[0] = ast.ForIn(item=ast.VarDecl(identifier=p[4], initializer=p[5]),
                      iterable=p[7],
                      statement=p[9])