package api import ( "reflect" "github.com/zeromicro/antlr" ) // Part 2 // 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 *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(114) 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() } type InfoSpecContext struct { *antlr.BaseParserRuleContext parser antlr.Parser infoToken antlr.Token lp antlr.Token rp antlr.Token } func NewEmptyInfoSpecContext() *InfoSpecContext { var p = new(InfoSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_infoSpec return p } func (*InfoSpecContext) IsInfoSpecContext() {} func NewInfoSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InfoSpecContext { var p = new(InfoSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.parser = parser p.RuleIndex = ApiParserParserRULE_infoSpec return p } func (s *InfoSpecContext) GetParser() antlr.Parser { return s.parser } func (s *InfoSpecContext) GetInfoToken() antlr.Token { return s.infoToken } func (s *InfoSpecContext) GetLp() antlr.Token { return s.lp } func (s *InfoSpecContext) GetRp() antlr.Token { return s.rp } func (s *InfoSpecContext) SetInfoToken(v antlr.Token) { s.infoToken = v } func (s *InfoSpecContext) SetLp(v antlr.Token) { s.lp = v } func (s *InfoSpecContext) SetRp(v antlr.Token) { s.rp = v } func (s *InfoSpecContext) ID() antlr.TerminalNode { return s.GetToken(ApiParserParserID, 0) } func (s *InfoSpecContext) AllKvLit() []IKvLitContext { var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem()) var tst = make([]IKvLitContext, len(ts)) for i, t := range ts { if t != nil { tst[i] = t.(IKvLitContext) } } return tst } func (s *InfoSpecContext) KvLit(i int) IKvLitContext { var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i) if t == nil { return nil } return t.(IKvLitContext) } func (s *InfoSpecContext) GetRuleContext() antlr.RuleContext { return s } func (s *InfoSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { return antlr.TreesStringTree(s, ruleNames, recog) } func (s *InfoSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitInfoSpec(s) default: return t.VisitChildren(s) } } func (p *ApiParserParser) InfoSpec() (localctx IInfoSpecContext) { localctx = NewInfoSpecContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 16, ApiParserParserRULE_infoSpec) 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) match(p,"info") { p.SetState(117) var _m = p.Match(ApiParserParserID) localctx.(*InfoSpecContext).infoToken = _m } { p.SetState(118) var _m = p.Match(ApiParserParserT__1) localctx.(*InfoSpecContext).lp = _m } p.SetState(120) p.GetErrorHandler().Sync(p) for ok := true; ok; ok = _la == ApiParserParserID { { p.SetState(119) p.KvLit() } p.SetState(122) p.GetErrorHandler().Sync(p) _la = p.GetTokenStream().LA(1) } { p.SetState(124) var _m = p.Match(ApiParserParserT__2) localctx.(*InfoSpecContext).rp = _m } return localctx } // ITypeSpecContext is an interface to support dynamic dispatch. type ITypeSpecContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // IsTypeSpecContext differentiates from other interfaces. IsTypeSpecContext() } type TypeSpecContext struct { *antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyTypeSpecContext() *TypeSpecContext { var p = new(TypeSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeSpec return p } func (*TypeSpecContext) IsTypeSpecContext() {} func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecContext { var p = new(TypeSpecContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.parser = parser p.RuleIndex = ApiParserParserRULE_typeSpec return p } func (s *TypeSpecContext) GetParser() antlr.Parser { return s.parser } func (s *TypeSpecContext) TypeLit() ITypeLitContext { var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0) if t == nil { return nil } return t.(ITypeLitContext) } func (s *TypeSpecContext) TypeBlock() ITypeBlockContext { var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0) if t == nil { return nil } return t.(ITypeBlockContext) } func (s *TypeSpecContext) GetRuleContext() antlr.RuleContext { return s } func (s *TypeSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { return antlr.TreesStringTree(s, ruleNames, recog) } func (s *TypeSpecContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeSpec(s) default: return t.VisitChildren(s) } } func (p *ApiParserParser) TypeSpec() (localctx ITypeSpecContext) { localctx = NewTypeSpecContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 18, ApiParserParserRULE_typeSpec) 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(128) p.GetErrorHandler().Sync(p) switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 5, p.GetParserRuleContext()) { case 1: p.EnterOuterAlt(localctx, 1) { p.SetState(126) p.TypeLit() } case 2: p.EnterOuterAlt(localctx, 2) { p.SetState(127) p.TypeBlock() } } return localctx } // ITypeLitContext is an interface to support dynamic dispatch. type ITypeLitContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // GetTypeToken returns the typeToken token. GetTypeToken() antlr.Token // SetTypeToken sets the typeToken token. SetTypeToken(antlr.Token) // IsTypeLitContext differentiates from other interfaces. IsTypeLitContext() } type TypeLitContext struct { *antlr.BaseParserRuleContext parser antlr.Parser typeToken antlr.Token } func NewEmptyTypeLitContext() *TypeLitContext { var p = new(TypeLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeLit return p } func (*TypeLitContext) IsTypeLitContext() {} func NewTypeLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitContext { var p = new(TypeLitContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.parser = parser p.RuleIndex = ApiParserParserRULE_typeLit return p } func (s *TypeLitContext) GetParser() antlr.Parser { return s.parser } func (s *TypeLitContext) GetTypeToken() antlr.Token { return s.typeToken } func (s *TypeLitContext) SetTypeToken(v antlr.Token) { s.typeToken = v } func (s *TypeLitContext) TypeLitBody() ITypeLitBodyContext { var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0) if t == nil { return nil } return t.(ITypeLitBodyContext) } func (s *TypeLitContext) ID() antlr.TerminalNode { return s.GetToken(ApiParserParserID, 0) } func (s *TypeLitContext) GetRuleContext() antlr.RuleContext { return s } func (s *TypeLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { return antlr.TreesStringTree(s, ruleNames, recog) } func (s *TypeLitContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeLit(s) default: return t.VisitChildren(s) } } func (p *ApiParserParser) TypeLit() (localctx ITypeLitContext) { localctx = NewTypeLitContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 20, ApiParserParserRULE_typeLit) 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,"type") { p.SetState(131) var _m = p.Match(ApiParserParserID) localctx.(*TypeLitContext).typeToken = _m } { p.SetState(132) p.TypeLitBody() } return localctx } // ITypeBlockContext is an interface to support dynamic dispatch. type ITypeBlockContext interface { antlr.ParserRuleContext // GetParser returns the parser. GetParser() antlr.Parser // GetTypeToken returns the typeToken token. GetTypeToken() antlr.Token // GetLp returns the lp token. GetLp() antlr.Token // GetRp returns the rp token. GetRp() antlr.Token // SetTypeToken sets the typeToken token. SetTypeToken(antlr.Token) // SetLp sets the lp token. SetLp(antlr.Token) // SetRp sets the rp token. SetRp(antlr.Token) // IsTypeBlockContext differentiates from other interfaces. IsTypeBlockContext() } type TypeBlockContext struct { *antlr.BaseParserRuleContext parser antlr.Parser typeToken antlr.Token lp antlr.Token rp antlr.Token } func NewEmptyTypeBlockContext() *TypeBlockContext { var p = new(TypeBlockContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) p.RuleIndex = ApiParserParserRULE_typeBlock return p } func (*TypeBlockContext) IsTypeBlockContext() {} func NewTypeBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockContext { var p = new(TypeBlockContext) p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) p.parser = parser p.RuleIndex = ApiParserParserRULE_typeBlock return p } func (s *TypeBlockContext) GetParser() antlr.Parser { return s.parser } func (s *TypeBlockContext) GetTypeToken() antlr.Token { return s.typeToken } func (s *TypeBlockContext) GetLp() antlr.Token { return s.lp } func (s *TypeBlockContext) GetRp() antlr.Token { return s.rp } func (s *TypeBlockContext) SetTypeToken(v antlr.Token) { s.typeToken = v } func (s *TypeBlockContext) SetLp(v antlr.Token) { s.lp = v } func (s *TypeBlockContext) SetRp(v antlr.Token) { s.rp = v } func (s *TypeBlockContext) ID() antlr.TerminalNode { return s.GetToken(ApiParserParserID, 0) } func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext { var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem()) var tst = make([]ITypeBlockBodyContext, len(ts)) for i, t := range ts { if t != nil { tst[i] = t.(ITypeBlockBodyContext) } } return tst } func (s *TypeBlockContext) TypeBlockBody(i int) ITypeBlockBodyContext { var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i) if t == nil { return nil } return t.(ITypeBlockBodyContext) } func (s *TypeBlockContext) GetRuleContext() antlr.RuleContext { return s } func (s *TypeBlockContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { return antlr.TreesStringTree(s, ruleNames, recog) } func (s *TypeBlockContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { switch t := visitor.(type) { case ApiParserVisitor: return t.VisitTypeBlock(s) default: return t.VisitChildren(s) } } func (p *ApiParserParser) TypeBlock() (localctx ITypeBlockContext) { localctx = NewTypeBlockContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 22, ApiParserParserRULE_typeBlock) 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) match(p,"type") { p.SetState(135) var _m = p.Match(ApiParserParserID) localctx.(*TypeBlockContext).typeToken = _m } { p.SetState(136) var _m = p.Match(ApiParserParserT__1) localctx.(*TypeBlockContext).lp = _m } p.SetState(140) p.GetErrorHandler().Sync(p) _la = p.GetTokenStream().LA(1) for _la == ApiParserParserID { { p.SetState(137) p.TypeBlockBody() } p.SetState(142) p.GetErrorHandler().Sync(p) _la = p.GetTokenStream().LA(1) } { p.SetState(143) var _m = p.Match(ApiParserParserT__2) localctx.(*TypeBlockContext).rp = _m } return localctx }