Пример #1
0
        public override Node VisitLogical([NotNull] TigerParser.LogicalContext context)
        {
            LogicalNode node;

            switch (context.op.Text)
            {
            case "&":
                node = new AndNode(context);
                break;

            case "|":
                node = new OrNode(context);
                break;

            default:
                throw new NotSupportedException();
            }

            node.Children.Add(Visit(context.expr(0))); // LEFT EXPRESSION
            node.Children.Add(Visit(context.expr(1))); // RIGHT EXPRESSION
            return(node);
        }
Пример #2
0
 /// <summary>
 /// Visit a parse tree produced by the <c>Logical</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 VisitLogical([NotNull] TigerParser.LogicalContext context)
 {
     return(VisitChildren(context));
 }