* fix #1318 * fix #1318 * remove never used code * fix unit tes Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
// 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
|
||||
@@ -18,16 +19,18 @@ type IBodyContext interface {
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetLp returns the lp token.
|
||||
GetLp() antlr.Token
|
||||
GetLp() antlr.Token
|
||||
|
||||
// GetRp returns the rp token.
|
||||
GetRp() antlr.Token
|
||||
GetRp() antlr.Token
|
||||
|
||||
|
||||
// SetLp sets the lp token.
|
||||
SetLp(antlr.Token)
|
||||
SetLp(antlr.Token)
|
||||
|
||||
// SetRp sets the rp token.
|
||||
SetRp(antlr.Token)
|
||||
SetRp(antlr.Token)
|
||||
|
||||
|
||||
// IsBodyContext differentiates from other interfaces.
|
||||
IsBodyContext()
|
||||
@@ -36,8 +39,8 @@ type IBodyContext interface {
|
||||
type BodyContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
lp antlr.Token
|
||||
rp antlr.Token
|
||||
lp antlr.Token
|
||||
rp antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyBodyContext() *BodyContext {
|
||||
@@ -66,10 +69,12 @@ 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)
|
||||
}
|
||||
@@ -82,6 +87,7 @@ func (s *BodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) s
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
|
||||
func (s *BodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
@@ -92,11 +98,15 @@ func (s *BodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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()
|
||||
}()
|
||||
@@ -115,34 +125,38 @@ func (p *ApiParserParser) Body() (localctx IBodyContext) {
|
||||
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(302)
|
||||
p.SetState(299)
|
||||
|
||||
var _m = p.Match(ApiParserParserT__1)
|
||||
|
||||
localctx.(*BodyContext).lp = _m
|
||||
}
|
||||
p.SetState(304)
|
||||
p.SetState(301)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
|
||||
if _la == ApiParserParserID {
|
||||
{
|
||||
p.SetState(303)
|
||||
p.SetState(300)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
|
||||
}
|
||||
{
|
||||
p.SetState(306)
|
||||
p.SetState(303)
|
||||
|
||||
var _m = p.Match(ApiParserParserT__2)
|
||||
|
||||
localctx.(*BodyContext).rp = _m
|
||||
}
|
||||
|
||||
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
|
||||
// IReplybodyContext is an interface to support dynamic dispatch.
|
||||
type IReplybodyContext interface {
|
||||
antlr.ParserRuleContext
|
||||
@@ -150,17 +164,25 @@ type IReplybodyContext interface {
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetReturnToken returns the returnToken token.
|
||||
GetReturnToken() antlr.Token
|
||||
|
||||
// GetLp returns the lp token.
|
||||
GetLp() antlr.Token
|
||||
GetLp() antlr.Token
|
||||
|
||||
// GetRp returns the rp token.
|
||||
GetRp() antlr.Token
|
||||
GetRp() antlr.Token
|
||||
|
||||
|
||||
// SetReturnToken sets the returnToken token.
|
||||
SetReturnToken(antlr.Token)
|
||||
|
||||
// SetLp sets the lp token.
|
||||
SetLp(antlr.Token)
|
||||
SetLp(antlr.Token)
|
||||
|
||||
// SetRp sets the rp token.
|
||||
SetRp(antlr.Token)
|
||||
SetRp(antlr.Token)
|
||||
|
||||
|
||||
// IsReplybodyContext differentiates from other interfaces.
|
||||
IsReplybodyContext()
|
||||
@@ -169,8 +191,9 @@ type IReplybodyContext interface {
|
||||
type ReplybodyContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
lp antlr.Token
|
||||
rp antlr.Token
|
||||
returnToken antlr.Token
|
||||
lp antlr.Token
|
||||
rp antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyReplybodyContext() *ReplybodyContext {
|
||||
@@ -195,14 +218,20 @@ func NewReplybodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, in
|
||||
|
||||
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 {
|
||||
var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
|
||||
|
||||
@@ -221,6 +250,7 @@ func (s *ReplybodyContext) ToStringTree(ruleNames []string, recog antlr.Recogniz
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
|
||||
func (s *ReplybodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
@@ -231,11 +261,15 @@ func (s *ReplybodyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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()
|
||||
}()
|
||||
@@ -254,34 +288,45 @@ func (p *ApiParserParser) Replybody() (localctx IReplybodyContext) {
|
||||
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(308)
|
||||
p.SetState(305)
|
||||
|
||||
var _m = p.Match(ApiParserParserT__9)
|
||||
|
||||
localctx.(*ReplybodyContext).returnToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(306)
|
||||
|
||||
var _m = p.Match(ApiParserParserT__1)
|
||||
|
||||
localctx.(*ReplybodyContext).lp = _m
|
||||
}
|
||||
p.SetState(310)
|
||||
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 {
|
||||
|
||||
if (((_la) & -(0x1f+1)) == 0 && ((1 << uint(_la)) & ((1 << ApiParserParserT__5) | (1 << ApiParserParserT__6) | (1 << ApiParserParserT__7) | (1 << ApiParserParserINTERFACE) | (1 << ApiParserParserID))) != 0) {
|
||||
{
|
||||
p.SetState(309)
|
||||
p.SetState(307)
|
||||
p.DataType()
|
||||
}
|
||||
|
||||
}
|
||||
{
|
||||
p.SetState(312)
|
||||
p.SetState(310)
|
||||
|
||||
var _m = p.Match(ApiParserParserT__2)
|
||||
|
||||
localctx.(*ReplybodyContext).rp = _m
|
||||
}
|
||||
|
||||
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
|
||||
// IKvLitContext is an interface to support dynamic dispatch.
|
||||
type IKvLitContext interface {
|
||||
antlr.ParserRuleContext
|
||||
@@ -290,16 +335,18 @@ type IKvLitContext interface {
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetKey returns the key token.
|
||||
GetKey() antlr.Token
|
||||
GetKey() antlr.Token
|
||||
|
||||
// GetValue returns the value token.
|
||||
GetValue() antlr.Token
|
||||
GetValue() antlr.Token
|
||||
|
||||
|
||||
// SetKey sets the key token.
|
||||
SetKey(antlr.Token)
|
||||
SetKey(antlr.Token)
|
||||
|
||||
// SetValue sets the value token.
|
||||
SetValue(antlr.Token)
|
||||
SetValue(antlr.Token)
|
||||
|
||||
|
||||
// IsKvLitContext differentiates from other interfaces.
|
||||
IsKvLitContext()
|
||||
@@ -308,8 +355,8 @@ type IKvLitContext interface {
|
||||
type KvLitContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
key antlr.Token
|
||||
value antlr.Token
|
||||
key antlr.Token
|
||||
value antlr.Token
|
||||
}
|
||||
|
||||
func NewEmptyKvLitContext() *KvLitContext {
|
||||
@@ -338,10 +385,12 @@ 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)
|
||||
}
|
||||
@@ -358,6 +407,7 @@ func (s *KvLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer)
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
|
||||
func (s *KvLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
@@ -368,6 +418,9 @@ func (s *KvLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func (p *ApiParserParser) KvLit() (localctx IKvLitContext) {
|
||||
localctx = NewKvLitContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 68, ApiParserParserRULE_kvLit)
|
||||
@@ -390,7 +443,7 @@ func (p *ApiParserParser) KvLit() (localctx IKvLitContext) {
|
||||
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(314)
|
||||
p.SetState(312)
|
||||
|
||||
var _m = p.Match(ApiParserParserID)
|
||||
|
||||
@@ -398,16 +451,19 @@ func (p *ApiParserParser) KvLit() (localctx IKvLitContext) {
|
||||
}
|
||||
checkKeyValue(p)
|
||||
{
|
||||
p.SetState(316)
|
||||
p.SetState(314)
|
||||
|
||||
var _m = p.Match(ApiParserParserLINE_VALUE)
|
||||
|
||||
localctx.(*KvLitContext).value = _m
|
||||
}
|
||||
|
||||
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
|
||||
// IServiceNameContext is an interface to support dynamic dispatch.
|
||||
type IServiceNameContext interface {
|
||||
antlr.ParserRuleContext
|
||||
@@ -462,6 +518,7 @@ func (s *ServiceNameContext) ToStringTree(ruleNames []string, recog antlr.Recogn
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
|
||||
func (s *ServiceNameContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
@@ -472,11 +529,15 @@ func (s *ServiceNameContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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()
|
||||
}()
|
||||
@@ -494,34 +555,39 @@ func (p *ApiParserParser) ServiceName() (localctx IServiceNameContext) {
|
||||
}()
|
||||
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
p.SetState(322)
|
||||
p.SetState(320)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserID {
|
||||
{
|
||||
p.SetState(318)
|
||||
p.SetState(316)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
p.SetState(320)
|
||||
p.SetState(318)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__9 {
|
||||
|
||||
if _la == ApiParserParserT__10 {
|
||||
{
|
||||
p.SetState(319)
|
||||
p.Match(ApiParserParserT__9)
|
||||
p.SetState(317)
|
||||
p.Match(ApiParserParserT__10)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
p.SetState(324)
|
||||
|
||||
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
|
||||
@@ -576,6 +642,7 @@ func (s *PathContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) s
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
|
||||
func (s *PathContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
@@ -586,11 +653,15 @@ func (s *PathContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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()
|
||||
}()
|
||||
@@ -607,91 +678,103 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
|
||||
}
|
||||
}()
|
||||
|
||||
p.SetState(346)
|
||||
p.SetState(344)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 39, p.GetParserRuleContext()) {
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 38, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
p.SetState(341)
|
||||
p.SetState(339)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserT__10 || _la == ApiParserParserT__11 {
|
||||
p.SetState(341)
|
||||
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__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)
|
||||
|
||||
for _la == ApiParserParserT__9 {
|
||||
{
|
||||
p.SetState(328)
|
||||
p.Match(ApiParserParserT__9)
|
||||
}
|
||||
{
|
||||
p.SetState(329)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
|
||||
p.SetState(334)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
|
||||
case ApiParserParserT__11:
|
||||
{
|
||||
p.SetState(335)
|
||||
p.SetState(324)
|
||||
p.Match(ApiParserParserT__11)
|
||||
}
|
||||
|
||||
{
|
||||
p.SetState(336)
|
||||
p.SetState(325)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
p.SetState(339)
|
||||
p.SetState(330)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__9 {
|
||||
|
||||
for _la == ApiParserParserT__10 {
|
||||
{
|
||||
p.SetState(337)
|
||||
p.Match(ApiParserParserT__9)
|
||||
p.SetState(326)
|
||||
p.Match(ApiParserParserT__10)
|
||||
}
|
||||
{
|
||||
p.SetState(338)
|
||||
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(343)
|
||||
p.SetState(341)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
|
||||
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(345)
|
||||
p.Match(ApiParserParserT__10)
|
||||
p.SetState(343)
|
||||
p.Match(ApiParserParserT__11)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user