You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/tools/goctl/api/parser/g4/gen/api/apiparser_parser8.go

713 lines
16 KiB
Go

package api
import (
"reflect"
"github.com/zeromicro/antlr"
)
// Part 8
// The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation.
// IBodyContext is an interface to support dynamic dispatch.
type IBodyContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsBodyContext differentiates from other interfaces.
IsBodyContext()
}
type BodyContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lp antlr.Token
rp antlr.Token
}
func NewEmptyBodyContext() *BodyContext {
p := new(BodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_body
return p
}
func (*BodyContext) IsBodyContext() {}
func NewBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *BodyContext {
p := new(BodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_body
return p
}
func (s *BodyContext) GetParser() antlr.Parser { return s.parser }
func (s *BodyContext) GetLp() antlr.Token { return s.lp }
func (s *BodyContext) GetRp() antlr.Token { return s.rp }
func (s *BodyContext) SetLp(v antlr.Token) { s.lp = v }
func (s *BodyContext) SetRp(v antlr.Token) { s.rp = v }
func (s *BodyContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *BodyContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *BodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *BodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitBody(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) Body() (localctx IBodyContext) {
localctx = NewBodyContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 64, ApiParserParserRULE_body)
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)
{
p.SetState(299)
_m := p.Match(ApiParserParserT__1)
localctx.(*BodyContext).lp = _m
}
p.SetState(301)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserID {
{
p.SetState(300)
p.Match(ApiParserParserID)
}
}
{
p.SetState(303)
_m := p.Match(ApiParserParserT__2)
localctx.(*BodyContext).rp = _m
}
return localctx
}
// IReplybodyContext is an interface to support dynamic dispatch.
type IReplybodyContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetReturnToken returns the returnToken token.
GetReturnToken() antlr.Token
// GetLp returns the lp token.
GetLp() antlr.Token
// GetRp returns the rp token.
GetRp() antlr.Token
// SetReturnToken sets the returnToken token.
SetReturnToken(antlr.Token)
// SetLp sets the lp token.
SetLp(antlr.Token)
// SetRp sets the rp token.
SetRp(antlr.Token)
// IsReplybodyContext differentiates from other interfaces.
IsReplybodyContext()
}
type ReplybodyContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
returnToken antlr.Token
lp antlr.Token
rp antlr.Token
}
func NewEmptyReplybodyContext() *ReplybodyContext {
p := new(ReplybodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_replybody
return p
}
func (*ReplybodyContext) IsReplybodyContext() {}
func NewReplybodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ReplybodyContext {
p := new(ReplybodyContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_replybody
return p
}
func (s *ReplybodyContext) GetParser() antlr.Parser { return s.parser }
func (s *ReplybodyContext) GetReturnToken() antlr.Token { return s.returnToken }
func (s *ReplybodyContext) GetLp() antlr.Token { return s.lp }
func (s *ReplybodyContext) GetRp() antlr.Token { return s.rp }
func (s *ReplybodyContext) SetReturnToken(v antlr.Token) { s.returnToken = v }
func (s *ReplybodyContext) SetLp(v antlr.Token) { s.lp = v }
func (s *ReplybodyContext) SetRp(v antlr.Token) { s.rp = v }
func (s *ReplybodyContext) DataType() IDataTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IDataTypeContext)
}
func (s *ReplybodyContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ReplybodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ReplybodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitReplybody(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) Replybody() (localctx IReplybodyContext) {
localctx = NewReplybodyContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 66, ApiParserParserRULE_replybody)
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)
{
p.SetState(305)
_m := p.Match(ApiParserParserT__9)
localctx.(*ReplybodyContext).returnToken = _m
}
{
p.SetState(306)
_m := p.Match(ApiParserParserT__1)
localctx.(*ReplybodyContext).lp = _m
}
p.SetState(308)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserT__5)|(1<<ApiParserParserT__6)|(1<<ApiParserParserT__7)|(1<<ApiParserParserINTERFACE)|(1<<ApiParserParserID))) != 0 {
{
p.SetState(307)
p.DataType()
}
}
{
p.SetState(310)
_m := p.Match(ApiParserParserT__2)
localctx.(*ReplybodyContext).rp = _m
}
return localctx
}
// IKvLitContext is an interface to support dynamic dispatch.
type IKvLitContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetKey returns the key token.
GetKey() antlr.Token
// GetValue returns the value token.
GetValue() antlr.Token
// SetKey sets the key token.
SetKey(antlr.Token)
// SetValue sets the value token.
SetValue(antlr.Token)
// IsKvLitContext differentiates from other interfaces.
IsKvLitContext()
}
type KvLitContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
key antlr.Token
value antlr.Token
}
func NewEmptyKvLitContext() *KvLitContext {
p := new(KvLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_kvLit
return p
}
func (*KvLitContext) IsKvLitContext() {}
func NewKvLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *KvLitContext {
p := new(KvLitContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_kvLit
return p
}
func (s *KvLitContext) GetParser() antlr.Parser { return s.parser }
func (s *KvLitContext) GetKey() antlr.Token { return s.key }
func (s *KvLitContext) GetValue() antlr.Token { return s.value }
func (s *KvLitContext) SetKey(v antlr.Token) { s.key = v }
func (s *KvLitContext) SetValue(v antlr.Token) { s.value = v }
func (s *KvLitContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *KvLitContext) LINE_VALUE() antlr.TerminalNode {
return s.GetToken(ApiParserParserLINE_VALUE, 0)
}
func (s *KvLitContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *KvLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *KvLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitKvLit(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) KvLit() (localctx IKvLitContext) {
localctx = NewKvLitContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 68, ApiParserParserRULE_kvLit)
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)
{
p.SetState(312)
_m := p.Match(ApiParserParserID)
localctx.(*KvLitContext).key = _m
}
checkKeyValue(p)
{
p.SetState(314)
_m := p.Match(ApiParserParserLINE_VALUE)
localctx.(*KvLitContext).value = _m
}
return localctx
}
// IServiceNameContext is an interface to support dynamic dispatch.
type IServiceNameContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsServiceNameContext differentiates from other interfaces.
IsServiceNameContext()
}
type ServiceNameContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyServiceNameContext() *ServiceNameContext {
p := new(ServiceNameContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceName
return p
}
func (*ServiceNameContext) IsServiceNameContext() {}
func NewServiceNameContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceNameContext {
p := new(ServiceNameContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_serviceName
return p
}
func (s *ServiceNameContext) GetParser() antlr.Parser { return s.parser }
func (s *ServiceNameContext) AllID() []antlr.TerminalNode {
return s.GetTokens(ApiParserParserID)
}
func (s *ServiceNameContext) ID(i int) antlr.TerminalNode {
return s.GetToken(ApiParserParserID, i)
}
func (s *ServiceNameContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ServiceNameContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ServiceNameContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitServiceName(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ServiceName() (localctx IServiceNameContext) {
localctx = NewServiceNameContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 70, ApiParserParserRULE_serviceName)
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)
p.SetState(320)
p.GetErrorHandler().Sync(p)
for ok := true; ok; ok = _la == ApiParserParserID {
{
p.SetState(316)
p.Match(ApiParserParserID)
}
p.SetState(318)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__10 {
{
p.SetState(317)
p.Match(ApiParserParserT__10)
}
}
p.SetState(322)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
return localctx
}
// IPathContext is an interface to support dynamic dispatch.
type IPathContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsPathContext differentiates from other interfaces.
IsPathContext()
}
type PathContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyPathContext() *PathContext {
p := new(PathContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_path
return p
}
func (*PathContext) IsPathContext() {}
func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathContext {
p := new(PathContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_path
return p
}
func (s *PathContext) GetParser() antlr.Parser { return s.parser }
func (s *PathContext) AllID() []antlr.TerminalNode {
return s.GetTokens(ApiParserParserID)
}
func (s *PathContext) ID(i int) antlr.TerminalNode {
return s.GetToken(ApiParserParserID, i)
}
func (s *PathContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *PathContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *PathContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitPath(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) Path() (localctx IPathContext) {
localctx = NewPathContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 72, ApiParserParserRULE_path)
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.SetState(344)
p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 38, p.GetParserRuleContext()) {
case 1:
p.EnterOuterAlt(localctx, 1)
p.SetState(339)
p.GetErrorHandler().Sync(p)
for ok := true; ok; ok = _la == ApiParserParserT__11 || _la == ApiParserParserT__12 {
p.SetState(339)
p.GetErrorHandler().Sync(p)
switch p.GetTokenStream().LA(1) {
case ApiParserParserT__11:
{
p.SetState(324)
p.Match(ApiParserParserT__11)
}
{
p.SetState(325)
p.Match(ApiParserParserID)
}
p.SetState(330)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for _la == ApiParserParserT__10 {
{
p.SetState(326)
p.Match(ApiParserParserT__10)
}
{
p.SetState(327)
p.Match(ApiParserParserID)
}
p.SetState(332)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
case ApiParserParserT__12:
{
p.SetState(333)
p.Match(ApiParserParserT__12)
}
{
p.SetState(334)
p.Match(ApiParserParserID)
}
p.SetState(337)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserT__10 {
{
p.SetState(335)
p.Match(ApiParserParserT__10)
}
{
p.SetState(336)
p.Match(ApiParserParserID)
}
}
default:
panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
}
p.SetState(341)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
case 2:
p.EnterOuterAlt(localctx, 2)
{
p.SetState(343)
p.Match(ApiParserParserT__11)
}
}
return localctx
}