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

666 lines
14 KiB
Go

package api
import (
"reflect"
"github.com/zeromicro/antlr"
)
// Part 5
// 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 (p *ApiParserParser) DataType() (localctx IDataTypeContext) {
localctx = NewDataTypeContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 42, ApiParserParserRULE_dataType)
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(221)
p.GetErrorHandler().Sync(p)
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 18, p.GetParserRuleContext()) {
case 1:
p.EnterOuterAlt(localctx, 1)
isInterface(p)
{
p.SetState(214)
p.Match(ApiParserParserID)
}
case 2:
p.EnterOuterAlt(localctx, 2)
{
p.SetState(215)
p.MapType()
}
case 3:
p.EnterOuterAlt(localctx, 3)
{
p.SetState(216)
p.ArrayType()
}
case 4:
p.EnterOuterAlt(localctx, 4)
{
p.SetState(217)
var _m = p.Match(ApiParserParserINTERFACE)
localctx.(*DataTypeContext).inter = _m
}
case 5:
p.EnterOuterAlt(localctx, 5)
{
p.SetState(218)
var _m = p.Match(ApiParserParserT__6)
localctx.(*DataTypeContext).time = _m
}
case 6:
p.EnterOuterAlt(localctx, 6)
{
p.SetState(219)
p.PointerType()
}
case 7:
p.EnterOuterAlt(localctx, 7)
{
p.SetState(220)
p.TypeStruct()
}
}
return localctx
}
// IPointerTypeContext is an interface to support dynamic dispatch.
type IPointerTypeContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetStar returns the star token.
GetStar() antlr.Token
// SetStar sets the star token.
SetStar(antlr.Token)
// IsPointerTypeContext differentiates from other interfaces.
IsPointerTypeContext()
}
type PointerTypeContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
star antlr.Token
}
func NewEmptyPointerTypeContext() *PointerTypeContext {
var p = new(PointerTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_pointerType
return p
}
func (*PointerTypeContext) IsPointerTypeContext() {}
func NewPointerTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PointerTypeContext {
var p = new(PointerTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_pointerType
return p
}
func (s *PointerTypeContext) GetParser() antlr.Parser { return s.parser }
func (s *PointerTypeContext) GetStar() antlr.Token { return s.star }
func (s *PointerTypeContext) SetStar(v antlr.Token) { s.star = v }
func (s *PointerTypeContext) ID() antlr.TerminalNode {
return s.GetToken(ApiParserParserID, 0)
}
func (s *PointerTypeContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *PointerTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *PointerTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitPointerType(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) PointerType() (localctx IPointerTypeContext) {
localctx = NewPointerTypeContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 44, ApiParserParserRULE_pointerType)
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(223)
var _m = p.Match(ApiParserParserT__5)
localctx.(*PointerTypeContext).star = _m
}
checkKeyword(p)
{
p.SetState(225)
p.Match(ApiParserParserID)
}
return localctx
}
// IMapTypeContext is an interface to support dynamic dispatch.
type IMapTypeContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// GetMapToken returns the mapToken token.
GetMapToken() antlr.Token
// GetLbrack returns the lbrack token.
GetLbrack() antlr.Token
// GetKey returns the key token.
GetKey() antlr.Token
// GetRbrack returns the rbrack token.
GetRbrack() antlr.Token
// SetMapToken sets the mapToken token.
SetMapToken(antlr.Token)
// SetLbrack sets the lbrack token.
SetLbrack(antlr.Token)
// SetKey sets the key token.
SetKey(antlr.Token)
// SetRbrack sets the rbrack token.
SetRbrack(antlr.Token)
// GetValue returns the value rule contexts.
GetValue() IDataTypeContext
// SetValue sets the value rule contexts.
SetValue(IDataTypeContext)
// IsMapTypeContext differentiates from other interfaces.
IsMapTypeContext()
}
type MapTypeContext struct {
*antlr.BaseParserRuleContext
parser antlr.Parser
mapToken antlr.Token
lbrack antlr.Token
key antlr.Token
rbrack antlr.Token
value IDataTypeContext
}
func NewEmptyMapTypeContext() *MapTypeContext {
var p = new(MapTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
p.RuleIndex = ApiParserParserRULE_mapType
return p
}
func (*MapTypeContext) IsMapTypeContext() {}
func NewMapTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MapTypeContext {
var p = new(MapTypeContext)
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
p.parser = parser
p.RuleIndex = ApiParserParserRULE_mapType
return p
}
func (s *MapTypeContext) GetParser() antlr.Parser { return s.parser }
func (s *MapTypeContext) GetMapToken() antlr.Token { return s.mapToken }
func (s *MapTypeContext) GetLbrack() antlr.Token { return s.lbrack }
func (s *MapTypeContext) GetKey() antlr.Token { return s.key }
func (s *MapTypeContext) GetRbrack() antlr.Token { return s.rbrack }
func (s *MapTypeContext) SetMapToken(v antlr.Token) { s.mapToken = v }
func (s *MapTypeContext) SetLbrack(v antlr.Token) { s.lbrack = v }
func (s *MapTypeContext) SetKey(v antlr.Token) { s.key = v }
func (s *MapTypeContext) SetRbrack(v antlr.Token) { s.rbrack = v }
func (s *MapTypeContext) GetValue() IDataTypeContext { return s.value }
func (s *MapTypeContext) SetValue(v IDataTypeContext) { s.value = v }
func (s *MapTypeContext) AllID() []antlr.TerminalNode {
return s.GetTokens(ApiParserParserID)
}
func (s *MapTypeContext) ID(i int) antlr.TerminalNode {
return s.GetToken(ApiParserParserID, i)
}
func (s *MapTypeContext) DataType() IDataTypeContext {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IDataTypeContext)
}
func (s *MapTypeContext) GetRuleContext() antlr.RuleContext {
return s
}
func (s *MapTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
return antlr.TreesStringTree(s, ruleNames, recog)
}
func (s *MapTypeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
switch t := visitor.(type) {
case ApiParserVisitor:
return t.VisitMapType(s)
default:
return t.VisitChildren(s)
}
}
func (p *ApiParserParser) MapType() (localctx IMapTypeContext) {
localctx = NewMapTypeContext(p, p.GetParserRuleContext(), p.GetState())
p.EnterRule(localctx, 46, ApiParserParserRULE_mapType)
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, "map")
{
p.SetState(228)
var _m = p.Match(ApiParserParserID)
localctx.(*MapTypeContext).mapToken = _m
}
{
p.SetState(229)
var _m = p.Match(ApiParserParserT__7)
localctx.(*MapTypeContext).lbrack = _m
}
checkKey(p)
{
p.SetState(231)
var _m = p.Match(ApiParserParserID)
localctx.(*MapTypeContext).key = _m
}
{
p.SetState(232)
var _m = p.Match(ApiParserParserT__8)
localctx.(*MapTypeContext).rbrack = _m
}
{
p.SetState(233)
var _x = p.DataType()
localctx.(*MapTypeContext).value = _x
}
return localctx
}
// 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 {
var 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 {
var 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 {
var 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(235)
var _m = p.Match(ApiParserParserT__7)
localctx.(*ArrayTypeContext).lbrack = _m
}
{
p.SetState(236)
var _m = p.Match(ApiParserParserT__8)
localctx.(*ArrayTypeContext).rbrack = _m
}
{
p.SetState(237)
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 {
var 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 {
var 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 {
var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceApiContext)(nil)).Elem(), 0)
if t == nil {
return nil
}
return t.(IServiceApiContext)
}
func (s *ServiceSpecContext) AtServer() IAtServerContext {
var 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(240)
p.GetErrorHandler().Sync(p)
_la = p.GetTokenStream().LA(1)
if _la == ApiParserParserATSERVER {
{
p.SetState(239)
p.AtServer()
}
}
{
p.SetState(242)
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()
}