Пример #1
0
        /// <summary>
        /// Visit a parse tree produced by <see cref="Z80EvalParser.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 override object VisitExpr(Z80EvalParser.ExprContext context)
        {
            if (IsInvalidContext(context))
            {
                return(null);
            }

            var expr = (ExpressionNode)VisitOrExpr(context.orExpr());

            if (context.ChildCount == 1)
            {
                return(expr);
            }

            return(new ConditionalExpressionNode()
            {
                Condition = expr,
                TrueExpression = (ExpressionNode)VisitExpr(context.expr()[0]),
                FalseExpression = (ExpressionNode)VisitExpr(context.expr()[1])
            });
        }
Пример #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="Z80EvalParser.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 VisitExpr([NotNull] Z80EvalParser.ExprContext context)
 {
     return(VisitChildren(context));
 }
Пример #3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="Z80EvalParser.expr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitExpr([NotNull] Z80EvalParser.ExprContext context)
 {
 }