From 857c4bfda4e92b36bcf3a3b3ee89d4680d7a8f5d Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Thu, 1 Jun 2023 10:26:07 +0300 Subject: [PATCH] [#75] Update antlr4 version to 4.13.0 Signed-off-by: Anton Nikiforov --- go.mod | 4 +- go.sum | 4 +- netmap/parser/query_base_visitor.go | 4 +- netmap/parser/query_lexer.go | 49 +- netmap/parser/query_parser.go | 800 ++++++++++++++++------------ netmap/parser/query_visitor.go | 4 +- netmap/policy.go | 2 +- 7 files changed, 484 insertions(+), 383 deletions(-) diff --git a/go.mod b/go.mod index 4a8c450..d4b330d 100644 --- a/go.mod +++ b/go.mod @@ -7,13 +7,14 @@ require ( git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230307110621-19a8ef2d02fb git.frostfs.info/TrueCloudLab/hrw v1.2.0 git.frostfs.info/TrueCloudLab/tzhash v1.8.0 - github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9 + github.com/antlr4-go/antlr/v4 v4.13.0 github.com/google/uuid v1.3.0 github.com/hashicorp/golang-lru/v2 v2.0.2 github.com/mr-tron/base58 v1.2.0 github.com/nspcc-dev/neo-go v0.101.1 github.com/stretchr/testify v1.8.3 go.uber.org/zap v1.24.0 + google.golang.org/grpc v1.55.0 ) require ( @@ -50,7 +51,6 @@ require ( golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.55.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 8bc61dc..7d360f7 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGn github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521073959-f0d4d129b7f1/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= -github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9 h1:goHVqTbFX3AIo0tzGr14pgfAW2ZfPChKO21Z9MGf/gk= -github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= +github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= +github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= diff --git a/netmap/parser/query_base_visitor.go b/netmap/parser/query_base_visitor.go index 235fd96..123302c 100644 --- a/netmap/parser/query_base_visitor.go +++ b/netmap/parser/query_base_visitor.go @@ -1,8 +1,8 @@ -// Code generated from Query.g4 by ANTLR 4.12.0. DO NOT EDIT. +// Code generated from /work/netmap/parser/Query.g4 by ANTLR 4.13.0. DO NOT EDIT. package parser // Query -import "github.com/antlr/antlr4/runtime/Go/antlr/v4" +import "github.com/antlr4-go/antlr/v4" type BaseQueryVisitor struct { *antlr.BaseParseTreeVisitor diff --git a/netmap/parser/query_lexer.go b/netmap/parser/query_lexer.go index 7c24aae..17b2b35 100644 --- a/netmap/parser/query_lexer.go +++ b/netmap/parser/query_lexer.go @@ -1,13 +1,12 @@ -// Code generated from QueryLexer.g4 by ANTLR 4.12.0. DO NOT EDIT. +// Code generated from /work/netmap/parser/QueryLexer.g4 by ANTLR 4.13.0. DO NOT EDIT. package parser import ( "fmt" + "github.com/antlr4-go/antlr/v4" "sync" "unicode" - - "github.com/antlr/antlr4/runtime/Go/antlr/v4" ) // Suppress unused import error @@ -22,45 +21,45 @@ type QueryLexer struct { // TODO: EOF string } -var querylexerLexerStaticData struct { +var QueryLexerLexerStaticData struct { once sync.Once serializedATN []int32 - channelNames []string - modeNames []string - literalNames []string - symbolicNames []string - ruleNames []string - predictionContextCache *antlr.PredictionContextCache + ChannelNames []string + ModeNames []string + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache atn *antlr.ATN decisionToDFA []*antlr.DFA } func querylexerLexerInit() { - staticData := &querylexerLexerStaticData - staticData.channelNames = []string{ + staticData := &QueryLexerLexerStaticData + staticData.ChannelNames = []string{ "DEFAULT_TOKEN_CHANNEL", "HIDDEN", } - staticData.modeNames = []string{ + staticData.ModeNames = []string{ "DEFAULT_MODE", } - staticData.literalNames = []string{ + staticData.LiteralNames = []string{ "", "'AND'", "'OR'", "", "'REP'", "'IN'", "'AS'", "'CBF'", "'SELECT'", "'FROM'", "'FILTER'", "'*'", "'SAME'", "'DISTINCT'", "'('", "')'", "'@'", "", "", "'0'", } - staticData.symbolicNames = []string{ + staticData.SymbolicNames = []string{ "", "AND_OP", "OR_OP", "SIMPLE_OP", "REP", "IN", "AS", "CBF", "SELECT", "FROM", "FILTER", "WILDCARD", "CLAUSE_SAME", "CLAUSE_DISTINCT", "L_PAREN", "R_PAREN", "AT", "IDENT", "NUMBER1", "ZERO", "STRING", "WS", } - staticData.ruleNames = []string{ + staticData.RuleNames = []string{ "AND_OP", "OR_OP", "SIMPLE_OP", "REP", "IN", "AS", "CBF", "SELECT", "FROM", "FILTER", "WILDCARD", "CLAUSE_SAME", "CLAUSE_DISTINCT", "L_PAREN", "R_PAREN", "AT", "IDENT", "Digit", "Nondigit", "NUMBER1", "ZERO", "STRING", "ESC", "UNICODE", "HEX", "SAFECODEPOINTSINGLE", "SAFECODEPOINTDOUBLE", "WS", } - staticData.predictionContextCache = antlr.NewPredictionContextCache() + staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ 4, 0, 21, 198, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, @@ -166,7 +165,7 @@ func querylexerLexerInit() { // NewQueryLexer(). You can call this function if you wish to initialize the static state ahead // of time. func QueryLexerInit() { - staticData := &querylexerLexerStaticData + staticData := &QueryLexerLexerStaticData staticData.once.Do(querylexerLexerInit) } @@ -175,13 +174,13 @@ func NewQueryLexer(input antlr.CharStream) *QueryLexer { QueryLexerInit() l := new(QueryLexer) l.BaseLexer = antlr.NewBaseLexer(input) - staticData := &querylexerLexerStaticData - l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.predictionContextCache) - l.channelNames = staticData.channelNames - l.modeNames = staticData.modeNames - l.RuleNames = staticData.ruleNames - l.LiteralNames = staticData.literalNames - l.SymbolicNames = staticData.symbolicNames + staticData := &QueryLexerLexerStaticData + l.Interpreter = antlr.NewLexerATNSimulator(l, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) + l.channelNames = staticData.ChannelNames + l.modeNames = staticData.ModeNames + l.RuleNames = staticData.RuleNames + l.LiteralNames = staticData.LiteralNames + l.SymbolicNames = staticData.SymbolicNames l.GrammarFileName = "QueryLexer.g4" // TODO: l.EOF = antlr.TokenEOF diff --git a/netmap/parser/query_parser.go b/netmap/parser/query_parser.go index 08d40b8..1909b55 100644 --- a/netmap/parser/query_parser.go +++ b/netmap/parser/query_parser.go @@ -1,4 +1,4 @@ -// Code generated from Query.g4 by ANTLR 4.12.0. DO NOT EDIT. +// Code generated from /work/netmap/parser/Query.g4 by ANTLR 4.13.0. DO NOT EDIT. package parser // Query @@ -7,7 +7,7 @@ import ( "strconv" "sync" - "github.com/antlr/antlr4/runtime/Go/antlr/v4" + "github.com/antlr4-go/antlr/v4" ) // Suppress unused import errors @@ -19,35 +19,35 @@ type Query struct { *antlr.BaseParser } -var queryParserStaticData struct { +var QueryParserStaticData struct { once sync.Once serializedATN []int32 - literalNames []string - symbolicNames []string - ruleNames []string - predictionContextCache *antlr.PredictionContextCache + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache atn *antlr.ATN decisionToDFA []*antlr.DFA } func queryParserInit() { - staticData := &queryParserStaticData - staticData.literalNames = []string{ + staticData := &QueryParserStaticData + staticData.LiteralNames = []string{ "", "'AND'", "'OR'", "", "'REP'", "'IN'", "'AS'", "'CBF'", "'SELECT'", "'FROM'", "'FILTER'", "'*'", "'SAME'", "'DISTINCT'", "'('", "')'", "'@'", "", "", "'0'", } - staticData.symbolicNames = []string{ + staticData.SymbolicNames = []string{ "", "AND_OP", "OR_OP", "SIMPLE_OP", "REP", "IN", "AS", "CBF", "SELECT", "FROM", "FILTER", "WILDCARD", "CLAUSE_SAME", "CLAUSE_DISTINCT", "L_PAREN", "R_PAREN", "AT", "IDENT", "NUMBER1", "ZERO", "STRING", "WS", } - staticData.ruleNames = []string{ + staticData.RuleNames = []string{ "policy", "repStmt", "cbfStmt", "selectStmt", "clause", "filterExpr", "filterStmt", "expr", "filterKey", "filterValue", "number", "keyword", "ident", "identWC", } - staticData.predictionContextCache = antlr.NewPredictionContextCache() + staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ 4, 1, 21, 130, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, @@ -119,7 +119,7 @@ func queryParserInit() { // NewQuery(). You can call this function if you wish to initialize the static state ahead // of time. func QueryInit() { - staticData := &queryParserStaticData + staticData := &QueryParserStaticData staticData.once.Do(queryParserInit) } @@ -128,11 +128,11 @@ func NewQuery(input antlr.TokenStream) *Query { QueryInit() this := new(Query) this.BaseParser = antlr.NewBaseParser(input) - staticData := &queryParserStaticData - this.Interpreter = antlr.NewParserATNSimulator(this, staticData.atn, staticData.decisionToDFA, staticData.predictionContextCache) - this.RuleNames = staticData.ruleNames - this.LiteralNames = staticData.literalNames - this.SymbolicNames = staticData.symbolicNames + staticData := &QueryParserStaticData + this.Interpreter = antlr.NewParserATNSimulator(this, staticData.atn, staticData.decisionToDFA, staticData.PredictionContextCache) + this.RuleNames = staticData.RuleNames + this.LiteralNames = staticData.LiteralNames + this.SymbolicNames = staticData.SymbolicNames this.GrammarFileName = "Query.g4" return this @@ -204,23 +204,28 @@ type IPolicyContext interface { } type PolicyContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyPolicyContext() *PolicyContext { var p = new(PolicyContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_policy return p } +func InitEmptyPolicyContext(p *PolicyContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_policy +} + func (*PolicyContext) IsPolicyContext() {} func NewPolicyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PolicyContext { var p = new(PolicyContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_policy @@ -392,32 +397,16 @@ func (s *PolicyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) Policy() (localctx IPolicyContext) { - this := p - _ = this - localctx = NewPolicyContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 0, QueryRULE_policy) 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(29) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) for ok := true; ok; ok = _la == QueryREP { @@ -428,10 +417,16 @@ func (p *Query) Policy() (localctx IPolicyContext) { p.SetState(31) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) } p.SetState(34) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) if _la == QueryCBF { @@ -443,6 +438,9 @@ func (p *Query) Policy() (localctx IPolicyContext) { } p.SetState(39) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) for _la == QuerySELECT { @@ -453,10 +451,16 @@ func (p *Query) Policy() (localctx IPolicyContext) { p.SetState(41) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) } p.SetState(45) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) for _la == QueryFILTER { @@ -467,14 +471,31 @@ func (p *Query) Policy() (localctx IPolicyContext) { p.SetState(47) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) } { p.SetState(48) p.Match(QueryEOF) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IRepStmtContext is an interface to support dynamic dispatch. @@ -507,7 +528,7 @@ type IRepStmtContext interface { } type RepStmtContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser Count antlr.Token Selector IIdentContext @@ -515,17 +536,22 @@ type RepStmtContext struct { func NewEmptyRepStmtContext() *RepStmtContext { var p = new(RepStmtContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_repStmt return p } +func InitEmptyRepStmtContext(p *RepStmtContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_repStmt +} + func (*RepStmtContext) IsRepStmtContext() {} func NewRepStmtContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RepStmtContext { var p = new(RepStmtContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_repStmt @@ -590,33 +616,18 @@ func (s *RepStmtContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) RepStmt() (localctx IRepStmtContext) { - this := p - _ = this - localctx = NewRepStmtContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 2, QueryRULE_repStmt) 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(50) p.Match(QueryREP) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(51) @@ -624,15 +635,26 @@ func (p *Query) RepStmt() (localctx IRepStmtContext) { var _m = p.Match(QueryNUMBER1) localctx.(*RepStmtContext).Count = _m + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } p.SetState(54) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) if _la == QueryIN { { p.SetState(52) p.Match(QueryIN) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(53) @@ -644,7 +666,17 @@ func (p *Query) RepStmt() (localctx IRepStmtContext) { } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // ICbfStmtContext is an interface to support dynamic dispatch. @@ -669,24 +701,29 @@ type ICbfStmtContext interface { } type CbfStmtContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser BackupFactor antlr.Token } func NewEmptyCbfStmtContext() *CbfStmtContext { var p = new(CbfStmtContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_cbfStmt return p } +func InitEmptyCbfStmtContext(p *CbfStmtContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_cbfStmt +} + func (*CbfStmtContext) IsCbfStmtContext() {} func NewCbfStmtContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CbfStmtContext { var p = new(CbfStmtContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_cbfStmt @@ -727,32 +764,16 @@ func (s *CbfStmtContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) CbfStmt() (localctx ICbfStmtContext) { - this := p - _ = this - localctx = NewCbfStmtContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 4, QueryRULE_cbfStmt) - - 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(56) p.Match(QueryCBF) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(57) @@ -760,9 +781,23 @@ func (p *Query) CbfStmt() (localctx ICbfStmtContext) { var _m = p.Match(QueryNUMBER1) localctx.(*CbfStmtContext).BackupFactor = _m + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // ISelectStmtContext is an interface to support dynamic dispatch. @@ -812,7 +847,7 @@ type ISelectStmtContext interface { } type SelectStmtContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser Count antlr.Token Bucket IIdentContext @@ -822,17 +857,22 @@ type SelectStmtContext struct { func NewEmptySelectStmtContext() *SelectStmtContext { var p = new(SelectStmtContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_selectStmt return p } +func InitEmptySelectStmtContext(p *SelectStmtContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_selectStmt +} + func (*SelectStmtContext) IsSelectStmtContext() {} func NewSelectStmtContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SelectStmtContext { var p = new(SelectStmtContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_selectStmt @@ -970,33 +1010,18 @@ func (s *SelectStmtContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) SelectStmt() (localctx ISelectStmtContext) { - this := p - _ = this - localctx = NewSelectStmtContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 6, QueryRULE_selectStmt) 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(59) p.Match(QuerySELECT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(60) @@ -1004,18 +1029,32 @@ func (p *Query) SelectStmt() (localctx ISelectStmtContext) { var _m = p.Match(QueryNUMBER1) localctx.(*SelectStmtContext).Count = _m + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } p.SetState(66) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) if _la == QueryIN { { p.SetState(61) p.Match(QueryIN) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } p.SetState(63) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) if _la == QueryCLAUSE_SAME || _la == QueryCLAUSE_DISTINCT { @@ -1037,6 +1076,10 @@ func (p *Query) SelectStmt() (localctx ISelectStmtContext) { { p.SetState(68) p.Match(QueryFROM) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(69) @@ -1047,12 +1090,19 @@ func (p *Query) SelectStmt() (localctx ISelectStmtContext) { } p.SetState(72) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) if _la == QueryAS { { p.SetState(70) p.Match(QueryAS) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(71) @@ -1064,7 +1114,17 @@ func (p *Query) SelectStmt() (localctx ISelectStmtContext) { } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IClauseContext is an interface to support dynamic dispatch. @@ -1083,23 +1143,28 @@ type IClauseContext interface { } type ClauseContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyClauseContext() *ClauseContext { var p = new(ClauseContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_clause return p } +func InitEmptyClauseContext(p *ClauseContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_clause +} + func (*ClauseContext) IsClauseContext() {} func NewClauseContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ClauseContext { var p = new(ClauseContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_clause @@ -1136,29 +1201,10 @@ func (s *ClauseContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) Clause() (localctx IClauseContext) { - this := p - _ = this - localctx = NewClauseContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 8, QueryRULE_clause) 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(74) @@ -1172,7 +1218,17 @@ func (p *Query) Clause() (localctx IClauseContext) { } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IFilterExprContext is an interface to support dynamic dispatch. @@ -1220,7 +1276,7 @@ type IFilterExprContext interface { } type FilterExprContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser F1 IFilterExprContext Inner IFilterExprContext @@ -1230,17 +1286,22 @@ type FilterExprContext struct { func NewEmptyFilterExprContext() *FilterExprContext { var p = new(FilterExprContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_filterExpr return p } +func InitEmptyFilterExprContext(p *FilterExprContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_filterExpr +} + func (*FilterExprContext) IsFilterExprContext() {} func NewFilterExprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FilterExprContext { var p = new(FilterExprContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_filterExpr @@ -1362,44 +1423,32 @@ func (p *Query) FilterExpr() (localctx IFilterExprContext) { } func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { - this := p - _ = this - var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext() + _parentState := p.GetState() localctx = NewFilterExprContext(p, p.GetParserRuleContext(), _parentState) var _prevctx IFilterExprContext = localctx var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. _startState := 10 p.EnterRecursionRule(localctx, 10, QueryRULE_filterExpr, _p) - - defer func() { - p.UnrollRecursionContexts(_parentctx) - }() - - 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) p.SetState(82) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case QueryL_PAREN: { p.SetState(77) p.Match(QueryL_PAREN) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(78) @@ -1411,6 +1460,10 @@ func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { { p.SetState(79) p.Match(QueryR_PAREN) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } case QueryREP, QueryIN, QueryAS, QuerySELECT, QueryFROM, QueryFILTER, QueryAT, QueryIDENT, QuerySTRING: @@ -1420,13 +1473,19 @@ func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { } default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit } p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1)) p.SetState(92) p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext()) - + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 10, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { if p.GetParseListeners() != nil { @@ -1435,7 +1494,11 @@ func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { _prevctx = localctx p.SetState(90) p.GetErrorHandler().Sync(p) - switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 9, p.GetParserRuleContext()) { + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 9, p.GetParserRuleContext()) { case 1: localctx = NewFilterExprContext(p, _parentctx, _parentState) localctx.(*FilterExprContext).F1 = _prevctx @@ -1443,7 +1506,8 @@ func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { p.SetState(84) if !(p.Precpred(p.GetParserRuleContext(), 4)) { - panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 4)", "")) + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 4)", "")) + goto errorExit } { p.SetState(85) @@ -1451,6 +1515,10 @@ func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { var _m = p.Match(QueryAND_OP) localctx.(*FilterExprContext).Op = _m + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(86) @@ -1467,7 +1535,8 @@ func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { p.SetState(87) if !(p.Precpred(p.GetParserRuleContext(), 3)) { - panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 3)", "")) + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 3)", "")) + goto errorExit } { p.SetState(88) @@ -1475,6 +1544,10 @@ func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { var _m = p.Match(QueryOR_OP) localctx.(*FilterExprContext).Op = _m + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(89) @@ -1484,15 +1557,33 @@ func (p *Query) filterExpr(_p int) (localctx IFilterExprContext) { localctx.(*FilterExprContext).F2 = _x } + case antlr.ATNInvalidAltNumber: + goto errorExit } } p.SetState(94) p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 10, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.UnrollRecursionContexts(_parentctx) return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IFilterStmtContext is an interface to support dynamic dispatch. @@ -1525,7 +1616,7 @@ type IFilterStmtContext interface { } type FilterStmtContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser Expr IFilterExprContext Name IIdentContext @@ -1533,17 +1624,22 @@ type FilterStmtContext struct { func NewEmptyFilterStmtContext() *FilterStmtContext { var p = new(FilterStmtContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_filterStmt return p } +func InitEmptyFilterStmtContext(p *FilterStmtContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_filterStmt +} + func (*FilterStmtContext) IsFilterStmtContext() {} func NewFilterStmtContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FilterStmtContext { var p = new(FilterStmtContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_filterStmt @@ -1620,32 +1716,16 @@ func (s *FilterStmtContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) FilterStmt() (localctx IFilterStmtContext) { - this := p - _ = this - localctx = NewFilterStmtContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 12, QueryRULE_filterStmt) - - 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(95) p.Match(QueryFILTER) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(96) @@ -1657,6 +1737,10 @@ func (p *Query) FilterStmt() (localctx IFilterStmtContext) { { p.SetState(97) p.Match(QueryAS) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(98) @@ -1666,7 +1750,17 @@ func (p *Query) FilterStmt() (localctx IFilterStmtContext) { localctx.(*FilterStmtContext).Name = _x } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IExprContext is an interface to support dynamic dispatch. @@ -1706,7 +1800,7 @@ type IExprContext interface { } type ExprContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser Filter IIdentContext Key IFilterKeyContext @@ -1715,17 +1809,22 @@ type ExprContext struct { func NewEmptyExprContext() *ExprContext { var p = new(ExprContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_expr return p } +func InitEmptyExprContext(p *ExprContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_expr +} + func (*ExprContext) IsExprContext() {} func NewExprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExprContext { var p = new(ExprContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_expr @@ -1822,30 +1921,13 @@ func (s *ExprContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) Expr() (localctx IExprContext) { - this := p - _ = this - localctx = NewExprContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 14, QueryRULE_expr) - - 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(106) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case QueryAT: @@ -1853,6 +1935,10 @@ func (p *Query) Expr() (localctx IExprContext) { { p.SetState(100) p.Match(QueryAT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(101) @@ -1874,6 +1960,10 @@ func (p *Query) Expr() (localctx IExprContext) { { p.SetState(103) p.Match(QuerySIMPLE_OP) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(104) @@ -1884,10 +1974,21 @@ func (p *Query) Expr() (localctx IExprContext) { } default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IFilterKeyContext is an interface to support dynamic dispatch. @@ -1906,23 +2007,28 @@ type IFilterKeyContext interface { } type FilterKeyContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyFilterKeyContext() *FilterKeyContext { var p = new(FilterKeyContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_filterKey return p } +func InitEmptyFilterKeyContext(p *FilterKeyContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_filterKey +} + func (*FilterKeyContext) IsFilterKeyContext() {} func NewFilterKeyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FilterKeyContext { var p = new(FilterKeyContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_filterKey @@ -1971,30 +2077,13 @@ func (s *FilterKeyContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) FilterKey() (localctx IFilterKeyContext) { - this := p - _ = this - localctx = NewFilterKeyContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 16, QueryRULE_filterKey) - - 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(110) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case QueryREP, QueryIN, QueryAS, QuerySELECT, QueryFROM, QueryFILTER, QueryIDENT: @@ -2009,13 +2098,28 @@ func (p *Query) FilterKey() (localctx IFilterKeyContext) { { p.SetState(109) p.Match(QuerySTRING) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IFilterValueContext is an interface to support dynamic dispatch. @@ -2035,23 +2139,28 @@ type IFilterValueContext interface { } type FilterValueContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyFilterValueContext() *FilterValueContext { var p = new(FilterValueContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_filterValue return p } +func InitEmptyFilterValueContext(p *FilterValueContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_filterValue +} + func (*FilterValueContext) IsFilterValueContext() {} func NewFilterValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FilterValueContext { var p = new(FilterValueContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_filterValue @@ -2116,30 +2225,13 @@ func (s *FilterValueContext) Accept(visitor antlr.ParseTreeVisitor) interface{} } func (p *Query) FilterValue() (localctx IFilterValueContext) { - this := p - _ = this - localctx = NewFilterValueContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 18, QueryRULE_filterValue) - - 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(115) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case QueryREP, QueryIN, QueryAS, QuerySELECT, QueryFROM, QueryFILTER, QueryIDENT: @@ -2161,13 +2253,28 @@ func (p *Query) FilterValue() (localctx IFilterValueContext) { { p.SetState(114) p.Match(QuerySTRING) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // INumberContext is an interface to support dynamic dispatch. @@ -2186,23 +2293,28 @@ type INumberContext interface { } type NumberContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyNumberContext() *NumberContext { var p = new(NumberContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_number return p } +func InitEmptyNumberContext(p *NumberContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_number +} + func (*NumberContext) IsNumberContext() {} func NewNumberContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NumberContext { var p = new(NumberContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_number @@ -2239,29 +2351,10 @@ func (s *NumberContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) Number() (localctx INumberContext) { - this := p - _ = this - localctx = NewNumberContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 20, QueryRULE_number) 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(117) @@ -2275,7 +2368,17 @@ func (p *Query) Number() (localctx INumberContext) { } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IKeywordContext is an interface to support dynamic dispatch. @@ -2298,23 +2401,28 @@ type IKeywordContext interface { } type KeywordContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyKeywordContext() *KeywordContext { var p = new(KeywordContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_keyword return p } +func InitEmptyKeywordContext(p *KeywordContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_keyword +} + func (*KeywordContext) IsKeywordContext() {} func NewKeywordContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *KeywordContext { var p = new(KeywordContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_keyword @@ -2367,29 +2475,10 @@ func (s *KeywordContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) Keyword() (localctx IKeywordContext) { - this := p - _ = this - localctx = NewKeywordContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 22, QueryRULE_keyword) 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(119) @@ -2403,7 +2492,17 @@ func (p *Query) Keyword() (localctx IKeywordContext) { } } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IIdentContext is an interface to support dynamic dispatch. @@ -2422,23 +2521,28 @@ type IIdentContext interface { } type IdentContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyIdentContext() *IdentContext { var p = new(IdentContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_ident return p } +func InitEmptyIdentContext(p *IdentContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_ident +} + func (*IdentContext) IsIdentContext() {} func NewIdentContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *IdentContext { var p = new(IdentContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_ident @@ -2487,30 +2591,13 @@ func (s *IdentContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) Ident() (localctx IIdentContext) { - this := p - _ = this - localctx = NewIdentContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 24, QueryRULE_ident) - - 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(123) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case QueryREP, QueryIN, QueryAS, QuerySELECT, QueryFROM, QueryFILTER: @@ -2525,13 +2612,28 @@ func (p *Query) Ident() (localctx IIdentContext) { { p.SetState(122) p.Match(QueryIDENT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } // IIdentWCContext is an interface to support dynamic dispatch. @@ -2550,23 +2652,28 @@ type IIdentWCContext interface { } type IdentWCContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyIdentWCContext() *IdentWCContext { var p = new(IdentWCContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = QueryRULE_identWC return p } +func InitEmptyIdentWCContext(p *IdentWCContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = QueryRULE_identWC +} + func (*IdentWCContext) IsIdentWCContext() {} func NewIdentWCContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *IdentWCContext { var p = new(IdentWCContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = QueryRULE_identWC @@ -2615,30 +2722,13 @@ func (s *IdentWCContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { } func (p *Query) IdentWC() (localctx IIdentWCContext) { - this := p - _ = this - localctx = NewIdentWCContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 26, QueryRULE_identWC) - - 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(127) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case QueryREP, QueryIN, QueryAS, QuerySELECT, QueryFROM, QueryFILTER, QueryIDENT: @@ -2653,13 +2743,28 @@ func (p *Query) IdentWC() (localctx IIdentWCContext) { { p.SetState(126) p.Match(QueryWILDCARD) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } default: - panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + p.SetError(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil)) + goto errorExit } +errorExit: + if p.HasError() { + v := p.GetError() + localctx.SetException(v) + p.GetErrorHandler().ReportError(p, v) + p.GetErrorHandler().Recover(p, v) + p.SetError(nil) + } + p.ExitRule() return localctx + goto errorExit // Trick to prevent compiler error if the label is not used } func (p *Query) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool { @@ -2677,9 +2782,6 @@ func (p *Query) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bo } func (p *Query) FilterExpr_Sempred(localctx antlr.RuleContext, predIndex int) bool { - this := p - _ = this - switch predIndex { case 0: return p.Precpred(p.GetParserRuleContext(), 4) diff --git a/netmap/parser/query_visitor.go b/netmap/parser/query_visitor.go index 06c0e58..edf8649 100644 --- a/netmap/parser/query_visitor.go +++ b/netmap/parser/query_visitor.go @@ -1,8 +1,8 @@ -// Code generated from Query.g4 by ANTLR 4.12.0. DO NOT EDIT. +// Code generated from /work/netmap/parser/Query.g4 by ANTLR 4.13.0. DO NOT EDIT. package parser // Query -import "github.com/antlr/antlr4/runtime/Go/antlr/v4" +import "github.com/antlr4-go/antlr/v4" // A complete Visitor for a parse tree produced by Query. type QueryVisitor interface { diff --git a/netmap/policy.go b/netmap/policy.go index b2dd766..d5b265f 100644 --- a/netmap/policy.go +++ b/netmap/policy.go @@ -9,7 +9,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap/parser" - "github.com/antlr/antlr4/runtime/Go/antlr/v4" + "github.com/antlr4-go/antlr/v4" ) // PlacementPolicy declares policy to store objects in the FrostFS container.