/// <summary>
        /// Visit a parse tree produced by <see cref="Generated.Z80TestParser.shiftExpr"/>.
        /// </summary>
        /// <param name="context">The parse tree.</param>
        /// <return>The visitor result.</return>
        public override object VisitShiftExpr(Z80TestParser.ShiftExprContext context)
        {
            if (IsInvalidContext(context))
            {
                return(null);
            }

            var expr    = (ExpressionNode)VisitAddExpr(context.addExpr()[0]);
            var opIndex = 1;

            for (var i = 1; i < context.addExpr().Length; i++)
            {
                var rightExpr = VisitAddExpr(context.addExpr()[i]);
                var opToken   = context.GetTokenText(opIndex);
                var shiftExpr = opToken == "<<"
                    ? new ShiftLeftOperationNode(context)
                    : new ShiftRightOperationNode(context) as BinaryOperationNode;
                shiftExpr.LeftOperand  = expr;
                shiftExpr.RightOperand = (ExpressionNode)rightExpr;
                expr     = shiftExpr;
                opIndex += 2;
            }
            return(expr);
        }
 /// <summary>
 /// Exit a parse tree produced by <see cref="Z80TestParser.shiftExpr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitShiftExpr([NotNull] Z80TestParser.ShiftExprContext context)
 {
 }
Exemple #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="Z80TestParser.shiftExpr"/>.
 /// <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 VisitShiftExpr([NotNull] Z80TestParser.ShiftExprContext context)
 {
     return(VisitChildren(context));
 }