* g4 code generation * Update grammar * g4 code generation * fix #2108 * fix #2102 * Remove comments
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/zeromicro/antlr"
|
||||
@@ -10,370 +11,6 @@ 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
|
||||
|
||||
// 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:
|
||||
@@ -406,17 +43,17 @@ func (p *ApiParserParser) KvLit() (localctx IKvLitContext) {
|
||||
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(312)
|
||||
p.SetState(314)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
var _m = p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*KvLitContext).key = _m
|
||||
}
|
||||
checkKeyValue(p)
|
||||
{
|
||||
p.SetState(314)
|
||||
p.SetState(316)
|
||||
|
||||
_m := p.Match(ApiParserParserLINE_VALUE)
|
||||
var _m = p.Match(ApiParserParserLINE_VALUE)
|
||||
|
||||
localctx.(*KvLitContext).value = _m
|
||||
}
|
||||
@@ -441,7 +78,7 @@ type ServiceNameContext struct {
|
||||
}
|
||||
|
||||
func NewEmptyServiceNameContext() *ServiceNameContext {
|
||||
p := new(ServiceNameContext)
|
||||
var p = new(ServiceNameContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_serviceName
|
||||
return p
|
||||
@@ -450,7 +87,7 @@ func NewEmptyServiceNameContext() *ServiceNameContext {
|
||||
func (*ServiceNameContext) IsServiceNameContext() {}
|
||||
|
||||
func NewServiceNameContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceNameContext {
|
||||
p := new(ServiceNameContext)
|
||||
var p = new(ServiceNameContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
@@ -510,26 +147,28 @@ func (p *ApiParserParser) ServiceName() (localctx IServiceNameContext) {
|
||||
}()
|
||||
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
p.SetState(320)
|
||||
p.SetState(322)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserID {
|
||||
{
|
||||
p.SetState(316)
|
||||
p.SetState(318)
|
||||
p.Match(ApiParserParserID)
|
||||
}
|
||||
p.SetState(318)
|
||||
p.SetState(320)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__10 {
|
||||
{
|
||||
p.SetState(317)
|
||||
p.SetState(319)
|
||||
p.Match(ApiParserParserT__10)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
p.SetState(322)
|
||||
p.SetState(324)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
@@ -554,7 +193,7 @@ type PathContext struct {
|
||||
}
|
||||
|
||||
func NewEmptyPathContext() *PathContext {
|
||||
p := new(PathContext)
|
||||
var p = new(PathContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_path
|
||||
return p
|
||||
@@ -563,7 +202,7 @@ func NewEmptyPathContext() *PathContext {
|
||||
func (*PathContext) IsPathContext() {}
|
||||
|
||||
func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathContext {
|
||||
p := new(PathContext)
|
||||
var p = new(PathContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
@@ -575,12 +214,27 @@ func NewPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokin
|
||||
|
||||
func (s *PathContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *PathContext) AllID() []antlr.TerminalNode {
|
||||
return s.GetTokens(ApiParserParserID)
|
||||
func (s *PathContext) AllPathItem() []IPathItemContext {
|
||||
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IPathItemContext)(nil)).Elem())
|
||||
var tst = make([]IPathItemContext, len(ts))
|
||||
|
||||
for i, t := range ts {
|
||||
if t != nil {
|
||||
tst[i] = t.(IPathItemContext)
|
||||
}
|
||||
}
|
||||
|
||||
return tst
|
||||
}
|
||||
|
||||
func (s *PathContext) ID(i int) antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, i)
|
||||
func (s *PathContext) PathItem(i int) IPathItemContext {
|
||||
var t = s.GetTypedRuleContext(reflect.TypeOf((*IPathItemContext)(nil)).Elem(), i)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.(IPathItemContext)
|
||||
}
|
||||
|
||||
func (s *PathContext) GetRuleContext() antlr.RuleContext {
|
||||
@@ -622,70 +276,71 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
|
||||
}
|
||||
}()
|
||||
|
||||
p.SetState(344)
|
||||
p.SetState(346)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 38, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
p.SetState(339)
|
||||
p.SetState(341)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserT__11 || _la == ApiParserParserT__12 {
|
||||
p.SetState(339)
|
||||
p.SetState(341)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
|
||||
switch p.GetTokenStream().LA(1) {
|
||||
case ApiParserParserT__11:
|
||||
{
|
||||
p.SetState(324)
|
||||
p.SetState(326)
|
||||
p.Match(ApiParserParserT__11)
|
||||
}
|
||||
|
||||
{
|
||||
p.SetState(325)
|
||||
p.Match(ApiParserParserID)
|
||||
p.SetState(327)
|
||||
p.PathItem()
|
||||
}
|
||||
p.SetState(330)
|
||||
p.SetState(332)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
for _la == ApiParserParserT__10 {
|
||||
{
|
||||
p.SetState(326)
|
||||
p.SetState(328)
|
||||
p.Match(ApiParserParserT__10)
|
||||
}
|
||||
{
|
||||
p.SetState(327)
|
||||
p.Match(ApiParserParserID)
|
||||
p.SetState(329)
|
||||
p.PathItem()
|
||||
}
|
||||
|
||||
p.SetState(332)
|
||||
p.SetState(334)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
|
||||
case ApiParserParserT__12:
|
||||
{
|
||||
p.SetState(333)
|
||||
p.SetState(335)
|
||||
p.Match(ApiParserParserT__12)
|
||||
}
|
||||
|
||||
{
|
||||
p.SetState(334)
|
||||
p.Match(ApiParserParserID)
|
||||
p.SetState(336)
|
||||
p.PathItem()
|
||||
}
|
||||
p.SetState(337)
|
||||
p.SetState(339)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if _la == ApiParserParserT__10 {
|
||||
{
|
||||
p.SetState(335)
|
||||
p.SetState(337)
|
||||
p.Match(ApiParserParserT__10)
|
||||
}
|
||||
{
|
||||
p.SetState(336)
|
||||
p.Match(ApiParserParserID)
|
||||
p.SetState(338)
|
||||
p.PathItem()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -694,7 +349,7 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
|
||||
panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
|
||||
}
|
||||
|
||||
p.SetState(341)
|
||||
p.SetState(343)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
@@ -702,7 +357,7 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(343)
|
||||
p.SetState(345)
|
||||
p.Match(ApiParserParserT__11)
|
||||
}
|
||||
|
||||
@@ -710,3 +365,146 @@ func (p *ApiParserParser) Path() (localctx IPathContext) {
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IPathItemContext is an interface to support dynamic dispatch.
|
||||
type IPathItemContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// IsPathItemContext differentiates from other interfaces.
|
||||
IsPathItemContext()
|
||||
}
|
||||
|
||||
type PathItemContext struct {
|
||||
*antlr.BaseParserRuleContext
|
||||
parser antlr.Parser
|
||||
}
|
||||
|
||||
func NewEmptyPathItemContext() *PathItemContext {
|
||||
var p = new(PathItemContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_pathItem
|
||||
return p
|
||||
}
|
||||
|
||||
func (*PathItemContext) IsPathItemContext() {}
|
||||
|
||||
func NewPathItemContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PathItemContext {
|
||||
var p = new(PathItemContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
p.parser = parser
|
||||
p.RuleIndex = ApiParserParserRULE_pathItem
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *PathItemContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *PathItemContext) AllID() []antlr.TerminalNode {
|
||||
return s.GetTokens(ApiParserParserID)
|
||||
}
|
||||
|
||||
func (s *PathItemContext) ID(i int) antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, i)
|
||||
}
|
||||
|
||||
func (s *PathItemContext) AllLetterOrDigit() []antlr.TerminalNode {
|
||||
return s.GetTokens(ApiParserParserLetterOrDigit)
|
||||
}
|
||||
|
||||
func (s *PathItemContext) LetterOrDigit(i int) antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserLetterOrDigit, i)
|
||||
}
|
||||
|
||||
func (s *PathItemContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *PathItemContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *PathItemContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitPathItem(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) PathItem() (localctx IPathItemContext) {
|
||||
localctx = NewPathItemContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 74, ApiParserParserRULE_pathItem)
|
||||
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(349)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserID || _la == ApiParserParserLetterOrDigit {
|
||||
{
|
||||
p.SetState(348)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
if !(_la == ApiParserParserID || _la == ApiParserParserLetterOrDigit) {
|
||||
p.GetErrorHandler().RecoverInline(p)
|
||||
} else {
|
||||
p.GetErrorHandler().ReportMatch(p)
|
||||
p.Consume()
|
||||
}
|
||||
}
|
||||
|
||||
p.SetState(351)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool {
|
||||
switch ruleIndex {
|
||||
case 18:
|
||||
var t *FieldContext = nil
|
||||
if localctx != nil {
|
||||
t = localctx.(*FieldContext)
|
||||
}
|
||||
return p.Field_Sempred(t, predIndex)
|
||||
|
||||
default:
|
||||
panic("No predicate with index: " + fmt.Sprint(ruleIndex))
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) Field_Sempred(localctx antlr.RuleContext, predIndex int) bool {
|
||||
switch predIndex {
|
||||
case 0:
|
||||
return isNormal(p)
|
||||
|
||||
default:
|
||||
panic("No predicate with index: " + fmt.Sprint(predIndex))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user