apiparser_parser1.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. package api
  2. import (
  3. "reflect"
  4. "github.com/zeromicro/antlr"
  5. )
  6. // Part 1
  7. // The apiparser_parser.go file was split into multiple files because it
  8. // was too large and caused a possible memory overflow during goctl installation.
  9. func (s *SyntaxLitContext) GetParser() antlr.Parser { return s.parser }
  10. func (s *SyntaxLitContext) GetSyntaxToken() antlr.Token { return s.syntaxToken }
  11. func (s *SyntaxLitContext) GetAssign() antlr.Token { return s.assign }
  12. func (s *SyntaxLitContext) GetVersion() antlr.Token { return s.version }
  13. func (s *SyntaxLitContext) SetSyntaxToken(v antlr.Token) { s.syntaxToken = v }
  14. func (s *SyntaxLitContext) SetAssign(v antlr.Token) { s.assign = v }
  15. func (s *SyntaxLitContext) SetVersion(v antlr.Token) { s.version = v }
  16. func (s *SyntaxLitContext) ID() antlr.TerminalNode {
  17. return s.GetToken(ApiParserParserID, 0)
  18. }
  19. func (s *SyntaxLitContext) STRING() antlr.TerminalNode {
  20. return s.GetToken(ApiParserParserSTRING, 0)
  21. }
  22. func (s *SyntaxLitContext) GetRuleContext() antlr.RuleContext {
  23. return s
  24. }
  25. func (s *SyntaxLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  26. return antlr.TreesStringTree(s, ruleNames, recog)
  27. }
  28. func (s *SyntaxLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
  29. switch t := visitor.(type) {
  30. case ApiParserVisitor:
  31. return t.VisitSyntaxLit(s)
  32. default:
  33. return t.VisitChildren(s)
  34. }
  35. }
  36. func (p *ApiParserParser) SyntaxLit() (localctx ISyntaxLitContext) {
  37. localctx = NewSyntaxLitContext(p, p.GetParserRuleContext(), p.GetState())
  38. p.EnterRule(localctx, 4, ApiParserParserRULE_syntaxLit)
  39. defer func() {
  40. p.ExitRule()
  41. }()
  42. defer func() {
  43. if err := recover(); err != nil {
  44. if v, ok := err.(antlr.RecognitionException); ok {
  45. localctx.SetException(v)
  46. p.GetErrorHandler().ReportError(p, v)
  47. p.GetErrorHandler().Recover(p, v)
  48. } else {
  49. panic(err)
  50. }
  51. }
  52. }()
  53. p.EnterOuterAlt(localctx, 1)
  54. match(p, "syntax")
  55. {
  56. p.SetState(88)
  57. var _m = p.Match(ApiParserParserID)
  58. localctx.(*SyntaxLitContext).syntaxToken = _m
  59. }
  60. {
  61. p.SetState(89)
  62. var _m = p.Match(ApiParserParserT__0)
  63. localctx.(*SyntaxLitContext).assign = _m
  64. }
  65. checkVersion(p)
  66. {
  67. p.SetState(91)
  68. var _m = p.Match(ApiParserParserSTRING)
  69. localctx.(*SyntaxLitContext).version = _m
  70. }
  71. return localctx
  72. }
  73. // IImportSpecContext is an interface to support dynamic dispatch.
  74. type IImportSpecContext interface {
  75. antlr.ParserRuleContext
  76. // GetParser returns the parser.
  77. GetParser() antlr.Parser
  78. // IsImportSpecContext differentiates from other interfaces.
  79. IsImportSpecContext()
  80. }
  81. type ImportSpecContext struct {
  82. *antlr.BaseParserRuleContext
  83. parser antlr.Parser
  84. }
  85. func NewEmptyImportSpecContext() *ImportSpecContext {
  86. var p = new(ImportSpecContext)
  87. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  88. p.RuleIndex = ApiParserParserRULE_importSpec
  89. return p
  90. }
  91. func (*ImportSpecContext) IsImportSpecContext() {}
  92. func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportSpecContext {
  93. var p = new(ImportSpecContext)
  94. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  95. p.parser = parser
  96. p.RuleIndex = ApiParserParserRULE_importSpec
  97. return p
  98. }
  99. func (s *ImportSpecContext) GetParser() antlr.Parser { return s.parser }
  100. func (s *ImportSpecContext) ImportLit() IImportLitContext {
  101. var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0)
  102. if t == nil {
  103. return nil
  104. }
  105. return t.(IImportLitContext)
  106. }
  107. func (s *ImportSpecContext) ImportBlock() IImportBlockContext {
  108. var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0)
  109. if t == nil {
  110. return nil
  111. }
  112. return t.(IImportBlockContext)
  113. }
  114. func (s *ImportSpecContext) GetRuleContext() antlr.RuleContext {
  115. return s
  116. }
  117. func (s *ImportSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  118. return antlr.TreesStringTree(s, ruleNames, recog)
  119. }
  120. func (s *ImportSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
  121. switch t := visitor.(type) {
  122. case ApiParserVisitor:
  123. return t.VisitImportSpec(s)
  124. default:
  125. return t.VisitChildren(s)
  126. }
  127. }
  128. func (p *ApiParserParser) ImportSpec() (localctx IImportSpecContext) {
  129. localctx = NewImportSpecContext(p, p.GetParserRuleContext(), p.GetState())
  130. p.EnterRule(localctx, 6, ApiParserParserRULE_importSpec)
  131. defer func() {
  132. p.ExitRule()
  133. }()
  134. defer func() {
  135. if err := recover(); err != nil {
  136. if v, ok := err.(antlr.RecognitionException); ok {
  137. localctx.SetException(v)
  138. p.GetErrorHandler().ReportError(p, v)
  139. p.GetErrorHandler().Recover(p, v)
  140. } else {
  141. panic(err)
  142. }
  143. }
  144. }()
  145. p.SetState(95)
  146. p.GetErrorHandler().Sync(p)
  147. switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 2, p.GetParserRuleContext()) {
  148. case 1:
  149. p.EnterOuterAlt(localctx, 1)
  150. {
  151. p.SetState(93)
  152. p.ImportLit()
  153. }
  154. case 2:
  155. p.EnterOuterAlt(localctx, 2)
  156. {
  157. p.SetState(94)
  158. p.ImportBlock()
  159. }
  160. }
  161. return localctx
  162. }
  163. // IImportLitContext is an interface to support dynamic dispatch.
  164. type IImportLitContext interface {
  165. antlr.ParserRuleContext
  166. // GetParser returns the parser.
  167. GetParser() antlr.Parser
  168. // GetImportToken returns the importToken token.
  169. GetImportToken() antlr.Token
  170. // SetImportToken sets the importToken token.
  171. SetImportToken(antlr.Token)
  172. // IsImportLitContext differentiates from other interfaces.
  173. IsImportLitContext()
  174. }
  175. type ImportLitContext struct {
  176. *antlr.BaseParserRuleContext
  177. parser antlr.Parser
  178. importToken antlr.Token
  179. }
  180. func NewEmptyImportLitContext() *ImportLitContext {
  181. var p = new(ImportLitContext)
  182. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  183. p.RuleIndex = ApiParserParserRULE_importLit
  184. return p
  185. }
  186. func (*ImportLitContext) IsImportLitContext() {}
  187. func NewImportLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportLitContext {
  188. var p = new(ImportLitContext)
  189. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  190. p.parser = parser
  191. p.RuleIndex = ApiParserParserRULE_importLit
  192. return p
  193. }
  194. func (s *ImportLitContext) GetParser() antlr.Parser { return s.parser }
  195. func (s *ImportLitContext) GetImportToken() antlr.Token { return s.importToken }
  196. func (s *ImportLitContext) SetImportToken(v antlr.Token) { s.importToken = v }
  197. func (s *ImportLitContext) ImportValue() IImportValueContext {
  198. var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
  199. if t == nil {
  200. return nil
  201. }
  202. return t.(IImportValueContext)
  203. }
  204. func (s *ImportLitContext) ID() antlr.TerminalNode {
  205. return s.GetToken(ApiParserParserID, 0)
  206. }
  207. func (s *ImportLitContext) GetRuleContext() antlr.RuleContext {
  208. return s
  209. }
  210. func (s *ImportLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  211. return antlr.TreesStringTree(s, ruleNames, recog)
  212. }
  213. func (s *ImportLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
  214. switch t := visitor.(type) {
  215. case ApiParserVisitor:
  216. return t.VisitImportLit(s)
  217. default:
  218. return t.VisitChildren(s)
  219. }
  220. }
  221. func (p *ApiParserParser) ImportLit() (localctx IImportLitContext) {
  222. localctx = NewImportLitContext(p, p.GetParserRuleContext(), p.GetState())
  223. p.EnterRule(localctx, 8, ApiParserParserRULE_importLit)
  224. defer func() {
  225. p.ExitRule()
  226. }()
  227. defer func() {
  228. if err := recover(); err != nil {
  229. if v, ok := err.(antlr.RecognitionException); ok {
  230. localctx.SetException(v)
  231. p.GetErrorHandler().ReportError(p, v)
  232. p.GetErrorHandler().Recover(p, v)
  233. } else {
  234. panic(err)
  235. }
  236. }
  237. }()
  238. p.EnterOuterAlt(localctx, 1)
  239. match(p, "import")
  240. {
  241. p.SetState(98)
  242. var _m = p.Match(ApiParserParserID)
  243. localctx.(*ImportLitContext).importToken = _m
  244. }
  245. {
  246. p.SetState(99)
  247. p.ImportValue()
  248. }
  249. return localctx
  250. }
  251. // IImportBlockContext is an interface to support dynamic dispatch.
  252. type IImportBlockContext interface {
  253. antlr.ParserRuleContext
  254. // GetParser returns the parser.
  255. GetParser() antlr.Parser
  256. // GetImportToken returns the importToken token.
  257. GetImportToken() antlr.Token
  258. // SetImportToken sets the importToken token.
  259. SetImportToken(antlr.Token)
  260. // IsImportBlockContext differentiates from other interfaces.
  261. IsImportBlockContext()
  262. }
  263. type ImportBlockContext struct {
  264. *antlr.BaseParserRuleContext
  265. parser antlr.Parser
  266. importToken antlr.Token
  267. }
  268. func NewEmptyImportBlockContext() *ImportBlockContext {
  269. var p = new(ImportBlockContext)
  270. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  271. p.RuleIndex = ApiParserParserRULE_importBlock
  272. return p
  273. }
  274. func (*ImportBlockContext) IsImportBlockContext() {}
  275. func NewImportBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockContext {
  276. var p = new(ImportBlockContext)
  277. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  278. p.parser = parser
  279. p.RuleIndex = ApiParserParserRULE_importBlock
  280. return p
  281. }
  282. func (s *ImportBlockContext) GetParser() antlr.Parser { return s.parser }
  283. func (s *ImportBlockContext) GetImportToken() antlr.Token { return s.importToken }
  284. func (s *ImportBlockContext) SetImportToken(v antlr.Token) { s.importToken = v }
  285. func (s *ImportBlockContext) ID() antlr.TerminalNode {
  286. return s.GetToken(ApiParserParserID, 0)
  287. }
  288. func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext {
  289. var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem())
  290. var tst = make([]IImportBlockValueContext, len(ts))
  291. for i, t := range ts {
  292. if t != nil {
  293. tst[i] = t.(IImportBlockValueContext)
  294. }
  295. }
  296. return tst
  297. }
  298. func (s *ImportBlockContext) ImportBlockValue(i int) IImportBlockValueContext {
  299. var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i)
  300. if t == nil {
  301. return nil
  302. }
  303. return t.(IImportBlockValueContext)
  304. }
  305. func (s *ImportBlockContext) GetRuleContext() antlr.RuleContext {
  306. return s
  307. }
  308. func (s *ImportBlockContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  309. return antlr.TreesStringTree(s, ruleNames, recog)
  310. }
  311. func (s *ImportBlockContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
  312. switch t := visitor.(type) {
  313. case ApiParserVisitor:
  314. return t.VisitImportBlock(s)
  315. default:
  316. return t.VisitChildren(s)
  317. }
  318. }
  319. func (p *ApiParserParser) ImportBlock() (localctx IImportBlockContext) {
  320. localctx = NewImportBlockContext(p, p.GetParserRuleContext(), p.GetState())
  321. p.EnterRule(localctx, 10, ApiParserParserRULE_importBlock)
  322. var _la int
  323. defer func() {
  324. p.ExitRule()
  325. }()
  326. defer func() {
  327. if err := recover(); err != nil {
  328. if v, ok := err.(antlr.RecognitionException); ok {
  329. localctx.SetException(v)
  330. p.GetErrorHandler().ReportError(p, v)
  331. p.GetErrorHandler().Recover(p, v)
  332. } else {
  333. panic(err)
  334. }
  335. }
  336. }()
  337. p.EnterOuterAlt(localctx, 1)
  338. match(p, "import")
  339. {
  340. p.SetState(102)
  341. var _m = p.Match(ApiParserParserID)
  342. localctx.(*ImportBlockContext).importToken = _m
  343. }
  344. {
  345. p.SetState(103)
  346. p.Match(ApiParserParserT__1)
  347. }
  348. p.SetState(105)
  349. p.GetErrorHandler().Sync(p)
  350. for ok := true; ok; ok = _la == ApiParserParserSTRING {
  351. {
  352. p.SetState(104)
  353. p.ImportBlockValue()
  354. }
  355. p.SetState(107)
  356. p.GetErrorHandler().Sync(p)
  357. _la = p.GetTokenStream().LA(1)
  358. }
  359. {
  360. p.SetState(109)
  361. p.Match(ApiParserParserT__2)
  362. }
  363. return localctx
  364. }
  365. // IImportBlockValueContext is an interface to support dynamic dispatch.
  366. type IImportBlockValueContext interface {
  367. antlr.ParserRuleContext
  368. // GetParser returns the parser.
  369. GetParser() antlr.Parser
  370. // IsImportBlockValueContext differentiates from other interfaces.
  371. IsImportBlockValueContext()
  372. }
  373. type ImportBlockValueContext struct {
  374. *antlr.BaseParserRuleContext
  375. parser antlr.Parser
  376. }
  377. func NewEmptyImportBlockValueContext() *ImportBlockValueContext {
  378. var p = new(ImportBlockValueContext)
  379. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  380. p.RuleIndex = ApiParserParserRULE_importBlockValue
  381. return p
  382. }
  383. func (*ImportBlockValueContext) IsImportBlockValueContext() {}
  384. func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockValueContext {
  385. var p = new(ImportBlockValueContext)
  386. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  387. p.parser = parser
  388. p.RuleIndex = ApiParserParserRULE_importBlockValue
  389. return p
  390. }
  391. func (s *ImportBlockValueContext) GetParser() antlr.Parser { return s.parser }
  392. func (s *ImportBlockValueContext) ImportValue() IImportValueContext {
  393. var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
  394. if t == nil {
  395. return nil
  396. }
  397. return t.(IImportValueContext)
  398. }
  399. func (s *ImportBlockValueContext) GetRuleContext() antlr.RuleContext {
  400. return s
  401. }
  402. func (s *ImportBlockValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  403. return antlr.TreesStringTree(s, ruleNames, recog)
  404. }
  405. func (s *ImportBlockValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
  406. switch t := visitor.(type) {
  407. case ApiParserVisitor:
  408. return t.VisitImportBlockValue(s)
  409. default:
  410. return t.VisitChildren(s)
  411. }
  412. }
  413. func (p *ApiParserParser) ImportBlockValue() (localctx IImportBlockValueContext) {
  414. localctx = NewImportBlockValueContext(p, p.GetParserRuleContext(), p.GetState())
  415. p.EnterRule(localctx, 12, ApiParserParserRULE_importBlockValue)
  416. defer func() {
  417. p.ExitRule()
  418. }()
  419. defer func() {
  420. if err := recover(); err != nil {
  421. if v, ok := err.(antlr.RecognitionException); ok {
  422. localctx.SetException(v)
  423. p.GetErrorHandler().ReportError(p, v)
  424. p.GetErrorHandler().Recover(p, v)
  425. } else {
  426. panic(err)
  427. }
  428. }
  429. }()
  430. p.EnterOuterAlt(localctx, 1)
  431. {
  432. p.SetState(111)
  433. p.ImportValue()
  434. }
  435. return localctx
  436. }
  437. // IImportValueContext is an interface to support dynamic dispatch.
  438. type IImportValueContext interface {
  439. antlr.ParserRuleContext
  440. // GetParser returns the parser.
  441. GetParser() antlr.Parser
  442. // IsImportValueContext differentiates from other interfaces.
  443. IsImportValueContext()
  444. }
  445. type ImportValueContext struct {
  446. *antlr.BaseParserRuleContext
  447. parser antlr.Parser
  448. }
  449. func NewEmptyImportValueContext() *ImportValueContext {
  450. var p = new(ImportValueContext)
  451. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  452. p.RuleIndex = ApiParserParserRULE_importValue
  453. return p
  454. }
  455. func (*ImportValueContext) IsImportValueContext() {}
  456. func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportValueContext {
  457. var p = new(ImportValueContext)
  458. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  459. p.parser = parser
  460. p.RuleIndex = ApiParserParserRULE_importValue
  461. return p
  462. }