public string Visit(NFunCall nFunCall) { string lexeme = nFunCall.AnchorToken.Lexeme; FunctionSym functionSym = semanticAnalyzer.GetFunctionSymbolByLexeme(lexeme); NExprList argumentList = (NExprList)nFunCall[0]; string argumentsPreparation = Visit(argumentList); string prefix = ""; if (functionSym.kind == FunctionSymKind.STANDARD) { prefix = "\t\tcall int64 class ['int64lib']'Int64'.'Utils'::"; } else { prefix = "\t\tcall int64 class 'Int64Program'::"; } string paramTypeList = ""; for (var i = 0; i < argumentList.children.Count; i++) { paramTypeList += "int64"; if (i != argumentList.children.Count - 1) { paramTypeList += ", "; } } if (lexeme == "new") { lexeme = "New"; } return(argumentsPreparation + prefix + "'" + lexeme + "'(" + paramTypeList + ")\n"); }
public void Visit(NFunCall nFunCall) { string lexeme = nFunCall.AnchorToken.Lexeme; FunctionSym functionSym = semanticAnalyzer.GetFunctionSymbolByLexeme(lexeme); NExprList argumentList = (NExprList)nFunCall[0]; if (functionSym != null && functionSym.GetArity() == argumentList.children.Count) { Visit(argumentList); } else { throw new SemanticError("Nonexistent function or signature mismatch", nFunCall.AnchorToken); } }
// Returns NExprList public Node FunCall() { NExprList nExprList = new NExprList(); Expect(TokenCategory.PARENTHESIS_LEFT); if (firstOfExprPrimary.Contains(CurrentToken) || firstOfUnary.Contains(CurrentToken)) { nExprList.Add(Expr()); while (CurrentToken == TokenCategory.COMMA) { Expect(TokenCategory.COMMA); nExprList.Add(Expr()); } } Expect(TokenCategory.PARENTHESIS_RIGHT); return(nExprList); }
//----------------------------------------------------------- public void Visit(NExprList node) { Console.WriteLine($"+++++++++++++++ NExprList ++++++++++++++++"); if (pasones == 2) { foreach (var i in node) { contadorArgumento++; } if (Table[llamadaFuncion].args != contadorArgumento) { throw new SemanticError("expected " + Table[llamadaFuncion].args + $" arguments in function call [{llamadaFuncion}]", errorFunctionCall); } } contadorArgumento = 0; VisitChildren(node); }
public void Visit(NExprList nExprList) { GenericChildVisitor(nExprList); }
public string Visit(NExprList nExprList) { return(GenericChildVisitor(nExprList)); }