Beispiel #1
0
        /// <summary>
        /// Visit a parse tree produced by <see cref="Z80EvalParser.relExpr"/>.
        /// <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 VisitRelExpr(Z80EvalParser.RelExprContext context)
        {
            if (IsInvalidContext(context))
            {
                return(null);
            }

            var expr    = (ExpressionNode)VisitShiftExpr(context.shiftExpr()[0]);
            var opIndex = 1;

            for (var i = 1; i < context.shiftExpr().Length; i++)
            {
                var rightExpr = VisitShiftExpr(context.shiftExpr()[i]);
                var opToken   = context.GetTokenText(opIndex);
                var relExpr   = opToken == "<"
                    ? new LessThanOperationNode()
                    : (opToken == "<="
                        ? new LessThanOrEqualOperationNode()
                        : (opToken == ">"
                            ? new GreaterThanOperationNode()
                            : new GreaterThanOrEqualOperationNode() as BinaryOperationNode));

                relExpr.LeftOperand  = expr;
                relExpr.RightOperand = (ExpressionNode)rightExpr;
                expr     = relExpr;
                opIndex += 2;
            }
            return(expr);
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="Z80EvalParser.relExpr"/>.
 /// <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 VisitRelExpr([NotNull] Z80EvalParser.RelExprContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// Exit a parse tree produced by <see cref="Z80EvalParser.relExpr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitRelExpr([NotNull] Z80EvalParser.RelExprContext context)
 {
 }