Esempio n. 1
0
        public override Node VisitIf([NotNull] TigerParser.IfContext context)
        {
            var node = new IfNode(context);

            node.Children.Add(Visit(context.expr(0))); //IF EXPRESSION
            node.Children.Add(Visit(context.expr(1))); //THEN EXPRESSION

            var elseExpr = context.expr(2);

            node.Children.Add(elseExpr != null ? Visit(elseExpr) : null); //ELSE EXPRESSION if any, otherwise nil
            return(node);
        }
Esempio n. 2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>If</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 VisitIf([NotNull] TigerParser.IfContext context)
 {
     return(VisitChildren(context));
 }