apiparser_parser2.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. package api
  2. import (
  3. "reflect"
  4. "github.com/zeromicro/antlr"
  5. )
  6. // Part 2
  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. type InfoSpecContext struct {
  10. *antlr.BaseParserRuleContext
  11. parser antlr.Parser
  12. infoToken antlr.Token
  13. lp antlr.Token
  14. rp antlr.Token
  15. }
  16. func NewEmptyInfoSpecContext() *InfoSpecContext {
  17. var p = new(InfoSpecContext)
  18. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  19. p.RuleIndex = ApiParserParserRULE_infoSpec
  20. return p
  21. }
  22. func (*InfoSpecContext) IsInfoSpecContext() {}
  23. func NewInfoSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InfoSpecContext {
  24. var p = new(InfoSpecContext)
  25. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  26. p.parser = parser
  27. p.RuleIndex = ApiParserParserRULE_infoSpec
  28. return p
  29. }
  30. func (s *InfoSpecContext) GetParser() antlr.Parser { return s.parser }
  31. func (s *InfoSpecContext) GetInfoToken() antlr.Token { return s.infoToken }
  32. func (s *InfoSpecContext) GetLp() antlr.Token { return s.lp }
  33. func (s *InfoSpecContext) GetRp() antlr.Token { return s.rp }
  34. func (s *InfoSpecContext) SetInfoToken(v antlr.Token) { s.infoToken = v }
  35. func (s *InfoSpecContext) SetLp(v antlr.Token) { s.lp = v }
  36. func (s *InfoSpecContext) SetRp(v antlr.Token) { s.rp = v }
  37. func (s *InfoSpecContext) ID() antlr.TerminalNode {
  38. return s.GetToken(ApiParserParserID, 0)
  39. }
  40. func (s *InfoSpecContext) AllKvLit() []IKvLitContext {
  41. var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
  42. var tst = make([]IKvLitContext, len(ts))
  43. for i, t := range ts {
  44. if t != nil {
  45. tst[i] = t.(IKvLitContext)
  46. }
  47. }
  48. return tst
  49. }
  50. func (s *InfoSpecContext) KvLit(i int) IKvLitContext {
  51. var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
  52. if t == nil {
  53. return nil
  54. }
  55. return t.(IKvLitContext)
  56. }
  57. func (s *InfoSpecContext) GetRuleContext() antlr.RuleContext {
  58. return s
  59. }
  60. func (s *InfoSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  61. return antlr.TreesStringTree(s, ruleNames, recog)
  62. }
  63. func (s *InfoSpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
  64. switch t := visitor.(type) {
  65. case ApiParserVisitor:
  66. return t.VisitInfoSpec(s)
  67. default:
  68. return t.VisitChildren(s)
  69. }
  70. }
  71. func (p *ApiParserParser) InfoSpec() (localctx IInfoSpecContext) {
  72. localctx = NewInfoSpecContext(p, p.GetParserRuleContext(), p.GetState())
  73. p.EnterRule(localctx, 16, ApiParserParserRULE_infoSpec)
  74. var _la int
  75. defer func() {
  76. p.ExitRule()
  77. }()
  78. defer func() {
  79. if err := recover(); err != nil {
  80. if v, ok := err.(antlr.RecognitionException); ok {
  81. localctx.SetException(v)
  82. p.GetErrorHandler().ReportError(p, v)
  83. p.GetErrorHandler().Recover(p, v)
  84. } else {
  85. panic(err)
  86. }
  87. }
  88. }()
  89. p.EnterOuterAlt(localctx, 1)
  90. match(p, "info")
  91. {
  92. p.SetState(119)
  93. var _m = p.Match(ApiParserParserID)
  94. localctx.(*InfoSpecContext).infoToken = _m
  95. }
  96. {
  97. p.SetState(120)
  98. var _m = p.Match(ApiParserParserT__1)
  99. localctx.(*InfoSpecContext).lp = _m
  100. }
  101. p.SetState(122)
  102. p.GetErrorHandler().Sync(p)
  103. _la = p.GetTokenStream().LA(1)
  104. for ok := true; ok; ok = _la == ApiParserParserID {
  105. {
  106. p.SetState(121)
  107. p.KvLit()
  108. }
  109. p.SetState(124)
  110. p.GetErrorHandler().Sync(p)
  111. _la = p.GetTokenStream().LA(1)
  112. }
  113. {
  114. p.SetState(126)
  115. var _m = p.Match(ApiParserParserT__2)
  116. localctx.(*InfoSpecContext).rp = _m
  117. }
  118. return localctx
  119. }
  120. // ITypeSpecContext is an interface to support dynamic dispatch.
  121. type ITypeSpecContext interface {
  122. antlr.ParserRuleContext
  123. // GetParser returns the parser.
  124. GetParser() antlr.Parser
  125. // IsTypeSpecContext differentiates from other interfaces.
  126. IsTypeSpecContext()
  127. }
  128. type TypeSpecContext struct {
  129. *antlr.BaseParserRuleContext
  130. parser antlr.Parser
  131. }
  132. func NewEmptyTypeSpecContext() *TypeSpecContext {
  133. var p = new(TypeSpecContext)
  134. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  135. p.RuleIndex = ApiParserParserRULE_typeSpec
  136. return p
  137. }
  138. func (*TypeSpecContext) IsTypeSpecContext() {}
  139. func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecContext {
  140. var p = new(TypeSpecContext)
  141. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  142. p.parser = parser
  143. p.RuleIndex = ApiParserParserRULE_typeSpec
  144. return p
  145. }
  146. func (s *TypeSpecContext) GetParser() antlr.Parser { return s.parser }
  147. func (s *TypeSpecContext) TypeLit() ITypeLitContext {
  148. var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0)
  149. if t == nil {
  150. return nil
  151. }
  152. return t.(ITypeLitContext)
  153. }
  154. func (s *TypeSpecContext) TypeBlock() ITypeBlockContext {
  155. var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0)
  156. if t == nil {
  157. return nil
  158. }
  159. return t.(ITypeBlockContext)
  160. }
  161. func (s *TypeSpecContext) GetRuleContext() antlr.RuleContext {
  162. return s
  163. }
  164. func (s *TypeSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  165. return antlr.TreesStringTree(s, ruleNames, recog)
  166. }
  167. func (s *TypeSpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
  168. switch t := visitor.(type) {
  169. case ApiParserVisitor:
  170. return t.VisitTypeSpec(s)
  171. default:
  172. return t.VisitChildren(s)
  173. }
  174. }
  175. func (p *ApiParserParser) TypeSpec() (localctx ITypeSpecContext) {
  176. localctx = NewTypeSpecContext(p, p.GetParserRuleContext(), p.GetState())
  177. p.EnterRule(localctx, 18, ApiParserParserRULE_typeSpec)
  178. defer func() {
  179. p.ExitRule()
  180. }()
  181. defer func() {
  182. if err := recover(); err != nil {
  183. if v, ok := err.(antlr.RecognitionException); ok {
  184. localctx.SetException(v)
  185. p.GetErrorHandler().ReportError(p, v)
  186. p.GetErrorHandler().Recover(p, v)
  187. } else {
  188. panic(err)
  189. }
  190. }
  191. }()
  192. p.SetState(130)
  193. p.GetErrorHandler().Sync(p)
  194. switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 5, p.GetParserRuleContext()) {
  195. case 1:
  196. p.EnterOuterAlt(localctx, 1)
  197. {
  198. p.SetState(128)
  199. p.TypeLit()
  200. }
  201. case 2:
  202. p.EnterOuterAlt(localctx, 2)
  203. {
  204. p.SetState(129)
  205. p.TypeBlock()
  206. }
  207. }
  208. return localctx
  209. }
  210. // ITypeLitContext is an interface to support dynamic dispatch.
  211. type ITypeLitContext interface {
  212. antlr.ParserRuleContext
  213. // GetParser returns the parser.
  214. GetParser() antlr.Parser
  215. // GetTypeToken returns the typeToken token.
  216. GetTypeToken() antlr.Token
  217. // SetTypeToken sets the typeToken token.
  218. SetTypeToken(antlr.Token)
  219. // IsTypeLitContext differentiates from other interfaces.
  220. IsTypeLitContext()
  221. }
  222. type TypeLitContext struct {
  223. *antlr.BaseParserRuleContext
  224. parser antlr.Parser
  225. typeToken antlr.Token
  226. }
  227. func NewEmptyTypeLitContext() *TypeLitContext {
  228. var p = new(TypeLitContext)
  229. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  230. p.RuleIndex = ApiParserParserRULE_typeLit
  231. return p
  232. }
  233. func (*TypeLitContext) IsTypeLitContext() {}
  234. func NewTypeLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitContext {
  235. var p = new(TypeLitContext)
  236. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  237. p.parser = parser
  238. p.RuleIndex = ApiParserParserRULE_typeLit
  239. return p
  240. }
  241. func (s *TypeLitContext) GetParser() antlr.Parser { return s.parser }
  242. func (s *TypeLitContext) GetTypeToken() antlr.Token { return s.typeToken }
  243. func (s *TypeLitContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
  244. func (s *TypeLitContext) TypeLitBody() ITypeLitBodyContext {
  245. var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0)
  246. if t == nil {
  247. return nil
  248. }
  249. return t.(ITypeLitBodyContext)
  250. }
  251. func (s *TypeLitContext) ID() antlr.TerminalNode {
  252. return s.GetToken(ApiParserParserID, 0)
  253. }
  254. func (s *TypeLitContext) GetRuleContext() antlr.RuleContext {
  255. return s
  256. }
  257. func (s *TypeLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  258. return antlr.TreesStringTree(s, ruleNames, recog)
  259. }
  260. func (s *TypeLitContext) Accept(visitor antlr.ParseTreeVisitor) any {
  261. switch t := visitor.(type) {
  262. case ApiParserVisitor:
  263. return t.VisitTypeLit(s)
  264. default:
  265. return t.VisitChildren(s)
  266. }
  267. }
  268. func (p *ApiParserParser) TypeLit() (localctx ITypeLitContext) {
  269. localctx = NewTypeLitContext(p, p.GetParserRuleContext(), p.GetState())
  270. p.EnterRule(localctx, 20, ApiParserParserRULE_typeLit)
  271. defer func() {
  272. p.ExitRule()
  273. }()
  274. defer func() {
  275. if err := recover(); err != nil {
  276. if v, ok := err.(antlr.RecognitionException); ok {
  277. localctx.SetException(v)
  278. p.GetErrorHandler().ReportError(p, v)
  279. p.GetErrorHandler().Recover(p, v)
  280. } else {
  281. panic(err)
  282. }
  283. }
  284. }()
  285. p.EnterOuterAlt(localctx, 1)
  286. match(p, "type")
  287. {
  288. p.SetState(133)
  289. var _m = p.Match(ApiParserParserID)
  290. localctx.(*TypeLitContext).typeToken = _m
  291. }
  292. {
  293. p.SetState(134)
  294. p.TypeLitBody()
  295. }
  296. return localctx
  297. }
  298. // ITypeBlockContext is an interface to support dynamic dispatch.
  299. type ITypeBlockContext interface {
  300. antlr.ParserRuleContext
  301. // GetParser returns the parser.
  302. GetParser() antlr.Parser
  303. // GetTypeToken returns the typeToken token.
  304. GetTypeToken() antlr.Token
  305. // GetLp returns the lp token.
  306. GetLp() antlr.Token
  307. // GetRp returns the rp token.
  308. GetRp() antlr.Token
  309. // SetTypeToken sets the typeToken token.
  310. SetTypeToken(antlr.Token)
  311. // SetLp sets the lp token.
  312. SetLp(antlr.Token)
  313. // SetRp sets the rp token.
  314. SetRp(antlr.Token)
  315. // IsTypeBlockContext differentiates from other interfaces.
  316. IsTypeBlockContext()
  317. }
  318. type TypeBlockContext struct {
  319. *antlr.BaseParserRuleContext
  320. parser antlr.Parser
  321. typeToken antlr.Token
  322. lp antlr.Token
  323. rp antlr.Token
  324. }
  325. func NewEmptyTypeBlockContext() *TypeBlockContext {
  326. var p = new(TypeBlockContext)
  327. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  328. p.RuleIndex = ApiParserParserRULE_typeBlock
  329. return p
  330. }
  331. func (*TypeBlockContext) IsTypeBlockContext() {}
  332. func NewTypeBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockContext {
  333. var p = new(TypeBlockContext)
  334. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  335. p.parser = parser
  336. p.RuleIndex = ApiParserParserRULE_typeBlock
  337. return p
  338. }
  339. func (s *TypeBlockContext) GetParser() antlr.Parser { return s.parser }
  340. func (s *TypeBlockContext) GetTypeToken() antlr.Token { return s.typeToken }
  341. func (s *TypeBlockContext) GetLp() antlr.Token { return s.lp }
  342. func (s *TypeBlockContext) GetRp() antlr.Token { return s.rp }
  343. func (s *TypeBlockContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
  344. func (s *TypeBlockContext) SetLp(v antlr.Token) { s.lp = v }
  345. func (s *TypeBlockContext) SetRp(v antlr.Token) { s.rp = v }
  346. func (s *TypeBlockContext) ID() antlr.TerminalNode {
  347. return s.GetToken(ApiParserParserID, 0)
  348. }
  349. func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext {
  350. var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem())
  351. var tst = make([]ITypeBlockBodyContext, len(ts))
  352. for i, t := range ts {
  353. if t != nil {
  354. tst[i] = t.(ITypeBlockBodyContext)
  355. }
  356. }
  357. return tst
  358. }
  359. func (s *TypeBlockContext) TypeBlockBody(i int) ITypeBlockBodyContext {
  360. var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i)
  361. if t == nil {
  362. return nil
  363. }
  364. return t.(ITypeBlockBodyContext)
  365. }
  366. func (s *TypeBlockContext) GetRuleContext() antlr.RuleContext {
  367. return s
  368. }
  369. func (s *TypeBlockContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  370. return antlr.TreesStringTree(s, ruleNames, recog)
  371. }
  372. func (s *TypeBlockContext) Accept(visitor antlr.ParseTreeVisitor) any {
  373. switch t := visitor.(type) {
  374. case ApiParserVisitor:
  375. return t.VisitTypeBlock(s)
  376. default:
  377. return t.VisitChildren(s)
  378. }
  379. }
  380. func (p *ApiParserParser) TypeBlock() (localctx ITypeBlockContext) {
  381. localctx = NewTypeBlockContext(p, p.GetParserRuleContext(), p.GetState())
  382. p.EnterRule(localctx, 22, ApiParserParserRULE_typeBlock)
  383. var _la int
  384. defer func() {
  385. p.ExitRule()
  386. }()
  387. defer func() {
  388. if err := recover(); err != nil {
  389. if v, ok := err.(antlr.RecognitionException); ok {
  390. localctx.SetException(v)
  391. p.GetErrorHandler().ReportError(p, v)
  392. p.GetErrorHandler().Recover(p, v)
  393. } else {
  394. panic(err)
  395. }
  396. }
  397. }()
  398. p.EnterOuterAlt(localctx, 1)
  399. match(p, "type")
  400. {
  401. p.SetState(137)
  402. var _m = p.Match(ApiParserParserID)
  403. localctx.(*TypeBlockContext).typeToken = _m
  404. }
  405. {
  406. p.SetState(138)
  407. var _m = p.Match(ApiParserParserT__1)
  408. localctx.(*TypeBlockContext).lp = _m
  409. }
  410. p.SetState(142)
  411. p.GetErrorHandler().Sync(p)
  412. _la = p.GetTokenStream().LA(1)
  413. for _la == ApiParserParserID {
  414. {
  415. p.SetState(139)
  416. p.TypeBlockBody()
  417. }
  418. p.SetState(144)
  419. p.GetErrorHandler().Sync(p)
  420. _la = p.GetTokenStream().LA(1)
  421. }
  422. {
  423. p.SetState(145)
  424. var _m = p.Match(ApiParserParserT__2)
  425. localctx.(*TypeBlockContext).rp = _m
  426. }
  427. return localctx
  428. }
  429. // ITypeLitBodyContext is an interface to support dynamic dispatch.
  430. type ITypeLitBodyContext interface {
  431. antlr.ParserRuleContext
  432. // GetParser returns the parser.
  433. GetParser() antlr.Parser
  434. // IsTypeLitBodyContext differentiates from other interfaces.
  435. IsTypeLitBodyContext()
  436. }
  437. type TypeLitBodyContext struct {
  438. *antlr.BaseParserRuleContext
  439. parser antlr.Parser
  440. }
  441. func NewEmptyTypeLitBodyContext() *TypeLitBodyContext {
  442. var p = new(TypeLitBodyContext)
  443. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
  444. p.RuleIndex = ApiParserParserRULE_typeLitBody
  445. return p
  446. }
  447. func (*TypeLitBodyContext) IsTypeLitBodyContext() {}
  448. func NewTypeLitBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitBodyContext {
  449. var p = new(TypeLitBodyContext)
  450. p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
  451. p.parser = parser
  452. p.RuleIndex = ApiParserParserRULE_typeLitBody
  453. return p
  454. }
  455. func (s *TypeLitBodyContext) GetParser() antlr.Parser { return s.parser }
  456. func (s *TypeLitBodyContext) TypeStruct() ITypeStructContext {
  457. var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0)
  458. if t == nil {
  459. return nil
  460. }
  461. return t.(ITypeStructContext)
  462. }
  463. func (s *TypeLitBodyContext) TypeAlias() ITypeAliasContext {
  464. var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeAliasContext)(nil)).Elem(), 0)
  465. if t == nil {
  466. return nil
  467. }
  468. return t.(ITypeAliasContext)
  469. }
  470. func (s *TypeLitBodyContext) GetRuleContext() antlr.RuleContext {
  471. return s
  472. }
  473. func (s *TypeLitBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
  474. return antlr.TreesStringTree(s, ruleNames, recog)
  475. }
  476. func (s *TypeLitBodyContext) Accept(visitor antlr.ParseTreeVisitor) any {
  477. switch t := visitor.(type) {
  478. case ApiParserVisitor:
  479. return t.VisitTypeLitBody(s)
  480. default:
  481. return t.VisitChildren(s)
  482. }
  483. }
  484. func (p *ApiParserParser) TypeLitBody() (localctx ITypeLitBodyContext) {
  485. localctx = NewTypeLitBodyContext(p, p.GetParserRuleContext(), p.GetState())
  486. p.EnterRule(localctx, 24, ApiParserParserRULE_typeLitBody)
  487. defer func() {
  488. p.ExitRule()
  489. }()
  490. defer func() {
  491. if err := recover(); err != nil {
  492. if v, ok := err.(antlr.RecognitionException); ok {
  493. localctx.SetException(v)
  494. p.GetErrorHandler().ReportError(p, v)
  495. p.GetErrorHandler().Recover(p, v)
  496. } else {
  497. panic(err)
  498. }
  499. }
  500. }()
  501. p.SetState(149)
  502. p.GetErrorHandler().Sync(p)
  503. switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 7, p.GetParserRuleContext()) {
  504. case 1:
  505. p.EnterOuterAlt(localctx, 1)
  506. {
  507. p.SetState(147)
  508. p.TypeStruct()
  509. }
  510. case 2:
  511. p.EnterOuterAlt(localctx, 2)
  512. {
  513. p.SetState(148)
  514. p.TypeAlias()
  515. }
  516. }
  517. return localctx
  518. }