def p_expression_8(p): '''expression : ID''' p[0] = Node('id',[],p[1]) p[0].value = p[1] f = symtab.findS2(p[1]) if f: #print "\n* %s *\n" % dir(f) p[0].typ = f.typ
def p_expression_7(p): '''expression : ID LPAREN expression_list RPAREN''' p[0] = Node('call',[p[3]],p[1]) p[0].value = p[1] #print "dir ",dir(p[1]),"name: ",p[1] f = symtab.findS2(p[1]) ##print "**dir ",dir(f),"name: ",f.name if f: p[0].typ = "int"
def p_stament_8(p): '''stament : ID LPAREN expression_list RPAREN''' #call f=symtab.findS2(p[1]) args = len(p[3].children) if p[3].leaf: args += 1 if not f: print "#Error# Función no declarada '%s' " % (p[1]), if hasattr(f,'lineno'): print "en la linea",f.lineno else: ##print "ARgs= ",args,"len(f.num)=",len(f.numpar) if args != len(f.numpar): print "#Error# Numero de argumentos erroneo en '%s'" % f.name else: if p[3].leaf: #print "adadsdsad: ", p[3].typ , ":::" , f.name,f.numpar if p[3].typ != f.numpar[0]: print "#Error# Tipos de argumentos erroneo en'%s'" % f.name else: for i in range(0,len(p[3].children)): ##print "p[3].children[i]= ",p[3].children[i],p[3].children[i].typ ##print "f.numpar[i+1]: ",f.numpar[i+1] if hasattr(p[3].children[i],'typ'): if p[3].children[i].typ != f.numpar[i+1]: print "#Error# Tipos de argumentos erroneo en'%s'" % f.name break #print "tiene argumentos arG? ",p[3].typ if hasattr(p[3],'typ'): p[0] = Node('',[p[3]],p[1]) p[0].name = p[1] p[0].value = p[1] p[0].call = 1 p[0].typ = p[3].typ else: p[0] = Node('',[p[3]],p[1]) p[0].call = 1 p[0].name = p[1] p[0].value = p[1]