public override Node VisitUser_method(DeltinScriptParser.User_methodContext context) { string name = context.PART(0).GetText(); string[] parameters = new string[context.PART().Length - 1]; for (int i = 0; i < parameters.Length; i++) { parameters[i] = context.PART(i + 1).GetText(); } BlockNode block = (BlockNode)VisitBlock(context.block()); Node node = new UserMethodNode(name, parameters, block, Range.GetRange(context)); CheckRange(node); return(node); }
public UserMethodNode(DeltinScriptParser.User_methodContext context, BuildAstVisitor visitor) : base(new Location(visitor.file, Range.GetRange(context))) { Name = context.name.Text; Type = context.type?.Text; Parameters = new ParameterDefineNode[context.setParameters().parameter_define().Length]; for (int i = 0; i < Parameters.Length; i++) { Parameters[i] = new ParameterDefineNode(context.setParameters().parameter_define(i), visitor); } Block = (BlockNode)visitor.VisitBlock(context.block()); IsRecursive = context.RECURSIVE() != null; Documentation = string.Join("\n\r", context.DOCUMENTATION().Select(doc => doc.GetText().TrimEnd().TrimStart('#', ' '))); AccessLevel = AccessLevel.Private; if (context.accessor() != null) { AccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), context.accessor().GetText(), true); } }