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_parser6.go

613 lines
14 KiB
Go

package api
import (
"reflect"
"github.com/zeromicro/antlr"
)
// Part 6
// The apiparser_parser.go file was split into multiple files because it
// was too large and caused a possible memory overflow during goctl installation.
// IArrayTypeContext is an interface to support dynamic dispatch.
type IArrayTypeContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetLbrack returns the lbrack token.
GetLbrack() antlr.Token
// GetRbrack returns the rbrack token.
GetRbrack() antlr.Token
// SetLbrack sets the lbrack token.
SetLbrack(antlr.Token)
// SetRbrack sets the rbrack token.
SetRbrack(antlr.Token)
// IsArrayTypeContext differentiates from other interfaces.
IsArrayTypeContext()
}
type ArrayTypeContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lbrack antlr.Token
rbrack antlr.Token
}
func NewEmptyArrayTypeContext() *ArrayTypeContext {
p := new(ArrayTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_arrayType
return p
}
func (*ArrayTypeContext) IsArrayTypeContext() {}
func NewArrayTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ArrayTypeContext {
p := new(ArrayTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_arrayType
return p
}
func (s *ArrayTypeContext) GetParser() antlr.Parser { return s.parser }
func (s *ArrayTypeContext) GetLbrack() antlr.Token { return s.lbrack }
func (s *ArrayTypeContext) GetRbrack() antlr.Token { return s.rbrack }
func (s *ArrayTypeContext) SetLbrack(v antlr.Token) { s.lbrack = v }
func (s *ArrayTypeContext) SetRbrack(v antlr.Token) { s.rbrack = v }
func (s *ArrayTypeContext) DataType() IDataTypeContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IDataTypeContext)
}
func (s *ArrayTypeContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ArrayTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ArrayTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitArrayType(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ArrayType() (localctx IArrayTypeContext) {
localctx = NewArrayTypeContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 48, ApiParserParserRULE_arrayType)
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(233)
_m := p.Match(ApiParserParserT__7)
localctx.(*ArrayTypeContext).lbrack = _m
}
{
p.SetState(234)
_m := p.Match(ApiParserParserT__8)
localctx.(*ArrayTypeContext).rbrack = _m
}
{
p.SetState(235)
p.DataType()
}
return localctx
}
// IServiceSpecContext is an interface to support dynamic dispatch.
type IServiceSpecContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsServiceSpecContext differentiates from other interfaces.
IsServiceSpecContext()
}
type ServiceSpecContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
}
func NewEmptyServiceSpecContext() *ServiceSpecContext {
p := new(ServiceSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceSpec
return p
}
func (*ServiceSpecContext) IsServiceSpecContext() {}
func NewServiceSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceSpecContext {
p := new(ServiceSpecContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_serviceSpec
return p
}
func (s *ServiceSpecContext) GetParser() antlr.Parser { return s.parser }
func (s *ServiceSpecContext) ServiceApi() IServiceApiContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceApiContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IServiceApiContext)
}
func (s *ServiceSpecContext) AtServer() IAtServerContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IAtServerContext)
}
func (s *ServiceSpecContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ServiceSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ServiceSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitServiceSpec(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ServiceSpec() (localctx IServiceSpecContext) {
localctx = NewServiceSpecContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 50, ApiParserParserRULE_serviceSpec)
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(238)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserATSERVER {
{
p.SetState(237)
p.AtServer()
}
}
{
p.SetState(240)
p.ServiceApi()
}
return localctx
}
// IAtServerContext is an interface to support dynamic dispatch.
type IAtServerContext 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)
// IsAtServerContext differentiates from other interfaces.
IsAtServerContext()
}
type AtServerContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
lp antlr.Token
rp antlr.Token
}
func NewEmptyAtServerContext() *AtServerContext {
p := new(AtServerContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_atServer
return p
}
func (*AtServerContext) IsAtServerContext() {}
func NewAtServerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtServerContext {
p := new(AtServerContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_atServer
return p
}
func (s *AtServerContext) GetParser() antlr.Parser { return s.parser }
func (s *AtServerContext) GetLp() antlr.Token { return s.lp }
func (s *AtServerContext) GetRp() antlr.Token { return s.rp }
func (s *AtServerContext) SetLp(v antlr.Token) { s.lp = v }
func (s *AtServerContext) SetRp(v antlr.Token) { s.rp = v }
func (s *AtServerContext) ATSERVER() antlr.TerminalNode {
return s.GetToken(ApiParserParserATSERVER, 0)
}
func (s *AtServerContext) 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 *AtServerContext) KvLit(i int) IKvLitContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
if t == nil {
return nil
}
return t.(IKvLitContext)
}
func (s *AtServerContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *AtServerContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *AtServerContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitAtServer(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) AtServer() (localctx IAtServerContext) {
localctx = NewAtServerContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 52, ApiParserParserRULE_atServer)
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(242)
p.Match(ApiParserParserATSERVER)
}
{
p.SetState(243)
_m := p.Match(ApiParserParserT__1)
localctx.(*AtServerContext).lp = _m
}
p.SetState(245)
p.GetErrorHandler().Sync(p)
for ok := true; ok; ok = _la == ApiParserParserID {
{
p.SetState(244)
p.KvLit()
}
p.SetState(247)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
{
p.SetState(249)
_m := p.Match(ApiParserParserT__2)
localctx.(*AtServerContext).rp = _m
}
return localctx
}
// IServiceApiContext is an interface to support dynamic dispatch.
type IServiceApiContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetServiceToken returns the serviceToken token.
GetServiceToken() antlr.Token
// GetLbrace returns the lbrace token.
GetLbrace() antlr.Token
// GetRbrace returns the rbrace token.
GetRbrace() antlr.Token
// SetServiceToken sets the serviceToken token.
SetServiceToken(antlr.Token)
// SetLbrace sets the lbrace token.
SetLbrace(antlr.Token)
// SetRbrace sets the rbrace token.
SetRbrace(antlr.Token)
// IsServiceApiContext differentiates from other interfaces.
IsServiceApiContext()
}
type ServiceApiContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
serviceToken antlr.Token
lbrace antlr.Token
rbrace antlr.Token
}
func NewEmptyServiceApiContext() *ServiceApiContext {
p := new(ServiceApiContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_serviceApi
return p
}
func (*ServiceApiContext) IsServiceApiContext() {}
func NewServiceApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceApiContext {
p := new(ServiceApiContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_serviceApi
return p
}
func (s *ServiceApiContext) GetParser() antlr.Parser { return s.parser }
func (s *ServiceApiContext) GetServiceToken() antlr.Token { return s.serviceToken }
func (s *ServiceApiContext) GetLbrace() antlr.Token { return s.lbrace }
func (s *ServiceApiContext) GetRbrace() antlr.Token { return s.rbrace }
func (s *ServiceApiContext) SetServiceToken(v antlr.Token) { s.serviceToken = v }
func (s *ServiceApiContext) SetLbrace(v antlr.Token) { s.lbrace = v }
func (s *ServiceApiContext) SetRbrace(v antlr.Token) { s.rbrace = v }
func (s *ServiceApiContext) ServiceName() IServiceNameContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceNameContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IServiceNameContext)
}
func (s *ServiceApiContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *ServiceApiContext) AllServiceRoute() []IServiceRouteContext {
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem())
tst := make([]IServiceRouteContext, len(ts))
for i, t := range ts {
if t != nil {
tst[i] = t.(IServiceRouteContext)
}
}
return tst
}
func (s *ServiceApiContext) ServiceRoute(i int) IServiceRouteContext {
t := s.GetTypedRuleContext(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem(), i)
if t == nil {
return nil
}
return t.(IServiceRouteContext)
}
func (s *ServiceApiContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *ServiceApiContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *ServiceApiContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitServiceApi(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) ServiceApi() (localctx IServiceApiContext) {
localctx = NewServiceApiContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 54, ApiParserParserRULE_serviceApi)
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, "service")
{
p.SetState(252)
_m := p.Match(ApiParserParserID)
localctx.(*ServiceApiContext).serviceToken = _m
}
{
p.SetState(253)
p.ServiceName()
}
{
p.SetState(254)
_m := p.Match(ApiParserParserT__3)
localctx.(*ServiceApiContext).lbrace = _m
}
p.SetState(258)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
for ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserATDOC)|(1<<ApiParserParserATHANDLER)|(1<<ApiParserParserATSERVER))) != 0 {
{
p.SetState(255)
p.ServiceRoute()
}
p.SetState(260)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
}
{
p.SetState(261)
_m := p.Match(ApiParserParserT__4)
localctx.(*ServiceApiContext).rbrace = _m
}
return localctx
}