001// Generated from de/isas/lipidomics/palinom/SumFormula.g4 by ANTLR 4.7.2 002package de.isas.lipidomics.palinom; 003import org.antlr.v4.runtime.atn.*; 004import org.antlr.v4.runtime.dfa.DFA; 005import org.antlr.v4.runtime.*; 006import org.antlr.v4.runtime.misc.*; 007import org.antlr.v4.runtime.tree.*; 008import java.util.List; 009import java.util.Iterator; 010import java.util.ArrayList; 011 012@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) 013public class SumFormulaParser extends Parser { 014 static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); } 015 016 protected static final DFA[] _decisionToDFA; 017 protected static final PredictionContextCache _sharedContextCache = 018 new PredictionContextCache(); 019 public static final int 020 T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, 021 T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16; 022 public static final int 023 RULE_molecule = 0, RULE_molecule_rule = 1, RULE_molecule_group = 2, RULE_element_group = 3, 024 RULE_single_element = 4, RULE_element = 5, RULE_count = 6, RULE_digit = 7; 025 private static String[] makeRuleNames() { 026 return new String[] { 027 "molecule", "molecule_rule", "molecule_group", "element_group", "single_element", 028 "element", "count", "digit" 029 }; 030 } 031 public static final String[] ruleNames = makeRuleNames(); 032 033 private static String[] makeLiteralNames() { 034 return new String[] { 035 null, "'C'", "'H'", "'N'", "'O'", "'P'", "'S'", "'0'", "'1'", "'2'", 036 "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'" 037 }; 038 } 039 private static final String[] _LITERAL_NAMES = makeLiteralNames(); 040 private static String[] makeSymbolicNames() { 041 return new String[] { 042 }; 043 } 044 private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); 045 public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); 046 047 /** 048 * @deprecated Use {@link #VOCABULARY} instead. 049 */ 050 @Deprecated 051 public static final String[] tokenNames; 052 static { 053 tokenNames = new String[_SYMBOLIC_NAMES.length]; 054 for (int i = 0; i < tokenNames.length; i++) { 055 tokenNames[i] = VOCABULARY.getLiteralName(i); 056 if (tokenNames[i] == null) { 057 tokenNames[i] = VOCABULARY.getSymbolicName(i); 058 } 059 060 if (tokenNames[i] == null) { 061 tokenNames[i] = "<INVALID>"; 062 } 063 } 064 } 065 066 @Override 067 @Deprecated 068 public String[] getTokenNames() { 069 return tokenNames; 070 } 071 072 @Override 073 074 public Vocabulary getVocabulary() { 075 return VOCABULARY; 076 } 077 078 @Override 079 public String getGrammarFileName() { return "SumFormula.g4"; } 080 081 @Override 082 public String[] getRuleNames() { return ruleNames; } 083 084 @Override 085 public String getSerializedATN() { return _serializedATN; } 086 087 @Override 088 public ATN getATN() { return _ATN; } 089 090 public SumFormulaParser(TokenStream input) { 091 super(input); 092 _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); 093 } 094 095 public static class MoleculeContext extends ParserRuleContext { 096 public Molecule_ruleContext molecule_rule() { 097 return getRuleContext(Molecule_ruleContext.class,0); 098 } 099 public TerminalNode EOF() { return getToken(SumFormulaParser.EOF, 0); } 100 public MoleculeContext(ParserRuleContext parent, int invokingState) { 101 super(parent, invokingState); 102 } 103 @Override public int getRuleIndex() { return RULE_molecule; } 104 @Override 105 public <T> T accept(ParseTreeVisitor<? extends T> visitor) { 106 if ( visitor instanceof SumFormulaVisitor ) return ((SumFormulaVisitor<? extends T>)visitor).visitMolecule(this); 107 else return visitor.visitChildren(this); 108 } 109 } 110 111 public final MoleculeContext molecule() throws RecognitionException { 112 MoleculeContext _localctx = new MoleculeContext(_ctx, getState()); 113 enterRule(_localctx, 0, RULE_molecule); 114 try { 115 enterOuterAlt(_localctx, 1); 116 { 117 setState(16); 118 molecule_rule(); 119 setState(17); 120 match(EOF); 121 } 122 } 123 catch (RecognitionException re) { 124 _localctx.exception = re; 125 _errHandler.reportError(this, re); 126 _errHandler.recover(this, re); 127 } 128 finally { 129 exitRule(); 130 } 131 return _localctx; 132 } 133 134 public static class Molecule_ruleContext extends ParserRuleContext { 135 public Molecule_groupContext molecule_group() { 136 return getRuleContext(Molecule_groupContext.class,0); 137 } 138 public Molecule_ruleContext(ParserRuleContext parent, int invokingState) { 139 super(parent, invokingState); 140 } 141 @Override public int getRuleIndex() { return RULE_molecule_rule; } 142 @Override 143 public <T> T accept(ParseTreeVisitor<? extends T> visitor) { 144 if ( visitor instanceof SumFormulaVisitor ) return ((SumFormulaVisitor<? extends T>)visitor).visitMolecule_rule(this); 145 else return visitor.visitChildren(this); 146 } 147 } 148 149 public final Molecule_ruleContext molecule_rule() throws RecognitionException { 150 Molecule_ruleContext _localctx = new Molecule_ruleContext(_ctx, getState()); 151 enterRule(_localctx, 2, RULE_molecule_rule); 152 try { 153 enterOuterAlt(_localctx, 1); 154 { 155 setState(19); 156 molecule_group(0); 157 } 158 } 159 catch (RecognitionException re) { 160 _localctx.exception = re; 161 _errHandler.reportError(this, re); 162 _errHandler.recover(this, re); 163 } 164 finally { 165 exitRule(); 166 } 167 return _localctx; 168 } 169 170 public static class Molecule_groupContext extends ParserRuleContext { 171 public Element_groupContext element_group() { 172 return getRuleContext(Element_groupContext.class,0); 173 } 174 public Single_elementContext single_element() { 175 return getRuleContext(Single_elementContext.class,0); 176 } 177 public List<Molecule_groupContext> molecule_group() { 178 return getRuleContexts(Molecule_groupContext.class); 179 } 180 public Molecule_groupContext molecule_group(int i) { 181 return getRuleContext(Molecule_groupContext.class,i); 182 } 183 public Molecule_groupContext(ParserRuleContext parent, int invokingState) { 184 super(parent, invokingState); 185 } 186 @Override public int getRuleIndex() { return RULE_molecule_group; } 187 @Override 188 public <T> T accept(ParseTreeVisitor<? extends T> visitor) { 189 if ( visitor instanceof SumFormulaVisitor ) return ((SumFormulaVisitor<? extends T>)visitor).visitMolecule_group(this); 190 else return visitor.visitChildren(this); 191 } 192 } 193 194 public final Molecule_groupContext molecule_group() throws RecognitionException { 195 return molecule_group(0); 196 } 197 198 private Molecule_groupContext molecule_group(int _p) throws RecognitionException { 199 ParserRuleContext _parentctx = _ctx; 200 int _parentState = getState(); 201 Molecule_groupContext _localctx = new Molecule_groupContext(_ctx, _parentState); 202 Molecule_groupContext _prevctx = _localctx; 203 int _startState = 4; 204 enterRecursionRule(_localctx, 4, RULE_molecule_group, _p); 205 try { 206 int _alt; 207 enterOuterAlt(_localctx, 1); 208 { 209 setState(24); 210 _errHandler.sync(this); 211 switch ( getInterpreter().adaptivePredict(_input,0,_ctx) ) { 212 case 1: 213 { 214 setState(22); 215 element_group(); 216 } 217 break; 218 case 2: 219 { 220 setState(23); 221 single_element(); 222 } 223 break; 224 } 225 _ctx.stop = _input.LT(-1); 226 setState(30); 227 _errHandler.sync(this); 228 _alt = getInterpreter().adaptivePredict(_input,1,_ctx); 229 while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { 230 if ( _alt==1 ) { 231 if ( _parseListeners!=null ) triggerExitRuleEvent(); 232 _prevctx = _localctx; 233 { 234 { 235 _localctx = new Molecule_groupContext(_parentctx, _parentState); 236 pushNewRecursionContext(_localctx, _startState, RULE_molecule_group); 237 setState(26); 238 if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); 239 setState(27); 240 molecule_group(2); 241 } 242 } 243 } 244 setState(32); 245 _errHandler.sync(this); 246 _alt = getInterpreter().adaptivePredict(_input,1,_ctx); 247 } 248 } 249 } 250 catch (RecognitionException re) { 251 _localctx.exception = re; 252 _errHandler.reportError(this, re); 253 _errHandler.recover(this, re); 254 } 255 finally { 256 unrollRecursionContexts(_parentctx); 257 } 258 return _localctx; 259 } 260 261 public static class Element_groupContext extends ParserRuleContext { 262 public ElementContext element() { 263 return getRuleContext(ElementContext.class,0); 264 } 265 public CountContext count() { 266 return getRuleContext(CountContext.class,0); 267 } 268 public Element_groupContext(ParserRuleContext parent, int invokingState) { 269 super(parent, invokingState); 270 } 271 @Override public int getRuleIndex() { return RULE_element_group; } 272 @Override 273 public <T> T accept(ParseTreeVisitor<? extends T> visitor) { 274 if ( visitor instanceof SumFormulaVisitor ) return ((SumFormulaVisitor<? extends T>)visitor).visitElement_group(this); 275 else return visitor.visitChildren(this); 276 } 277 } 278 279 public final Element_groupContext element_group() throws RecognitionException { 280 Element_groupContext _localctx = new Element_groupContext(_ctx, getState()); 281 enterRule(_localctx, 6, RULE_element_group); 282 try { 283 enterOuterAlt(_localctx, 1); 284 { 285 setState(33); 286 element(); 287 setState(34); 288 count(); 289 } 290 } 291 catch (RecognitionException re) { 292 _localctx.exception = re; 293 _errHandler.reportError(this, re); 294 _errHandler.recover(this, re); 295 } 296 finally { 297 exitRule(); 298 } 299 return _localctx; 300 } 301 302 public static class Single_elementContext extends ParserRuleContext { 303 public ElementContext element() { 304 return getRuleContext(ElementContext.class,0); 305 } 306 public Single_elementContext(ParserRuleContext parent, int invokingState) { 307 super(parent, invokingState); 308 } 309 @Override public int getRuleIndex() { return RULE_single_element; } 310 @Override 311 public <T> T accept(ParseTreeVisitor<? extends T> visitor) { 312 if ( visitor instanceof SumFormulaVisitor ) return ((SumFormulaVisitor<? extends T>)visitor).visitSingle_element(this); 313 else return visitor.visitChildren(this); 314 } 315 } 316 317 public final Single_elementContext single_element() throws RecognitionException { 318 Single_elementContext _localctx = new Single_elementContext(_ctx, getState()); 319 enterRule(_localctx, 8, RULE_single_element); 320 try { 321 enterOuterAlt(_localctx, 1); 322 { 323 setState(36); 324 element(); 325 } 326 } 327 catch (RecognitionException re) { 328 _localctx.exception = re; 329 _errHandler.reportError(this, re); 330 _errHandler.recover(this, re); 331 } 332 finally { 333 exitRule(); 334 } 335 return _localctx; 336 } 337 338 public static class ElementContext extends ParserRuleContext { 339 public ElementContext(ParserRuleContext parent, int invokingState) { 340 super(parent, invokingState); 341 } 342 @Override public int getRuleIndex() { return RULE_element; } 343 @Override 344 public <T> T accept(ParseTreeVisitor<? extends T> visitor) { 345 if ( visitor instanceof SumFormulaVisitor ) return ((SumFormulaVisitor<? extends T>)visitor).visitElement(this); 346 else return visitor.visitChildren(this); 347 } 348 } 349 350 public final ElementContext element() throws RecognitionException { 351 ElementContext _localctx = new ElementContext(_ctx, getState()); 352 enterRule(_localctx, 10, RULE_element); 353 int _la; 354 try { 355 enterOuterAlt(_localctx, 1); 356 { 357 setState(38); 358 _la = _input.LA(1); 359 if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__1) | (1L << T__2) | (1L << T__3) | (1L << T__4) | (1L << T__5))) != 0)) ) { 360 _errHandler.recoverInline(this); 361 } 362 else { 363 if ( _input.LA(1)==Token.EOF ) matchedEOF = true; 364 _errHandler.reportMatch(this); 365 consume(); 366 } 367 } 368 } 369 catch (RecognitionException re) { 370 _localctx.exception = re; 371 _errHandler.reportError(this, re); 372 _errHandler.recover(this, re); 373 } 374 finally { 375 exitRule(); 376 } 377 return _localctx; 378 } 379 380 public static class CountContext extends ParserRuleContext { 381 public DigitContext digit() { 382 return getRuleContext(DigitContext.class,0); 383 } 384 public CountContext(ParserRuleContext parent, int invokingState) { 385 super(parent, invokingState); 386 } 387 @Override public int getRuleIndex() { return RULE_count; } 388 @Override 389 public <T> T accept(ParseTreeVisitor<? extends T> visitor) { 390 if ( visitor instanceof SumFormulaVisitor ) return ((SumFormulaVisitor<? extends T>)visitor).visitCount(this); 391 else return visitor.visitChildren(this); 392 } 393 } 394 395 public final CountContext count() throws RecognitionException { 396 CountContext _localctx = new CountContext(_ctx, getState()); 397 enterRule(_localctx, 12, RULE_count); 398 try { 399 enterOuterAlt(_localctx, 1); 400 { 401 setState(40); 402 digit(0); 403 } 404 } 405 catch (RecognitionException re) { 406 _localctx.exception = re; 407 _errHandler.reportError(this, re); 408 _errHandler.recover(this, re); 409 } 410 finally { 411 exitRule(); 412 } 413 return _localctx; 414 } 415 416 public static class DigitContext extends ParserRuleContext { 417 public List<DigitContext> digit() { 418 return getRuleContexts(DigitContext.class); 419 } 420 public DigitContext digit(int i) { 421 return getRuleContext(DigitContext.class,i); 422 } 423 public DigitContext(ParserRuleContext parent, int invokingState) { 424 super(parent, invokingState); 425 } 426 @Override public int getRuleIndex() { return RULE_digit; } 427 @Override 428 public <T> T accept(ParseTreeVisitor<? extends T> visitor) { 429 if ( visitor instanceof SumFormulaVisitor ) return ((SumFormulaVisitor<? extends T>)visitor).visitDigit(this); 430 else return visitor.visitChildren(this); 431 } 432 } 433 434 public final DigitContext digit() throws RecognitionException { 435 return digit(0); 436 } 437 438 private DigitContext digit(int _p) throws RecognitionException { 439 ParserRuleContext _parentctx = _ctx; 440 int _parentState = getState(); 441 DigitContext _localctx = new DigitContext(_ctx, _parentState); 442 DigitContext _prevctx = _localctx; 443 int _startState = 14; 444 enterRecursionRule(_localctx, 14, RULE_digit, _p); 445 try { 446 int _alt; 447 enterOuterAlt(_localctx, 1); 448 { 449 setState(53); 450 _errHandler.sync(this); 451 switch (_input.LA(1)) { 452 case T__6: 453 { 454 setState(43); 455 match(T__6); 456 } 457 break; 458 case T__7: 459 { 460 setState(44); 461 match(T__7); 462 } 463 break; 464 case T__8: 465 { 466 setState(45); 467 match(T__8); 468 } 469 break; 470 case T__9: 471 { 472 setState(46); 473 match(T__9); 474 } 475 break; 476 case T__10: 477 { 478 setState(47); 479 match(T__10); 480 } 481 break; 482 case T__11: 483 { 484 setState(48); 485 match(T__11); 486 } 487 break; 488 case T__12: 489 { 490 setState(49); 491 match(T__12); 492 } 493 break; 494 case T__13: 495 { 496 setState(50); 497 match(T__13); 498 } 499 break; 500 case T__14: 501 { 502 setState(51); 503 match(T__14); 504 } 505 break; 506 case T__15: 507 { 508 setState(52); 509 match(T__15); 510 } 511 break; 512 default: 513 throw new NoViableAltException(this); 514 } 515 _ctx.stop = _input.LT(-1); 516 setState(59); 517 _errHandler.sync(this); 518 _alt = getInterpreter().adaptivePredict(_input,3,_ctx); 519 while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { 520 if ( _alt==1 ) { 521 if ( _parseListeners!=null ) triggerExitRuleEvent(); 522 _prevctx = _localctx; 523 { 524 { 525 _localctx = new DigitContext(_parentctx, _parentState); 526 pushNewRecursionContext(_localctx, _startState, RULE_digit); 527 setState(55); 528 if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); 529 setState(56); 530 digit(2); 531 } 532 } 533 } 534 setState(61); 535 _errHandler.sync(this); 536 _alt = getInterpreter().adaptivePredict(_input,3,_ctx); 537 } 538 } 539 } 540 catch (RecognitionException re) { 541 _localctx.exception = re; 542 _errHandler.reportError(this, re); 543 _errHandler.recover(this, re); 544 } 545 finally { 546 unrollRecursionContexts(_parentctx); 547 } 548 return _localctx; 549 } 550 551 public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { 552 switch (ruleIndex) { 553 case 2: 554 return molecule_group_sempred((Molecule_groupContext)_localctx, predIndex); 555 case 7: 556 return digit_sempred((DigitContext)_localctx, predIndex); 557 } 558 return true; 559 } 560 private boolean molecule_group_sempred(Molecule_groupContext _localctx, int predIndex) { 561 switch (predIndex) { 562 case 0: 563 return precpred(_ctx, 1); 564 } 565 return true; 566 } 567 private boolean digit_sempred(DigitContext _localctx, int predIndex) { 568 switch (predIndex) { 569 case 1: 570 return precpred(_ctx, 1); 571 } 572 return true; 573 } 574 575 public static final String _serializedATN = 576 "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\22A\4\2\t\2\4\3\t"+ 577 "\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\3\2\3\2\3\2\3\3\3\3"+ 578 "\3\4\3\4\3\4\5\4\33\n\4\3\4\3\4\7\4\37\n\4\f\4\16\4\"\13\4\3\5\3\5\3\5"+ 579 "\3\6\3\6\3\7\3\7\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\5"+ 580 "\t8\n\t\3\t\3\t\7\t<\n\t\f\t\16\t?\13\t\3\t\2\4\6\20\n\2\4\6\b\n\f\16"+ 581 "\20\2\3\3\2\3\b\2D\2\22\3\2\2\2\4\25\3\2\2\2\6\32\3\2\2\2\b#\3\2\2\2\n"+ 582 "&\3\2\2\2\f(\3\2\2\2\16*\3\2\2\2\20\67\3\2\2\2\22\23\5\4\3\2\23\24\7\2"+ 583 "\2\3\24\3\3\2\2\2\25\26\5\6\4\2\26\5\3\2\2\2\27\30\b\4\1\2\30\33\5\b\5"+ 584 "\2\31\33\5\n\6\2\32\27\3\2\2\2\32\31\3\2\2\2\33 \3\2\2\2\34\35\f\3\2\2"+ 585 "\35\37\5\6\4\4\36\34\3\2\2\2\37\"\3\2\2\2 \36\3\2\2\2 !\3\2\2\2!\7\3\2"+ 586 "\2\2\" \3\2\2\2#$\5\f\7\2$%\5\16\b\2%\t\3\2\2\2&\'\5\f\7\2\'\13\3\2\2"+ 587 "\2()\t\2\2\2)\r\3\2\2\2*+\5\20\t\2+\17\3\2\2\2,-\b\t\1\2-8\7\t\2\2.8\7"+ 588 "\n\2\2/8\7\13\2\2\608\7\f\2\2\618\7\r\2\2\628\7\16\2\2\638\7\17\2\2\64"+ 589 "8\7\20\2\2\658\7\21\2\2\668\7\22\2\2\67,\3\2\2\2\67.\3\2\2\2\67/\3\2\2"+ 590 "\2\67\60\3\2\2\2\67\61\3\2\2\2\67\62\3\2\2\2\67\63\3\2\2\2\67\64\3\2\2"+ 591 "\2\67\65\3\2\2\2\67\66\3\2\2\28=\3\2\2\29:\f\3\2\2:<\5\20\t\4;9\3\2\2"+ 592 "\2<?\3\2\2\2=;\3\2\2\2=>\3\2\2\2>\21\3\2\2\2?=\3\2\2\2\6\32 \67="; 593 public static final ATN _ATN = 594 new ATNDeserializer().deserialize(_serializedATN.toCharArray()); 595 static { 596 _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; 597 for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { 598 _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); 599 } 600 } 601}