示例#1
0
        public override object VisitNegate(NegateContext context)
        {
            var r    = (new Result());
            var expr = (Result)(Visit(context.expression()));

            r.data = expr.data;
            r.text = "!" + expr.text;
            return(r);
        }
示例#2
0
    public NegateContext negate()
    {
        NegateContext _localctx = new NegateContext(Context, State);

        EnterRule(_localctx, 6, RULE_negate);
        try {
            State = 42;
            ErrorHandler.Sync(this);
            switch (TokenStream.LA(1))
            {
            case ADDOP:
                _localctx = new AddopNegateContext(_localctx);
                EnterOuterAlt(_localctx, 1);
                {
                    State = 39;
                    Match(ADDOP);
                    State = 40;
                    negate();
                }
                break;

            case NUM:
            case LP:
                _localctx = new NegateToPowerContext(_localctx);
                EnterOuterAlt(_localctx, 2);
                {
                    State = 41;
                    power();
                }
                break;

            default:
                throw new NoViableAltException(this);
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
示例#3
0
 public NegateToPowerContext(NegateContext context)
 {
     CopyFrom(context);
 }
示例#4
0
 public AddopNegateContext(NegateContext context)
 {
     CopyFrom(context);
 }
示例#5
0
 public virtual void CopyFrom(NegateContext context)
 {
     base.CopyFrom(context);
 }