Пример #1
0
        public override Node VisitFuncDecl([NotNull] TigerParser.FuncDeclContext context)
        {
            var node = new FuncDeclNode(context);

            // ID
            node.Children.Add(
                new IdNode(context.id.Line, context.id.Column, context.id.Text));

            // PARAMS ?
            TigerParser.Type_fieldsContext typeFields = context.type_fields();
            node.Children.Add(
                typeFields == null ?
                null :
                Visit(typeFields));

            // RETURN TYPE ?
            node.Children.Add(
                context.typeId == null ?
                null :
                new IdNode(context.typeId.Line, context.typeId.Column, context.typeId.Text));

            // BODY
            node.Children.Add(Visit(context.expr()));

            return(node);
        }
Пример #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>FuncDecl</c>
 /// labeled alternative in <see cref="TigerParser.func_decl"/>.
 /// <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 VisitFuncDecl([NotNull] TigerParser.FuncDeclContext context)
 {
     return(VisitChildren(context));
 }