Exemplo n.º 1
0
            public override Result VisitMultiplicativeExpression([NotNull] OclParser.MultiplicativeExpressionContext context)
            {
                if (context.multiplyOperator() == null || context.multiplyOperator().Length == 0)
                {
                    return(this.VisitUnaryExpression(context.unaryExpression()[0]));
                }

                Result startMul = this.VisitUnaryExpression(context.unaryExpression()[0]);

                for (int i = 1; i < context.unaryExpression().Length; i++)
                {
                    switch (context.multiplyOperator()[i - 1].Start.Text)
                    {
                    case "*":
                        startMul = startMul.Multiply(this.VisitUnaryExpression(context.unaryExpression()[i]));
                        break;

                    case "/":
                        startMul = startMul.Divide(this.VisitUnaryExpression(context.unaryExpression()[i]));
                        break;
                    }
                }

                return(startMul);
            }
Exemplo n.º 2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="OclParser.multiplicativeExpression"/>.
 /// <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 VisitMultiplicativeExpression([NotNull] OclParser.MultiplicativeExpressionContext context)
 {
     return(VisitChildren(context));
 }