Пример #1
0
        // addExpr op=('+'|'-') multExpr
        public override object VisitAddExpr([NotNull] WSParser.AddExprContext context)
        {
            var left  = Int32.Parse(Visit(context.expr()[0]).ToString());
            var right = Int32.Parse(Visit(context.expr()[1]).ToString());

            switch (context.op.Text)
            {
            case "+":
                return(left + right);

            case "-":
                return(left - right);

            default:
                Console.WriteLine("Unkown op " + context.op.Text);
                break;
            }
            return(base.VisitAddExpr(context));
        }
Пример #2
0
 /// <summary>
 /// Exit a parse tree produced by the <c>AddExpr</c>
 /// labeled alternative in <see cref="WSParser.expr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitAddExpr([NotNull] WSParser.AddExprContext context)
 {
 }
Пример #3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>AddExpr</c>
 /// labeled alternative in <see cref="WSParser.expr"/>.
 /// <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] WSParser.AddExprContext context)
 {
     return(VisitChildren(context));
 }