* g4 code generation * Update grammar * g4 code generation * fix #2108 * fix #2102 * Remove comments
This commit is contained in:
@@ -10,24 +10,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.
|
||||
|
||||
func (s *SyntaxLitContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *SyntaxLitContext) GetSyntaxToken() antlr.Token { return s.syntaxToken }
|
||||
|
||||
func (s *SyntaxLitContext) GetAssign() antlr.Token { return s.assign }
|
||||
|
||||
func (s *SyntaxLitContext) GetVersion() antlr.Token { return s.version }
|
||||
|
||||
func (s *SyntaxLitContext) SetSyntaxToken(v antlr.Token) { s.syntaxToken = v }
|
||||
|
||||
func (s *SyntaxLitContext) SetAssign(v antlr.Token) { s.assign = v }
|
||||
|
||||
func (s *SyntaxLitContext) SetVersion(v antlr.Token) { s.version = v }
|
||||
|
||||
func (s *SyntaxLitContext) ID() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserID, 0)
|
||||
}
|
||||
|
||||
func (s *SyntaxLitContext) STRING() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserSTRING, 0)
|
||||
}
|
||||
@@ -73,24 +55,24 @@ func (p *ApiParserParser) SyntaxLit() (localctx ISyntaxLitContext) {
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
match(p, "syntax")
|
||||
{
|
||||
p.SetState(88)
|
||||
p.SetState(90)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
var _m = p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*SyntaxLitContext).syntaxToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(89)
|
||||
p.SetState(91)
|
||||
|
||||
_m := p.Match(ApiParserParserT__0)
|
||||
var _m = p.Match(ApiParserParserT__0)
|
||||
|
||||
localctx.(*SyntaxLitContext).assign = _m
|
||||
}
|
||||
checkVersion(p)
|
||||
{
|
||||
p.SetState(91)
|
||||
p.SetState(93)
|
||||
|
||||
_m := p.Match(ApiParserParserSTRING)
|
||||
var _m = p.Match(ApiParserParserSTRING)
|
||||
|
||||
localctx.(*SyntaxLitContext).version = _m
|
||||
}
|
||||
@@ -115,7 +97,7 @@ type ImportSpecContext struct {
|
||||
}
|
||||
|
||||
func NewEmptyImportSpecContext() *ImportSpecContext {
|
||||
p := new(ImportSpecContext)
|
||||
var p = new(ImportSpecContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importSpec
|
||||
return p
|
||||
@@ -124,7 +106,7 @@ func NewEmptyImportSpecContext() *ImportSpecContext {
|
||||
func (*ImportSpecContext) IsImportSpecContext() {}
|
||||
|
||||
func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportSpecContext {
|
||||
p := new(ImportSpecContext)
|
||||
var p = new(ImportSpecContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
@@ -137,7 +119,7 @@ func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, i
|
||||
func (s *ImportSpecContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ImportSpecContext) ImportLit() IImportLitContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0)
|
||||
var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
@@ -147,7 +129,7 @@ func (s *ImportSpecContext) ImportLit() IImportLitContext {
|
||||
}
|
||||
|
||||
func (s *ImportSpecContext) ImportBlock() IImportBlockContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0)
|
||||
var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
@@ -194,20 +176,20 @@ func (p *ApiParserParser) ImportSpec() (localctx IImportSpecContext) {
|
||||
}
|
||||
}()
|
||||
|
||||
p.SetState(95)
|
||||
p.SetState(97)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 2, p.GetParserRuleContext()) {
|
||||
case 1:
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(93)
|
||||
p.SetState(95)
|
||||
p.ImportLit()
|
||||
}
|
||||
|
||||
case 2:
|
||||
p.EnterOuterAlt(localctx, 2)
|
||||
{
|
||||
p.SetState(94)
|
||||
p.SetState(96)
|
||||
p.ImportBlock()
|
||||
}
|
||||
|
||||
@@ -240,7 +222,7 @@ type ImportLitContext struct {
|
||||
}
|
||||
|
||||
func NewEmptyImportLitContext() *ImportLitContext {
|
||||
p := new(ImportLitContext)
|
||||
var p = new(ImportLitContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importLit
|
||||
return p
|
||||
@@ -249,7 +231,7 @@ func NewEmptyImportLitContext() *ImportLitContext {
|
||||
func (*ImportLitContext) IsImportLitContext() {}
|
||||
|
||||
func NewImportLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportLitContext {
|
||||
p := new(ImportLitContext)
|
||||
var p = new(ImportLitContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
@@ -266,7 +248,7 @@ func (s *ImportLitContext) GetImportToken() antlr.Token { return s.importToken }
|
||||
func (s *ImportLitContext) SetImportToken(v antlr.Token) { s.importToken = v }
|
||||
|
||||
func (s *ImportLitContext) ImportValue() IImportValueContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
|
||||
var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
@@ -320,14 +302,14 @@ func (p *ApiParserParser) ImportLit() (localctx IImportLitContext) {
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
match(p, "import")
|
||||
{
|
||||
p.SetState(98)
|
||||
p.SetState(100)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
var _m = p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*ImportLitContext).importToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(99)
|
||||
p.SetState(101)
|
||||
p.ImportValue()
|
||||
}
|
||||
|
||||
@@ -358,7 +340,7 @@ type ImportBlockContext struct {
|
||||
}
|
||||
|
||||
func NewEmptyImportBlockContext() *ImportBlockContext {
|
||||
p := new(ImportBlockContext)
|
||||
var p = new(ImportBlockContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importBlock
|
||||
return p
|
||||
@@ -367,7 +349,7 @@ func NewEmptyImportBlockContext() *ImportBlockContext {
|
||||
func (*ImportBlockContext) IsImportBlockContext() {}
|
||||
|
||||
func NewImportBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockContext {
|
||||
p := new(ImportBlockContext)
|
||||
var p = new(ImportBlockContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
@@ -388,8 +370,8 @@ func (s *ImportBlockContext) ID() antlr.TerminalNode {
|
||||
}
|
||||
|
||||
func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext {
|
||||
ts := s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem())
|
||||
tst := make([]IImportBlockValueContext, len(ts))
|
||||
var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem())
|
||||
var tst = make([]IImportBlockValueContext, len(ts))
|
||||
|
||||
for i, t := range ts {
|
||||
if t != nil {
|
||||
@@ -401,7 +383,7 @@ func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext {
|
||||
}
|
||||
|
||||
func (s *ImportBlockContext) ImportBlockValue(i int) IImportBlockValueContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i)
|
||||
var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
@@ -452,31 +434,32 @@ func (p *ApiParserParser) ImportBlock() (localctx IImportBlockContext) {
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
match(p, "import")
|
||||
{
|
||||
p.SetState(102)
|
||||
p.SetState(104)
|
||||
|
||||
_m := p.Match(ApiParserParserID)
|
||||
var _m = p.Match(ApiParserParserID)
|
||||
|
||||
localctx.(*ImportBlockContext).importToken = _m
|
||||
}
|
||||
{
|
||||
p.SetState(103)
|
||||
p.SetState(105)
|
||||
p.Match(ApiParserParserT__1)
|
||||
}
|
||||
p.SetState(105)
|
||||
p.SetState(107)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
|
||||
for ok := true; ok; ok = _la == ApiParserParserSTRING {
|
||||
{
|
||||
p.SetState(104)
|
||||
p.SetState(106)
|
||||
p.ImportBlockValue()
|
||||
}
|
||||
|
||||
p.SetState(107)
|
||||
p.SetState(109)
|
||||
p.GetErrorHandler().Sync(p)
|
||||
_la = p.GetTokenStream().LA(1)
|
||||
}
|
||||
{
|
||||
p.SetState(109)
|
||||
p.SetState(111)
|
||||
p.Match(ApiParserParserT__2)
|
||||
}
|
||||
|
||||
@@ -500,7 +483,7 @@ type ImportBlockValueContext struct {
|
||||
}
|
||||
|
||||
func NewEmptyImportBlockValueContext() *ImportBlockValueContext {
|
||||
p := new(ImportBlockValueContext)
|
||||
var p = new(ImportBlockValueContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importBlockValue
|
||||
return p
|
||||
@@ -509,7 +492,7 @@ func NewEmptyImportBlockValueContext() *ImportBlockValueContext {
|
||||
func (*ImportBlockValueContext) IsImportBlockValueContext() {}
|
||||
|
||||
func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockValueContext {
|
||||
p := new(ImportBlockValueContext)
|
||||
var p = new(ImportBlockValueContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
@@ -522,7 +505,7 @@ func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleCont
|
||||
func (s *ImportBlockValueContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ImportBlockValueContext) ImportValue() IImportValueContext {
|
||||
t := s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
|
||||
var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
|
||||
|
||||
if t == nil {
|
||||
return nil
|
||||
@@ -571,7 +554,7 @@ func (p *ApiParserParser) ImportBlockValue() (localctx IImportBlockValueContext)
|
||||
|
||||
p.EnterOuterAlt(localctx, 1)
|
||||
{
|
||||
p.SetState(111)
|
||||
p.SetState(113)
|
||||
p.ImportValue()
|
||||
}
|
||||
|
||||
@@ -595,7 +578,7 @@ type ImportValueContext struct {
|
||||
}
|
||||
|
||||
func NewEmptyImportValueContext() *ImportValueContext {
|
||||
p := new(ImportValueContext)
|
||||
var p = new(ImportValueContext)
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
|
||||
p.RuleIndex = ApiParserParserRULE_importValue
|
||||
return p
|
||||
@@ -604,7 +587,7 @@ func NewEmptyImportValueContext() *ImportValueContext {
|
||||
func (*ImportValueContext) IsImportValueContext() {}
|
||||
|
||||
func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportValueContext {
|
||||
p := new(ImportValueContext)
|
||||
var p = new(ImportValueContext)
|
||||
|
||||
p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
|
||||
|
||||
@@ -613,3 +596,86 @@ func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext,
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (s *ImportValueContext) GetParser() antlr.Parser { return s.parser }
|
||||
|
||||
func (s *ImportValueContext) STRING() antlr.TerminalNode {
|
||||
return s.GetToken(ApiParserParserSTRING, 0)
|
||||
}
|
||||
|
||||
func (s *ImportValueContext) GetRuleContext() antlr.RuleContext {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *ImportValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
|
||||
return antlr.TreesStringTree(s, ruleNames, recog)
|
||||
}
|
||||
|
||||
func (s *ImportValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
|
||||
switch t := visitor.(type) {
|
||||
case ApiParserVisitor:
|
||||
return t.VisitImportValue(s)
|
||||
|
||||
default:
|
||||
return t.VisitChildren(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ApiParserParser) ImportValue() (localctx IImportValueContext) {
|
||||
localctx = NewImportValueContext(p, p.GetParserRuleContext(), p.GetState())
|
||||
p.EnterRule(localctx, 14, ApiParserParserRULE_importValue)
|
||||
|
||||
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)
|
||||
checkImportValue(p)
|
||||
{
|
||||
p.SetState(116)
|
||||
p.Match(ApiParserParserSTRING)
|
||||
}
|
||||
|
||||
return localctx
|
||||
}
|
||||
|
||||
// IInfoSpecContext is an interface to support dynamic dispatch.
|
||||
type IInfoSpecContext interface {
|
||||
antlr.ParserRuleContext
|
||||
|
||||
// GetParser returns the parser.
|
||||
GetParser() antlr.Parser
|
||||
|
||||
// GetInfoToken returns the infoToken token.
|
||||
GetInfoToken() antlr.Token
|
||||
|
||||
// GetLp returns the lp token.
|
||||
GetLp() antlr.Token
|
||||
|
||||
// GetRp returns the rp token.
|
||||
GetRp() antlr.Token
|
||||
|
||||
// SetInfoToken sets the infoToken token.
|
||||
SetInfoToken(antlr.Token)
|
||||
|
||||
// SetLp sets the lp token.
|
||||
SetLp(antlr.Token)
|
||||
|
||||
// SetRp sets the rp token.
|
||||
SetRp(antlr.Token)
|
||||
|
||||
// IsInfoSpecContext differentiates from other interfaces.
|
||||
IsInfoSpecContext()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user