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

            var expr    = (ExpressionNode)VisitMultExpr(context.multExpr()[0]);
            var opIndex = 1;

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