123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692 |
- package api
- import (
- "reflect"
- "github.com/zeromicro/antlr"
- )
- // Part 2
- // The apiparser_parser.go file was split into multiple files because it
- // was too large and caused a possible memory overflow during goctl installation.
- type InfoSpecContext struct {
- *antlr.BaseParserRuleContext
- parser antlr.Parser
- infoToken antlr.Token
- lp antlr.Token
- rp antlr.Token
- }
- func NewEmptyInfoSpecContext() *InfoSpecContext {
- var p = new(InfoSpecContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
- p.RuleIndex = ApiParserParserRULE_infoSpec
- return p
- }
- func (*InfoSpecContext) IsInfoSpecContext() {}
- func NewInfoSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InfoSpecContext {
- var p = new(InfoSpecContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
- p.parser = parser
- p.RuleIndex = ApiParserParserRULE_infoSpec
- return p
- }
- func (s *InfoSpecContext) GetParser() antlr.Parser { return s.parser }
- func (s *InfoSpecContext) GetInfoToken() antlr.Token { return s.infoToken }
- func (s *InfoSpecContext) GetLp() antlr.Token { return s.lp }
- func (s *InfoSpecContext) GetRp() antlr.Token { return s.rp }
- func (s *InfoSpecContext) SetInfoToken(v antlr.Token) { s.infoToken = v }
- func (s *InfoSpecContext) SetLp(v antlr.Token) { s.lp = v }
- func (s *InfoSpecContext) SetRp(v antlr.Token) { s.rp = v }
- func (s *InfoSpecContext) ID() antlr.TerminalNode {
- return s.GetToken(ApiParserParserID, 0)
- }
- func (s *InfoSpecContext) AllKvLit() []IKvLitContext {
- var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
- var tst = make([]IKvLitContext, len(ts))
- for i, t := range ts {
- if t != nil {
- tst[i] = t.(IKvLitContext)
- }
- }
- return tst
- }
- func (s *InfoSpecContext) KvLit(i int) IKvLitContext {
- var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
- if t == nil {
- return nil
- }
- return t.(IKvLitContext)
- }
- func (s *InfoSpecContext) GetRuleContext() antlr.RuleContext {
- return s
- }
- func (s *InfoSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
- return antlr.TreesStringTree(s, ruleNames, recog)
- }
- func (s *InfoSpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
- switch t := visitor.(type) {
- case ApiParserVisitor:
- return t.VisitInfoSpec(s)
- default:
- return t.VisitChildren(s)
- }
- }
- func (p *ApiParserParser) InfoSpec() (localctx IInfoSpecContext) {
- localctx = NewInfoSpecContext(p, p.GetParserRuleContext(), p.GetState())
- p.EnterRule(localctx, 16, ApiParserParserRULE_infoSpec)
- var _la int
- defer func() {
- p.ExitRule()
- }()
- defer func() {
- if err := recover(); err != nil {
- if v, ok := err.(antlr.RecognitionException); ok {
- localctx.SetException(v)
- p.GetErrorHandler().ReportError(p, v)
- p.GetErrorHandler().Recover(p, v)
- } else {
- panic(err)
- }
- }
- }()
- p.EnterOuterAlt(localctx, 1)
- match(p, "info")
- {
- p.SetState(119)
- var _m = p.Match(ApiParserParserID)
- localctx.(*InfoSpecContext).infoToken = _m
- }
- {
- p.SetState(120)
- var _m = p.Match(ApiParserParserT__1)
- localctx.(*InfoSpecContext).lp = _m
- }
- p.SetState(122)
- p.GetErrorHandler().Sync(p)
- _la = p.GetTokenStream().LA(1)
- for ok := true; ok; ok = _la == ApiParserParserID {
- {
- p.SetState(121)
- p.KvLit()
- }
- p.SetState(124)
- p.GetErrorHandler().Sync(p)
- _la = p.GetTokenStream().LA(1)
- }
- {
- p.SetState(126)
- var _m = p.Match(ApiParserParserT__2)
- localctx.(*InfoSpecContext).rp = _m
- }
- return localctx
- }
- // ITypeSpecContext is an interface to support dynamic dispatch.
- type ITypeSpecContext interface {
- antlr.ParserRuleContext
- // GetParser returns the parser.
- GetParser() antlr.Parser
- // IsTypeSpecContext differentiates from other interfaces.
- IsTypeSpecContext()
- }
- type TypeSpecContext struct {
- *antlr.BaseParserRuleContext
- parser antlr.Parser
- }
- func NewEmptyTypeSpecContext() *TypeSpecContext {
- var p = new(TypeSpecContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
- p.RuleIndex = ApiParserParserRULE_typeSpec
- return p
- }
- func (*TypeSpecContext) IsTypeSpecContext() {}
- func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecContext {
- var p = new(TypeSpecContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
- p.parser = parser
- p.RuleIndex = ApiParserParserRULE_typeSpec
- return p
- }
- func (s *TypeSpecContext) GetParser() antlr.Parser { return s.parser }
- func (s *TypeSpecContext) TypeLit() ITypeLitContext {
- var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0)
- if t == nil {
- return nil
- }
- return t.(ITypeLitContext)
- }
- func (s *TypeSpecContext) TypeBlock() ITypeBlockContext {
- var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0)
- if t == nil {
- return nil
- }
- return t.(ITypeBlockContext)
- }
- func (s *TypeSpecContext) GetRuleContext() antlr.RuleContext {
- return s
- }
- func (s *TypeSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
- return antlr.TreesStringTree(s, ruleNames, recog)
- }
- func (s *TypeSpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
- switch t := visitor.(type) {
- case ApiParserVisitor:
- return t.VisitTypeSpec(s)
- default:
- return t.VisitChildren(s)
- }
- }
- func (p *ApiParserParser) TypeSpec() (localctx ITypeSpecContext) {
- localctx = NewTypeSpecContext(p, p.GetParserRuleContext(), p.GetState())
- p.EnterRule(localctx, 18, ApiParserParserRULE_typeSpec)
- defer func() {
- p.ExitRule()
- }()
- defer func() {
- if err := recover(); err != nil {
- if v, ok := err.(antlr.RecognitionException); ok {
- localctx.SetException(v)
- p.GetErrorHandler().ReportError(p, v)
- p.GetErrorHandler().Recover(p, v)
- } else {
- panic(err)
- }
- }
- }()
- p.SetState(130)
- p.GetErrorHandler().Sync(p)
- switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 5, p.GetParserRuleContext()) {
- case 1:
- p.EnterOuterAlt(localctx, 1)
- {
- p.SetState(128)
- p.TypeLit()
- }
- case 2:
- p.EnterOuterAlt(localctx, 2)
- {
- p.SetState(129)
- p.TypeBlock()
- }
- }
- return localctx
- }
- // ITypeLitContext is an interface to support dynamic dispatch.
- type ITypeLitContext interface {
- antlr.ParserRuleContext
- // GetParser returns the parser.
- GetParser() antlr.Parser
- // GetTypeToken returns the typeToken token.
- GetTypeToken() antlr.Token
- // SetTypeToken sets the typeToken token.
- SetTypeToken(antlr.Token)
- // IsTypeLitContext differentiates from other interfaces.
- IsTypeLitContext()
- }
- type TypeLitContext struct {
- *antlr.BaseParserRuleContext
- parser antlr.Parser
- typeToken antlr.Token
- }
- func NewEmptyTypeLitContext() *TypeLitContext {
- var p = new(TypeLitContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
- p.RuleIndex = ApiParserParserRULE_typeLit
- return p
- }
- func (*TypeLitContext) IsTypeLitContext() {}
- func NewTypeLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitContext {
- var p = new(TypeLitContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
- p.parser = parser
- p.RuleIndex = ApiParserParserRULE_typeLit
- return p
- }
- func (s *TypeLitContext) GetParser() antlr.Parser { return s.parser }
- func (s *TypeLitContext) GetTypeToken() antlr.Token { return s.typeToken }
- func (s *TypeLitContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
- func (s *TypeLitContext) TypeLitBody() ITypeLitBodyContext {
- var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0)
- if t == nil {
- return nil
- }
- return t.(ITypeLitBodyContext)
- }
- func (s *TypeLitContext) ID() antlr.TerminalNode {
- return s.GetToken(ApiParserParserID, 0)
- }
- func (s *TypeLitContext) GetRuleContext() antlr.RuleContext {
- return s
- }
- func (s *TypeLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
- return antlr.TreesStringTree(s, ruleNames, recog)
- }
- func (s *TypeLitContext) Accept(visitor antlr.ParseTreeVisitor) any {
- switch t := visitor.(type) {
- case ApiParserVisitor:
- return t.VisitTypeLit(s)
- default:
- return t.VisitChildren(s)
- }
- }
- func (p *ApiParserParser) TypeLit() (localctx ITypeLitContext) {
- localctx = NewTypeLitContext(p, p.GetParserRuleContext(), p.GetState())
- p.EnterRule(localctx, 20, ApiParserParserRULE_typeLit)
- defer func() {
- p.ExitRule()
- }()
- defer func() {
- if err := recover(); err != nil {
- if v, ok := err.(antlr.RecognitionException); ok {
- localctx.SetException(v)
- p.GetErrorHandler().ReportError(p, v)
- p.GetErrorHandler().Recover(p, v)
- } else {
- panic(err)
- }
- }
- }()
- p.EnterOuterAlt(localctx, 1)
- match(p, "type")
- {
- p.SetState(133)
- var _m = p.Match(ApiParserParserID)
- localctx.(*TypeLitContext).typeToken = _m
- }
- {
- p.SetState(134)
- p.TypeLitBody()
- }
- return localctx
- }
- // ITypeBlockContext is an interface to support dynamic dispatch.
- type ITypeBlockContext interface {
- antlr.ParserRuleContext
- // GetParser returns the parser.
- GetParser() antlr.Parser
- // GetTypeToken returns the typeToken token.
- GetTypeToken() antlr.Token
- // GetLp returns the lp token.
- GetLp() antlr.Token
- // GetRp returns the rp token.
- GetRp() antlr.Token
- // SetTypeToken sets the typeToken token.
- SetTypeToken(antlr.Token)
- // SetLp sets the lp token.
- SetLp(antlr.Token)
- // SetRp sets the rp token.
- SetRp(antlr.Token)
- // IsTypeBlockContext differentiates from other interfaces.
- IsTypeBlockContext()
- }
- type TypeBlockContext struct {
- *antlr.BaseParserRuleContext
- parser antlr.Parser
- typeToken antlr.Token
- lp antlr.Token
- rp antlr.Token
- }
- func NewEmptyTypeBlockContext() *TypeBlockContext {
- var p = new(TypeBlockContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
- p.RuleIndex = ApiParserParserRULE_typeBlock
- return p
- }
- func (*TypeBlockContext) IsTypeBlockContext() {}
- func NewTypeBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockContext {
- var p = new(TypeBlockContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
- p.parser = parser
- p.RuleIndex = ApiParserParserRULE_typeBlock
- return p
- }
- func (s *TypeBlockContext) GetParser() antlr.Parser { return s.parser }
- func (s *TypeBlockContext) GetTypeToken() antlr.Token { return s.typeToken }
- func (s *TypeBlockContext) GetLp() antlr.Token { return s.lp }
- func (s *TypeBlockContext) GetRp() antlr.Token { return s.rp }
- func (s *TypeBlockContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
- func (s *TypeBlockContext) SetLp(v antlr.Token) { s.lp = v }
- func (s *TypeBlockContext) SetRp(v antlr.Token) { s.rp = v }
- func (s *TypeBlockContext) ID() antlr.TerminalNode {
- return s.GetToken(ApiParserParserID, 0)
- }
- func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext {
- var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem())
- var tst = make([]ITypeBlockBodyContext, len(ts))
- for i, t := range ts {
- if t != nil {
- tst[i] = t.(ITypeBlockBodyContext)
- }
- }
- return tst
- }
- func (s *TypeBlockContext) TypeBlockBody(i int) ITypeBlockBodyContext {
- var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i)
- if t == nil {
- return nil
- }
- return t.(ITypeBlockBodyContext)
- }
- func (s *TypeBlockContext) GetRuleContext() antlr.RuleContext {
- return s
- }
- func (s *TypeBlockContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
- return antlr.TreesStringTree(s, ruleNames, recog)
- }
- func (s *TypeBlockContext) Accept(visitor antlr.ParseTreeVisitor) any {
- switch t := visitor.(type) {
- case ApiParserVisitor:
- return t.VisitTypeBlock(s)
- default:
- return t.VisitChildren(s)
- }
- }
- func (p *ApiParserParser) TypeBlock() (localctx ITypeBlockContext) {
- localctx = NewTypeBlockContext(p, p.GetParserRuleContext(), p.GetState())
- p.EnterRule(localctx, 22, ApiParserParserRULE_typeBlock)
- var _la int
- defer func() {
- p.ExitRule()
- }()
- defer func() {
- if err := recover(); err != nil {
- if v, ok := err.(antlr.RecognitionException); ok {
- localctx.SetException(v)
- p.GetErrorHandler().ReportError(p, v)
- p.GetErrorHandler().Recover(p, v)
- } else {
- panic(err)
- }
- }
- }()
- p.EnterOuterAlt(localctx, 1)
- match(p, "type")
- {
- p.SetState(137)
- var _m = p.Match(ApiParserParserID)
- localctx.(*TypeBlockContext).typeToken = _m
- }
- {
- p.SetState(138)
- var _m = p.Match(ApiParserParserT__1)
- localctx.(*TypeBlockContext).lp = _m
- }
- p.SetState(142)
- p.GetErrorHandler().Sync(p)
- _la = p.GetTokenStream().LA(1)
- for _la == ApiParserParserID {
- {
- p.SetState(139)
- p.TypeBlockBody()
- }
- p.SetState(144)
- p.GetErrorHandler().Sync(p)
- _la = p.GetTokenStream().LA(1)
- }
- {
- p.SetState(145)
- var _m = p.Match(ApiParserParserT__2)
- localctx.(*TypeBlockContext).rp = _m
- }
- return localctx
- }
- // ITypeLitBodyContext is an interface to support dynamic dispatch.
- type ITypeLitBodyContext interface {
- antlr.ParserRuleContext
- // GetParser returns the parser.
- GetParser() antlr.Parser
- // IsTypeLitBodyContext differentiates from other interfaces.
- IsTypeLitBodyContext()
- }
- type TypeLitBodyContext struct {
- *antlr.BaseParserRuleContext
- parser antlr.Parser
- }
- func NewEmptyTypeLitBodyContext() *TypeLitBodyContext {
- var p = new(TypeLitBodyContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
- p.RuleIndex = ApiParserParserRULE_typeLitBody
- return p
- }
- func (*TypeLitBodyContext) IsTypeLitBodyContext() {}
- func NewTypeLitBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitBodyContext {
- var p = new(TypeLitBodyContext)
- p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
- p.parser = parser
- p.RuleIndex = ApiParserParserRULE_typeLitBody
- return p
- }
- func (s *TypeLitBodyContext) GetParser() antlr.Parser { return s.parser }
- func (s *TypeLitBodyContext) TypeStruct() ITypeStructContext {
- var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0)
- if t == nil {
- return nil
- }
- return t.(ITypeStructContext)
- }
- func (s *TypeLitBodyContext) TypeAlias() ITypeAliasContext {
- var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeAliasContext)(nil)).Elem(), 0)
- if t == nil {
- return nil
- }
- return t.(ITypeAliasContext)
- }
- func (s *TypeLitBodyContext) GetRuleContext() antlr.RuleContext {
- return s
- }
- func (s *TypeLitBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
- return antlr.TreesStringTree(s, ruleNames, recog)
- }
- func (s *TypeLitBodyContext) Accept(visitor antlr.ParseTreeVisitor) any {
- switch t := visitor.(type) {
- case ApiParserVisitor:
- return t.VisitTypeLitBody(s)
- default:
- return t.VisitChildren(s)
- }
- }
- func (p *ApiParserParser) TypeLitBody() (localctx ITypeLitBodyContext) {
- localctx = NewTypeLitBodyContext(p, p.GetParserRuleContext(), p.GetState())
- p.EnterRule(localctx, 24, ApiParserParserRULE_typeLitBody)
- defer func() {
- p.ExitRule()
- }()
- defer func() {
- if err := recover(); err != nil {
- if v, ok := err.(antlr.RecognitionException); ok {
- localctx.SetException(v)
- p.GetErrorHandler().ReportError(p, v)
- p.GetErrorHandler().Recover(p, v)
- } else {
- panic(err)
- }
- }
- }()
- p.SetState(149)
- p.GetErrorHandler().Sync(p)
- switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 7, p.GetParserRuleContext()) {
- case 1:
- p.EnterOuterAlt(localctx, 1)
- {
- p.SetState(147)
- p.TypeStruct()
- }
- case 2:
- p.EnterOuterAlt(localctx, 2)
- {
- p.SetState(148)
- p.TypeAlias()
- }
- }
- return localctx
- }
|