Ejemplo n.º 1
0
 def p_actual_arguments_list_1(self, p):
     """actual_arguments_list : actual_arguments_list COMMA exp"""
     print("""actual_arguments_list -> actual_arguments_list COMMA exp""")
     p[0] = Nonterminal()
     p[0].code = p[1].code + p[3].code
     p[0].args = p[1].args
     p[0].args.append(p[3].get_value())
Ejemplo n.º 2
0
 def p_function_call_1(self, p):
     """function_call : lvalue1 function_call_body"""
     print("""function_call -> lvalue1 function_call_body""")
     p[0] = Nonterminal()
     label = self.new_label()
     p[0].args = p[2].args
     if self.t_counter > -1 :
         for i in range(0, self.t_counter):
             self.FuncVARIABLES.append("TT"+str(i))
     p[0].code = CodeGenerator.storeVariables(self, self.FuncVARIABLES) + CodeGenerator.pushAddress(self,label)
     p[0].code += "// store arguments\n" + p[2].code + CodeGenerator.storeArgs(self,p[2].args)+  "\n goto " + p[1].get_value() + ";\n"
     p[0].place = self.new_temp()
     p[0].code += "// return label:\n" + label + ":\n" + "// load return value\n" + CodeGenerator.popVariable(self,p[0].place) +"\n  //varaiables:" + CodeGenerator.loadVariables(self,self.FuncVARIABLES)
     print(p[0].code)
     print("-------------function call--------------")
Ejemplo n.º 3
0
 def p_actual_arguments_e(self, p):
     """actual_arguments : """
     print("""actual_arguments ->/* Lambda */""")
     p[0] = Nonterminal()
     p[0].code = ""
     p[0].args = ""