-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathOpsParser.java
More file actions
721 lines (694 loc) · 25.8 KB
/
Copy pathMathOpsParser.java
File metadata and controls
721 lines (694 loc) · 25.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
// Generated from C:/Users/khali/OneDrive/Documents/CS 320/Coding Assignment 3-1/src/MathOps.g4 by ANTLR 4.13.1
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"})
public class MathOpsParser extends Parser {
static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
SCIENTIFIC_NUMBER=1, BASE10=2, BASEe=3, SIN=4, COS=5, TAN=6, ASIN=7, ACOS=8,
ATAN=9, SINH=10, COSH=11, TANH=12, FACTORIAL=13, LPAREN=14, RPAREN=15,
PLUS=16, MINUS=17, TIMES=18, DIV=19, POW=20, WS=21;
public static final int
RULE_file_ = 0, RULE_expression = 1, RULE_atom = 2, RULE_scientific = 3;
private static String[] makeRuleNames() {
return new String[] {
"file_", "expression", "atom", "scientific"
};
}
public static final String[] ruleNames = makeRuleNames();
private static String[] makeLiteralNames() {
return new String[] {
null, null, "'log'", "'ln'", "'sin'", "'cos'", "'tan'", "'asin'", "'acos'",
"'atan'", "'sinh'", "'cosh'", "'tanh'", "'!'", "'('", "')'", "'+'", "'-'",
"'x'", "'\\u00F7'", "'**'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, "SCIENTIFIC_NUMBER", "BASE10", "BASEe", "SIN", "COS", "TAN", "ASIN",
"ACOS", "ATAN", "SINH", "COSH", "TANH", "FACTORIAL", "LPAREN", "RPAREN",
"PLUS", "MINUS", "TIMES", "DIV", "POW", "WS"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null) {
tokenNames[i] = "<INVALID>";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
@Override
public String getGrammarFileName() { return "MathOps.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public MathOpsParser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
@SuppressWarnings("CheckReturnValue")
public static class File_Context extends ParserRuleContext {
public File_Context(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_file_; }
public File_Context() { }
public void copyFrom(File_Context ctx) {
super.copyFrom(ctx);
}
}
@SuppressWarnings("CheckReturnValue")
public static class FinalExprContext extends File_Context {
public ExpressionContext epr;
public List<ExpressionContext> expression() {
return getRuleContexts(ExpressionContext.class);
}
public ExpressionContext expression(int i) {
return getRuleContext(ExpressionContext.class,i);
}
public FinalExprContext(File_Context ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterFinalExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitFinalExpr(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitFinalExpr(this);
else return visitor.visitChildren(this);
}
}
public final File_Context file_() throws RecognitionException {
File_Context _localctx = new File_Context(_ctx, getState());
enterRule(_localctx, 0, RULE_file_);
int _la;
try {
_localctx = new FinalExprContext(_localctx);
enterOuterAlt(_localctx, 1);
{
setState(11);
_errHandler.sync(this);
_la = _input.LA(1);
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 155646L) != 0)) {
{
{
setState(8);
((FinalExprContext)_localctx).epr = expression(0);
}
}
setState(13);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
@SuppressWarnings("CheckReturnValue")
public static class ExpressionContext extends ParserRuleContext {
public ExpressionContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_expression; }
public ExpressionContext() { }
public void copyFrom(ExpressionContext ctx) {
super.copyFrom(ctx);
}
}
@SuppressWarnings("CheckReturnValue")
public static class ParenContext extends ExpressionContext {
public TerminalNode LPAREN() { return getToken(MathOpsParser.LPAREN, 0); }
public ExpressionContext expression() {
return getRuleContext(ExpressionContext.class,0);
}
public TerminalNode RPAREN() { return getToken(MathOpsParser.RPAREN, 0); }
public ParenContext(ExpressionContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterParen(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitParen(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitParen(this);
else return visitor.visitChildren(this);
}
}
@SuppressWarnings("CheckReturnValue")
public static class NegationContext extends ExpressionContext {
public ExpressionContext right;
public TerminalNode MINUS() { return getToken(MathOpsParser.MINUS, 0); }
public ExpressionContext expression() {
return getRuleContext(ExpressionContext.class,0);
}
public NegationContext(ExpressionContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterNegation(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitNegation(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitNegation(this);
else return visitor.visitChildren(this);
}
}
@SuppressWarnings("CheckReturnValue")
public static class FuncContext extends ExpressionContext {
public Token op;
public ExpressionContext right;
public TerminalNode LPAREN() { return getToken(MathOpsParser.LPAREN, 0); }
public TerminalNode RPAREN() { return getToken(MathOpsParser.RPAREN, 0); }
public ExpressionContext expression() {
return getRuleContext(ExpressionContext.class,0);
}
public TerminalNode SIN() { return getToken(MathOpsParser.SIN, 0); }
public TerminalNode COS() { return getToken(MathOpsParser.COS, 0); }
public TerminalNode TAN() { return getToken(MathOpsParser.TAN, 0); }
public TerminalNode ASIN() { return getToken(MathOpsParser.ASIN, 0); }
public TerminalNode ACOS() { return getToken(MathOpsParser.ACOS, 0); }
public TerminalNode ATAN() { return getToken(MathOpsParser.ATAN, 0); }
public TerminalNode SINH() { return getToken(MathOpsParser.SINH, 0); }
public TerminalNode COSH() { return getToken(MathOpsParser.COSH, 0); }
public TerminalNode TANH() { return getToken(MathOpsParser.TANH, 0); }
public TerminalNode BASE10() { return getToken(MathOpsParser.BASE10, 0); }
public TerminalNode BASEe() { return getToken(MathOpsParser.BASEe, 0); }
public FuncContext(ExpressionContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterFunc(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitFunc(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitFunc(this);
else return visitor.visitChildren(this);
}
}
@SuppressWarnings("CheckReturnValue")
public static class MulDivContext extends ExpressionContext {
public Token op;
public List<ExpressionContext> expression() {
return getRuleContexts(ExpressionContext.class);
}
public ExpressionContext expression(int i) {
return getRuleContext(ExpressionContext.class,i);
}
public TerminalNode TIMES() { return getToken(MathOpsParser.TIMES, 0); }
public TerminalNode DIV() { return getToken(MathOpsParser.DIV, 0); }
public MulDivContext(ExpressionContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterMulDiv(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitMulDiv(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitMulDiv(this);
else return visitor.visitChildren(this);
}
}
@SuppressWarnings("CheckReturnValue")
public static class AddSubContext extends ExpressionContext {
public Token op;
public List<ExpressionContext> expression() {
return getRuleContexts(ExpressionContext.class);
}
public ExpressionContext expression(int i) {
return getRuleContext(ExpressionContext.class,i);
}
public TerminalNode PLUS() { return getToken(MathOpsParser.PLUS, 0); }
public TerminalNode MINUS() { return getToken(MathOpsParser.MINUS, 0); }
public AddSubContext(ExpressionContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterAddSub(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitAddSub(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitAddSub(this);
else return visitor.visitChildren(this);
}
}
@SuppressWarnings("CheckReturnValue")
public static class NumContext extends ExpressionContext {
public AtomContext atom() {
return getRuleContext(AtomContext.class,0);
}
public NumContext(ExpressionContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterNum(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitNum(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitNum(this);
else return visitor.visitChildren(this);
}
}
@SuppressWarnings("CheckReturnValue")
public static class PowContext extends ExpressionContext {
public ExpressionContext left;
public Token op;
public ExpressionContext right;
public List<ExpressionContext> expression() {
return getRuleContexts(ExpressionContext.class);
}
public ExpressionContext expression(int i) {
return getRuleContext(ExpressionContext.class,i);
}
public TerminalNode POW() { return getToken(MathOpsParser.POW, 0); }
public PowContext(ExpressionContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterPow(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitPow(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitPow(this);
else return visitor.visitChildren(this);
}
}
@SuppressWarnings("CheckReturnValue")
public static class FactContext extends ExpressionContext {
public Token op;
public ExpressionContext expression() {
return getRuleContext(ExpressionContext.class,0);
}
public TerminalNode FACTORIAL() { return getToken(MathOpsParser.FACTORIAL, 0); }
public FactContext(ExpressionContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterFact(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitFact(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitFact(this);
else return visitor.visitChildren(this);
}
}
public final ExpressionContext expression() throws RecognitionException {
return expression(0);
}
private ExpressionContext expression(int _p) throws RecognitionException {
ParserRuleContext _parentctx = _ctx;
int _parentState = getState();
ExpressionContext _localctx = new ExpressionContext(_ctx, _parentState);
ExpressionContext _prevctx = _localctx;
int _startState = 2;
enterRecursionRule(_localctx, 2, RULE_expression, _p);
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(27);
_errHandler.sync(this);
switch (_input.LA(1)) {
case SCIENTIFIC_NUMBER:
{
_localctx = new NumContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(15);
atom();
}
break;
case BASE10:
case BASEe:
case SIN:
case COS:
case TAN:
case ASIN:
case ACOS:
case ATAN:
case SINH:
case COSH:
case TANH:
{
_localctx = new FuncContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(16);
((FuncContext)_localctx).op = _input.LT(1);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 8188L) != 0)) ) {
((FuncContext)_localctx).op = (Token)_errHandler.recoverInline(this);
}
else {
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
setState(17);
match(LPAREN);
setState(18);
((FuncContext)_localctx).right = expression(0);
setState(19);
match(RPAREN);
}
break;
case MINUS:
{
_localctx = new NegationContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(21);
match(MINUS);
setState(22);
((NegationContext)_localctx).right = expression(4);
}
break;
case LPAREN:
{
_localctx = new ParenContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(23);
match(LPAREN);
setState(24);
expression(0);
setState(25);
match(RPAREN);
}
break;
default:
throw new NoViableAltException(this);
}
_ctx.stop = _input.LT(-1);
setState(42);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,3,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( _parseListeners!=null ) triggerExitRuleEvent();
_prevctx = _localctx;
{
setState(40);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) {
case 1:
{
_localctx = new PowContext(new ExpressionContext(_parentctx, _parentState));
((PowContext)_localctx).left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_expression);
setState(29);
if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)");
setState(30);
((PowContext)_localctx).op = match(POW);
setState(31);
((PowContext)_localctx).right = expression(6);
}
break;
case 2:
{
_localctx = new MulDivContext(new ExpressionContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expression);
setState(32);
if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)");
setState(33);
((MulDivContext)_localctx).op = _input.LT(1);
_la = _input.LA(1);
if ( !(_la==TIMES || _la==DIV) ) {
((MulDivContext)_localctx).op = (Token)_errHandler.recoverInline(this);
}
else {
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
setState(34);
expression(4);
}
break;
case 3:
{
_localctx = new AddSubContext(new ExpressionContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expression);
setState(35);
if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)");
setState(36);
((AddSubContext)_localctx).op = _input.LT(1);
_la = _input.LA(1);
if ( !(_la==PLUS || _la==MINUS) ) {
((AddSubContext)_localctx).op = (Token)_errHandler.recoverInline(this);
}
else {
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
_errHandler.reportMatch(this);
consume();
}
setState(37);
expression(3);
}
break;
case 4:
{
_localctx = new FactContext(new ExpressionContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expression);
setState(38);
if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)");
setState(39);
((FactContext)_localctx).op = match(FACTORIAL);
}
break;
}
}
}
setState(44);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,3,_ctx);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
unrollRecursionContexts(_parentctx);
}
return _localctx;
}
@SuppressWarnings("CheckReturnValue")
public static class AtomContext extends ParserRuleContext {
public ScientificContext scientific() {
return getRuleContext(ScientificContext.class,0);
}
public AtomContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_atom; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterAtom(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitAtom(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitAtom(this);
else return visitor.visitChildren(this);
}
}
public final AtomContext atom() throws RecognitionException {
AtomContext _localctx = new AtomContext(_ctx, getState());
enterRule(_localctx, 4, RULE_atom);
try {
enterOuterAlt(_localctx, 1);
{
setState(45);
scientific();
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
@SuppressWarnings("CheckReturnValue")
public static class ScientificContext extends ParserRuleContext {
public TerminalNode SCIENTIFIC_NUMBER() { return getToken(MathOpsParser.SCIENTIFIC_NUMBER, 0); }
public ScientificContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_scientific; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).enterScientific(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof MathOpsListener ) ((MathOpsListener)listener).exitScientific(this);
}
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof MathOpsVisitor ) return ((MathOpsVisitor<? extends T>)visitor).visitScientific(this);
else return visitor.visitChildren(this);
}
}
public final ScientificContext scientific() throws RecognitionException {
ScientificContext _localctx = new ScientificContext(_ctx, getState());
enterRule(_localctx, 6, RULE_scientific);
try {
enterOuterAlt(_localctx, 1);
{
setState(47);
match(SCIENTIFIC_NUMBER);
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
case 1:
return expression_sempred((ExpressionContext)_localctx, predIndex);
}
return true;
}
private boolean expression_sempred(ExpressionContext _localctx, int predIndex) {
switch (predIndex) {
case 0:
return precpred(_ctx, 5);
case 1:
return precpred(_ctx, 3);
case 2:
return precpred(_ctx, 2);
case 3:
return precpred(_ctx, 6);
}
return true;
}
public static final String _serializedATN =
"\u0004\u0001\u00152\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
"\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0001\u0000\u0005\u0000\n\b"+
"\u0000\n\u0000\f\u0000\r\t\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0003\u0001\u001c\b\u0001\u0001"+
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0005\u0001)\b"+
"\u0001\n\u0001\f\u0001,\t\u0001\u0001\u0002\u0001\u0002\u0001\u0003\u0001"+
"\u0003\u0001\u0003\u0000\u0001\u0002\u0004\u0000\u0002\u0004\u0006\u0000"+
"\u0003\u0001\u0000\u0002\f\u0001\u0000\u0012\u0013\u0001\u0000\u0010\u0011"+
"5\u0000\u000b\u0001\u0000\u0000\u0000\u0002\u001b\u0001\u0000\u0000\u0000"+
"\u0004-\u0001\u0000\u0000\u0000\u0006/\u0001\u0000\u0000\u0000\b\n\u0003"+
"\u0002\u0001\u0000\t\b\u0001\u0000\u0000\u0000\n\r\u0001\u0000\u0000\u0000"+
"\u000b\t\u0001\u0000\u0000\u0000\u000b\f\u0001\u0000\u0000\u0000\f\u0001"+
"\u0001\u0000\u0000\u0000\r\u000b\u0001\u0000\u0000\u0000\u000e\u000f\u0006"+
"\u0001\uffff\uffff\u0000\u000f\u001c\u0003\u0004\u0002\u0000\u0010\u0011"+
"\u0007\u0000\u0000\u0000\u0011\u0012\u0005\u000e\u0000\u0000\u0012\u0013"+
"\u0003\u0002\u0001\u0000\u0013\u0014\u0005\u000f\u0000\u0000\u0014\u001c"+
"\u0001\u0000\u0000\u0000\u0015\u0016\u0005\u0011\u0000\u0000\u0016\u001c"+
"\u0003\u0002\u0001\u0004\u0017\u0018\u0005\u000e\u0000\u0000\u0018\u0019"+
"\u0003\u0002\u0001\u0000\u0019\u001a\u0005\u000f\u0000\u0000\u001a\u001c"+
"\u0001\u0000\u0000\u0000\u001b\u000e\u0001\u0000\u0000\u0000\u001b\u0010"+
"\u0001\u0000\u0000\u0000\u001b\u0015\u0001\u0000\u0000\u0000\u001b\u0017"+
"\u0001\u0000\u0000\u0000\u001c*\u0001\u0000\u0000\u0000\u001d\u001e\n"+
"\u0005\u0000\u0000\u001e\u001f\u0005\u0014\u0000\u0000\u001f)\u0003\u0002"+
"\u0001\u0006 !\n\u0003\u0000\u0000!\"\u0007\u0001\u0000\u0000\")\u0003"+
"\u0002\u0001\u0004#$\n\u0002\u0000\u0000$%\u0007\u0002\u0000\u0000%)\u0003"+
"\u0002\u0001\u0003&\'\n\u0006\u0000\u0000\')\u0005\r\u0000\u0000(\u001d"+
"\u0001\u0000\u0000\u0000( \u0001\u0000\u0000\u0000(#\u0001\u0000\u0000"+
"\u0000(&\u0001\u0000\u0000\u0000),\u0001\u0000\u0000\u0000*(\u0001\u0000"+
"\u0000\u0000*+\u0001\u0000\u0000\u0000+\u0003\u0001\u0000\u0000\u0000"+
",*\u0001\u0000\u0000\u0000-.\u0003\u0006\u0003\u0000.\u0005\u0001\u0000"+
"\u0000\u0000/0\u0005\u0001\u0000\u00000\u0007\u0001\u0000\u0000\u0000"+
"\u0004\u000b\u001b(*";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
}