private FunctionCall ParseOopCall(ParseTreeNode node) { if (node.Term.Name == "OopCall") { var expr = ParsePrefix(node.ChildNodes[0]); var token = node.ChildNodes[1].Token; var name = token.ValueString; var call = new FunctionCall(); call.Arguments.Add(expr); //call.Function = new Ast.Variable() { Name = name, Prefix = expr }; call.Function = new TableAccess { Expression = expr, Index = new StringLiteral { Value = name, lineNumber = token.Location.Line, columnNumber = token.Location.Column, filename = curParseTree.FileName } }; var root = node.ChildNodes[2].ChildNodes[0]; if (root.ChildNodes.Count != 0) { root = root.ChildNodes[0]; while (true) { call.Arguments.Add(ParseExpression(root.ChildNodes[0])); if (root.ChildNodes.Count == 1) break; root = root.ChildNodes[1]; } } return call; } throw new Exception("Invalid OopCall node"); }
private FunctionCall ParseFunctionCall(ParseTreeNode node) { if (node.Term.Name == "FunctionCall") { var expr = ParsePrefix(node.ChildNodes[0]); var call = new FunctionCall(); call.Arguments = new List<IExpression>(); call.Function = expr; var root = node.ChildNodes[1].ChildNodes[0]; if (root.ChildNodes.Count != 0) { root = root.ChildNodes[0]; while (true) { call.Arguments.Add(ParseExpression(root.ChildNodes[0])); if (root.ChildNodes.Count == 1) break; root = root.ChildNodes[1]; } } return call; } throw new Exception("Invalid FunctionCall node"); }