Exemplo n.º 1
0
        /// <summary>
        /// Visit a parse tree produced by <see cref="Z80EvalParser.multExpr"/>.
        /// <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 VisitMultExpr(Z80EvalParser.MultExprContext context)
        {
            if (IsInvalidContext(context))
            {
                return(null);
            }

            var expr    = (ExpressionNode)VisitUnaryExpr(context.unaryExpr()[0]);
            var opIndex = 1;

            for (var i = 1; i < context.unaryExpr().Length; i++)
            {
                var rightExpr = VisitUnaryExpr(context.unaryExpr()[i]);
                var opToken   = context.GetTokenText(opIndex);
                var multExpr  = opToken == "*"
                    ? new MultiplyOperationNode()
                    : (opToken == "/"
                        ? new DivideOperationNode()
                        : new ModuloOperationNode() as BinaryOperationNode);
                multExpr.LeftOperand  = expr;
                multExpr.RightOperand = (ExpressionNode)rightExpr;
                expr     = multExpr;
                opIndex += 2;
            }
            return(expr);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="Z80EvalParser.multExpr"/>.
 /// <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 VisitMultExpr([NotNull] Z80EvalParser.MultExprContext context)
 {
     return(VisitChildren(context));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="Z80EvalParser.multExpr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitMultExpr([NotNull] Z80EvalParser.MultExprContext context)
 {
 }