def p_var_list_item_1(self, p): """var_list_item : ID""" print("""var_list_item -> ID""") p[0] = Nonterminal() p[0].code = "" p[0].vars = [p[1]]
def p_var_list_item_2(self, p): """var_list_item : item1""" print("""var_list_item -> item1""") p[0] = Nonterminal() p[0].code = p[1].code p[0].vars = p[1].vars
def p_var_list_2(self, p): """var_list : var_list_item""" print("""var_list -> var_list_item""") p[0] = Nonterminal() p[0].code = p[1].code p[0].vars = p[1].vars
def p_item1(self, p): """item1 : ID ASSIGNMENT exp""" print("""item1 -> ID ASSIGNMENT exp""") p[0] = Nonterminal() p[0].code = p[3].code + p[1] + " = " + p[3].get_value() + ";\n" p[0].vars = [p[1]]
def p_var_list_1(self, p): """var_list : var_list COMMA var_list_item""" print("""var_list -> var_list COMMA var_list_item""") p[0] = Nonterminal() p[0].code = p[1].code + p[3].code p[0].vars = p[1].vars + p[3].vars