Beispiel #1
0
        public override Node VisitLet([NotNull] TigerParser.LetContext context)
        {
            var node = new LetNode(context);

            TigerParser.DeclsContext[] decls = context.decls();
            var declarations = new DeclarationListNode(decls[0]);

            declarations.Children.AddRange(from d in decls select Visit(d)); // declaration list -> DECLARATION+
            node.Children.Add(declarations);                                 // DECLARATION LIST

            TigerParser.ExprContext[] exprs = context.expr();

            ExpressionSeqNode expressions;

            if (exprs.Length > 0)
            {
                expressions = new ExpressionSeqNode(exprs[0]);
            }
            else
            {
                expressions = new ExpressionSeqNode(-1, -1);
            }

            expressions.Children.AddRange(from e in exprs select Visit(e)); // expression sequence -> EXPRESSION*
            node.Children.Add(expressions);                                 // EXPRESSION SEQUENCE

            return(node);
        }
Beispiel #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>Let</c>
 /// labeled alternative in <see cref="TigerParser.expr"/>.
 /// <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 VisitLet([NotNull] TigerParser.LetContext context)
 {
     return(VisitChildren(context));
 }