// program - returns (functions, generic_functions, type_definitions)

        public new(List <FunctionNode>, List <FunctionNode>, List <TypeDefinitionNode>) VisitProgram([NotNull] functionalParser.ProgramContext context)
        {
            var funcs        = new List <FunctionNode>();
            var genericfuncs = new List <FunctionNode>();
            var aliases      = new List <TypeDefinitionNode>();

            foreach (var d in context.definition())
            {
                var def = Visit(d);
                if (def is null)
                {
                    continue;              // Maat directives
                }
                else if (def is FunctionNode fdef)
                {
                    if (fdef.IsGeneric)
                    {
                        genericfuncs.Add(fdef);
                    }
                    else
                    {
                        funcs.Add(fdef);
                    }
                }
                else if (def is TypeDefinitionNode tdef)
                {
                    aliases.Add(tdef);
                    typeTable.Insert(tdef.Name, tdef.ActualType, tdef.FileAndLine);
                }
            }
            return(funcs, genericfuncs, aliases);
        }
예제 #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="functionalParser.program"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitProgram([NotNull] functionalParser.ProgramContext context)
 {
     return(VisitChildren(context));
 }