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.
638 lines
15 KiB
Go
638 lines
15 KiB
Go
package api
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/zeromicro/antlr"
|
|
)
|
|
|
|
// Part 3
|
|
// The apiparser_parser.go file was split into multiple files because it
|
|
// was too large and caused a possible memory overflow during goctl installation.
|
|
|
|
// 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) interface{} {
|
|
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(147)
|
|
p.GetErrorHandler().Sync(p)
|
|
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 7, p.GetParserRuleContext()) {
|
|
case 1:
|
|
p.EnterOuterAlt(localctx, 1)
|
|
{
|
|
p.SetState(145)
|
|
p.TypeStruct()
|
|
}
|
|
|
|
case 2:
|
|
p.EnterOuterAlt(localctx, 2)
|
|
{
|
|
p.SetState(146)
|
|
p.TypeAlias()
|
|
}
|
|
|
|
}
|
|
|
|
return localctx
|
|
}
|
|
|
|
// ITypeBlockBodyContext is an interface to support dynamic dispatch.
|
|
type ITypeBlockBodyContext interface {
|
|
antlr.ParserRuleContext
|
|
|
|
// GetParser returns the parser.
|
|
GetParser() antlr.Parser
|
|
|
|
// IsTypeBlockBodyContext differentiates from other interfaces.
|
|
IsTypeBlockBodyContext()
|
|
}
|
|
|
|
type TypeBlockBodyContext struct {
|
|
*antlr.BaseParserRuleContext
|
|
parser antlr.Parser
|
|
}
|
|
|
|
func NewEmptyTypeBlockBodyContext() *TypeBlockBodyContext {
|
|
var p = new(TypeBlockBodyContext)
|
|
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
|
p.RuleIndex = ApiParserParserRULE_typeBlockBody
|
|
return p
|
|
}
|
|
|
|
func (*TypeBlockBodyContext) IsTypeBlockBodyContext() {}
|
|
|
|
func NewTypeBlockBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockBodyContext {
|
|
var p = new(TypeBlockBodyContext)
|
|
|
|
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
|
|
|
p.parser = parser
|
|
p.RuleIndex = ApiParserParserRULE_typeBlockBody
|
|
|
|
return p
|
|
}
|
|
|
|
func (s *TypeBlockBodyContext) GetParser() antlr.Parser { return s.parser }
|
|
|
|
func (s *TypeBlockBodyContext) TypeBlockStruct() ITypeBlockStructContext {
|
|
var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockStructContext)(nil)).Elem(), 0)
|
|
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
|
|
return t.(ITypeBlockStructContext)
|
|
}
|
|
|
|
func (s *TypeBlockBodyContext) TypeBlockAlias() ITypeBlockAliasContext {
|
|
var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockAliasContext)(nil)).Elem(), 0)
|
|
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
|
|
return t.(ITypeBlockAliasContext)
|
|
}
|
|
|
|
func (s *TypeBlockBodyContext) GetRuleContext() antlr.RuleContext {
|
|
return s
|
|
}
|
|
|
|
func (s *TypeBlockBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
|
return antlr.TreesStringTree(s, ruleNames, recog)
|
|
}
|
|
|
|
func (s *TypeBlockBodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
|
switch t := visitor.(type) {
|
|
case ApiParserVisitor:
|
|
return t.VisitTypeBlockBody(s)
|
|
|
|
default:
|
|
return t.VisitChildren(s)
|
|
}
|
|
}
|
|
|
|
func (p *ApiParserParser) TypeBlockBody() (localctx ITypeBlockBodyContext) {
|
|
localctx = NewTypeBlockBodyContext(p, p.GetParserRuleContext(), p.GetState())
|
|
p.EnterRule(localctx, 26, ApiParserParserRULE_typeBlockBody)
|
|
|
|
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(151)
|
|
p.GetErrorHandler().Sync(p)
|
|
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) {
|
|
case 1:
|
|
p.EnterOuterAlt(localctx, 1)
|
|
{
|
|
p.SetState(149)
|
|
p.TypeBlockStruct()
|
|
}
|
|
|
|
case 2:
|
|
p.EnterOuterAlt(localctx, 2)
|
|
{
|
|
p.SetState(150)
|
|
p.TypeBlockAlias()
|
|
}
|
|
|
|
}
|
|
|
|
return localctx
|
|
}
|
|
|
|
// ITypeStructContext is an interface to support dynamic dispatch.
|
|
type ITypeStructContext interface {
|
|
antlr.ParserRuleContext
|
|
|
|
// GetParser returns the parser.
|
|
GetParser() antlr.Parser
|
|
|
|
// GetStructName returns the structName token.
|
|
GetStructName() antlr.Token
|
|
|
|
// GetStructToken returns the structToken token.
|
|
GetStructToken() antlr.Token
|
|
|
|
// GetLbrace returns the lbrace token.
|
|
GetLbrace() antlr.Token
|
|
|
|
// GetRbrace returns the rbrace token.
|
|
GetRbrace() antlr.Token
|
|
|
|
// SetStructName sets the structName token.
|
|
SetStructName(antlr.Token)
|
|
|
|
// SetStructToken sets the structToken token.
|
|
SetStructToken(antlr.Token)
|
|
|
|
// SetLbrace sets the lbrace token.
|
|
SetLbrace(antlr.Token)
|
|
|
|
// SetRbrace sets the rbrace token.
|
|
SetRbrace(antlr.Token)
|
|
|
|
// IsTypeStructContext differentiates from other interfaces.
|
|
IsTypeStructContext()
|
|
}
|
|
|
|
type TypeStructContext struct {
|
|
*antlr.BaseParserRuleContext
|
|
parser antlr.Parser
|
|
structName antlr.Token
|
|
structToken antlr.Token
|
|
lbrace antlr.Token
|
|
rbrace antlr.Token
|
|
}
|
|
|
|
func NewEmptyTypeStructContext() *TypeStructContext {
|
|
var p = new(TypeStructContext)
|
|
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
|
p.RuleIndex = ApiParserParserRULE_typeStruct
|
|
return p
|
|
}
|
|
|
|
func (*TypeStructContext) IsTypeStructContext() {}
|
|
|
|
func NewTypeStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeStructContext {
|
|
var p = new(TypeStructContext)
|
|
|
|
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
|
|
|
p.parser = parser
|
|
p.RuleIndex = ApiParserParserRULE_typeStruct
|
|
|
|
return p
|
|
}
|
|
|
|
func (s *TypeStructContext) GetParser() antlr.Parser { return s.parser }
|
|
|
|
func (s *TypeStructContext) GetStructName() antlr.Token { return s.structName }
|
|
|
|
func (s *TypeStructContext) GetStructToken() antlr.Token { return s.structToken }
|
|
|
|
func (s *TypeStructContext) GetLbrace() antlr.Token { return s.lbrace }
|
|
|
|
func (s *TypeStructContext) GetRbrace() antlr.Token { return s.rbrace }
|
|
|
|
func (s *TypeStructContext) SetStructName(v antlr.Token) { s.structName = v }
|
|
|
|
func (s *TypeStructContext) SetStructToken(v antlr.Token) { s.structToken = v }
|
|
|
|
func (s *TypeStructContext) SetLbrace(v antlr.Token) { s.lbrace = v }
|
|
|
|
func (s *TypeStructContext) SetRbrace(v antlr.Token) { s.rbrace = v }
|
|
|
|
func (s *TypeStructContext) AllID() []antlr.TerminalNode {
|
|
return s.GetTokens(ApiParserParserID)
|
|
}
|
|
|
|
func (s *TypeStructContext) ID(i int) antlr.TerminalNode {
|
|
return s.GetToken(ApiParserParserID, i)
|
|
}
|
|
|
|
func (s *TypeStructContext) AllField() []IFieldContext {
|
|
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem())
|
|
var tst = make([]IFieldContext, len(ts))
|
|
|
|
for i, t := range ts {
|
|
if t != nil {
|
|
tst[i] = t.(IFieldContext)
|
|
}
|
|
}
|
|
|
|
return tst
|
|
}
|
|
|
|
func (s *TypeStructContext) Field(i int) IFieldContext {
|
|
var t = s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i)
|
|
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
|
|
return t.(IFieldContext)
|
|
}
|
|
|
|
func (s *TypeStructContext) GetRuleContext() antlr.RuleContext {
|
|
return s
|
|
}
|
|
|
|
func (s *TypeStructContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
|
return antlr.TreesStringTree(s, ruleNames, recog)
|
|
}
|
|
|
|
func (s *TypeStructContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
|
switch t := visitor.(type) {
|
|
case ApiParserVisitor:
|
|
return t.VisitTypeStruct(s)
|
|
|
|
default:
|
|
return t.VisitChildren(s)
|
|
}
|
|
}
|
|
|
|
func (p *ApiParserParser) TypeStruct() (localctx ITypeStructContext) {
|
|
localctx = NewTypeStructContext(p, p.GetParserRuleContext(), p.GetState())
|
|
p.EnterRule(localctx, 28, ApiParserParserRULE_typeStruct)
|
|
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)
|
|
}
|
|
}
|
|
}()
|
|
|
|
var _alt int
|
|
|
|
p.EnterOuterAlt(localctx, 1)
|
|
checkKeyword(p)
|
|
{
|
|
p.SetState(154)
|
|
|
|
var _m = p.Match(ApiParserParserID)
|
|
|
|
localctx.(*TypeStructContext).structName = _m
|
|
}
|
|
p.SetState(156)
|
|
p.GetErrorHandler().Sync(p)
|
|
_la = p.GetTokenStream().LA(1)
|
|
|
|
if _la == ApiParserParserID {
|
|
{
|
|
p.SetState(155)
|
|
|
|
var _m = p.Match(ApiParserParserID)
|
|
|
|
localctx.(*TypeStructContext).structToken = _m
|
|
}
|
|
|
|
}
|
|
{
|
|
p.SetState(158)
|
|
|
|
var _m = p.Match(ApiParserParserT__3)
|
|
|
|
localctx.(*TypeStructContext).lbrace = _m
|
|
}
|
|
p.SetState(162)
|
|
p.GetErrorHandler().Sync(p)
|
|
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext())
|
|
|
|
for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
|
|
if _alt == 1 {
|
|
{
|
|
p.SetState(159)
|
|
p.Field()
|
|
}
|
|
|
|
}
|
|
p.SetState(164)
|
|
p.GetErrorHandler().Sync(p)
|
|
_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext())
|
|
}
|
|
{
|
|
p.SetState(165)
|
|
|
|
var _m = p.Match(ApiParserParserT__4)
|
|
|
|
localctx.(*TypeStructContext).rbrace = _m
|
|
}
|
|
|
|
return localctx
|
|
}
|
|
|
|
// ITypeAliasContext is an interface to support dynamic dispatch.
|
|
type ITypeAliasContext interface {
|
|
antlr.ParserRuleContext
|
|
|
|
// GetParser returns the parser.
|
|
GetParser() antlr.Parser
|
|
|
|
// GetAlias returns the alias token.
|
|
GetAlias() antlr.Token
|
|
|
|
// GetAssign returns the assign token.
|
|
GetAssign() antlr.Token
|
|
|
|
// SetAlias sets the alias token.
|
|
SetAlias(antlr.Token)
|
|
|
|
// SetAssign sets the assign token.
|
|
SetAssign(antlr.Token)
|
|
|
|
// IsTypeAliasContext differentiates from other interfaces.
|
|
IsTypeAliasContext()
|
|
}
|
|
|
|
type TypeAliasContext struct {
|
|
*antlr.BaseParserRuleContext
|
|
parser antlr.Parser
|
|
alias antlr.Token
|
|
assign antlr.Token
|
|
}
|
|
|
|
func NewEmptyTypeAliasContext() *TypeAliasContext {
|
|
var p = new(TypeAliasContext)
|
|
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
|
p.RuleIndex = ApiParserParserRULE_typeAlias
|
|
return p
|
|
}
|
|
|
|
func (*TypeAliasContext) IsTypeAliasContext() {}
|
|
|
|
func NewTypeAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeAliasContext {
|
|
var p = new(TypeAliasContext)
|
|
|
|
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
|
|
|
p.parser = parser
|
|
p.RuleIndex = ApiParserParserRULE_typeAlias
|
|
|
|
return p
|
|
}
|
|
|
|
func (s *TypeAliasContext) GetParser() antlr.Parser { return s.parser }
|
|
|
|
func (s *TypeAliasContext) GetAlias() antlr.Token { return s.alias }
|
|
|
|
func (s *TypeAliasContext) GetAssign() antlr.Token { return s.assign }
|
|
|
|
func (s *TypeAliasContext) SetAlias(v antlr.Token) { s.alias = v }
|
|
|
|
func (s *TypeAliasContext) SetAssign(v antlr.Token) { s.assign = v }
|
|
|
|
func (s *TypeAliasContext) DataType() IDataTypeContext {
|
|
var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
|
|
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
|
|
return t.(IDataTypeContext)
|
|
}
|
|
|
|
func (s *TypeAliasContext) ID() antlr.TerminalNode {
|
|
return s.GetToken(ApiParserParserID, 0)
|
|
}
|
|
|
|
func (s *TypeAliasContext) GetRuleContext() antlr.RuleContext {
|
|
return s
|
|
}
|
|
|
|
func (s *TypeAliasContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
|
return antlr.TreesStringTree(s, ruleNames, recog)
|
|
}
|
|
|
|
func (s *TypeAliasContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
|
switch t := visitor.(type) {
|
|
case ApiParserVisitor:
|
|
return t.VisitTypeAlias(s)
|
|
|
|
default:
|
|
return t.VisitChildren(s)
|
|
}
|
|
}
|
|
|
|
func (p *ApiParserParser) TypeAlias() (localctx ITypeAliasContext) {
|
|
localctx = NewTypeAliasContext(p, p.GetParserRuleContext(), p.GetState())
|
|
p.EnterRule(localctx, 30, ApiParserParserRULE_typeAlias)
|
|
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)
|
|
checkKeyword(p)
|
|
{
|
|
p.SetState(168)
|
|
|
|
var _m = p.Match(ApiParserParserID)
|
|
|
|
localctx.(*TypeAliasContext).alias = _m
|
|
}
|
|
p.SetState(170)
|
|
p.GetErrorHandler().Sync(p)
|
|
_la = p.GetTokenStream().LA(1)
|
|
|
|
if _la == ApiParserParserT__0 {
|
|
{
|
|
p.SetState(169)
|
|
|
|
var _m = p.Match(ApiParserParserT__0)
|
|
|
|
localctx.(*TypeAliasContext).assign = _m
|
|
}
|
|
|
|
}
|
|
{
|
|
p.SetState(172)
|
|
p.DataType()
|
|
}
|
|
|
|
return localctx
|
|
}
|
|
|
|
// ITypeBlockStructContext is an interface to support dynamic dispatch.
|
|
type ITypeBlockStructContext interface {
|
|
antlr.ParserRuleContext
|
|
|
|
// GetParser returns the parser.
|
|
GetParser() antlr.Parser
|
|
|
|
// GetStructName returns the structName token.
|
|
GetStructName() antlr.Token
|
|
|
|
// GetStructToken returns the structToken token.
|
|
GetStructToken() antlr.Token
|
|
|
|
// GetLbrace returns the lbrace token.
|
|
GetLbrace() antlr.Token
|
|
|
|
// GetRbrace returns the rbrace token.
|
|
GetRbrace() antlr.Token
|
|
|
|
// SetStructName sets the structName token.
|
|
SetStructName(antlr.Token)
|
|
|
|
// SetStructToken sets the structToken token.
|
|
SetStructToken(antlr.Token)
|
|
|
|
// SetLbrace sets the lbrace token.
|
|
SetLbrace(antlr.Token)
|
|
|
|
// SetRbrace sets the rbrace token.
|
|
SetRbrace(antlr.Token)
|
|
|
|
// IsTypeBlockStructContext differentiates from other interfaces.
|
|
IsTypeBlockStructContext()
|
|
}
|