public override AbstractNode VisitFunctionDcl([NotNull] GiraphParser.FunctionDclContext context) { FunctionNode FNode = new FunctionNode(context.Start.Line, context.Start.Column); // Extract the Name of the function, and the return type FNode.Name = context.variable().GetText(); // Name _funcName = FNode.Name; FNode.ReturnType = context.allTypeWithColl().allType().GetText(); // Return Type FNode.IsCollection = context.allTypeWithColl().COLLECTION() != null; // Extract the parameters from the function if (context.formalParams() != null) { foreach (var Parameter in context.formalParams().formalParam()) { var Type = Parameter.allTypeWithColl().allType().GetText(); // Parameter Type var Name = Parameter.variable().GetText(); // Parameter Name bool IsCollection = Parameter.allTypeWithColl().COLLECTION() != null; FNode.AddParameter(Type, Name, IsCollection, context.Start.Line, context.Start.Column); } } foreach (var Child in context.codeBlock().codeBlockContent()) { FNode.AdoptChildren(Visit(Child.GetChild(0))); } return(FNode); }
public override AstNode VisitFunction(ALangParser.FunctionContext context) { var functionNode = new FunctionNode(); functionNode.Identifier = context.ID().GetText(); if (context.@params() != null) { functionNode.Params = context.@params().Accept(this); } functionNode.Type = Type.GetType(context); functionNode.AdoptChildren(context.stmts().Accept(this)); return(functionNode); }