UNPKG

thrift-parser-ts

Version:

A parser of Thrift , by Antlr4 and antlr4ts

1,873 lines (1,823 loc) 109 kB
// Generated from Thrift.g4 by ANTLR 4.9.0-SNAPSHOT import { ATN } from "antlr4ts/atn/ATN"; import { ATNDeserializer } from "antlr4ts/atn/ATNDeserializer"; import { FailedPredicateException } from "antlr4ts/FailedPredicateException"; import { NotNull } from "antlr4ts/Decorators"; import { NoViableAltException } from "antlr4ts/NoViableAltException"; import { Override } from "antlr4ts/Decorators"; import { Parser } from "antlr4ts/Parser"; import { ParserRuleContext } from "antlr4ts/ParserRuleContext"; import { ParserATNSimulator } from "antlr4ts/atn/ParserATNSimulator"; import { ParseTreeListener } from "antlr4ts/tree/ParseTreeListener"; import { ParseTreeVisitor } from "antlr4ts/tree/ParseTreeVisitor"; import { RecognitionException } from "antlr4ts/RecognitionException"; import { RuleContext } from "antlr4ts/RuleContext"; //import { RuleVersion } from "antlr4ts/RuleVersion"; import { TerminalNode } from "antlr4ts/tree/TerminalNode"; import { Token } from "antlr4ts/Token"; import { TokenStream } from "antlr4ts/TokenStream"; import { Vocabulary } from "antlr4ts/Vocabulary"; import { VocabularyImpl } from "antlr4ts/VocabularyImpl"; import * as Utils from "antlr4ts/misc/Utils"; import { ThriftListener } from "./ThriftListener"; export class ThriftParser extends Parser { public static readonly T__0 = 1; public static readonly T__1 = 2; public static readonly T__2 = 3; public static readonly T__3 = 4; public static readonly T__4 = 5; public static readonly T__5 = 6; public static readonly T__6 = 7; public static readonly T__7 = 8; public static readonly T__8 = 9; public static readonly T__9 = 10; public static readonly T__10 = 11; public static readonly T__11 = 12; public static readonly T__12 = 13; public static readonly T__13 = 14; public static readonly T__14 = 15; public static readonly T__15 = 16; public static readonly T__16 = 17; public static readonly T__17 = 18; public static readonly T__18 = 19; public static readonly T__19 = 20; public static readonly T__20 = 21; public static readonly T__21 = 22; public static readonly T__22 = 23; public static readonly T__23 = 24; public static readonly T__24 = 25; public static readonly T__25 = 26; public static readonly T__26 = 27; public static readonly T__27 = 28; public static readonly T__28 = 29; public static readonly T__29 = 30; public static readonly T__30 = 31; public static readonly T__31 = 32; public static readonly T__32 = 33; public static readonly T__33 = 34; public static readonly T__34 = 35; public static readonly T__35 = 36; public static readonly INTEGER = 37; public static readonly HEX_INTEGER = 38; public static readonly DOUBLE = 39; public static readonly TYPE_BOOL = 40; public static readonly TYPE_BYTE = 41; public static readonly TYPE_I16 = 42; public static readonly TYPE_I32 = 43; public static readonly TYPE_I64 = 44; public static readonly TYPE_DOUBLE = 45; public static readonly TYPE_STRING = 46; public static readonly TYPE_BINARY = 47; public static readonly LITERAL = 48; public static readonly IDENTIFIER = 49; public static readonly COMMA = 50; public static readonly WS = 51; public static readonly SL_COMMENT = 52; public static readonly ML_COMMENT = 53; public static readonly RULE_document = 0; public static readonly RULE_header = 1; public static readonly RULE_include_ = 2; public static readonly RULE_namespace_ = 3; public static readonly RULE_cpp_include = 4; public static readonly RULE_definition = 5; public static readonly RULE_const_rule = 6; public static readonly RULE_typedef_ = 7; public static readonly RULE_enum_rule = 8; public static readonly RULE_enum_field = 9; public static readonly RULE_senum = 10; public static readonly RULE_struct_ = 11; public static readonly RULE_union_ = 12; public static readonly RULE_exception_ = 13; public static readonly RULE_service = 14; public static readonly RULE_field = 15; public static readonly RULE_field_id = 16; public static readonly RULE_field_req = 17; public static readonly RULE_function_ = 18; public static readonly RULE_oneway = 19; public static readonly RULE_function_type = 20; public static readonly RULE_throws_list = 21; public static readonly RULE_type_annotations = 22; public static readonly RULE_type_annotation = 23; public static readonly RULE_annotation_value = 24; public static readonly RULE_field_type = 25; public static readonly RULE_base_type = 26; public static readonly RULE_container_type = 27; public static readonly RULE_map_type = 28; public static readonly RULE_set_type = 29; public static readonly RULE_list_type = 30; public static readonly RULE_cpp_type = 31; public static readonly RULE_const_value = 32; public static readonly RULE_integer = 33; public static readonly RULE_const_list = 34; public static readonly RULE_const_map_entry = 35; public static readonly RULE_const_map = 36; public static readonly RULE_list_separator = 37; public static readonly RULE_real_base_type = 38; // tslint:disable:no-trailing-whitespace public static readonly ruleNames: string[] = [ "document", "header", "include_", "namespace_", "cpp_include", "definition", "const_rule", "typedef_", "enum_rule", "enum_field", "senum", "struct_", "union_", "exception_", "service", "field", "field_id", "field_req", "function_", "oneway", "function_type", "throws_list", "type_annotations", "type_annotation", "annotation_value", "field_type", "base_type", "container_type", "map_type", "set_type", "list_type", "cpp_type", "const_value", "integer", "const_list", "const_map_entry", "const_map", "list_separator", "real_base_type", ]; private static readonly _LITERAL_NAMES: Array<string | undefined> = [ undefined, "'include'", "'namespace'", "'*'", "'cpp_namespace'", "'php_namespace'", "'cpp_include'", "'const'", "'='", "'typedef'", "'enum'", "'{'", "'}'", "'senum'", "'struct'", "'union'", "'exception'", "'service'", "'extends'", "':'", "'required'", "'optional'", "'('", "')'", "'oneway'", "'async'", "'void'", "'throws'", "'map'", "'<'", "'>'", "'set'", "'list'", "'cpp_type'", "'['", "']'", "';'", undefined, undefined, undefined, "'bool'", "'byte'", "'i16'", "'i32'", "'i64'", "'double'", "'string'", "'binary'", undefined, undefined, "','", ]; private static readonly _SYMBOLIC_NAMES: Array<string | undefined> = [ undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, "INTEGER", "HEX_INTEGER", "DOUBLE", "TYPE_BOOL", "TYPE_BYTE", "TYPE_I16", "TYPE_I32", "TYPE_I64", "TYPE_DOUBLE", "TYPE_STRING", "TYPE_BINARY", "LITERAL", "IDENTIFIER", "COMMA", "WS", "SL_COMMENT", "ML_COMMENT", ]; public static readonly VOCABULARY: Vocabulary = new VocabularyImpl(ThriftParser._LITERAL_NAMES, ThriftParser._SYMBOLIC_NAMES, []); // @Override // @NotNull public get vocabulary(): Vocabulary { return ThriftParser.VOCABULARY; } // tslint:enable:no-trailing-whitespace // @Override public get grammarFileName(): string { return "Thrift.g4"; } // @Override public get ruleNames(): string[] { return ThriftParser.ruleNames; } // @Override public get serializedATN(): string { return ThriftParser._serializedATN; } protected createFailedPredicateException(predicate?: string, message?: string): FailedPredicateException { return new FailedPredicateException(this, predicate, message); } constructor(input: TokenStream) { super(input); this._interp = new ParserATNSimulator(ThriftParser._ATN, this); } // @RuleVersion(0) public document(): DocumentContext { let _localctx: DocumentContext = new DocumentContext(this._ctx, this.state); this.enterRule(_localctx, 0, ThriftParser.RULE_document); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 81; this._errHandler.sync(this); _la = this._input.LA(1); while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ThriftParser.T__0) | (1 << ThriftParser.T__1) | (1 << ThriftParser.T__3) | (1 << ThriftParser.T__4) | (1 << ThriftParser.T__5))) !== 0)) { { { this.state = 78; this.header(); } } this.state = 83; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 87; this._errHandler.sync(this); _la = this._input.LA(1); while ((((_la) & ~0x1F) === 0 && ((1 << _la) & ((1 << ThriftParser.T__6) | (1 << ThriftParser.T__8) | (1 << ThriftParser.T__9) | (1 << ThriftParser.T__12) | (1 << ThriftParser.T__13) | (1 << ThriftParser.T__14) | (1 << ThriftParser.T__15) | (1 << ThriftParser.T__16))) !== 0)) { { { this.state = 84; this.definition(); } } this.state = 89; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 90; this.match(ThriftParser.EOF); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public header(): HeaderContext { let _localctx: HeaderContext = new HeaderContext(this._ctx, this.state); this.enterRule(_localctx, 2, ThriftParser.RULE_header); try { this.state = 95; this._errHandler.sync(this); switch (this._input.LA(1)) { case ThriftParser.T__0: this.enterOuterAlt(_localctx, 1); { this.state = 92; this.include_(); } break; case ThriftParser.T__1: case ThriftParser.T__3: case ThriftParser.T__4: this.enterOuterAlt(_localctx, 2); { this.state = 93; this.namespace_(); } break; case ThriftParser.T__5: this.enterOuterAlt(_localctx, 3); { this.state = 94; this.cpp_include(); } break; default: throw new NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public include_(): Include_Context { let _localctx: Include_Context = new Include_Context(this._ctx, this.state); this.enterRule(_localctx, 4, ThriftParser.RULE_include_); try { this.enterOuterAlt(_localctx, 1); { this.state = 97; this.match(ThriftParser.T__0); this.state = 98; this.match(ThriftParser.LITERAL); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public namespace_(): Namespace_Context { let _localctx: Namespace_Context = new Namespace_Context(this._ctx, this.state); this.enterRule(_localctx, 6, ThriftParser.RULE_namespace_); let _la: number; try { this.state = 113; this._errHandler.sync(this); switch ( this.interpreter.adaptivePredict(this._input, 4, this._ctx) ) { case 1: this.enterOuterAlt(_localctx, 1); { this.state = 100; this.match(ThriftParser.T__1); this.state = 101; this.match(ThriftParser.T__2); this.state = 102; _la = this._input.LA(1); if (!(_la === ThriftParser.LITERAL || _la === ThriftParser.IDENTIFIER)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } } break; case 2: this.enterOuterAlt(_localctx, 2); { this.state = 103; this.match(ThriftParser.T__1); this.state = 104; this.match(ThriftParser.IDENTIFIER); this.state = 105; _la = this._input.LA(1); if (!(_la === ThriftParser.LITERAL || _la === ThriftParser.IDENTIFIER)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } this.state = 107; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 106; this.type_annotations(); } } } break; case 3: this.enterOuterAlt(_localctx, 3); { this.state = 109; this.match(ThriftParser.T__3); this.state = 110; this.match(ThriftParser.IDENTIFIER); } break; case 4: this.enterOuterAlt(_localctx, 4); { this.state = 111; this.match(ThriftParser.T__4); this.state = 112; this.match(ThriftParser.IDENTIFIER); } break; } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public cpp_include(): Cpp_includeContext { let _localctx: Cpp_includeContext = new Cpp_includeContext(this._ctx, this.state); this.enterRule(_localctx, 8, ThriftParser.RULE_cpp_include); try { this.enterOuterAlt(_localctx, 1); { this.state = 115; this.match(ThriftParser.T__5); this.state = 116; this.match(ThriftParser.LITERAL); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public definition(): DefinitionContext { let _localctx: DefinitionContext = new DefinitionContext(this._ctx, this.state); this.enterRule(_localctx, 10, ThriftParser.RULE_definition); try { this.state = 126; this._errHandler.sync(this); switch (this._input.LA(1)) { case ThriftParser.T__6: this.enterOuterAlt(_localctx, 1); { this.state = 118; this.const_rule(); } break; case ThriftParser.T__8: this.enterOuterAlt(_localctx, 2); { this.state = 119; this.typedef_(); } break; case ThriftParser.T__9: this.enterOuterAlt(_localctx, 3); { this.state = 120; this.enum_rule(); } break; case ThriftParser.T__12: this.enterOuterAlt(_localctx, 4); { this.state = 121; this.senum(); } break; case ThriftParser.T__13: this.enterOuterAlt(_localctx, 5); { this.state = 122; this.struct_(); } break; case ThriftParser.T__14: this.enterOuterAlt(_localctx, 6); { this.state = 123; this.union_(); } break; case ThriftParser.T__15: this.enterOuterAlt(_localctx, 7); { this.state = 124; this.exception_(); } break; case ThriftParser.T__16: this.enterOuterAlt(_localctx, 8); { this.state = 125; this.service(); } break; default: throw new NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public const_rule(): Const_ruleContext { let _localctx: Const_ruleContext = new Const_ruleContext(this._ctx, this.state); this.enterRule(_localctx, 12, ThriftParser.RULE_const_rule); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 128; this.match(ThriftParser.T__6); this.state = 129; this.field_type(); this.state = 130; this.match(ThriftParser.IDENTIFIER); this.state = 133; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__7) { { this.state = 131; this.match(ThriftParser.T__7); this.state = 132; this.const_value(); } } this.state = 136; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__35 || _la === ThriftParser.COMMA) { { this.state = 135; this.list_separator(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public typedef_(): Typedef_Context { let _localctx: Typedef_Context = new Typedef_Context(this._ctx, this.state); this.enterRule(_localctx, 14, ThriftParser.RULE_typedef_); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 138; this.match(ThriftParser.T__8); this.state = 139; this.field_type(); this.state = 140; this.match(ThriftParser.IDENTIFIER); this.state = 142; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 141; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public enum_rule(): Enum_ruleContext { let _localctx: Enum_ruleContext = new Enum_ruleContext(this._ctx, this.state); this.enterRule(_localctx, 16, ThriftParser.RULE_enum_rule); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 144; this.match(ThriftParser.T__9); this.state = 145; this.match(ThriftParser.IDENTIFIER); this.state = 146; this.match(ThriftParser.T__10); this.state = 150; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === ThriftParser.IDENTIFIER) { { { this.state = 147; this.enum_field(); } } this.state = 152; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 153; this.match(ThriftParser.T__11); this.state = 155; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 154; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public enum_field(): Enum_fieldContext { let _localctx: Enum_fieldContext = new Enum_fieldContext(this._ctx, this.state); this.enterRule(_localctx, 18, ThriftParser.RULE_enum_field); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 157; this.match(ThriftParser.IDENTIFIER); this.state = 160; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__7) { { this.state = 158; this.match(ThriftParser.T__7); this.state = 159; this.integer(); } } this.state = 163; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 162; this.type_annotations(); } } this.state = 166; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__35 || _la === ThriftParser.COMMA) { { this.state = 165; this.list_separator(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public senum(): SenumContext { let _localctx: SenumContext = new SenumContext(this._ctx, this.state); this.enterRule(_localctx, 20, ThriftParser.RULE_senum); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 168; this.match(ThriftParser.T__12); this.state = 169; this.match(ThriftParser.IDENTIFIER); this.state = 170; this.match(ThriftParser.T__10); this.state = 177; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === ThriftParser.LITERAL) { { { this.state = 171; this.match(ThriftParser.LITERAL); this.state = 173; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__35 || _la === ThriftParser.COMMA) { { this.state = 172; this.list_separator(); } } } } this.state = 179; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 180; this.match(ThriftParser.T__11); this.state = 182; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 181; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public struct_(): Struct_Context { let _localctx: Struct_Context = new Struct_Context(this._ctx, this.state); this.enterRule(_localctx, 22, ThriftParser.RULE_struct_); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 184; this.match(ThriftParser.T__13); this.state = 185; this.match(ThriftParser.IDENTIFIER); this.state = 186; this.match(ThriftParser.T__10); this.state = 190; this._errHandler.sync(this); _la = this._input.LA(1); while (((((_la - 20)) & ~0x1F) === 0 && ((1 << (_la - 20)) & ((1 << (ThriftParser.T__19 - 20)) | (1 << (ThriftParser.T__20 - 20)) | (1 << (ThriftParser.T__27 - 20)) | (1 << (ThriftParser.T__30 - 20)) | (1 << (ThriftParser.T__31 - 20)) | (1 << (ThriftParser.INTEGER - 20)) | (1 << (ThriftParser.HEX_INTEGER - 20)) | (1 << (ThriftParser.TYPE_BOOL - 20)) | (1 << (ThriftParser.TYPE_BYTE - 20)) | (1 << (ThriftParser.TYPE_I16 - 20)) | (1 << (ThriftParser.TYPE_I32 - 20)) | (1 << (ThriftParser.TYPE_I64 - 20)) | (1 << (ThriftParser.TYPE_DOUBLE - 20)) | (1 << (ThriftParser.TYPE_STRING - 20)) | (1 << (ThriftParser.TYPE_BINARY - 20)) | (1 << (ThriftParser.IDENTIFIER - 20)))) !== 0)) { { { this.state = 187; this.field(); } } this.state = 192; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 193; this.match(ThriftParser.T__11); this.state = 195; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 194; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public union_(): Union_Context { let _localctx: Union_Context = new Union_Context(this._ctx, this.state); this.enterRule(_localctx, 24, ThriftParser.RULE_union_); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 197; this.match(ThriftParser.T__14); this.state = 198; this.match(ThriftParser.IDENTIFIER); this.state = 199; this.match(ThriftParser.T__10); this.state = 203; this._errHandler.sync(this); _la = this._input.LA(1); while (((((_la - 20)) & ~0x1F) === 0 && ((1 << (_la - 20)) & ((1 << (ThriftParser.T__19 - 20)) | (1 << (ThriftParser.T__20 - 20)) | (1 << (ThriftParser.T__27 - 20)) | (1 << (ThriftParser.T__30 - 20)) | (1 << (ThriftParser.T__31 - 20)) | (1 << (ThriftParser.INTEGER - 20)) | (1 << (ThriftParser.HEX_INTEGER - 20)) | (1 << (ThriftParser.TYPE_BOOL - 20)) | (1 << (ThriftParser.TYPE_BYTE - 20)) | (1 << (ThriftParser.TYPE_I16 - 20)) | (1 << (ThriftParser.TYPE_I32 - 20)) | (1 << (ThriftParser.TYPE_I64 - 20)) | (1 << (ThriftParser.TYPE_DOUBLE - 20)) | (1 << (ThriftParser.TYPE_STRING - 20)) | (1 << (ThriftParser.TYPE_BINARY - 20)) | (1 << (ThriftParser.IDENTIFIER - 20)))) !== 0)) { { { this.state = 200; this.field(); } } this.state = 205; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 206; this.match(ThriftParser.T__11); this.state = 208; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 207; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public exception_(): Exception_Context { let _localctx: Exception_Context = new Exception_Context(this._ctx, this.state); this.enterRule(_localctx, 26, ThriftParser.RULE_exception_); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 210; this.match(ThriftParser.T__15); this.state = 211; this.match(ThriftParser.IDENTIFIER); this.state = 212; this.match(ThriftParser.T__10); this.state = 216; this._errHandler.sync(this); _la = this._input.LA(1); while (((((_la - 20)) & ~0x1F) === 0 && ((1 << (_la - 20)) & ((1 << (ThriftParser.T__19 - 20)) | (1 << (ThriftParser.T__20 - 20)) | (1 << (ThriftParser.T__27 - 20)) | (1 << (ThriftParser.T__30 - 20)) | (1 << (ThriftParser.T__31 - 20)) | (1 << (ThriftParser.INTEGER - 20)) | (1 << (ThriftParser.HEX_INTEGER - 20)) | (1 << (ThriftParser.TYPE_BOOL - 20)) | (1 << (ThriftParser.TYPE_BYTE - 20)) | (1 << (ThriftParser.TYPE_I16 - 20)) | (1 << (ThriftParser.TYPE_I32 - 20)) | (1 << (ThriftParser.TYPE_I64 - 20)) | (1 << (ThriftParser.TYPE_DOUBLE - 20)) | (1 << (ThriftParser.TYPE_STRING - 20)) | (1 << (ThriftParser.TYPE_BINARY - 20)) | (1 << (ThriftParser.IDENTIFIER - 20)))) !== 0)) { { { this.state = 213; this.field(); } } this.state = 218; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 219; this.match(ThriftParser.T__11); this.state = 221; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 220; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public service(): ServiceContext { let _localctx: ServiceContext = new ServiceContext(this._ctx, this.state); this.enterRule(_localctx, 28, ThriftParser.RULE_service); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 223; this.match(ThriftParser.T__16); this.state = 224; this.match(ThriftParser.IDENTIFIER); this.state = 227; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__17) { { this.state = 225; this.match(ThriftParser.T__17); this.state = 226; this.match(ThriftParser.IDENTIFIER); } } this.state = 229; this.match(ThriftParser.T__10); this.state = 233; this._errHandler.sync(this); _la = this._input.LA(1); while (((((_la - 24)) & ~0x1F) === 0 && ((1 << (_la - 24)) & ((1 << (ThriftParser.T__23 - 24)) | (1 << (ThriftParser.T__24 - 24)) | (1 << (ThriftParser.T__25 - 24)) | (1 << (ThriftParser.T__27 - 24)) | (1 << (ThriftParser.T__30 - 24)) | (1 << (ThriftParser.T__31 - 24)) | (1 << (ThriftParser.TYPE_BOOL - 24)) | (1 << (ThriftParser.TYPE_BYTE - 24)) | (1 << (ThriftParser.TYPE_I16 - 24)) | (1 << (ThriftParser.TYPE_I32 - 24)) | (1 << (ThriftParser.TYPE_I64 - 24)) | (1 << (ThriftParser.TYPE_DOUBLE - 24)) | (1 << (ThriftParser.TYPE_STRING - 24)) | (1 << (ThriftParser.TYPE_BINARY - 24)) | (1 << (ThriftParser.IDENTIFIER - 24)))) !== 0)) { { { this.state = 230; this.function_(); } } this.state = 235; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 236; this.match(ThriftParser.T__11); this.state = 238; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 237; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public field(): FieldContext { let _localctx: FieldContext = new FieldContext(this._ctx, this.state); this.enterRule(_localctx, 30, ThriftParser.RULE_field); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 241; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.INTEGER || _la === ThriftParser.HEX_INTEGER) { { this.state = 240; this.field_id(); } } this.state = 244; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__19 || _la === ThriftParser.T__20) { { this.state = 243; this.field_req(); } } this.state = 246; this.field_type(); this.state = 247; this.match(ThriftParser.IDENTIFIER); this.state = 250; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__7) { { this.state = 248; this.match(ThriftParser.T__7); this.state = 249; this.const_value(); } } this.state = 253; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 252; this.type_annotations(); } } this.state = 256; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__35 || _la === ThriftParser.COMMA) { { this.state = 255; this.list_separator(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public field_id(): Field_idContext { let _localctx: Field_idContext = new Field_idContext(this._ctx, this.state); this.enterRule(_localctx, 32, ThriftParser.RULE_field_id); try { this.enterOuterAlt(_localctx, 1); { this.state = 258; this.integer(); this.state = 259; this.match(ThriftParser.T__18); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public field_req(): Field_reqContext { let _localctx: Field_reqContext = new Field_reqContext(this._ctx, this.state); this.enterRule(_localctx, 34, ThriftParser.RULE_field_req); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 261; _la = this._input.LA(1); if (!(_la === ThriftParser.T__19 || _la === ThriftParser.T__20)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public function_(): Function_Context { let _localctx: Function_Context = new Function_Context(this._ctx, this.state); this.enterRule(_localctx, 36, ThriftParser.RULE_function_); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 264; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__23 || _la === ThriftParser.T__24) { { this.state = 263; this.oneway(); } } this.state = 266; this.function_type(); this.state = 267; this.match(ThriftParser.IDENTIFIER); this.state = 268; this.match(ThriftParser.T__21); this.state = 272; this._errHandler.sync(this); _la = this._input.LA(1); while (((((_la - 20)) & ~0x1F) === 0 && ((1 << (_la - 20)) & ((1 << (ThriftParser.T__19 - 20)) | (1 << (ThriftParser.T__20 - 20)) | (1 << (ThriftParser.T__27 - 20)) | (1 << (ThriftParser.T__30 - 20)) | (1 << (ThriftParser.T__31 - 20)) | (1 << (ThriftParser.INTEGER - 20)) | (1 << (ThriftParser.HEX_INTEGER - 20)) | (1 << (ThriftParser.TYPE_BOOL - 20)) | (1 << (ThriftParser.TYPE_BYTE - 20)) | (1 << (ThriftParser.TYPE_I16 - 20)) | (1 << (ThriftParser.TYPE_I32 - 20)) | (1 << (ThriftParser.TYPE_I64 - 20)) | (1 << (ThriftParser.TYPE_DOUBLE - 20)) | (1 << (ThriftParser.TYPE_STRING - 20)) | (1 << (ThriftParser.TYPE_BINARY - 20)) | (1 << (ThriftParser.IDENTIFIER - 20)))) !== 0)) { { { this.state = 269; this.field(); } } this.state = 274; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 275; this.match(ThriftParser.T__22); this.state = 277; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__26) { { this.state = 276; this.throws_list(); } } this.state = 280; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 279; this.type_annotations(); } } this.state = 283; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__35 || _la === ThriftParser.COMMA) { { this.state = 282; this.list_separator(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public oneway(): OnewayContext { let _localctx: OnewayContext = new OnewayContext(this._ctx, this.state); this.enterRule(_localctx, 38, ThriftParser.RULE_oneway); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 285; _la = this._input.LA(1); if (!(_la === ThriftParser.T__23 || _la === ThriftParser.T__24)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public function_type(): Function_typeContext { let _localctx: Function_typeContext = new Function_typeContext(this._ctx, this.state); this.enterRule(_localctx, 40, ThriftParser.RULE_function_type); try { this.state = 289; this._errHandler.sync(this); switch (this._input.LA(1)) { case ThriftParser.T__27: case ThriftParser.T__30: case ThriftParser.T__31: case ThriftParser.TYPE_BOOL: case ThriftParser.TYPE_BYTE: case ThriftParser.TYPE_I16: case ThriftParser.TYPE_I32: case ThriftParser.TYPE_I64: case ThriftParser.TYPE_DOUBLE: case ThriftParser.TYPE_STRING: case ThriftParser.TYPE_BINARY: case ThriftParser.IDENTIFIER: this.enterOuterAlt(_localctx, 1); { this.state = 287; this.field_type(); } break; case ThriftParser.T__25: this.enterOuterAlt(_localctx, 2); { this.state = 288; this.match(ThriftParser.T__25); } break; default: throw new NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public throws_list(): Throws_listContext { let _localctx: Throws_listContext = new Throws_listContext(this._ctx, this.state); this.enterRule(_localctx, 42, ThriftParser.RULE_throws_list); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 291; this.match(ThriftParser.T__26); this.state = 292; this.match(ThriftParser.T__21); this.state = 296; this._errHandler.sync(this); _la = this._input.LA(1); while (((((_la - 20)) & ~0x1F) === 0 && ((1 << (_la - 20)) & ((1 << (ThriftParser.T__19 - 20)) | (1 << (ThriftParser.T__20 - 20)) | (1 << (ThriftParser.T__27 - 20)) | (1 << (ThriftParser.T__30 - 20)) | (1 << (ThriftParser.T__31 - 20)) | (1 << (ThriftParser.INTEGER - 20)) | (1 << (ThriftParser.HEX_INTEGER - 20)) | (1 << (ThriftParser.TYPE_BOOL - 20)) | (1 << (ThriftParser.TYPE_BYTE - 20)) | (1 << (ThriftParser.TYPE_I16 - 20)) | (1 << (ThriftParser.TYPE_I32 - 20)) | (1 << (ThriftParser.TYPE_I64 - 20)) | (1 << (ThriftParser.TYPE_DOUBLE - 20)) | (1 << (ThriftParser.TYPE_STRING - 20)) | (1 << (ThriftParser.TYPE_BINARY - 20)) | (1 << (ThriftParser.IDENTIFIER - 20)))) !== 0)) { { { this.state = 293; this.field(); } } this.state = 298; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 299; this.match(ThriftParser.T__22); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public type_annotations(): Type_annotationsContext { let _localctx: Type_annotationsContext = new Type_annotationsContext(this._ctx, this.state); this.enterRule(_localctx, 44, ThriftParser.RULE_type_annotations); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 301; this.match(ThriftParser.T__21); this.state = 305; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === ThriftParser.IDENTIFIER) { { { this.state = 302; this.type_annotation(); } } this.state = 307; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 308; this.match(ThriftParser.T__22); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public type_annotation(): Type_annotationContext { let _localctx: Type_annotationContext = new Type_annotationContext(this._ctx, this.state); this.enterRule(_localctx, 46, ThriftParser.RULE_type_annotation); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 310; this.match(ThriftParser.IDENTIFIER); this.state = 313; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__7) { { this.state = 311; this.match(ThriftParser.T__7); this.state = 312; this.annotation_value(); } } this.state = 316; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__35 || _la === ThriftParser.COMMA) { { this.state = 315; this.list_separator(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public annotation_value(): Annotation_valueContext { let _localctx: Annotation_valueContext = new Annotation_valueContext(this._ctx, this.state); this.enterRule(_localctx, 48, ThriftParser.RULE_annotation_value); try { this.state = 320; this._errHandler.sync(this); switch (this._input.LA(1)) { case ThriftParser.INTEGER: case ThriftParser.HEX_INTEGER: this.enterOuterAlt(_localctx, 1); { this.state = 318; this.integer(); } break; case ThriftParser.LITERAL: this.enterOuterAlt(_localctx, 2); { this.state = 319; this.match(ThriftParser.LITERAL); } break; default: throw new NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public field_type(): Field_typeContext { let _localctx: Field_typeContext = new Field_typeContext(this._ctx, this.state); this.enterRule(_localctx, 50, ThriftParser.RULE_field_type); try { this.state = 325; this._errHandler.sync(this); switch (this._input.LA(1)) { case ThriftParser.TYPE_BOOL: case ThriftParser.TYPE_BYTE: case ThriftParser.TYPE_I16: case ThriftParser.TYPE_I32: case ThriftParser.TYPE_I64: case ThriftParser.TYPE_DOUBLE: case ThriftParser.TYPE_STRING: case ThriftParser.TYPE_BINARY: this.enterOuterAlt(_localctx, 1); { this.state = 322; this.base_type(); } break; case ThriftParser.IDENTIFIER: this.enterOuterAlt(_localctx, 2); { this.state = 323; this.match(ThriftParser.IDENTIFIER); } break; case ThriftParser.T__27: case ThriftParser.T__30: case ThriftParser.T__31: this.enterOuterAlt(_localctx, 3); { this.state = 324; this.container_type(); } break; default: throw new NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public base_type(): Base_typeContext { let _localctx: Base_typeContext = new Base_typeContext(this._ctx, this.state); this.enterRule(_localctx, 52, ThriftParser.RULE_base_type); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 327; this.real_base_type(); this.state = 329; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 328; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public container_type(): Container_typeContext { let _localctx: Container_typeContext = new Container_typeContext(this._ctx, this.state); this.enterRule(_localctx, 54, ThriftParser.RULE_container_type); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 334; this._errHandler.sync(this); switch (this._input.LA(1)) { case ThriftParser.T__27: { this.state = 331; this.map_type(); } break; case ThriftParser.T__30: { this.state = 332; this.set_type(); } break; case ThriftParser.T__31: { this.state = 333; this.list_type(); } break; default: throw new NoViableAltException(this); } this.state = 337; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__21) { { this.state = 336; this.type_annotations(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public map_type(): Map_typeContext { let _localctx: Map_typeContext = new Map_typeContext(this._ctx, this.state); this.enterRule(_localctx, 56, ThriftParser.RULE_map_type); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 339; this.match(ThriftParser.T__27); this.state = 341; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__32) { { this.state = 340; this.cpp_type(); } } this.state = 343; this.match(ThriftParser.T__28); this.state = 344; this.field_type(); this.state = 345; this.match(ThriftParser.COMMA); this.state = 346; this.field_type(); this.state = 347; this.match(ThriftParser.T__29); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public set_type(): Set_typeContext { let _localctx: Set_typeContext = new Set_typeContext(this._ctx, this.state); this.enterRule(_localctx, 58, ThriftParser.RULE_set_type); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 349; this.match(ThriftParser.T__30); this.state = 351; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__32) { { this.state = 350; this.cpp_type(); } } this.state = 353; this.match(ThriftParser.T__28); this.state = 354; this.field_type(); this.state = 355; this.match(ThriftParser.T__29); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public list_type(): List_typeContext { let _localctx: List_typeContext = new List_typeContext(this._ctx, this.state); this.enterRule(_localctx, 60, ThriftParser.RULE_list_type); let _la: number; try { this.enterOuterAlt(_localctx, 1); { this.state = 357; this.match(ThriftParser.T__31); this.state = 358; this.match(ThriftParser.T__28); this.state = 359; this.field_type(); this.state = 360; this.match(ThriftParser.T__29); this.state = 362; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === ThriftParser.T__32) { { this.state = 361; this.cpp_type(); } } } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public cpp_type(): Cpp_typeContext { let _localctx: Cpp_typeContext = new Cpp_typeContext(this._ctx, this.state); this.enterRule(_localctx, 62, ThriftParser.RULE_cpp_type); try { this.enterOuterAlt(_localctx, 1); { this.state = 364; this.match(ThriftParser.T__32); this.state = 365; this.match(ThriftParser.LITERAL); } } catch (re) { if (re instanceof RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } // @RuleVersion(0) public const_value(): Const_valueContext { let _localctx: Const_valueContext = new Const_valueContext(this._ctx, this.state); this.enterRule(_localctx, 64, ThriftParser.RULE_const_value); try { this.state = 373; this._errHandler.sync(this); switch (this._input.LA(1)) { case ThriftParser.INTEGER: case ThriftParser.HEX_INTEGER: this.enterOuterAlt(_localctx, 1); { this.state = 367; this.integer(); } break; case ThriftParser.DOUBLE: this.enterOuterAlt(_localctx, 2); { this.state = 368; this.match(ThriftParser.DOUBLE); } break; case ThriftParser.LITERAL: this.enterOuterAlt(_localctx, 3); { this.state = 369; this.match(ThriftParser.LITERAL); } break; case ThriftParser.IDENTIFIER: this.enterOuterAlt(_localctx, 4); { this.state = 370; this.match(ThriftParser.IDENTIFIER); } break; case ThriftParser.T__33: this.enterOuterAlt(_localctx, 5); { this.state = 371; this.const_list(); } break; case ThriftParser.T__10: this.enterOuterAlt(_localctx, 6); { this.state = 372; this.const_map(); } break; default: thr