Files
go-zero/tools/goctl/api/parser/g4/gen/api/apiparser_parser2.go
2021-12-14 11:29:44 +08:00

657 lines
14 KiB
Go
Executable File

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.
func (s *ImportValueContext) GetParser() antlr.Parser { return s.parser }
func (s *ImportValueContext) STRING() antlr.TerminalNode {
return s.GetToken(ApiParserParserSTRING, 0)
}
func (s *ImportValueContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ImportValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ImportValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitImportValue(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ImportValue() (localctx IImportValueContext) {
localctx = NewImportValueContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 14, ApiParserParserRULE_importValue)
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)
checkImportValue(p)
{
p.SetState(114)
p.Match(ApiParserParserSTRING)
}
return localctx
}
// IInfoSpecContext is an interface to support dynamic dispatch.
type IInfoSpecContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetInfoToken returns the infoToken token.
GetInfoToken() antlr.Token
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetInfoToken sets the infoToken token.
SetInfoToken(antlr.Token)
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsInfoSpecContext differentiates from other interfaces.
IsInfoSpecContext()
}
type InfoSpecContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
infoToken antlr.Token
lp antlr.Token
rp antlr.Token
}
func NewEmptyInfoSpecContext() *InfoSpecContext {
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 {
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 {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
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 {
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) interface{} {
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(117)
_m := p.Match(ApiParserParserID)
localctx.(*InfoSpecContext).infoToken = _m
}
{
p.SetState(118)
_m := p.Match(ApiParserParserT__1)
localctx.(*InfoSpecContext).lp = _m
}
p.SetState(120)
p.GetErrorHandler().Sync(p)
for ok := true; ok; ok = _la == ApiParserParserID {
{
p.SetState(119)
p.KvLit()
}
p.SetState(122)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
{
p.SetState(124)
_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 {
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 {
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 {
t := s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(ITypeLitContext)
}
func (s *TypeSpecContext) TypeBlock() ITypeBlockContext {
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) interface{} {
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(128)
p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 5, p.GetParserRuleContext()) {
case 1:
p.EnterOuterAlt(localctx, 1)
{
p.SetState(126)
p.TypeLit()
}
case 2:
p.EnterOuterAlt(localctx, 2)
{
p.SetState(127)
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 {
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 {
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 {
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) interface{} {
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(131)
_m := p.Match(ApiParserParserID)
localctx.(*TypeLitContext).typeToken = _m
}
{
p.SetState(132)
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 {
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 {
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 {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem())
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 {
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) interface{} {
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(135)
_m := p.Match(ApiParserParserID)
localctx.(*TypeBlockContext).typeToken = _m
}
{
p.SetState(136)
_m := p.Match(ApiParserParserT__1)
localctx.(*TypeBlockContext).lp = _m
}
p.SetState(140)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for _la == ApiParserParserID {
{
p.SetState(137)
p.TypeBlockBody()
}
p.SetState(142)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
{
p.SetState(143)
_m := p.Match(ApiParserParserT__2)
localctx.(*TypeBlockContext).rp = _m
}
return localctx
}