Exemplo n.º 1
0
        public override ASTNode VisitFundef([NotNull] llangParser.FundefContext context)
        {
            string            funname  = context.Iden().GetText();
            List <string>     args     = new List <string>();
            List <TypeSymbol> argtypes = new List <TypeSymbol>();
            TypeSymbol        rettype  = TypeSymbol.INFER_SYMOBOL(context.typename().GetText());

            if (context.defargslist() != null)
            {
                foreach (llangParser.DefargitemContext c in context.defargslist().defargitem())
                {
                    args.Add(c.Iden().GetText());
                    argtypes.Add(TypeSymbol.INFER_SYMOBOL(c.typename().GetText()));
                }
            }

            TypeSymbol functionType = TypeSymbol.FUNCTION_SYMBOL(funname, funname, rettype, argtypes);

            Statement body = (Statement)Visit(context.block());

            return(new FunDefNode(funname, args, argtypes, rettype, body, MakeSourceLoc(context)));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="llangParser.fundef"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitFundef([NotNull] llangParser.FundefContext context)
 {
 }
Exemplo n.º 3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="llangParser.fundef"/>.
 /// <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 VisitFundef([NotNull] llangParser.FundefContext context)
 {
     return(VisitChildren(context));
 }