diff --git a/WORKSPACE b/WORKSPACE index 64c7aaac18..29a41c1913 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -138,14 +138,14 @@ http_archive( name = "rules_antlr", # XXX(roosd): This hash is not guaranteed to be stable by GitHub. # See: https://github.blog/changelog/2023-01-30-git-archive-checksums-may-change - sha256 = "8d7c457cc266965bdcf7e85aa349d2f851b772a55877354d9ae92ada7a62c857", - strip_prefix = "rules_antlr-0.6.0", - urls = ["https://github.com/bacek/rules_antlr/archive/refs/tags/0.6.0.tar.gz"], + sha256 = "a9b2f98aae1fb26e9608be1e975587e6271a3287e424ced28cbc77f32190ec41", + strip_prefix = "rules_antlr-0.6.1", + urls = ["https://github.com/bacek/rules_antlr/archive/refs/tags/0.6.1.tar.gz"], ) load("@rules_antlr//antlr:repositories.bzl", "rules_antlr_dependencies") -rules_antlr_dependencies("4.9.3") +rules_antlr_dependencies("4.13.1") # Rules for container image building http_archive( diff --git a/antlr/sequence/BUILD.bazel b/antlr/sequence/BUILD.bazel index 345c5df360..b168bee93f 100644 --- a/antlr/sequence/BUILD.bazel +++ b/antlr/sequence/BUILD.bazel @@ -5,7 +5,8 @@ load("@apple_rules_lint//lint:defs.bzl", "package_lint_config") go_lint_config( name = "go_lint_config", exclude_filter = [ - "sequence_parser.go", + "_parser.go", + "_lexer.go", ], visibility = [ "//visibility:public", @@ -26,5 +27,5 @@ go_library( ], importpath = "github.com/scionproto/scion/antlr/sequence", visibility = ["//visibility:public"], - deps = ["@com_github_antlr_antlr4_runtime_go_antlr//:go_default_library"], + deps = ["@com_github_antlr4_go_antlr_v4//:go_default_library"], ) diff --git a/antlr/sequence/sequence_base_listener.go b/antlr/sequence/sequence_base_listener.go index d5961642a2..db48eedaf0 100644 --- a/antlr/sequence/sequence_base_listener.go +++ b/antlr/sequence/sequence_base_listener.go @@ -1,7 +1,7 @@ // File generated by ANTLR. DO NOT EDIT. package sequence // Sequence -import "github.com/antlr/antlr4/runtime/Go/antlr" +import "github.com/antlr4-go/antlr/v4" // BaseSequenceListener is a complete listener for a parse tree produced by SequenceParser. type BaseSequenceListener struct{} diff --git a/antlr/sequence/sequence_lexer.go b/antlr/sequence/sequence_lexer.go index 479ad161dd..d297d01205 100644 --- a/antlr/sequence/sequence_lexer.go +++ b/antlr/sequence/sequence_lexer.go @@ -4,108 +4,127 @@ package sequence import ( "fmt" + "github.com/antlr4-go/antlr/v4" + "sync" "unicode" - - "github.com/antlr/antlr4/runtime/Go/antlr" ) // Suppress unused import error var _ = fmt.Printf +var _ = sync.Once{} var _ = unicode.IsLetter -var serializedLexerAtn = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 16, 88, 8, - 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, - 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, - 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 3, 2, 3, 2, 7, 2, - 36, 10, 2, 12, 2, 14, 2, 39, 11, 2, 3, 2, 5, 2, 42, 10, 2, 3, 3, 6, 3, - 45, 10, 3, 13, 3, 14, 3, 46, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 7, 5, - 55, 10, 5, 12, 5, 14, 5, 58, 11, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, - 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, - 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, - 3, 16, 2, 2, 17, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, - 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 3, 2, 7, 5, 2, 51, - 59, 67, 72, 99, 104, 5, 2, 50, 59, 67, 72, 99, 104, 5, 2, 11, 12, 15, 15, - 34, 34, 3, 2, 51, 59, 3, 2, 50, 59, 2, 90, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, - 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, - 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, - 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, - 31, 3, 2, 2, 2, 3, 41, 3, 2, 2, 2, 5, 44, 3, 2, 2, 2, 7, 50, 3, 2, 2, 2, - 9, 52, 3, 2, 2, 2, 11, 59, 3, 2, 2, 2, 13, 62, 3, 2, 2, 2, 15, 65, 3, 2, - 2, 2, 17, 72, 3, 2, 2, 2, 19, 74, 3, 2, 2, 2, 21, 76, 3, 2, 2, 2, 23, 78, - 3, 2, 2, 2, 25, 80, 3, 2, 2, 2, 27, 82, 3, 2, 2, 2, 29, 84, 3, 2, 2, 2, - 31, 86, 3, 2, 2, 2, 33, 37, 9, 2, 2, 2, 34, 36, 9, 3, 2, 2, 35, 34, 3, - 2, 2, 2, 36, 39, 3, 2, 2, 2, 37, 35, 3, 2, 2, 2, 37, 38, 3, 2, 2, 2, 38, - 42, 3, 2, 2, 2, 39, 37, 3, 2, 2, 2, 40, 42, 7, 50, 2, 2, 41, 33, 3, 2, - 2, 2, 41, 40, 3, 2, 2, 2, 42, 4, 3, 2, 2, 2, 43, 45, 9, 4, 2, 2, 44, 43, - 3, 2, 2, 2, 45, 46, 3, 2, 2, 2, 46, 44, 3, 2, 2, 2, 46, 47, 3, 2, 2, 2, - 47, 48, 3, 2, 2, 2, 48, 49, 8, 3, 2, 2, 49, 6, 3, 2, 2, 2, 50, 51, 7, 50, - 2, 2, 51, 8, 3, 2, 2, 2, 52, 56, 9, 5, 2, 2, 53, 55, 9, 6, 2, 2, 54, 53, - 3, 2, 2, 2, 55, 58, 3, 2, 2, 2, 56, 54, 3, 2, 2, 2, 56, 57, 3, 2, 2, 2, - 57, 10, 3, 2, 2, 2, 58, 56, 3, 2, 2, 2, 59, 60, 7, 47, 2, 2, 60, 61, 7, - 50, 2, 2, 61, 12, 3, 2, 2, 2, 62, 63, 7, 47, 2, 2, 63, 64, 5, 9, 5, 2, - 64, 14, 3, 2, 2, 2, 65, 66, 7, 47, 2, 2, 66, 67, 5, 3, 2, 2, 67, 68, 7, - 60, 2, 2, 68, 69, 5, 3, 2, 2, 69, 70, 7, 60, 2, 2, 70, 71, 5, 3, 2, 2, - 71, 16, 3, 2, 2, 2, 72, 73, 7, 37, 2, 2, 73, 18, 3, 2, 2, 2, 74, 75, 7, - 46, 2, 2, 75, 20, 3, 2, 2, 2, 76, 77, 7, 65, 2, 2, 77, 22, 3, 2, 2, 2, - 78, 79, 7, 45, 2, 2, 79, 24, 3, 2, 2, 2, 80, 81, 7, 44, 2, 2, 81, 26, 3, - 2, 2, 2, 82, 83, 7, 126, 2, 2, 83, 28, 3, 2, 2, 2, 84, 85, 7, 42, 2, 2, - 85, 30, 3, 2, 2, 2, 86, 87, 7, 43, 2, 2, 87, 32, 3, 2, 2, 2, 7, 2, 37, - 41, 46, 56, 3, 8, 2, 2, -} - -var lexerChannelNames = []string{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", -} - -var lexerModeNames = []string{ - "DEFAULT_MODE", -} - -var lexerLiteralNames = []string{ - "", "", "'0'", "", "", "", "", "'#'", "','", "'?'", "'+'", "'*'", "'|'", - "'('", "')'", +type SequenceLexer struct { + *antlr.BaseLexer + channelNames []string + modeNames []string + // TODO: EOF string } -var lexerSymbolicNames = []string{ - "", "WHITESPACE", "ZERO", "NUM", "WILDCARDAS", "LEGACYAS", "AS", "HASH", - "COMMA", "QUESTIONMARK", "PLUS", "ASTERISK", "OR", "LPAR", "RPAR", +var SequenceLexerLexerStaticData struct { + once sync.Once + serializedATN []int32 + ChannelNames []string + ModeNames []string + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA } -var lexerRuleNames = []string{ - "HEXA", "WHITESPACE", "ZERO", "NUM", "WILDCARDAS", "LEGACYAS", "AS", "HASH", - "COMMA", "QUESTIONMARK", "PLUS", "ASTERISK", "OR", "LPAR", "RPAR", +func sequencelexerLexerInit() { + staticData := &SequenceLexerLexerStaticData + staticData.ChannelNames = []string{ + "DEFAULT_TOKEN_CHANNEL", "HIDDEN", + } + staticData.ModeNames = []string{ + "DEFAULT_MODE", + } + staticData.LiteralNames = []string{ + "", "", "'0'", "", "", "", "", "'#'", "','", "'?'", "'+'", "'*'", "'|'", + "'('", "')'", + } + staticData.SymbolicNames = []string{ + "", "WHITESPACE", "ZERO", "NUM", "WILDCARDAS", "LEGACYAS", "AS", "HASH", + "COMMA", "QUESTIONMARK", "PLUS", "ASTERISK", "OR", "LPAR", "RPAR", + } + staticData.RuleNames = []string{ + "HEXA", "WHITESPACE", "ZERO", "NUM", "WILDCARDAS", "LEGACYAS", "AS", + "HASH", "COMMA", "QUESTIONMARK", "PLUS", "ASTERISK", "OR", "LPAR", "RPAR", + } + staticData.PredictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 0, 14, 86, 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, + 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 1, 0, + 1, 0, 5, 0, 34, 8, 0, 10, 0, 12, 0, 37, 9, 0, 1, 0, 3, 0, 40, 8, 0, 1, + 1, 4, 1, 43, 8, 1, 11, 1, 12, 1, 44, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, + 5, 3, 53, 8, 3, 10, 3, 12, 3, 56, 9, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, + 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, + 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, + 1, 14, 0, 0, 15, 1, 0, 3, 1, 5, 2, 7, 3, 9, 4, 11, 5, 13, 6, 15, 7, 17, + 8, 19, 9, 21, 10, 23, 11, 25, 12, 27, 13, 29, 14, 1, 0, 5, 3, 0, 49, 57, + 65, 70, 97, 102, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 9, 10, 13, 13, 32, + 32, 1, 0, 49, 57, 1, 0, 48, 57, 88, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, + 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, + 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, + 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, + 0, 0, 0, 1, 39, 1, 0, 0, 0, 3, 42, 1, 0, 0, 0, 5, 48, 1, 0, 0, 0, 7, 50, + 1, 0, 0, 0, 9, 57, 1, 0, 0, 0, 11, 60, 1, 0, 0, 0, 13, 63, 1, 0, 0, 0, + 15, 70, 1, 0, 0, 0, 17, 72, 1, 0, 0, 0, 19, 74, 1, 0, 0, 0, 21, 76, 1, + 0, 0, 0, 23, 78, 1, 0, 0, 0, 25, 80, 1, 0, 0, 0, 27, 82, 1, 0, 0, 0, 29, + 84, 1, 0, 0, 0, 31, 35, 7, 0, 0, 0, 32, 34, 7, 1, 0, 0, 33, 32, 1, 0, 0, + 0, 34, 37, 1, 0, 0, 0, 35, 33, 1, 0, 0, 0, 35, 36, 1, 0, 0, 0, 36, 40, + 1, 0, 0, 0, 37, 35, 1, 0, 0, 0, 38, 40, 5, 48, 0, 0, 39, 31, 1, 0, 0, 0, + 39, 38, 1, 0, 0, 0, 40, 2, 1, 0, 0, 0, 41, 43, 7, 2, 0, 0, 42, 41, 1, 0, + 0, 0, 43, 44, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 46, + 1, 0, 0, 0, 46, 47, 6, 1, 0, 0, 47, 4, 1, 0, 0, 0, 48, 49, 5, 48, 0, 0, + 49, 6, 1, 0, 0, 0, 50, 54, 7, 3, 0, 0, 51, 53, 7, 4, 0, 0, 52, 51, 1, 0, + 0, 0, 53, 56, 1, 0, 0, 0, 54, 52, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 8, + 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 57, 58, 5, 45, 0, 0, 58, 59, 5, 48, 0, + 0, 59, 10, 1, 0, 0, 0, 60, 61, 5, 45, 0, 0, 61, 62, 3, 7, 3, 0, 62, 12, + 1, 0, 0, 0, 63, 64, 5, 45, 0, 0, 64, 65, 3, 1, 0, 0, 65, 66, 5, 58, 0, + 0, 66, 67, 3, 1, 0, 0, 67, 68, 5, 58, 0, 0, 68, 69, 3, 1, 0, 0, 69, 14, + 1, 0, 0, 0, 70, 71, 5, 35, 0, 0, 71, 16, 1, 0, 0, 0, 72, 73, 5, 44, 0, + 0, 73, 18, 1, 0, 0, 0, 74, 75, 5, 63, 0, 0, 75, 20, 1, 0, 0, 0, 76, 77, + 5, 43, 0, 0, 77, 22, 1, 0, 0, 0, 78, 79, 5, 42, 0, 0, 79, 24, 1, 0, 0, + 0, 80, 81, 5, 124, 0, 0, 81, 26, 1, 0, 0, 0, 82, 83, 5, 40, 0, 0, 83, 28, + 1, 0, 0, 0, 84, 85, 5, 41, 0, 0, 85, 30, 1, 0, 0, 0, 5, 0, 35, 39, 44, + 54, 1, 6, 0, 0, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } } -type SequenceLexer struct { - *antlr.BaseLexer - channelNames []string - modeNames []string - // TODO: EOF string +// SequenceLexerInit initializes any static state used to implement SequenceLexer. By default the +// static state used to implement the lexer is lazily initialized during the first call to +// NewSequenceLexer(). You can call this function if you wish to initialize the static state ahead +// of time. +func SequenceLexerInit() { + staticData := &SequenceLexerLexerStaticData + staticData.once.Do(sequencelexerLexerInit) } // NewSequenceLexer produces a new lexer instance for the optional input antlr.CharStream. -// -// The *SequenceLexer instance produced may be reused by calling the SetInputStream method. -// The initial lexer configuration is expensive to construct, and the object is not thread-safe; -// however, if used within a Golang sync.Pool, the construction cost amortizes well and the -// objects can be used in a thread-safe manner. func NewSequenceLexer(input antlr.CharStream) *SequenceLexer { + SequenceLexerInit() l := new(SequenceLexer) - lexerDeserializer := antlr.NewATNDeserializer(nil) - lexerAtn := lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn) - lexerDecisionToDFA := make([]*antlr.DFA, len(lexerAtn.DecisionToState)) - for index, ds := range lexerAtn.DecisionToState { - lexerDecisionToDFA[index] = antlr.NewDFA(ds, index) - } l.BaseLexer = antlr.NewBaseLexer(input) - l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache()) - - l.channelNames = lexerChannelNames - l.modeNames = lexerModeNames - l.RuleNames = lexerRuleNames - l.LiteralNames = lexerLiteralNames - l.SymbolicNames = lexerSymbolicNames + staticData := &SequenceLexerLexerStaticData + 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 = "Sequence.g4" // TODO: l.EOF = antlr.TokenEOF diff --git a/antlr/sequence/sequence_listener.go b/antlr/sequence/sequence_listener.go index a5a57fe902..2c4f1ff753 100644 --- a/antlr/sequence/sequence_listener.go +++ b/antlr/sequence/sequence_listener.go @@ -1,7 +1,7 @@ // File generated by ANTLR. DO NOT EDIT. package sequence // Sequence -import "github.com/antlr/antlr4/runtime/Go/antlr" +import "github.com/antlr4-go/antlr/v4" // SequenceListener is a complete listener for a parse tree produced by SequenceParser. type SequenceListener interface { diff --git a/antlr/sequence/sequence_parser.go b/antlr/sequence/sequence_parser.go index 13fafc282f..03512894bc 100644 --- a/antlr/sequence/sequence_parser.go +++ b/antlr/sequence/sequence_parser.go @@ -3,86 +3,106 @@ package sequence // Sequence import ( "fmt" - "reflect" "strconv" + "sync" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr4-go/antlr/v4" ) // Suppress unused import errors var _ = fmt.Printf -var _ = reflect.Copy var _ = strconv.Itoa - -var parserATN = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 16, 73, 4, - 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 3, - 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 24, 10, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 37, - 10, 3, 12, 3, 14, 3, 40, 11, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, - 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 58, 10, - 4, 3, 5, 3, 5, 5, 5, 62, 10, 5, 3, 6, 3, 6, 3, 6, 5, 6, 67, 10, 6, 3, 7, - 3, 7, 5, 7, 71, 10, 7, 3, 7, 2, 3, 4, 8, 2, 4, 6, 8, 10, 12, 2, 2, 2, 79, - 2, 14, 3, 2, 2, 2, 4, 23, 3, 2, 2, 2, 6, 57, 3, 2, 2, 2, 8, 61, 3, 2, 2, - 2, 10, 66, 3, 2, 2, 2, 12, 70, 3, 2, 2, 2, 14, 15, 5, 4, 3, 2, 15, 16, - 7, 2, 2, 3, 16, 3, 3, 2, 2, 2, 17, 18, 8, 3, 1, 2, 18, 19, 7, 15, 2, 2, - 19, 20, 5, 4, 3, 2, 20, 21, 7, 16, 2, 2, 21, 24, 3, 2, 2, 2, 22, 24, 5, - 6, 4, 2, 23, 17, 3, 2, 2, 2, 23, 22, 3, 2, 2, 2, 24, 38, 3, 2, 2, 2, 25, - 26, 12, 6, 2, 2, 26, 27, 7, 14, 2, 2, 27, 37, 5, 4, 3, 7, 28, 29, 12, 5, - 2, 2, 29, 37, 5, 4, 3, 6, 30, 31, 12, 9, 2, 2, 31, 37, 7, 11, 2, 2, 32, - 33, 12, 8, 2, 2, 33, 37, 7, 12, 2, 2, 34, 35, 12, 7, 2, 2, 35, 37, 7, 13, - 2, 2, 36, 25, 3, 2, 2, 2, 36, 28, 3, 2, 2, 2, 36, 30, 3, 2, 2, 2, 36, 32, - 3, 2, 2, 2, 36, 34, 3, 2, 2, 2, 37, 40, 3, 2, 2, 2, 38, 36, 3, 2, 2, 2, - 38, 39, 3, 2, 2, 2, 39, 5, 3, 2, 2, 2, 40, 38, 3, 2, 2, 2, 41, 58, 5, 8, - 5, 2, 42, 43, 5, 8, 5, 2, 43, 44, 5, 10, 6, 2, 44, 58, 3, 2, 2, 2, 45, - 46, 5, 8, 5, 2, 46, 47, 5, 10, 6, 2, 47, 48, 7, 9, 2, 2, 48, 49, 5, 12, - 7, 2, 49, 58, 3, 2, 2, 2, 50, 51, 5, 8, 5, 2, 51, 52, 5, 10, 6, 2, 52, - 53, 7, 9, 2, 2, 53, 54, 5, 12, 7, 2, 54, 55, 7, 10, 2, 2, 55, 56, 5, 12, - 7, 2, 56, 58, 3, 2, 2, 2, 57, 41, 3, 2, 2, 2, 57, 42, 3, 2, 2, 2, 57, 45, - 3, 2, 2, 2, 57, 50, 3, 2, 2, 2, 58, 7, 3, 2, 2, 2, 59, 62, 7, 4, 2, 2, - 60, 62, 7, 5, 2, 2, 61, 59, 3, 2, 2, 2, 61, 60, 3, 2, 2, 2, 62, 9, 3, 2, - 2, 2, 63, 67, 7, 6, 2, 2, 64, 67, 7, 7, 2, 2, 65, 67, 7, 8, 2, 2, 66, 63, - 3, 2, 2, 2, 66, 64, 3, 2, 2, 2, 66, 65, 3, 2, 2, 2, 67, 11, 3, 2, 2, 2, - 68, 71, 7, 4, 2, 2, 69, 71, 7, 5, 2, 2, 70, 68, 3, 2, 2, 2, 70, 69, 3, - 2, 2, 2, 71, 13, 3, 2, 2, 2, 9, 23, 36, 38, 57, 61, 66, 70, -} -var literalNames = []string{ - "", "", "'0'", "", "", "", "", "'#'", "','", "'?'", "'+'", "'*'", "'|'", - "'('", "')'", -} -var symbolicNames = []string{ - "", "WHITESPACE", "ZERO", "NUM", "WILDCARDAS", "LEGACYAS", "AS", "HASH", - "COMMA", "QUESTIONMARK", "PLUS", "ASTERISK", "OR", "LPAR", "RPAR", -} - -var ruleNames = []string{ - "start", "sequence", "onehop", "isd", "as", "iface", -} +var _ = sync.Once{} type SequenceParser struct { *antlr.BaseParser } +var SequenceParserStaticData struct { + once sync.Once + serializedATN []int32 + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA +} + +func sequenceParserInit() { + staticData := &SequenceParserStaticData + staticData.LiteralNames = []string{ + "", "", "'0'", "", "", "", "", "'#'", "','", "'?'", "'+'", "'*'", "'|'", + "'('", "')'", + } + staticData.SymbolicNames = []string{ + "", "WHITESPACE", "ZERO", "NUM", "WILDCARDAS", "LEGACYAS", "AS", "HASH", + "COMMA", "QUESTIONMARK", "PLUS", "ASTERISK", "OR", "LPAR", "RPAR", + } + staticData.RuleNames = []string{ + "start", "sequence", "onehop", "isd", "as", "iface", + } + staticData.PredictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 1, 14, 71, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 4, 2, 5, 7, 5, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 1, 22, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 1, 35, 8, 1, 10, 1, 12, 1, 38, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, + 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, + 2, 56, 8, 2, 1, 3, 1, 3, 3, 3, 60, 8, 3, 1, 4, 1, 4, 1, 4, 3, 4, 65, 8, + 4, 1, 5, 1, 5, 3, 5, 69, 8, 5, 1, 5, 0, 1, 2, 6, 0, 2, 4, 6, 8, 10, 0, + 0, 77, 0, 12, 1, 0, 0, 0, 2, 21, 1, 0, 0, 0, 4, 55, 1, 0, 0, 0, 6, 59, + 1, 0, 0, 0, 8, 64, 1, 0, 0, 0, 10, 68, 1, 0, 0, 0, 12, 13, 3, 2, 1, 0, + 13, 14, 5, 0, 0, 1, 14, 1, 1, 0, 0, 0, 15, 16, 6, 1, -1, 0, 16, 17, 5, + 13, 0, 0, 17, 18, 3, 2, 1, 0, 18, 19, 5, 14, 0, 0, 19, 22, 1, 0, 0, 0, + 20, 22, 3, 4, 2, 0, 21, 15, 1, 0, 0, 0, 21, 20, 1, 0, 0, 0, 22, 36, 1, + 0, 0, 0, 23, 24, 10, 4, 0, 0, 24, 25, 5, 12, 0, 0, 25, 35, 3, 2, 1, 5, + 26, 27, 10, 3, 0, 0, 27, 35, 3, 2, 1, 4, 28, 29, 10, 7, 0, 0, 29, 35, 5, + 9, 0, 0, 30, 31, 10, 6, 0, 0, 31, 35, 5, 10, 0, 0, 32, 33, 10, 5, 0, 0, + 33, 35, 5, 11, 0, 0, 34, 23, 1, 0, 0, 0, 34, 26, 1, 0, 0, 0, 34, 28, 1, + 0, 0, 0, 34, 30, 1, 0, 0, 0, 34, 32, 1, 0, 0, 0, 35, 38, 1, 0, 0, 0, 36, + 34, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 3, 1, 0, 0, 0, 38, 36, 1, 0, 0, + 0, 39, 56, 3, 6, 3, 0, 40, 41, 3, 6, 3, 0, 41, 42, 3, 8, 4, 0, 42, 56, + 1, 0, 0, 0, 43, 44, 3, 6, 3, 0, 44, 45, 3, 8, 4, 0, 45, 46, 5, 7, 0, 0, + 46, 47, 3, 10, 5, 0, 47, 56, 1, 0, 0, 0, 48, 49, 3, 6, 3, 0, 49, 50, 3, + 8, 4, 0, 50, 51, 5, 7, 0, 0, 51, 52, 3, 10, 5, 0, 52, 53, 5, 8, 0, 0, 53, + 54, 3, 10, 5, 0, 54, 56, 1, 0, 0, 0, 55, 39, 1, 0, 0, 0, 55, 40, 1, 0, + 0, 0, 55, 43, 1, 0, 0, 0, 55, 48, 1, 0, 0, 0, 56, 5, 1, 0, 0, 0, 57, 60, + 5, 2, 0, 0, 58, 60, 5, 3, 0, 0, 59, 57, 1, 0, 0, 0, 59, 58, 1, 0, 0, 0, + 60, 7, 1, 0, 0, 0, 61, 65, 5, 4, 0, 0, 62, 65, 5, 5, 0, 0, 63, 65, 5, 6, + 0, 0, 64, 61, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 63, 1, 0, 0, 0, 65, 9, + 1, 0, 0, 0, 66, 69, 5, 2, 0, 0, 67, 69, 5, 3, 0, 0, 68, 66, 1, 0, 0, 0, + 68, 67, 1, 0, 0, 0, 69, 11, 1, 0, 0, 0, 7, 21, 34, 36, 55, 59, 64, 68, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } +} + +// SequenceParserInit initializes any static state used to implement SequenceParser. By default the +// static state used to implement the parser is lazily initialized during the first call to +// NewSequenceParser(). You can call this function if you wish to initialize the static state ahead +// of time. +func SequenceParserInit() { + staticData := &SequenceParserStaticData + staticData.once.Do(sequenceParserInit) +} + // NewSequenceParser produces a new parser instance for the optional input antlr.TokenStream. -// -// The *SequenceParser instance produced may be reused by calling the SetInputStream method. -// The initial parser configuration is expensive to construct, and the object is not thread-safe; -// however, if used within a Golang sync.Pool, the construction cost amortizes well and the -// objects can be used in a thread-safe manner. func NewSequenceParser(input antlr.TokenStream) *SequenceParser { + SequenceParserInit() this := new(SequenceParser) - deserializer := antlr.NewATNDeserializer(nil) - deserializedATN := deserializer.DeserializeFromUInt16(parserATN) - decisionToDFA := make([]*antlr.DFA, len(deserializedATN.DecisionToState)) - for index, ds := range deserializedATN.DecisionToState { - decisionToDFA[index] = antlr.NewDFA(ds, index) - } this.BaseParser = antlr.NewBaseParser(input) - - this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, antlr.NewPredictionContextCache()) - this.RuleNames = ruleNames - this.LiteralNames = literalNames - this.SymbolicNames = symbolicNames + staticData := &SequenceParserStaticData + 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 = "Sequence.g4" return this @@ -124,28 +144,37 @@ type IStartContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + Sequence() ISequenceContext + EOF() antlr.TerminalNode + // IsStartContext differentiates from other interfaces. IsStartContext() } type StartContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyStartContext() *StartContext { var p = new(StartContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = SequenceParserRULE_start return p } +func InitEmptyStartContext(p *StartContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = SequenceParserRULE_start +} + func (*StartContext) IsStartContext() {} func NewStartContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *StartContext { var p = new(StartContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = SequenceParserRULE_start @@ -156,7 +185,13 @@ func NewStartContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoki func (s *StartContext) GetParser() antlr.Parser { return s.parser } func (s *StartContext) Sequence() ISequenceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISequenceContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ISequenceContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -189,29 +224,9 @@ func (s *StartContext) ExitRule(listener antlr.ParseTreeListener) { } } -func (p *SequenceParser) Start() (localctx IStartContext) { - this := p - _ = this - +func (p *SequenceParser) Start_() (localctx IStartContext) { localctx = NewStartContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 0, SequenceParserRULE_start) - - 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(12) @@ -220,9 +235,23 @@ func (p *SequenceParser) Start() (localctx IStartContext) { { p.SetState(13) p.Match(SequenceParserEOF) + 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 } // ISequenceContext is an interface to support dynamic dispatch. @@ -231,29 +260,33 @@ type ISequenceContext interface { // GetParser returns the parser. GetParser() antlr.Parser - // IsSequenceContext differentiates from other interfaces. IsSequenceContext() } type SequenceContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptySequenceContext() *SequenceContext { var p = new(SequenceContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = SequenceParserRULE_sequence return p } +func InitEmptySequenceContext(p *SequenceContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = SequenceParserRULE_sequence +} + func (*SequenceContext) IsSequenceContext() {} func NewSequenceContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SequenceContext { var p = new(SequenceContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = SequenceParserRULE_sequence @@ -263,8 +296,8 @@ func NewSequenceContext(parser antlr.Parser, parent antlr.ParserRuleContext, inv func (s *SequenceContext) GetParser() antlr.Parser { return s.parser } -func (s *SequenceContext) CopyFrom(ctx *SequenceContext) { - s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) +func (s *SequenceContext) CopyAll(ctx *SequenceContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) } func (s *SequenceContext) GetRuleContext() antlr.RuleContext { @@ -276,15 +309,15 @@ func (s *SequenceContext) ToStringTree(ruleNames []string, recog antlr.Recognize } type OrContext struct { - *SequenceContext + SequenceContext } func NewOrContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *OrContext { var p = new(OrContext) - p.SequenceContext = NewEmptySequenceContext() + InitEmptySequenceContext(&p.SequenceContext) p.parser = parser - p.CopyFrom(ctx.(*SequenceContext)) + p.CopyAll(ctx.(*SequenceContext)) return p } @@ -294,12 +327,20 @@ func (s *OrContext) GetRuleContext() antlr.RuleContext { } func (s *OrContext) AllSequence() []ISequenceContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ISequenceContext)(nil)).Elem()) - var tst = make([]ISequenceContext, len(ts)) + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(ISequenceContext); ok { + len++ + } + } - for i, t := range ts { - if t != nil { + tst := make([]ISequenceContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(ISequenceContext); ok { tst[i] = t.(ISequenceContext) + i++ } } @@ -307,7 +348,17 @@ func (s *OrContext) AllSequence() []ISequenceContext { } func (s *OrContext) Sequence(i int) ISequenceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISequenceContext)(nil)).Elem(), i) + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ISequenceContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } if t == nil { return nil @@ -333,15 +384,15 @@ func (s *OrContext) ExitRule(listener antlr.ParseTreeListener) { } type ConcatenationContext struct { - *SequenceContext + SequenceContext } func NewConcatenationContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ConcatenationContext { var p = new(ConcatenationContext) - p.SequenceContext = NewEmptySequenceContext() + InitEmptySequenceContext(&p.SequenceContext) p.parser = parser - p.CopyFrom(ctx.(*SequenceContext)) + p.CopyAll(ctx.(*SequenceContext)) return p } @@ -351,12 +402,20 @@ func (s *ConcatenationContext) GetRuleContext() antlr.RuleContext { } func (s *ConcatenationContext) AllSequence() []ISequenceContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ISequenceContext)(nil)).Elem()) - var tst = make([]ISequenceContext, len(ts)) + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(ISequenceContext); ok { + len++ + } + } - for i, t := range ts { - if t != nil { + tst := make([]ISequenceContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(ISequenceContext); ok { tst[i] = t.(ISequenceContext) + i++ } } @@ -364,7 +423,17 @@ func (s *ConcatenationContext) AllSequence() []ISequenceContext { } func (s *ConcatenationContext) Sequence(i int) ISequenceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISequenceContext)(nil)).Elem(), i) + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ISequenceContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } if t == nil { return nil @@ -386,15 +455,15 @@ func (s *ConcatenationContext) ExitRule(listener antlr.ParseTreeListener) { } type QuestionMarkContext struct { - *SequenceContext + SequenceContext } func NewQuestionMarkContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *QuestionMarkContext { var p = new(QuestionMarkContext) - p.SequenceContext = NewEmptySequenceContext() + InitEmptySequenceContext(&p.SequenceContext) p.parser = parser - p.CopyFrom(ctx.(*SequenceContext)) + p.CopyAll(ctx.(*SequenceContext)) return p } @@ -404,7 +473,13 @@ func (s *QuestionMarkContext) GetRuleContext() antlr.RuleContext { } func (s *QuestionMarkContext) Sequence() ISequenceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISequenceContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ISequenceContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -430,15 +505,15 @@ func (s *QuestionMarkContext) ExitRule(listener antlr.ParseTreeListener) { } type HopContext struct { - *SequenceContext + SequenceContext } func NewHopContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *HopContext { var p = new(HopContext) - p.SequenceContext = NewEmptySequenceContext() + InitEmptySequenceContext(&p.SequenceContext) p.parser = parser - p.CopyFrom(ctx.(*SequenceContext)) + p.CopyAll(ctx.(*SequenceContext)) return p } @@ -448,7 +523,13 @@ func (s *HopContext) GetRuleContext() antlr.RuleContext { } func (s *HopContext) Onehop() IOnehopContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IOnehopContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IOnehopContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -470,15 +551,15 @@ func (s *HopContext) ExitRule(listener antlr.ParseTreeListener) { } type PlusContext struct { - *SequenceContext + SequenceContext } func NewPlusContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *PlusContext { var p = new(PlusContext) - p.SequenceContext = NewEmptySequenceContext() + InitEmptySequenceContext(&p.SequenceContext) p.parser = parser - p.CopyFrom(ctx.(*SequenceContext)) + p.CopyAll(ctx.(*SequenceContext)) return p } @@ -488,7 +569,13 @@ func (s *PlusContext) GetRuleContext() antlr.RuleContext { } func (s *PlusContext) Sequence() ISequenceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISequenceContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ISequenceContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -514,15 +601,15 @@ func (s *PlusContext) ExitRule(listener antlr.ParseTreeListener) { } type AsteriskContext struct { - *SequenceContext + SequenceContext } func NewAsteriskContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *AsteriskContext { var p = new(AsteriskContext) - p.SequenceContext = NewEmptySequenceContext() + InitEmptySequenceContext(&p.SequenceContext) p.parser = parser - p.CopyFrom(ctx.(*SequenceContext)) + p.CopyAll(ctx.(*SequenceContext)) return p } @@ -532,7 +619,13 @@ func (s *AsteriskContext) GetRuleContext() antlr.RuleContext { } func (s *AsteriskContext) Sequence() ISequenceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISequenceContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ISequenceContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -558,15 +651,15 @@ func (s *AsteriskContext) ExitRule(listener antlr.ParseTreeListener) { } type ParenthesesContext struct { - *SequenceContext + SequenceContext } func NewParenthesesContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ParenthesesContext { var p = new(ParenthesesContext) - p.SequenceContext = NewEmptySequenceContext() + InitEmptySequenceContext(&p.SequenceContext) p.parser = parser - p.CopyFrom(ctx.(*SequenceContext)) + p.CopyAll(ctx.(*SequenceContext)) return p } @@ -580,7 +673,13 @@ func (s *ParenthesesContext) LPAR() antlr.TerminalNode { } func (s *ParenthesesContext) Sequence() ISequenceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ISequenceContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ISequenceContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -610,38 +709,22 @@ func (p *SequenceParser) Sequence() (localctx ISequenceContext) { } func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { - this := p - _ = this - var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext() + _parentState := p.GetState() localctx = NewSequenceContext(p, p.GetParserRuleContext(), _parentState) var _prevctx ISequenceContext = localctx var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning. _startState := 2 p.EnterRecursionRule(localctx, 2, SequenceParserRULE_sequence, _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(21) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case SequenceParserLPAR: @@ -652,6 +735,10 @@ func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { { p.SetState(16) p.Match(SequenceParserLPAR) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(17) @@ -660,6 +747,10 @@ func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { { p.SetState(18) p.Match(SequenceParserRPAR) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } case SequenceParserZERO, SequenceParserNUM: @@ -672,13 +763,19 @@ func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { } 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(36) p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 2, p.GetParserRuleContext()) - + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { if _alt == 1 { if p.GetParseListeners() != nil { @@ -687,18 +784,27 @@ func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { _prevctx = localctx p.SetState(34) p.GetErrorHandler().Sync(p) - switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 1, p.GetParserRuleContext()) { + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 1, p.GetParserRuleContext()) { case 1: localctx = NewOrContext(p, NewSequenceContext(p, _parentctx, _parentState)) p.PushNewRecursionContext(localctx, _startState, SequenceParserRULE_sequence) p.SetState(23) 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(24) p.Match(SequenceParserOR) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(25) @@ -711,7 +817,8 @@ func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { p.SetState(26) 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(27) @@ -724,11 +831,16 @@ func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { p.SetState(28) if !(p.Precpred(p.GetParserRuleContext(), 7)) { - panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 7)", "")) + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 7)", "")) + goto errorExit } { p.SetState(29) p.Match(SequenceParserQUESTIONMARK) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } case 4: @@ -737,11 +849,16 @@ func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { p.SetState(30) if !(p.Precpred(p.GetParserRuleContext(), 6)) { - panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 6)", "")) + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 6)", "")) + goto errorExit } { p.SetState(31) p.Match(SequenceParserPLUS) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } case 5: @@ -750,22 +867,45 @@ func (p *SequenceParser) sequence(_p int) (localctx ISequenceContext) { p.SetState(32) if !(p.Precpred(p.GetParserRuleContext(), 5)) { - panic(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 5)", "")) + p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 5)", "")) + goto errorExit } { p.SetState(33) p.Match(SequenceParserASTERISK) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } + case antlr.ATNInvalidAltNumber: + goto errorExit } } p.SetState(38) p.GetErrorHandler().Sync(p) - _alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 2, p.GetParserRuleContext()) + if p.HasError() { + goto errorExit + } + _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, 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 } // IOnehopContext is an interface to support dynamic dispatch. @@ -774,29 +914,33 @@ type IOnehopContext interface { // GetParser returns the parser. GetParser() antlr.Parser - // IsOnehopContext differentiates from other interfaces. IsOnehopContext() } type OnehopContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyOnehopContext() *OnehopContext { var p = new(OnehopContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = SequenceParserRULE_onehop return p } +func InitEmptyOnehopContext(p *OnehopContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = SequenceParserRULE_onehop +} + func (*OnehopContext) IsOnehopContext() {} func NewOnehopContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *OnehopContext { var p = new(OnehopContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = SequenceParserRULE_onehop @@ -806,8 +950,8 @@ func NewOnehopContext(parser antlr.Parser, parent antlr.ParserRuleContext, invok func (s *OnehopContext) GetParser() antlr.Parser { return s.parser } -func (s *OnehopContext) CopyFrom(ctx *OnehopContext) { - s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) +func (s *OnehopContext) CopyAll(ctx *OnehopContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) } func (s *OnehopContext) GetRuleContext() antlr.RuleContext { @@ -819,15 +963,15 @@ func (s *OnehopContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) } type ISDASHopContext struct { - *OnehopContext + OnehopContext } func NewISDASHopContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ISDASHopContext { var p = new(ISDASHopContext) - p.OnehopContext = NewEmptyOnehopContext() + InitEmptyOnehopContext(&p.OnehopContext) p.parser = parser - p.CopyFrom(ctx.(*OnehopContext)) + p.CopyAll(ctx.(*OnehopContext)) return p } @@ -837,7 +981,13 @@ func (s *ISDASHopContext) GetRuleContext() antlr.RuleContext { } func (s *ISDASHopContext) Isd() IIsdContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IIsdContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIsdContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -847,7 +997,13 @@ func (s *ISDASHopContext) Isd() IIsdContext { } func (s *ISDASHopContext) As() IAsContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IAsContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IAsContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -869,15 +1025,15 @@ func (s *ISDASHopContext) ExitRule(listener antlr.ParseTreeListener) { } type ISDASIFIFHopContext struct { - *OnehopContext + OnehopContext } func NewISDASIFIFHopContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ISDASIFIFHopContext { var p = new(ISDASIFIFHopContext) - p.OnehopContext = NewEmptyOnehopContext() + InitEmptyOnehopContext(&p.OnehopContext) p.parser = parser - p.CopyFrom(ctx.(*OnehopContext)) + p.CopyAll(ctx.(*OnehopContext)) return p } @@ -887,7 +1043,13 @@ func (s *ISDASIFIFHopContext) GetRuleContext() antlr.RuleContext { } func (s *ISDASIFIFHopContext) Isd() IIsdContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IIsdContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIsdContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -897,7 +1059,13 @@ func (s *ISDASIFIFHopContext) Isd() IIsdContext { } func (s *ISDASIFIFHopContext) As() IAsContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IAsContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IAsContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -911,12 +1079,20 @@ func (s *ISDASIFIFHopContext) HASH() antlr.TerminalNode { } func (s *ISDASIFIFHopContext) AllIface() []IIfaceContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IIfaceContext)(nil)).Elem()) - var tst = make([]IIfaceContext, len(ts)) + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(IIfaceContext); ok { + len++ + } + } - for i, t := range ts { - if t != nil { + tst := make([]IIfaceContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(IIfaceContext); ok { tst[i] = t.(IIfaceContext) + i++ } } @@ -924,7 +1100,17 @@ func (s *ISDASIFIFHopContext) AllIface() []IIfaceContext { } func (s *ISDASIFIFHopContext) Iface(i int) IIfaceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IIfaceContext)(nil)).Elem(), i) + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIfaceContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } if t == nil { return nil @@ -950,15 +1136,15 @@ func (s *ISDASIFIFHopContext) ExitRule(listener antlr.ParseTreeListener) { } type ISDHopContext struct { - *OnehopContext + OnehopContext } func NewISDHopContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ISDHopContext { var p = new(ISDHopContext) - p.OnehopContext = NewEmptyOnehopContext() + InitEmptyOnehopContext(&p.OnehopContext) p.parser = parser - p.CopyFrom(ctx.(*OnehopContext)) + p.CopyAll(ctx.(*OnehopContext)) return p } @@ -968,7 +1154,13 @@ func (s *ISDHopContext) GetRuleContext() antlr.RuleContext { } func (s *ISDHopContext) Isd() IIsdContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IIsdContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIsdContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -990,15 +1182,15 @@ func (s *ISDHopContext) ExitRule(listener antlr.ParseTreeListener) { } type ISDASIFHopContext struct { - *OnehopContext + OnehopContext } func NewISDASIFHopContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ISDASIFHopContext { var p = new(ISDASIFHopContext) - p.OnehopContext = NewEmptyOnehopContext() + InitEmptyOnehopContext(&p.OnehopContext) p.parser = parser - p.CopyFrom(ctx.(*OnehopContext)) + p.CopyAll(ctx.(*OnehopContext)) return p } @@ -1008,7 +1200,13 @@ func (s *ISDASIFHopContext) GetRuleContext() antlr.RuleContext { } func (s *ISDASIFHopContext) Isd() IIsdContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IIsdContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIsdContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1018,7 +1216,13 @@ func (s *ISDASIFHopContext) Isd() IIsdContext { } func (s *ISDASIFHopContext) As() IAsContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IAsContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IAsContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1032,7 +1236,13 @@ func (s *ISDASIFHopContext) HASH() antlr.TerminalNode { } func (s *ISDASIFHopContext) Iface() IIfaceContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IIfaceContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IIfaceContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1054,31 +1264,15 @@ func (s *ISDASIFHopContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *SequenceParser) Onehop() (localctx IOnehopContext) { - this := p - _ = this - localctx = NewOnehopContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 4, SequenceParserRULE_onehop) - - 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(55) p.GetErrorHandler().Sync(p) - switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 3, p.GetParserRuleContext()) { + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) { case 1: localctx = NewISDHopContext(p, localctx) p.EnterOuterAlt(localctx, 1) @@ -1113,6 +1307,10 @@ func (p *SequenceParser) Onehop() (localctx IOnehopContext) { { p.SetState(45) p.Match(SequenceParserHASH) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(46) @@ -1133,6 +1331,10 @@ func (p *SequenceParser) Onehop() (localctx IOnehopContext) { { p.SetState(50) p.Match(SequenceParserHASH) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(51) @@ -1141,15 +1343,31 @@ func (p *SequenceParser) Onehop() (localctx IOnehopContext) { { p.SetState(52) p.Match(SequenceParserCOMMA) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(53) p.Iface() } + case antlr.ATNInvalidAltNumber: + 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 } // IIsdContext is an interface to support dynamic dispatch. @@ -1158,29 +1376,33 @@ type IIsdContext interface { // GetParser returns the parser. GetParser() antlr.Parser - // IsIsdContext differentiates from other interfaces. IsIsdContext() } type IsdContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyIsdContext() *IsdContext { var p = new(IsdContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = SequenceParserRULE_isd return p } +func InitEmptyIsdContext(p *IsdContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = SequenceParserRULE_isd +} + func (*IsdContext) IsIsdContext() {} func NewIsdContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *IsdContext { var p = new(IsdContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = SequenceParserRULE_isd @@ -1190,8 +1412,8 @@ func NewIsdContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoking func (s *IsdContext) GetParser() antlr.Parser { return s.parser } -func (s *IsdContext) CopyFrom(ctx *IsdContext) { - s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) +func (s *IsdContext) CopyAll(ctx *IsdContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) } func (s *IsdContext) GetRuleContext() antlr.RuleContext { @@ -1203,15 +1425,15 @@ func (s *IsdContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) st } type WildcardISDContext struct { - *IsdContext + IsdContext } func NewWildcardISDContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *WildcardISDContext { var p = new(WildcardISDContext) - p.IsdContext = NewEmptyIsdContext() + InitEmptyIsdContext(&p.IsdContext) p.parser = parser - p.CopyFrom(ctx.(*IsdContext)) + p.CopyAll(ctx.(*IsdContext)) return p } @@ -1237,15 +1459,15 @@ func (s *WildcardISDContext) ExitRule(listener antlr.ParseTreeListener) { } type ISDContext struct { - *IsdContext + IsdContext } func NewISDContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ISDContext { var p = new(ISDContext) - p.IsdContext = NewEmptyIsdContext() + InitEmptyIsdContext(&p.IsdContext) p.parser = parser - p.CopyFrom(ctx.(*IsdContext)) + p.CopyAll(ctx.(*IsdContext)) return p } @@ -1271,30 +1493,13 @@ func (s *ISDContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *SequenceParser) Isd() (localctx IIsdContext) { - this := p - _ = this - localctx = NewIsdContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 6, SequenceParserRULE_isd) - - 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(59) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case SequenceParserZERO: @@ -1303,6 +1508,10 @@ func (p *SequenceParser) Isd() (localctx IIsdContext) { { p.SetState(57) p.Match(SequenceParserZERO) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } case SequenceParserNUM: @@ -1311,13 +1520,28 @@ func (p *SequenceParser) Isd() (localctx IIsdContext) { { p.SetState(58) p.Match(SequenceParserNUM) + 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 } // IAsContext is an interface to support dynamic dispatch. @@ -1326,29 +1550,33 @@ type IAsContext interface { // GetParser returns the parser. GetParser() antlr.Parser - // IsAsContext differentiates from other interfaces. IsAsContext() } type AsContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyAsContext() *AsContext { var p = new(AsContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = SequenceParserRULE_as return p } +func InitEmptyAsContext(p *AsContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = SequenceParserRULE_as +} + func (*AsContext) IsAsContext() {} func NewAsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AsContext { var p = new(AsContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = SequenceParserRULE_as @@ -1358,8 +1586,8 @@ func NewAsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingS func (s *AsContext) GetParser() antlr.Parser { return s.parser } -func (s *AsContext) CopyFrom(ctx *AsContext) { - s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) +func (s *AsContext) CopyAll(ctx *AsContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) } func (s *AsContext) GetRuleContext() antlr.RuleContext { @@ -1371,15 +1599,15 @@ func (s *AsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) str } type ASContext struct { - *AsContext + AsContext } func NewASContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ASContext { var p = new(ASContext) - p.AsContext = NewEmptyAsContext() + InitEmptyAsContext(&p.AsContext) p.parser = parser - p.CopyFrom(ctx.(*AsContext)) + p.CopyAll(ctx.(*AsContext)) return p } @@ -1405,15 +1633,15 @@ func (s *ASContext) ExitRule(listener antlr.ParseTreeListener) { } type LegacyASContext struct { - *AsContext + AsContext } func NewLegacyASContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *LegacyASContext { var p = new(LegacyASContext) - p.AsContext = NewEmptyAsContext() + InitEmptyAsContext(&p.AsContext) p.parser = parser - p.CopyFrom(ctx.(*AsContext)) + p.CopyAll(ctx.(*AsContext)) return p } @@ -1439,15 +1667,15 @@ func (s *LegacyASContext) ExitRule(listener antlr.ParseTreeListener) { } type WildcardASContext struct { - *AsContext + AsContext } func NewWildcardASContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *WildcardASContext { var p = new(WildcardASContext) - p.AsContext = NewEmptyAsContext() + InitEmptyAsContext(&p.AsContext) p.parser = parser - p.CopyFrom(ctx.(*AsContext)) + p.CopyAll(ctx.(*AsContext)) return p } @@ -1473,30 +1701,13 @@ func (s *WildcardASContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *SequenceParser) As() (localctx IAsContext) { - this := p - _ = this - localctx = NewAsContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 8, SequenceParserRULE_as) - - 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(64) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case SequenceParserWILDCARDAS: @@ -1505,6 +1716,10 @@ func (p *SequenceParser) As() (localctx IAsContext) { { p.SetState(61) p.Match(SequenceParserWILDCARDAS) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } case SequenceParserLEGACYAS: @@ -1513,6 +1728,10 @@ func (p *SequenceParser) As() (localctx IAsContext) { { p.SetState(62) p.Match(SequenceParserLEGACYAS) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } case SequenceParserAS: @@ -1521,13 +1740,28 @@ func (p *SequenceParser) As() (localctx IAsContext) { { p.SetState(63) p.Match(SequenceParserAS) + 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 } // IIfaceContext is an interface to support dynamic dispatch. @@ -1536,29 +1770,33 @@ type IIfaceContext interface { // GetParser returns the parser. GetParser() antlr.Parser - // IsIfaceContext differentiates from other interfaces. IsIfaceContext() } type IfaceContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyIfaceContext() *IfaceContext { var p = new(IfaceContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = SequenceParserRULE_iface return p } +func InitEmptyIfaceContext(p *IfaceContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = SequenceParserRULE_iface +} + func (*IfaceContext) IsIfaceContext() {} func NewIfaceContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *IfaceContext { var p = new(IfaceContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = SequenceParserRULE_iface @@ -1568,8 +1806,8 @@ func NewIfaceContext(parser antlr.Parser, parent antlr.ParserRuleContext, invoki func (s *IfaceContext) GetParser() antlr.Parser { return s.parser } -func (s *IfaceContext) CopyFrom(ctx *IfaceContext) { - s.BaseParserRuleContext.CopyFrom(ctx.BaseParserRuleContext) +func (s *IfaceContext) CopyAll(ctx *IfaceContext) { + s.CopyFrom(&ctx.BaseParserRuleContext) } func (s *IfaceContext) GetRuleContext() antlr.RuleContext { @@ -1581,15 +1819,15 @@ func (s *IfaceContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) } type IFaceContext struct { - *IfaceContext + IfaceContext } func NewIFaceContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *IFaceContext { var p = new(IFaceContext) - p.IfaceContext = NewEmptyIfaceContext() + InitEmptyIfaceContext(&p.IfaceContext) p.parser = parser - p.CopyFrom(ctx.(*IfaceContext)) + p.CopyAll(ctx.(*IfaceContext)) return p } @@ -1615,15 +1853,15 @@ func (s *IFaceContext) ExitRule(listener antlr.ParseTreeListener) { } type WildcardIFaceContext struct { - *IfaceContext + IfaceContext } func NewWildcardIFaceContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *WildcardIFaceContext { var p = new(WildcardIFaceContext) - p.IfaceContext = NewEmptyIfaceContext() + InitEmptyIfaceContext(&p.IfaceContext) p.parser = parser - p.CopyFrom(ctx.(*IfaceContext)) + p.CopyAll(ctx.(*IfaceContext)) return p } @@ -1649,30 +1887,13 @@ func (s *WildcardIFaceContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *SequenceParser) Iface() (localctx IIfaceContext) { - this := p - _ = this - localctx = NewIfaceContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 10, SequenceParserRULE_iface) - - 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(68) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case SequenceParserZERO: @@ -1681,6 +1902,10 @@ func (p *SequenceParser) Iface() (localctx IIfaceContext) { { p.SetState(66) p.Match(SequenceParserZERO) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } case SequenceParserNUM: @@ -1689,13 +1914,28 @@ func (p *SequenceParser) Iface() (localctx IIfaceContext) { { p.SetState(67) p.Match(SequenceParserNUM) + 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 *SequenceParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool { @@ -1713,9 +1953,6 @@ func (p *SequenceParser) Sempred(localctx antlr.RuleContext, ruleIndex, predInde } func (p *SequenceParser) Sequence_Sempred(localctx antlr.RuleContext, predIndex int) bool { - this := p - _ = this - switch predIndex { case 0: return p.Precpred(p.GetParserRuleContext(), 4) diff --git a/antlr/traffic_class/BUILD.bazel b/antlr/traffic_class/BUILD.bazel index a4ce1db4ef..6071e1f8bd 100644 --- a/antlr/traffic_class/BUILD.bazel +++ b/antlr/traffic_class/BUILD.bazel @@ -1,4 +1,20 @@ load("//tools/lint:go.bzl", "go_library") +load("//tools/lint:go_config.bzl", "go_lint_config") +load("@apple_rules_lint//lint:defs.bzl", "package_lint_config") + +go_lint_config( + name = "go_lint_config", + exclude_filter = [ + "_lexer.go", + ], + visibility = [ + "//visibility:public", + ], +) + +package_lint_config({ + "go": ":go_lint_config", +}) go_library( name = "go_default_library", @@ -10,5 +26,5 @@ go_library( ], importpath = "github.com/scionproto/scion/antlr/traffic_class", visibility = ["//visibility:public"], - deps = ["@com_github_antlr_antlr4_runtime_go_antlr//:go_default_library"], + deps = ["@com_github_antlr4_go_antlr_v4//:go_default_library"], ) diff --git a/antlr/traffic_class/trafficclass_base_listener.go b/antlr/traffic_class/trafficclass_base_listener.go index 4efc81b515..e975605691 100644 --- a/antlr/traffic_class/trafficclass_base_listener.go +++ b/antlr/traffic_class/trafficclass_base_listener.go @@ -1,7 +1,7 @@ // File generated by ANTLR. DO NOT EDIT. package traffic_class // TrafficClass -import "github.com/antlr/antlr4/runtime/Go/antlr" +import "github.com/antlr4-go/antlr/v4" // BaseTrafficClassListener is a complete listener for a parse tree produced by TrafficClassParser. type BaseTrafficClassListener struct{} diff --git a/antlr/traffic_class/trafficclass_lexer.go b/antlr/traffic_class/trafficclass_lexer.go index 3cf8608e9d..50ae746279 100644 --- a/antlr/traffic_class/trafficclass_lexer.go +++ b/antlr/traffic_class/trafficclass_lexer.go @@ -4,178 +4,197 @@ package traffic_class import ( "fmt" + "github.com/antlr4-go/antlr/v4" + "sync" "unicode" - - "github.com/antlr/antlr4/runtime/Go/antlr" ) // Suppress unused import error var _ = fmt.Printf +var _ = sync.Once{} var _ = unicode.IsLetter -var serializedLexerAtn = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 27, 238, - 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, - 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, - 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, - 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, - 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 3, 2, 3, 2, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, - 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, - 10, 3, 10, 3, 10, 3, 11, 6, 11, 85, 10, 11, 13, 11, 14, 11, 86, 3, 11, - 3, 11, 3, 12, 3, 12, 3, 12, 7, 12, 94, 10, 12, 12, 12, 14, 12, 97, 11, - 12, 5, 12, 99, 10, 12, 3, 13, 6, 13, 102, 10, 13, 13, 13, 14, 13, 103, - 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, - 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 5, 15, 122, 10, 15, 3, 16, 3, 16, - 3, 16, 3, 16, 3, 16, 3, 16, 5, 16, 130, 10, 16, 3, 17, 3, 17, 3, 17, 3, - 17, 3, 17, 3, 17, 5, 17, 138, 10, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, - 3, 18, 3, 18, 3, 18, 5, 18, 148, 10, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, - 19, 3, 19, 5, 19, 156, 10, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, - 5, 20, 164, 10, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, - 21, 5, 21, 174, 10, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 5, 22, - 182, 10, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, - 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 5, 23, 200, 10, 23, - 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, - 24, 3, 24, 3, 24, 3, 24, 5, 24, 216, 10, 24, 3, 25, 3, 25, 3, 25, 3, 25, - 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 5, - 25, 232, 10, 25, 3, 26, 6, 26, 235, 10, 26, 13, 26, 14, 26, 236, 2, 2, - 27, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, - 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, - 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 3, 2, 7, 5, 2, 11, 12, - 15, 15, 34, 34, 3, 2, 51, 59, 3, 2, 50, 59, 5, 2, 50, 59, 67, 72, 99, 104, - 4, 2, 67, 92, 99, 124, 2, 253, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, - 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, - 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, - 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, - 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, - 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, - 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 3, 53, - 3, 2, 2, 2, 5, 55, 3, 2, 2, 2, 7, 59, 3, 2, 2, 2, 9, 61, 3, 2, 2, 2, 11, - 66, 3, 2, 2, 2, 13, 68, 3, 2, 2, 2, 15, 70, 3, 2, 2, 2, 17, 72, 3, 2, 2, - 2, 19, 77, 3, 2, 2, 2, 21, 84, 3, 2, 2, 2, 23, 98, 3, 2, 2, 2, 25, 101, - 3, 2, 2, 2, 27, 105, 3, 2, 2, 2, 29, 121, 3, 2, 2, 2, 31, 129, 3, 2, 2, - 2, 33, 137, 3, 2, 2, 2, 35, 147, 3, 2, 2, 2, 37, 155, 3, 2, 2, 2, 39, 163, - 3, 2, 2, 2, 41, 173, 3, 2, 2, 2, 43, 181, 3, 2, 2, 2, 45, 199, 3, 2, 2, - 2, 47, 215, 3, 2, 2, 2, 49, 231, 3, 2, 2, 2, 51, 234, 3, 2, 2, 2, 53, 54, - 7, 63, 2, 2, 54, 4, 3, 2, 2, 2, 55, 56, 7, 63, 2, 2, 56, 57, 7, 50, 2, - 2, 57, 58, 7, 122, 2, 2, 58, 6, 3, 2, 2, 2, 59, 60, 7, 47, 2, 2, 60, 8, - 3, 2, 2, 2, 61, 62, 7, 101, 2, 2, 62, 63, 7, 110, 2, 2, 63, 64, 7, 117, - 2, 2, 64, 65, 7, 63, 2, 2, 65, 10, 3, 2, 2, 2, 66, 67, 7, 42, 2, 2, 67, - 12, 3, 2, 2, 2, 68, 69, 7, 46, 2, 2, 69, 14, 3, 2, 2, 2, 70, 71, 7, 43, - 2, 2, 71, 16, 3, 2, 2, 2, 72, 73, 7, 118, 2, 2, 73, 74, 7, 116, 2, 2, 74, - 75, 7, 119, 2, 2, 75, 76, 7, 103, 2, 2, 76, 18, 3, 2, 2, 2, 77, 78, 7, - 104, 2, 2, 78, 79, 7, 99, 2, 2, 79, 80, 7, 110, 2, 2, 80, 81, 7, 117, 2, - 2, 81, 82, 7, 103, 2, 2, 82, 20, 3, 2, 2, 2, 83, 85, 9, 2, 2, 2, 84, 83, - 3, 2, 2, 2, 85, 86, 3, 2, 2, 2, 86, 84, 3, 2, 2, 2, 86, 87, 3, 2, 2, 2, - 87, 88, 3, 2, 2, 2, 88, 89, 8, 11, 2, 2, 89, 22, 3, 2, 2, 2, 90, 99, 7, - 50, 2, 2, 91, 95, 9, 3, 2, 2, 92, 94, 9, 4, 2, 2, 93, 92, 3, 2, 2, 2, 94, - 97, 3, 2, 2, 2, 95, 93, 3, 2, 2, 2, 95, 96, 3, 2, 2, 2, 96, 99, 3, 2, 2, - 2, 97, 95, 3, 2, 2, 2, 98, 90, 3, 2, 2, 2, 98, 91, 3, 2, 2, 2, 99, 24, - 3, 2, 2, 2, 100, 102, 9, 5, 2, 2, 101, 100, 3, 2, 2, 2, 102, 103, 3, 2, - 2, 2, 103, 101, 3, 2, 2, 2, 103, 104, 3, 2, 2, 2, 104, 26, 3, 2, 2, 2, - 105, 106, 5, 23, 12, 2, 106, 107, 7, 48, 2, 2, 107, 108, 5, 23, 12, 2, - 108, 109, 7, 48, 2, 2, 109, 110, 5, 23, 12, 2, 110, 111, 7, 48, 2, 2, 111, - 112, 5, 23, 12, 2, 112, 113, 7, 49, 2, 2, 113, 114, 5, 23, 12, 2, 114, - 28, 3, 2, 2, 2, 115, 116, 7, 67, 2, 2, 116, 117, 7, 80, 2, 2, 117, 122, - 7, 91, 2, 2, 118, 119, 7, 99, 2, 2, 119, 120, 7, 112, 2, 2, 120, 122, 7, - 123, 2, 2, 121, 115, 3, 2, 2, 2, 121, 118, 3, 2, 2, 2, 122, 30, 3, 2, 2, - 2, 123, 124, 7, 67, 2, 2, 124, 125, 7, 78, 2, 2, 125, 130, 7, 78, 2, 2, - 126, 127, 7, 99, 2, 2, 127, 128, 7, 110, 2, 2, 128, 130, 7, 110, 2, 2, - 129, 123, 3, 2, 2, 2, 129, 126, 3, 2, 2, 2, 130, 32, 3, 2, 2, 2, 131, 132, - 7, 80, 2, 2, 132, 133, 7, 81, 2, 2, 133, 138, 7, 86, 2, 2, 134, 135, 7, - 112, 2, 2, 135, 136, 7, 113, 2, 2, 136, 138, 7, 118, 2, 2, 137, 131, 3, - 2, 2, 2, 137, 134, 3, 2, 2, 2, 138, 34, 3, 2, 2, 2, 139, 140, 7, 68, 2, - 2, 140, 141, 7, 81, 2, 2, 141, 142, 7, 81, 2, 2, 142, 148, 7, 78, 2, 2, - 143, 144, 7, 100, 2, 2, 144, 145, 7, 113, 2, 2, 145, 146, 7, 113, 2, 2, - 146, 148, 7, 110, 2, 2, 147, 139, 3, 2, 2, 2, 147, 143, 3, 2, 2, 2, 148, - 36, 3, 2, 2, 2, 149, 150, 7, 85, 2, 2, 150, 151, 7, 84, 2, 2, 151, 156, - 7, 69, 2, 2, 152, 153, 7, 117, 2, 2, 153, 154, 7, 116, 2, 2, 154, 156, - 7, 101, 2, 2, 155, 149, 3, 2, 2, 2, 155, 152, 3, 2, 2, 2, 156, 38, 3, 2, - 2, 2, 157, 158, 7, 70, 2, 2, 158, 159, 7, 85, 2, 2, 159, 164, 7, 86, 2, - 2, 160, 161, 7, 102, 2, 2, 161, 162, 7, 117, 2, 2, 162, 164, 7, 118, 2, - 2, 163, 157, 3, 2, 2, 2, 163, 160, 3, 2, 2, 2, 164, 40, 3, 2, 2, 2, 165, - 166, 7, 70, 2, 2, 166, 167, 7, 85, 2, 2, 167, 168, 7, 69, 2, 2, 168, 174, - 7, 82, 2, 2, 169, 170, 7, 102, 2, 2, 170, 171, 7, 117, 2, 2, 171, 172, - 7, 101, 2, 2, 172, 174, 7, 114, 2, 2, 173, 165, 3, 2, 2, 2, 173, 169, 3, - 2, 2, 2, 174, 42, 3, 2, 2, 2, 175, 176, 7, 86, 2, 2, 176, 177, 7, 81, 2, - 2, 177, 182, 7, 85, 2, 2, 178, 179, 7, 118, 2, 2, 179, 180, 7, 113, 2, - 2, 180, 182, 7, 117, 2, 2, 181, 175, 3, 2, 2, 2, 181, 178, 3, 2, 2, 2, - 182, 44, 3, 2, 2, 2, 183, 184, 7, 82, 2, 2, 184, 185, 7, 84, 2, 2, 185, - 186, 7, 81, 2, 2, 186, 187, 7, 86, 2, 2, 187, 188, 7, 81, 2, 2, 188, 189, - 7, 69, 2, 2, 189, 190, 7, 81, 2, 2, 190, 200, 7, 78, 2, 2, 191, 192, 7, - 114, 2, 2, 192, 193, 7, 116, 2, 2, 193, 194, 7, 113, 2, 2, 194, 195, 7, - 118, 2, 2, 195, 196, 7, 113, 2, 2, 196, 197, 7, 101, 2, 2, 197, 198, 7, - 113, 2, 2, 198, 200, 7, 110, 2, 2, 199, 183, 3, 2, 2, 2, 199, 191, 3, 2, - 2, 2, 200, 46, 3, 2, 2, 2, 201, 202, 7, 85, 2, 2, 202, 203, 7, 84, 2, 2, - 203, 204, 7, 69, 2, 2, 204, 205, 7, 82, 2, 2, 205, 206, 7, 81, 2, 2, 206, - 207, 7, 84, 2, 2, 207, 216, 7, 86, 2, 2, 208, 209, 7, 117, 2, 2, 209, 210, - 7, 116, 2, 2, 210, 211, 7, 101, 2, 2, 211, 212, 7, 114, 2, 2, 212, 213, - 7, 113, 2, 2, 213, 214, 7, 116, 2, 2, 214, 216, 7, 118, 2, 2, 215, 201, - 3, 2, 2, 2, 215, 208, 3, 2, 2, 2, 216, 48, 3, 2, 2, 2, 217, 218, 7, 70, - 2, 2, 218, 219, 7, 85, 2, 2, 219, 220, 7, 86, 2, 2, 220, 221, 7, 82, 2, - 2, 221, 222, 7, 81, 2, 2, 222, 223, 7, 84, 2, 2, 223, 232, 7, 86, 2, 2, - 224, 225, 7, 102, 2, 2, 225, 226, 7, 117, 2, 2, 226, 227, 7, 118, 2, 2, - 227, 228, 7, 114, 2, 2, 228, 229, 7, 113, 2, 2, 229, 230, 7, 116, 2, 2, - 230, 232, 7, 118, 2, 2, 231, 217, 3, 2, 2, 2, 231, 224, 3, 2, 2, 2, 232, - 50, 3, 2, 2, 2, 233, 235, 9, 6, 2, 2, 234, 233, 3, 2, 2, 2, 235, 236, 3, - 2, 2, 2, 236, 234, 3, 2, 2, 2, 236, 237, 3, 2, 2, 2, 237, 52, 3, 2, 2, - 2, 20, 2, 86, 95, 98, 101, 103, 121, 129, 137, 147, 155, 163, 173, 181, - 199, 215, 231, 236, 3, 8, 2, 2, -} - -var lexerChannelNames = []string{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", -} - -var lexerModeNames = []string{ - "DEFAULT_MODE", -} - -var lexerLiteralNames = []string{ - "", "'='", "'=0x'", "'-'", "'cls='", "'('", "','", "')'", "'true'", "'false'", +type TrafficClassLexer struct { + *antlr.BaseLexer + channelNames []string + modeNames []string + // TODO: EOF string } -var lexerSymbolicNames = []string{ - "", "", "", "", "", "", "", "", "", "", "WHITESPACE", "DIGITS", "HEX_DIGITS", - "NET", "ANY", "ALL", "NOT", "BOOL", "SRC", "DST", "DSCP", "TOS", "PROTOCOL", - "SRCPORT", "DSTPORT", "STRING", +var TrafficClassLexerLexerStaticData struct { + once sync.Once + serializedATN []int32 + ChannelNames []string + ModeNames []string + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA } -var lexerRuleNames = []string{ - "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", - "WHITESPACE", "DIGITS", "HEX_DIGITS", "NET", "ANY", "ALL", "NOT", "BOOL", - "SRC", "DST", "DSCP", "TOS", "PROTOCOL", "SRCPORT", "DSTPORT", "STRING", +func trafficclasslexerLexerInit() { + staticData := &TrafficClassLexerLexerStaticData + staticData.ChannelNames = []string{ + "DEFAULT_TOKEN_CHANNEL", "HIDDEN", + } + staticData.ModeNames = []string{ + "DEFAULT_MODE", + } + staticData.LiteralNames = []string{ + "", "'='", "'=0x'", "'-'", "'cls='", "'('", "','", "')'", "'true'", + "'false'", + } + staticData.SymbolicNames = []string{ + "", "", "", "", "", "", "", "", "", "", "WHITESPACE", "DIGITS", "HEX_DIGITS", + "NET", "ANY", "ALL", "NOT", "BOOL", "SRC", "DST", "DSCP", "TOS", "PROTOCOL", + "SRCPORT", "DSTPORT", "STRING", + } + staticData.RuleNames = []string{ + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "WHITESPACE", "DIGITS", "HEX_DIGITS", "NET", "ANY", "ALL", "NOT", "BOOL", + "SRC", "DST", "DSCP", "TOS", "PROTOCOL", "SRCPORT", "DSTPORT", "STRING", + } + staticData.PredictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 0, 25, 236, 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, + 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, + 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, + 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 1, 0, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, + 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, + 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 4, 9, 83, 8, 9, 11, 9, 12, 9, 84, 1, 9, 1, + 9, 1, 10, 1, 10, 1, 10, 5, 10, 92, 8, 10, 10, 10, 12, 10, 95, 9, 10, 3, + 10, 97, 8, 10, 1, 11, 4, 11, 100, 8, 11, 11, 11, 12, 11, 101, 1, 12, 1, + 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, + 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 120, 8, 13, 1, 14, 1, 14, 1, 14, 1, + 14, 1, 14, 1, 14, 3, 14, 128, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, + 1, 15, 3, 15, 136, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, + 16, 1, 16, 3, 16, 146, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, + 3, 17, 154, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 162, + 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 172, + 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 180, 8, 20, 1, + 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, + 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 198, 8, 21, 1, 22, 1, 22, 1, + 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, + 1, 22, 3, 22, 214, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, + 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 230, 8, 23, + 1, 24, 4, 24, 233, 8, 24, 11, 24, 12, 24, 234, 0, 0, 25, 1, 1, 3, 2, 5, + 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, + 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, + 22, 45, 23, 47, 24, 49, 25, 1, 0, 5, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, + 49, 57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 2, 0, 65, 90, 97, + 122, 251, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, + 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, + 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, + 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, + 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, + 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, + 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 1, 51, 1, 0, 0, 0, 3, 53, 1, + 0, 0, 0, 5, 57, 1, 0, 0, 0, 7, 59, 1, 0, 0, 0, 9, 64, 1, 0, 0, 0, 11, 66, + 1, 0, 0, 0, 13, 68, 1, 0, 0, 0, 15, 70, 1, 0, 0, 0, 17, 75, 1, 0, 0, 0, + 19, 82, 1, 0, 0, 0, 21, 96, 1, 0, 0, 0, 23, 99, 1, 0, 0, 0, 25, 103, 1, + 0, 0, 0, 27, 119, 1, 0, 0, 0, 29, 127, 1, 0, 0, 0, 31, 135, 1, 0, 0, 0, + 33, 145, 1, 0, 0, 0, 35, 153, 1, 0, 0, 0, 37, 161, 1, 0, 0, 0, 39, 171, + 1, 0, 0, 0, 41, 179, 1, 0, 0, 0, 43, 197, 1, 0, 0, 0, 45, 213, 1, 0, 0, + 0, 47, 229, 1, 0, 0, 0, 49, 232, 1, 0, 0, 0, 51, 52, 5, 61, 0, 0, 52, 2, + 1, 0, 0, 0, 53, 54, 5, 61, 0, 0, 54, 55, 5, 48, 0, 0, 55, 56, 5, 120, 0, + 0, 56, 4, 1, 0, 0, 0, 57, 58, 5, 45, 0, 0, 58, 6, 1, 0, 0, 0, 59, 60, 5, + 99, 0, 0, 60, 61, 5, 108, 0, 0, 61, 62, 5, 115, 0, 0, 62, 63, 5, 61, 0, + 0, 63, 8, 1, 0, 0, 0, 64, 65, 5, 40, 0, 0, 65, 10, 1, 0, 0, 0, 66, 67, + 5, 44, 0, 0, 67, 12, 1, 0, 0, 0, 68, 69, 5, 41, 0, 0, 69, 14, 1, 0, 0, + 0, 70, 71, 5, 116, 0, 0, 71, 72, 5, 114, 0, 0, 72, 73, 5, 117, 0, 0, 73, + 74, 5, 101, 0, 0, 74, 16, 1, 0, 0, 0, 75, 76, 5, 102, 0, 0, 76, 77, 5, + 97, 0, 0, 77, 78, 5, 108, 0, 0, 78, 79, 5, 115, 0, 0, 79, 80, 5, 101, 0, + 0, 80, 18, 1, 0, 0, 0, 81, 83, 7, 0, 0, 0, 82, 81, 1, 0, 0, 0, 83, 84, + 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, + 86, 87, 6, 9, 0, 0, 87, 20, 1, 0, 0, 0, 88, 97, 5, 48, 0, 0, 89, 93, 7, + 1, 0, 0, 90, 92, 7, 2, 0, 0, 91, 90, 1, 0, 0, 0, 92, 95, 1, 0, 0, 0, 93, + 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 97, 1, 0, 0, 0, 95, 93, 1, 0, 0, + 0, 96, 88, 1, 0, 0, 0, 96, 89, 1, 0, 0, 0, 97, 22, 1, 0, 0, 0, 98, 100, + 7, 3, 0, 0, 99, 98, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 99, 1, 0, 0, + 0, 101, 102, 1, 0, 0, 0, 102, 24, 1, 0, 0, 0, 103, 104, 3, 21, 10, 0, 104, + 105, 5, 46, 0, 0, 105, 106, 3, 21, 10, 0, 106, 107, 5, 46, 0, 0, 107, 108, + 3, 21, 10, 0, 108, 109, 5, 46, 0, 0, 109, 110, 3, 21, 10, 0, 110, 111, + 5, 47, 0, 0, 111, 112, 3, 21, 10, 0, 112, 26, 1, 0, 0, 0, 113, 114, 5, + 65, 0, 0, 114, 115, 5, 78, 0, 0, 115, 120, 5, 89, 0, 0, 116, 117, 5, 97, + 0, 0, 117, 118, 5, 110, 0, 0, 118, 120, 5, 121, 0, 0, 119, 113, 1, 0, 0, + 0, 119, 116, 1, 0, 0, 0, 120, 28, 1, 0, 0, 0, 121, 122, 5, 65, 0, 0, 122, + 123, 5, 76, 0, 0, 123, 128, 5, 76, 0, 0, 124, 125, 5, 97, 0, 0, 125, 126, + 5, 108, 0, 0, 126, 128, 5, 108, 0, 0, 127, 121, 1, 0, 0, 0, 127, 124, 1, + 0, 0, 0, 128, 30, 1, 0, 0, 0, 129, 130, 5, 78, 0, 0, 130, 131, 5, 79, 0, + 0, 131, 136, 5, 84, 0, 0, 132, 133, 5, 110, 0, 0, 133, 134, 5, 111, 0, + 0, 134, 136, 5, 116, 0, 0, 135, 129, 1, 0, 0, 0, 135, 132, 1, 0, 0, 0, + 136, 32, 1, 0, 0, 0, 137, 138, 5, 66, 0, 0, 138, 139, 5, 79, 0, 0, 139, + 140, 5, 79, 0, 0, 140, 146, 5, 76, 0, 0, 141, 142, 5, 98, 0, 0, 142, 143, + 5, 111, 0, 0, 143, 144, 5, 111, 0, 0, 144, 146, 5, 108, 0, 0, 145, 137, + 1, 0, 0, 0, 145, 141, 1, 0, 0, 0, 146, 34, 1, 0, 0, 0, 147, 148, 5, 83, + 0, 0, 148, 149, 5, 82, 0, 0, 149, 154, 5, 67, 0, 0, 150, 151, 5, 115, 0, + 0, 151, 152, 5, 114, 0, 0, 152, 154, 5, 99, 0, 0, 153, 147, 1, 0, 0, 0, + 153, 150, 1, 0, 0, 0, 154, 36, 1, 0, 0, 0, 155, 156, 5, 68, 0, 0, 156, + 157, 5, 83, 0, 0, 157, 162, 5, 84, 0, 0, 158, 159, 5, 100, 0, 0, 159, 160, + 5, 115, 0, 0, 160, 162, 5, 116, 0, 0, 161, 155, 1, 0, 0, 0, 161, 158, 1, + 0, 0, 0, 162, 38, 1, 0, 0, 0, 163, 164, 5, 68, 0, 0, 164, 165, 5, 83, 0, + 0, 165, 166, 5, 67, 0, 0, 166, 172, 5, 80, 0, 0, 167, 168, 5, 100, 0, 0, + 168, 169, 5, 115, 0, 0, 169, 170, 5, 99, 0, 0, 170, 172, 5, 112, 0, 0, + 171, 163, 1, 0, 0, 0, 171, 167, 1, 0, 0, 0, 172, 40, 1, 0, 0, 0, 173, 174, + 5, 84, 0, 0, 174, 175, 5, 79, 0, 0, 175, 180, 5, 83, 0, 0, 176, 177, 5, + 116, 0, 0, 177, 178, 5, 111, 0, 0, 178, 180, 5, 115, 0, 0, 179, 173, 1, + 0, 0, 0, 179, 176, 1, 0, 0, 0, 180, 42, 1, 0, 0, 0, 181, 182, 5, 80, 0, + 0, 182, 183, 5, 82, 0, 0, 183, 184, 5, 79, 0, 0, 184, 185, 5, 84, 0, 0, + 185, 186, 5, 79, 0, 0, 186, 187, 5, 67, 0, 0, 187, 188, 5, 79, 0, 0, 188, + 198, 5, 76, 0, 0, 189, 190, 5, 112, 0, 0, 190, 191, 5, 114, 0, 0, 191, + 192, 5, 111, 0, 0, 192, 193, 5, 116, 0, 0, 193, 194, 5, 111, 0, 0, 194, + 195, 5, 99, 0, 0, 195, 196, 5, 111, 0, 0, 196, 198, 5, 108, 0, 0, 197, + 181, 1, 0, 0, 0, 197, 189, 1, 0, 0, 0, 198, 44, 1, 0, 0, 0, 199, 200, 5, + 83, 0, 0, 200, 201, 5, 82, 0, 0, 201, 202, 5, 67, 0, 0, 202, 203, 5, 80, + 0, 0, 203, 204, 5, 79, 0, 0, 204, 205, 5, 82, 0, 0, 205, 214, 5, 84, 0, + 0, 206, 207, 5, 115, 0, 0, 207, 208, 5, 114, 0, 0, 208, 209, 5, 99, 0, + 0, 209, 210, 5, 112, 0, 0, 210, 211, 5, 111, 0, 0, 211, 212, 5, 114, 0, + 0, 212, 214, 5, 116, 0, 0, 213, 199, 1, 0, 0, 0, 213, 206, 1, 0, 0, 0, + 214, 46, 1, 0, 0, 0, 215, 216, 5, 68, 0, 0, 216, 217, 5, 83, 0, 0, 217, + 218, 5, 84, 0, 0, 218, 219, 5, 80, 0, 0, 219, 220, 5, 79, 0, 0, 220, 221, + 5, 82, 0, 0, 221, 230, 5, 84, 0, 0, 222, 223, 5, 100, 0, 0, 223, 224, 5, + 115, 0, 0, 224, 225, 5, 116, 0, 0, 225, 226, 5, 112, 0, 0, 226, 227, 5, + 111, 0, 0, 227, 228, 5, 114, 0, 0, 228, 230, 5, 116, 0, 0, 229, 215, 1, + 0, 0, 0, 229, 222, 1, 0, 0, 0, 230, 48, 1, 0, 0, 0, 231, 233, 7, 4, 0, + 0, 232, 231, 1, 0, 0, 0, 233, 234, 1, 0, 0, 0, 234, 232, 1, 0, 0, 0, 234, + 235, 1, 0, 0, 0, 235, 50, 1, 0, 0, 0, 18, 0, 84, 93, 96, 99, 101, 119, + 127, 135, 145, 153, 161, 171, 179, 197, 213, 229, 234, 1, 6, 0, 0, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } } -type TrafficClassLexer struct { - *antlr.BaseLexer - channelNames []string - modeNames []string - // TODO: EOF string +// TrafficClassLexerInit initializes any static state used to implement TrafficClassLexer. By default the +// static state used to implement the lexer is lazily initialized during the first call to +// NewTrafficClassLexer(). You can call this function if you wish to initialize the static state ahead +// of time. +func TrafficClassLexerInit() { + staticData := &TrafficClassLexerLexerStaticData + staticData.once.Do(trafficclasslexerLexerInit) } // NewTrafficClassLexer produces a new lexer instance for the optional input antlr.CharStream. -// -// The *TrafficClassLexer instance produced may be reused by calling the SetInputStream method. -// The initial lexer configuration is expensive to construct, and the object is not thread-safe; -// however, if used within a Golang sync.Pool, the construction cost amortizes well and the -// objects can be used in a thread-safe manner. func NewTrafficClassLexer(input antlr.CharStream) *TrafficClassLexer { + TrafficClassLexerInit() l := new(TrafficClassLexer) - lexerDeserializer := antlr.NewATNDeserializer(nil) - lexerAtn := lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn) - lexerDecisionToDFA := make([]*antlr.DFA, len(lexerAtn.DecisionToState)) - for index, ds := range lexerAtn.DecisionToState { - lexerDecisionToDFA[index] = antlr.NewDFA(ds, index) - } l.BaseLexer = antlr.NewBaseLexer(input) - l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache()) - - l.channelNames = lexerChannelNames - l.modeNames = lexerModeNames - l.RuleNames = lexerRuleNames - l.LiteralNames = lexerLiteralNames - l.SymbolicNames = lexerSymbolicNames + staticData := &TrafficClassLexerLexerStaticData + 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 = "TrafficClass.g4" // TODO: l.EOF = antlr.TokenEOF diff --git a/antlr/traffic_class/trafficclass_listener.go b/antlr/traffic_class/trafficclass_listener.go index d4ddda5af7..c21411c127 100644 --- a/antlr/traffic_class/trafficclass_listener.go +++ b/antlr/traffic_class/trafficclass_listener.go @@ -1,7 +1,7 @@ // File generated by ANTLR. DO NOT EDIT. package traffic_class // TrafficClass -import "github.com/antlr/antlr4/runtime/Go/antlr" +import "github.com/antlr4-go/antlr/v4" // TrafficClassListener is a complete listener for a parse tree produced by TrafficClassParser. type TrafficClassListener interface { diff --git a/antlr/traffic_class/trafficclass_parser.go b/antlr/traffic_class/trafficclass_parser.go index 99299bac74..904dc75648 100644 --- a/antlr/traffic_class/trafficclass_parser.go +++ b/antlr/traffic_class/trafficclass_parser.go @@ -3,114 +3,136 @@ package traffic_class // TrafficClass import ( "fmt" - "reflect" "strconv" + "sync" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr4-go/antlr/v4" ) // Suppress unused import errors var _ = fmt.Printf -var _ = reflect.Copy var _ = strconv.Itoa - -var parserATN = []uint16{ - 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 27, 140, - 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, - 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, - 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, - 18, 4, 19, 9, 19, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, - 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, - 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, - 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, - 12, 3, 12, 3, 12, 3, 12, 3, 12, 7, 12, 87, 10, 12, 12, 12, 14, 12, 90, - 11, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 7, 13, 99, 10, - 13, 12, 13, 14, 13, 102, 11, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, - 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, - 5, 16, 120, 10, 16, 3, 17, 3, 17, 3, 17, 3, 17, 5, 17, 126, 10, 17, 3, - 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 5, 18, 135, 10, 18, 3, 19, - 3, 19, 3, 19, 3, 19, 2, 2, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, - 24, 26, 28, 30, 32, 34, 36, 2, 4, 3, 2, 13, 14, 3, 2, 10, 11, 2, 136, 2, - 38, 3, 2, 2, 2, 4, 42, 3, 2, 2, 2, 6, 46, 3, 2, 2, 2, 8, 50, 3, 2, 2, 2, - 10, 54, 3, 2, 2, 2, 12, 58, 3, 2, 2, 2, 14, 62, 3, 2, 2, 2, 16, 68, 3, - 2, 2, 2, 18, 72, 3, 2, 2, 2, 20, 78, 3, 2, 2, 2, 22, 81, 3, 2, 2, 2, 24, - 93, 3, 2, 2, 2, 26, 105, 3, 2, 2, 2, 28, 110, 3, 2, 2, 2, 30, 119, 3, 2, - 2, 2, 32, 125, 3, 2, 2, 2, 34, 134, 3, 2, 2, 2, 36, 136, 3, 2, 2, 2, 38, - 39, 7, 20, 2, 2, 39, 40, 7, 3, 2, 2, 40, 41, 7, 15, 2, 2, 41, 3, 3, 2, - 2, 2, 42, 43, 7, 21, 2, 2, 43, 44, 7, 3, 2, 2, 44, 45, 7, 15, 2, 2, 45, - 5, 3, 2, 2, 2, 46, 47, 7, 22, 2, 2, 47, 48, 7, 4, 2, 2, 48, 49, 9, 2, 2, - 2, 49, 7, 3, 2, 2, 2, 50, 51, 7, 23, 2, 2, 51, 52, 7, 4, 2, 2, 52, 53, - 9, 2, 2, 2, 53, 9, 3, 2, 2, 2, 54, 55, 7, 24, 2, 2, 55, 56, 7, 3, 2, 2, - 56, 57, 7, 27, 2, 2, 57, 11, 3, 2, 2, 2, 58, 59, 7, 25, 2, 2, 59, 60, 7, - 3, 2, 2, 60, 61, 7, 13, 2, 2, 61, 13, 3, 2, 2, 2, 62, 63, 7, 25, 2, 2, - 63, 64, 7, 3, 2, 2, 64, 65, 7, 13, 2, 2, 65, 66, 7, 5, 2, 2, 66, 67, 7, - 13, 2, 2, 67, 15, 3, 2, 2, 2, 68, 69, 7, 26, 2, 2, 69, 70, 7, 3, 2, 2, - 70, 71, 7, 13, 2, 2, 71, 17, 3, 2, 2, 2, 72, 73, 7, 26, 2, 2, 73, 74, 7, - 3, 2, 2, 74, 75, 7, 13, 2, 2, 75, 76, 7, 5, 2, 2, 76, 77, 7, 13, 2, 2, - 77, 19, 3, 2, 2, 2, 78, 79, 7, 6, 2, 2, 79, 80, 7, 13, 2, 2, 80, 21, 3, - 2, 2, 2, 81, 82, 7, 16, 2, 2, 82, 83, 7, 7, 2, 2, 83, 88, 5, 34, 18, 2, - 84, 85, 7, 8, 2, 2, 85, 87, 5, 34, 18, 2, 86, 84, 3, 2, 2, 2, 87, 90, 3, - 2, 2, 2, 88, 86, 3, 2, 2, 2, 88, 89, 3, 2, 2, 2, 89, 91, 3, 2, 2, 2, 90, - 88, 3, 2, 2, 2, 91, 92, 7, 9, 2, 2, 92, 23, 3, 2, 2, 2, 93, 94, 7, 17, - 2, 2, 94, 95, 7, 7, 2, 2, 95, 100, 5, 34, 18, 2, 96, 97, 7, 8, 2, 2, 97, - 99, 5, 34, 18, 2, 98, 96, 3, 2, 2, 2, 99, 102, 3, 2, 2, 2, 100, 98, 3, - 2, 2, 2, 100, 101, 3, 2, 2, 2, 101, 103, 3, 2, 2, 2, 102, 100, 3, 2, 2, - 2, 103, 104, 7, 9, 2, 2, 104, 25, 3, 2, 2, 2, 105, 106, 7, 18, 2, 2, 106, - 107, 7, 7, 2, 2, 107, 108, 5, 34, 18, 2, 108, 109, 7, 9, 2, 2, 109, 27, - 3, 2, 2, 2, 110, 111, 7, 19, 2, 2, 111, 112, 7, 3, 2, 2, 112, 113, 9, 3, - 2, 2, 113, 29, 3, 2, 2, 2, 114, 120, 5, 2, 2, 2, 115, 120, 5, 4, 3, 2, - 116, 120, 5, 6, 4, 2, 117, 120, 5, 8, 5, 2, 118, 120, 5, 10, 6, 2, 119, - 114, 3, 2, 2, 2, 119, 115, 3, 2, 2, 2, 119, 116, 3, 2, 2, 2, 119, 117, - 3, 2, 2, 2, 119, 118, 3, 2, 2, 2, 120, 31, 3, 2, 2, 2, 121, 126, 5, 12, - 7, 2, 122, 126, 5, 14, 8, 2, 123, 126, 5, 16, 9, 2, 124, 126, 5, 18, 10, - 2, 125, 121, 3, 2, 2, 2, 125, 122, 3, 2, 2, 2, 125, 123, 3, 2, 2, 2, 125, - 124, 3, 2, 2, 2, 126, 33, 3, 2, 2, 2, 127, 135, 5, 24, 13, 2, 128, 135, - 5, 22, 12, 2, 129, 135, 5, 26, 14, 2, 130, 135, 5, 30, 16, 2, 131, 135, - 5, 32, 17, 2, 132, 135, 5, 20, 11, 2, 133, 135, 5, 28, 15, 2, 134, 127, - 3, 2, 2, 2, 134, 128, 3, 2, 2, 2, 134, 129, 3, 2, 2, 2, 134, 130, 3, 2, - 2, 2, 134, 131, 3, 2, 2, 2, 134, 132, 3, 2, 2, 2, 134, 133, 3, 2, 2, 2, - 135, 35, 3, 2, 2, 2, 136, 137, 5, 34, 18, 2, 137, 138, 7, 2, 2, 3, 138, - 37, 3, 2, 2, 2, 7, 88, 100, 119, 125, 134, -} -var literalNames = []string{ - "", "'='", "'=0x'", "'-'", "'cls='", "'('", "','", "')'", "'true'", "'false'", -} -var symbolicNames = []string{ - "", "", "", "", "", "", "", "", "", "", "WHITESPACE", "DIGITS", "HEX_DIGITS", - "NET", "ANY", "ALL", "NOT", "BOOL", "SRC", "DST", "DSCP", "TOS", "PROTOCOL", - "SRCPORT", "DSTPORT", "STRING", -} - -var ruleNames = []string{ - "matchSrc", "matchDst", "matchDSCP", "matchTOS", "matchProtocol", "matchSrcPort", - "matchSrcPortRange", "matchDstPort", "matchDstPortRange", "condCls", "condAny", - "condAll", "condNot", "condBool", "condIPv4", "condPort", "cond", "trafficClass", -} +var _ = sync.Once{} type TrafficClassParser struct { *antlr.BaseParser } +var TrafficClassParserStaticData struct { + once sync.Once + serializedATN []int32 + LiteralNames []string + SymbolicNames []string + RuleNames []string + PredictionContextCache *antlr.PredictionContextCache + atn *antlr.ATN + decisionToDFA []*antlr.DFA +} + +func trafficclassParserInit() { + staticData := &TrafficClassParserStaticData + staticData.LiteralNames = []string{ + "", "'='", "'=0x'", "'-'", "'cls='", "'('", "','", "')'", "'true'", + "'false'", + } + staticData.SymbolicNames = []string{ + "", "", "", "", "", "", "", "", "", "", "WHITESPACE", "DIGITS", "HEX_DIGITS", + "NET", "ANY", "ALL", "NOT", "BOOL", "SRC", "DST", "DSCP", "TOS", "PROTOCOL", + "SRCPORT", "DSTPORT", "STRING", + } + staticData.RuleNames = []string{ + "matchSrc", "matchDst", "matchDSCP", "matchTOS", "matchProtocol", "matchSrcPort", + "matchSrcPortRange", "matchDstPort", "matchDstPortRange", "condCls", + "condAny", "condAll", "condNot", "condBool", "condIPv4", "condPort", + "cond", "trafficClass", + } + staticData.PredictionContextCache = antlr.NewPredictionContextCache() + staticData.serializedATN = []int32{ + 4, 1, 25, 138, 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, + 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, + 2, 16, 7, 16, 2, 17, 7, 17, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, + 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, + 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, + 10, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 85, 8, 10, 10, 10, 12, 10, 88, 9, + 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 97, 8, 11, + 10, 11, 12, 11, 100, 9, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, + 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, + 118, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 124, 8, 15, 1, 16, 1, 16, + 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 133, 8, 16, 1, 17, 1, 17, 1, + 17, 1, 17, 0, 0, 18, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, + 28, 30, 32, 34, 0, 2, 1, 0, 11, 12, 1, 0, 8, 9, 134, 0, 36, 1, 0, 0, 0, + 2, 40, 1, 0, 0, 0, 4, 44, 1, 0, 0, 0, 6, 48, 1, 0, 0, 0, 8, 52, 1, 0, 0, + 0, 10, 56, 1, 0, 0, 0, 12, 60, 1, 0, 0, 0, 14, 66, 1, 0, 0, 0, 16, 70, + 1, 0, 0, 0, 18, 76, 1, 0, 0, 0, 20, 79, 1, 0, 0, 0, 22, 91, 1, 0, 0, 0, + 24, 103, 1, 0, 0, 0, 26, 108, 1, 0, 0, 0, 28, 117, 1, 0, 0, 0, 30, 123, + 1, 0, 0, 0, 32, 132, 1, 0, 0, 0, 34, 134, 1, 0, 0, 0, 36, 37, 5, 18, 0, + 0, 37, 38, 5, 1, 0, 0, 38, 39, 5, 13, 0, 0, 39, 1, 1, 0, 0, 0, 40, 41, + 5, 19, 0, 0, 41, 42, 5, 1, 0, 0, 42, 43, 5, 13, 0, 0, 43, 3, 1, 0, 0, 0, + 44, 45, 5, 20, 0, 0, 45, 46, 5, 2, 0, 0, 46, 47, 7, 0, 0, 0, 47, 5, 1, + 0, 0, 0, 48, 49, 5, 21, 0, 0, 49, 50, 5, 2, 0, 0, 50, 51, 7, 0, 0, 0, 51, + 7, 1, 0, 0, 0, 52, 53, 5, 22, 0, 0, 53, 54, 5, 1, 0, 0, 54, 55, 5, 25, + 0, 0, 55, 9, 1, 0, 0, 0, 56, 57, 5, 23, 0, 0, 57, 58, 5, 1, 0, 0, 58, 59, + 5, 11, 0, 0, 59, 11, 1, 0, 0, 0, 60, 61, 5, 23, 0, 0, 61, 62, 5, 1, 0, + 0, 62, 63, 5, 11, 0, 0, 63, 64, 5, 3, 0, 0, 64, 65, 5, 11, 0, 0, 65, 13, + 1, 0, 0, 0, 66, 67, 5, 24, 0, 0, 67, 68, 5, 1, 0, 0, 68, 69, 5, 11, 0, + 0, 69, 15, 1, 0, 0, 0, 70, 71, 5, 24, 0, 0, 71, 72, 5, 1, 0, 0, 72, 73, + 5, 11, 0, 0, 73, 74, 5, 3, 0, 0, 74, 75, 5, 11, 0, 0, 75, 17, 1, 0, 0, + 0, 76, 77, 5, 4, 0, 0, 77, 78, 5, 11, 0, 0, 78, 19, 1, 0, 0, 0, 79, 80, + 5, 14, 0, 0, 80, 81, 5, 5, 0, 0, 81, 86, 3, 32, 16, 0, 82, 83, 5, 6, 0, + 0, 83, 85, 3, 32, 16, 0, 84, 82, 1, 0, 0, 0, 85, 88, 1, 0, 0, 0, 86, 84, + 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 89, 1, 0, 0, 0, 88, 86, 1, 0, 0, 0, + 89, 90, 5, 7, 0, 0, 90, 21, 1, 0, 0, 0, 91, 92, 5, 15, 0, 0, 92, 93, 5, + 5, 0, 0, 93, 98, 3, 32, 16, 0, 94, 95, 5, 6, 0, 0, 95, 97, 3, 32, 16, 0, + 96, 94, 1, 0, 0, 0, 97, 100, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 98, 99, 1, + 0, 0, 0, 99, 101, 1, 0, 0, 0, 100, 98, 1, 0, 0, 0, 101, 102, 5, 7, 0, 0, + 102, 23, 1, 0, 0, 0, 103, 104, 5, 16, 0, 0, 104, 105, 5, 5, 0, 0, 105, + 106, 3, 32, 16, 0, 106, 107, 5, 7, 0, 0, 107, 25, 1, 0, 0, 0, 108, 109, + 5, 17, 0, 0, 109, 110, 5, 1, 0, 0, 110, 111, 7, 1, 0, 0, 111, 27, 1, 0, + 0, 0, 112, 118, 3, 0, 0, 0, 113, 118, 3, 2, 1, 0, 114, 118, 3, 4, 2, 0, + 115, 118, 3, 6, 3, 0, 116, 118, 3, 8, 4, 0, 117, 112, 1, 0, 0, 0, 117, + 113, 1, 0, 0, 0, 117, 114, 1, 0, 0, 0, 117, 115, 1, 0, 0, 0, 117, 116, + 1, 0, 0, 0, 118, 29, 1, 0, 0, 0, 119, 124, 3, 10, 5, 0, 120, 124, 3, 12, + 6, 0, 121, 124, 3, 14, 7, 0, 122, 124, 3, 16, 8, 0, 123, 119, 1, 0, 0, + 0, 123, 120, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 123, 122, 1, 0, 0, 0, 124, + 31, 1, 0, 0, 0, 125, 133, 3, 22, 11, 0, 126, 133, 3, 20, 10, 0, 127, 133, + 3, 24, 12, 0, 128, 133, 3, 28, 14, 0, 129, 133, 3, 30, 15, 0, 130, 133, + 3, 18, 9, 0, 131, 133, 3, 26, 13, 0, 132, 125, 1, 0, 0, 0, 132, 126, 1, + 0, 0, 0, 132, 127, 1, 0, 0, 0, 132, 128, 1, 0, 0, 0, 132, 129, 1, 0, 0, + 0, 132, 130, 1, 0, 0, 0, 132, 131, 1, 0, 0, 0, 133, 33, 1, 0, 0, 0, 134, + 135, 3, 32, 16, 0, 135, 136, 5, 0, 0, 1, 136, 35, 1, 0, 0, 0, 5, 86, 98, + 117, 123, 132, + } + deserializer := antlr.NewATNDeserializer(nil) + staticData.atn = deserializer.Deserialize(staticData.serializedATN) + atn := staticData.atn + staticData.decisionToDFA = make([]*antlr.DFA, len(atn.DecisionToState)) + decisionToDFA := staticData.decisionToDFA + for index, state := range atn.DecisionToState { + decisionToDFA[index] = antlr.NewDFA(state, index) + } +} + +// TrafficClassParserInit initializes any static state used to implement TrafficClassParser. By default the +// static state used to implement the parser is lazily initialized during the first call to +// NewTrafficClassParser(). You can call this function if you wish to initialize the static state ahead +// of time. +func TrafficClassParserInit() { + staticData := &TrafficClassParserStaticData + staticData.once.Do(trafficclassParserInit) +} + // NewTrafficClassParser produces a new parser instance for the optional input antlr.TokenStream. -// -// The *TrafficClassParser instance produced may be reused by calling the SetInputStream method. -// The initial parser configuration is expensive to construct, and the object is not thread-safe; -// however, if used within a Golang sync.Pool, the construction cost amortizes well and the -// objects can be used in a thread-safe manner. func NewTrafficClassParser(input antlr.TokenStream) *TrafficClassParser { + TrafficClassParserInit() this := new(TrafficClassParser) - deserializer := antlr.NewATNDeserializer(nil) - deserializedATN := deserializer.DeserializeFromUInt16(parserATN) - decisionToDFA := make([]*antlr.DFA, len(deserializedATN.DecisionToState)) - for index, ds := range deserializedATN.DecisionToState { - decisionToDFA[index] = antlr.NewDFA(ds, index) - } this.BaseParser = antlr.NewBaseParser(input) - - this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, antlr.NewPredictionContextCache()) - this.RuleNames = ruleNames - this.LiteralNames = literalNames - this.SymbolicNames = symbolicNames + staticData := &TrafficClassParserStaticData + 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 = "TrafficClass.g4" return this @@ -175,28 +197,37 @@ type IMatchSrcContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + SRC() antlr.TerminalNode + NET() antlr.TerminalNode + // IsMatchSrcContext differentiates from other interfaces. IsMatchSrcContext() } type MatchSrcContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchSrcContext() *MatchSrcContext { var p = new(MatchSrcContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchSrc return p } +func InitEmptyMatchSrcContext(p *MatchSrcContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchSrc +} + func (*MatchSrcContext) IsMatchSrcContext() {} func NewMatchSrcContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchSrcContext { var p = new(MatchSrcContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchSrc @@ -235,43 +266,45 @@ func (s *MatchSrcContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchSrc() (localctx IMatchSrcContext) { - this := p - _ = this - localctx = NewMatchSrcContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 0, TrafficClassParserRULE_matchSrc) - - 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(36) p.Match(TrafficClassParserSRC) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(37) p.Match(TrafficClassParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(38) p.Match(TrafficClassParserNET) + 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 } // IMatchDstContext is an interface to support dynamic dispatch. @@ -281,28 +314,37 @@ type IMatchDstContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + DST() antlr.TerminalNode + NET() antlr.TerminalNode + // IsMatchDstContext differentiates from other interfaces. IsMatchDstContext() } type MatchDstContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchDstContext() *MatchDstContext { var p = new(MatchDstContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchDst return p } +func InitEmptyMatchDstContext(p *MatchDstContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchDst +} + func (*MatchDstContext) IsMatchDstContext() {} func NewMatchDstContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchDstContext { var p = new(MatchDstContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchDst @@ -341,43 +383,45 @@ func (s *MatchDstContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchDst() (localctx IMatchDstContext) { - this := p - _ = this - localctx = NewMatchDstContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 2, TrafficClassParserRULE_matchDst) - - 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(40) p.Match(TrafficClassParserDST) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(41) p.Match(TrafficClassParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(42) p.Match(TrafficClassParserNET) + 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 } // IMatchDSCPContext is an interface to support dynamic dispatch. @@ -387,28 +431,38 @@ type IMatchDSCPContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + DSCP() antlr.TerminalNode + HEX_DIGITS() antlr.TerminalNode + DIGITS() antlr.TerminalNode + // IsMatchDSCPContext differentiates from other interfaces. IsMatchDSCPContext() } type MatchDSCPContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchDSCPContext() *MatchDSCPContext { var p = new(MatchDSCPContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchDSCP return p } +func InitEmptyMatchDSCPContext(p *MatchDSCPContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchDSCP +} + func (*MatchDSCPContext) IsMatchDSCPContext() {} func NewMatchDSCPContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchDSCPContext { var p = new(MatchDSCPContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchDSCP @@ -451,37 +505,26 @@ func (s *MatchDSCPContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchDSCP() (localctx IMatchDSCPContext) { - this := p - _ = this - localctx = NewMatchDSCPContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 4, TrafficClassParserRULE_matchDSCP) 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(44) p.Match(TrafficClassParserDSCP) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(45) p.Match(TrafficClassParserT__1) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(46) @@ -495,7 +538,17 @@ func (p *TrafficClassParser) MatchDSCP() (localctx IMatchDSCPContext) { } } +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 } // IMatchTOSContext is an interface to support dynamic dispatch. @@ -505,28 +558,38 @@ type IMatchTOSContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + TOS() antlr.TerminalNode + HEX_DIGITS() antlr.TerminalNode + DIGITS() antlr.TerminalNode + // IsMatchTOSContext differentiates from other interfaces. IsMatchTOSContext() } type MatchTOSContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchTOSContext() *MatchTOSContext { var p = new(MatchTOSContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchTOS return p } +func InitEmptyMatchTOSContext(p *MatchTOSContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchTOS +} + func (*MatchTOSContext) IsMatchTOSContext() {} func NewMatchTOSContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchTOSContext { var p = new(MatchTOSContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchTOS @@ -569,37 +632,26 @@ func (s *MatchTOSContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchTOS() (localctx IMatchTOSContext) { - this := p - _ = this - localctx = NewMatchTOSContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 6, TrafficClassParserRULE_matchTOS) 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(48) p.Match(TrafficClassParserTOS) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(49) p.Match(TrafficClassParserT__1) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(50) @@ -613,7 +665,17 @@ func (p *TrafficClassParser) MatchTOS() (localctx IMatchTOSContext) { } } +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 } // IMatchProtocolContext is an interface to support dynamic dispatch. @@ -623,28 +685,37 @@ type IMatchProtocolContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + PROTOCOL() antlr.TerminalNode + STRING() antlr.TerminalNode + // IsMatchProtocolContext differentiates from other interfaces. IsMatchProtocolContext() } type MatchProtocolContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchProtocolContext() *MatchProtocolContext { var p = new(MatchProtocolContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchProtocol return p } +func InitEmptyMatchProtocolContext(p *MatchProtocolContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchProtocol +} + func (*MatchProtocolContext) IsMatchProtocolContext() {} func NewMatchProtocolContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchProtocolContext { var p = new(MatchProtocolContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchProtocol @@ -683,43 +754,45 @@ func (s *MatchProtocolContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchProtocol() (localctx IMatchProtocolContext) { - this := p - _ = this - localctx = NewMatchProtocolContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 8, TrafficClassParserRULE_matchProtocol) - - 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(52) p.Match(TrafficClassParserPROTOCOL) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(53) p.Match(TrafficClassParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(54) p.Match(TrafficClassParserSTRING) + 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 } // IMatchSrcPortContext is an interface to support dynamic dispatch. @@ -729,28 +802,37 @@ type IMatchSrcPortContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + SRCPORT() antlr.TerminalNode + DIGITS() antlr.TerminalNode + // IsMatchSrcPortContext differentiates from other interfaces. IsMatchSrcPortContext() } type MatchSrcPortContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchSrcPortContext() *MatchSrcPortContext { var p = new(MatchSrcPortContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchSrcPort return p } +func InitEmptyMatchSrcPortContext(p *MatchSrcPortContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchSrcPort +} + func (*MatchSrcPortContext) IsMatchSrcPortContext() {} func NewMatchSrcPortContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchSrcPortContext { var p = new(MatchSrcPortContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchSrcPort @@ -789,43 +871,45 @@ func (s *MatchSrcPortContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchSrcPort() (localctx IMatchSrcPortContext) { - this := p - _ = this - localctx = NewMatchSrcPortContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 10, TrafficClassParserRULE_matchSrcPort) - - 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(TrafficClassParserSRCPORT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(57) p.Match(TrafficClassParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(58) p.Match(TrafficClassParserDIGITS) + 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 } // IMatchSrcPortRangeContext is an interface to support dynamic dispatch. @@ -835,28 +919,38 @@ type IMatchSrcPortRangeContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + SRCPORT() antlr.TerminalNode + AllDIGITS() []antlr.TerminalNode + DIGITS(i int) antlr.TerminalNode + // IsMatchSrcPortRangeContext differentiates from other interfaces. IsMatchSrcPortRangeContext() } type MatchSrcPortRangeContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchSrcPortRangeContext() *MatchSrcPortRangeContext { var p = new(MatchSrcPortRangeContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchSrcPortRange return p } +func InitEmptyMatchSrcPortRangeContext(p *MatchSrcPortRangeContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchSrcPortRange +} + func (*MatchSrcPortRangeContext) IsMatchSrcPortRangeContext() {} func NewMatchSrcPortRangeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchSrcPortRangeContext { var p = new(MatchSrcPortRangeContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchSrcPortRange @@ -899,51 +993,61 @@ func (s *MatchSrcPortRangeContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchSrcPortRange() (localctx IMatchSrcPortRangeContext) { - this := p - _ = this - localctx = NewMatchSrcPortRangeContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 12, TrafficClassParserRULE_matchSrcPortRange) - - 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(60) p.Match(TrafficClassParserSRCPORT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(61) p.Match(TrafficClassParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(62) p.Match(TrafficClassParserDIGITS) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(63) p.Match(TrafficClassParserT__2) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(64) p.Match(TrafficClassParserDIGITS) + 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 } // IMatchDstPortContext is an interface to support dynamic dispatch. @@ -953,28 +1057,37 @@ type IMatchDstPortContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + DSTPORT() antlr.TerminalNode + DIGITS() antlr.TerminalNode + // IsMatchDstPortContext differentiates from other interfaces. IsMatchDstPortContext() } type MatchDstPortContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchDstPortContext() *MatchDstPortContext { var p = new(MatchDstPortContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchDstPort return p } +func InitEmptyMatchDstPortContext(p *MatchDstPortContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchDstPort +} + func (*MatchDstPortContext) IsMatchDstPortContext() {} func NewMatchDstPortContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchDstPortContext { var p = new(MatchDstPortContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchDstPort @@ -1013,43 +1126,45 @@ func (s *MatchDstPortContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchDstPort() (localctx IMatchDstPortContext) { - this := p - _ = this - localctx = NewMatchDstPortContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 14, TrafficClassParserRULE_matchDstPort) - - 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(66) p.Match(TrafficClassParserDSTPORT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(67) p.Match(TrafficClassParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(68) p.Match(TrafficClassParserDIGITS) + 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 } // IMatchDstPortRangeContext is an interface to support dynamic dispatch. @@ -1059,28 +1174,38 @@ type IMatchDstPortRangeContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + DSTPORT() antlr.TerminalNode + AllDIGITS() []antlr.TerminalNode + DIGITS(i int) antlr.TerminalNode + // IsMatchDstPortRangeContext differentiates from other interfaces. IsMatchDstPortRangeContext() } type MatchDstPortRangeContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyMatchDstPortRangeContext() *MatchDstPortRangeContext { var p = new(MatchDstPortRangeContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_matchDstPortRange return p } +func InitEmptyMatchDstPortRangeContext(p *MatchDstPortRangeContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_matchDstPortRange +} + func (*MatchDstPortRangeContext) IsMatchDstPortRangeContext() {} func NewMatchDstPortRangeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchDstPortRangeContext { var p = new(MatchDstPortRangeContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_matchDstPortRange @@ -1123,51 +1248,61 @@ func (s *MatchDstPortRangeContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) MatchDstPortRange() (localctx IMatchDstPortRangeContext) { - this := p - _ = this - localctx = NewMatchDstPortRangeContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 16, TrafficClassParserRULE_matchDstPortRange) - - 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(70) p.Match(TrafficClassParserDSTPORT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(71) p.Match(TrafficClassParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(72) p.Match(TrafficClassParserDIGITS) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(73) p.Match(TrafficClassParserT__2) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(74) p.Match(TrafficClassParserDIGITS) + 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 } // ICondClsContext is an interface to support dynamic dispatch. @@ -1177,28 +1312,36 @@ type ICondClsContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + DIGITS() antlr.TerminalNode + // IsCondClsContext differentiates from other interfaces. IsCondClsContext() } type CondClsContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyCondClsContext() *CondClsContext { var p = new(CondClsContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_condCls return p } +func InitEmptyCondClsContext(p *CondClsContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_condCls +} + func (*CondClsContext) IsCondClsContext() {} func NewCondClsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CondClsContext { var p = new(CondClsContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_condCls @@ -1233,39 +1376,37 @@ func (s *CondClsContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) CondCls() (localctx ICondClsContext) { - this := p - _ = this - localctx = NewCondClsContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 18, TrafficClassParserRULE_condCls) - - 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(76) p.Match(TrafficClassParserT__3) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(77) p.Match(TrafficClassParserDIGITS) + 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 } // ICondAnyContext is an interface to support dynamic dispatch. @@ -1275,28 +1416,38 @@ type ICondAnyContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + ANY() antlr.TerminalNode + AllCond() []ICondContext + Cond(i int) ICondContext + // IsCondAnyContext differentiates from other interfaces. IsCondAnyContext() } type CondAnyContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyCondAnyContext() *CondAnyContext { var p = new(CondAnyContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_condAny return p } +func InitEmptyCondAnyContext(p *CondAnyContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_condAny +} + func (*CondAnyContext) IsCondAnyContext() {} func NewCondAnyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CondAnyContext { var p = new(CondAnyContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_condAny @@ -1311,12 +1462,20 @@ func (s *CondAnyContext) ANY() antlr.TerminalNode { } func (s *CondAnyContext) AllCond() []ICondContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ICondContext)(nil)).Elem()) - var tst = make([]ICondContext, len(ts)) + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(ICondContext); ok { + len++ + } + } - for i, t := range ts { - if t != nil { + tst := make([]ICondContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(ICondContext); ok { tst[i] = t.(ICondContext) + i++ } } @@ -1324,7 +1483,17 @@ func (s *CondAnyContext) AllCond() []ICondContext { } func (s *CondAnyContext) Cond(i int) ICondContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondContext)(nil)).Elem(), i) + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } if t == nil { return nil @@ -1354,37 +1523,26 @@ func (s *CondAnyContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) CondAny() (localctx ICondAnyContext) { - this := p - _ = this - localctx = NewCondAnyContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 20, TrafficClassParserRULE_condAny) 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(79) p.Match(TrafficClassParserANY) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(80) p.Match(TrafficClassParserT__4) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(81) @@ -1392,12 +1550,19 @@ func (p *TrafficClassParser) CondAny() (localctx ICondAnyContext) { } p.SetState(86) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) for _la == TrafficClassParserT__5 { { p.SetState(82) p.Match(TrafficClassParserT__5) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(83) @@ -1406,14 +1571,31 @@ func (p *TrafficClassParser) CondAny() (localctx ICondAnyContext) { p.SetState(88) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) } { p.SetState(89) p.Match(TrafficClassParserT__6) + 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 } // ICondAllContext is an interface to support dynamic dispatch. @@ -1423,28 +1605,38 @@ type ICondAllContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + ALL() antlr.TerminalNode + AllCond() []ICondContext + Cond(i int) ICondContext + // IsCondAllContext differentiates from other interfaces. IsCondAllContext() } type CondAllContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyCondAllContext() *CondAllContext { var p = new(CondAllContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_condAll return p } +func InitEmptyCondAllContext(p *CondAllContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_condAll +} + func (*CondAllContext) IsCondAllContext() {} func NewCondAllContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CondAllContext { var p = new(CondAllContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_condAll @@ -1459,12 +1651,20 @@ func (s *CondAllContext) ALL() antlr.TerminalNode { } func (s *CondAllContext) AllCond() []ICondContext { - var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ICondContext)(nil)).Elem()) - var tst = make([]ICondContext, len(ts)) + children := s.GetChildren() + len := 0 + for _, ctx := range children { + if _, ok := ctx.(ICondContext); ok { + len++ + } + } - for i, t := range ts { - if t != nil { + tst := make([]ICondContext, len) + i := 0 + for _, ctx := range children { + if t, ok := ctx.(ICondContext); ok { tst[i] = t.(ICondContext) + i++ } } @@ -1472,7 +1672,17 @@ func (s *CondAllContext) AllCond() []ICondContext { } func (s *CondAllContext) Cond(i int) ICondContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondContext)(nil)).Elem(), i) + var t antlr.RuleContext + j := 0 + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondContext); ok { + if j == i { + t = ctx.(antlr.RuleContext) + break + } + j++ + } + } if t == nil { return nil @@ -1502,37 +1712,26 @@ func (s *CondAllContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) CondAll() (localctx ICondAllContext) { - this := p - _ = this - localctx = NewCondAllContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 22, TrafficClassParserRULE_condAll) 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(91) p.Match(TrafficClassParserALL) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(92) p.Match(TrafficClassParserT__4) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(93) @@ -1540,12 +1739,19 @@ func (p *TrafficClassParser) CondAll() (localctx ICondAllContext) { } p.SetState(98) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) for _la == TrafficClassParserT__5 { { p.SetState(94) p.Match(TrafficClassParserT__5) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(95) @@ -1554,14 +1760,31 @@ func (p *TrafficClassParser) CondAll() (localctx ICondAllContext) { p.SetState(100) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } _la = p.GetTokenStream().LA(1) } { p.SetState(101) p.Match(TrafficClassParserT__6) + 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 } // ICondNotContext is an interface to support dynamic dispatch. @@ -1571,28 +1794,37 @@ type ICondNotContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + NOT() antlr.TerminalNode + Cond() ICondContext + // IsCondNotContext differentiates from other interfaces. IsCondNotContext() } type CondNotContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyCondNotContext() *CondNotContext { var p = new(CondNotContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_condNot return p } +func InitEmptyCondNotContext(p *CondNotContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_condNot +} + func (*CondNotContext) IsCondNotContext() {} func NewCondNotContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CondNotContext { var p = new(CondNotContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_condNot @@ -1607,7 +1839,13 @@ func (s *CondNotContext) NOT() antlr.TerminalNode { } func (s *CondNotContext) Cond() ICondContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1637,36 +1875,24 @@ func (s *CondNotContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) CondNot() (localctx ICondNotContext) { - this := p - _ = this - localctx = NewCondNotContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 24, TrafficClassParserRULE_condNot) - - 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(103) p.Match(TrafficClassParserNOT) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(104) p.Match(TrafficClassParserT__4) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(105) @@ -1675,9 +1901,23 @@ func (p *TrafficClassParser) CondNot() (localctx ICondNotContext) { { p.SetState(106) p.Match(TrafficClassParserT__6) + 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 } // ICondBoolContext is an interface to support dynamic dispatch. @@ -1687,28 +1927,36 @@ type ICondBoolContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + BOOL() antlr.TerminalNode + // IsCondBoolContext differentiates from other interfaces. IsCondBoolContext() } type CondBoolContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyCondBoolContext() *CondBoolContext { var p = new(CondBoolContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_condBool return p } +func InitEmptyCondBoolContext(p *CondBoolContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_condBool +} + func (*CondBoolContext) IsCondBoolContext() {} func NewCondBoolContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CondBoolContext { var p = new(CondBoolContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_condBool @@ -1743,37 +1991,26 @@ func (s *CondBoolContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) CondBool() (localctx ICondBoolContext) { - this := p - _ = this - localctx = NewCondBoolContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 26, TrafficClassParserRULE_condBool) 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(108) p.Match(TrafficClassParserBOOL) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(109) p.Match(TrafficClassParserT__0) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } } { p.SetState(110) @@ -1787,7 +2024,17 @@ func (p *TrafficClassParser) CondBool() (localctx ICondBoolContext) { } } +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 } // ICondIPv4Context is an interface to support dynamic dispatch. @@ -1797,28 +2044,40 @@ type ICondIPv4Context interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + MatchSrc() IMatchSrcContext + MatchDst() IMatchDstContext + MatchDSCP() IMatchDSCPContext + MatchTOS() IMatchTOSContext + MatchProtocol() IMatchProtocolContext + // IsCondIPv4Context differentiates from other interfaces. IsCondIPv4Context() } type CondIPv4Context struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyCondIPv4Context() *CondIPv4Context { var p = new(CondIPv4Context) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_condIPv4 return p } +func InitEmptyCondIPv4Context(p *CondIPv4Context) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_condIPv4 +} + func (*CondIPv4Context) IsCondIPv4Context() {} func NewCondIPv4Context(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CondIPv4Context { var p = new(CondIPv4Context) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_condIPv4 @@ -1829,7 +2088,13 @@ func NewCondIPv4Context(parser antlr.Parser, parent antlr.ParserRuleContext, inv func (s *CondIPv4Context) GetParser() antlr.Parser { return s.parser } func (s *CondIPv4Context) MatchSrc() IMatchSrcContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchSrcContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchSrcContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1839,7 +2104,13 @@ func (s *CondIPv4Context) MatchSrc() IMatchSrcContext { } func (s *CondIPv4Context) MatchDst() IMatchDstContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchDstContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchDstContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1849,7 +2120,13 @@ func (s *CondIPv4Context) MatchDst() IMatchDstContext { } func (s *CondIPv4Context) MatchDSCP() IMatchDSCPContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchDSCPContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchDSCPContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1859,7 +2136,13 @@ func (s *CondIPv4Context) MatchDSCP() IMatchDSCPContext { } func (s *CondIPv4Context) MatchTOS() IMatchTOSContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchTOSContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchTOSContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1869,7 +2152,13 @@ func (s *CondIPv4Context) MatchTOS() IMatchTOSContext { } func (s *CondIPv4Context) MatchProtocol() IMatchProtocolContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchProtocolContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchProtocolContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -1899,30 +2188,13 @@ func (s *CondIPv4Context) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) CondIPv4() (localctx ICondIPv4Context) { - this := p - _ = this - localctx = NewCondIPv4Context(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 28, TrafficClassParserRULE_condIPv4) - - 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(117) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case TrafficClassParserSRC: @@ -1961,10 +2233,21 @@ func (p *TrafficClassParser) CondIPv4() (localctx ICondIPv4Context) { } 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 } // ICondPortContext is an interface to support dynamic dispatch. @@ -1974,28 +2257,39 @@ type ICondPortContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + MatchSrcPort() IMatchSrcPortContext + MatchSrcPortRange() IMatchSrcPortRangeContext + MatchDstPort() IMatchDstPortContext + MatchDstPortRange() IMatchDstPortRangeContext + // IsCondPortContext differentiates from other interfaces. IsCondPortContext() } type CondPortContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyCondPortContext() *CondPortContext { var p = new(CondPortContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_condPort return p } +func InitEmptyCondPortContext(p *CondPortContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_condPort +} + func (*CondPortContext) IsCondPortContext() {} func NewCondPortContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CondPortContext { var p = new(CondPortContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_condPort @@ -2006,7 +2300,13 @@ func NewCondPortContext(parser antlr.Parser, parent antlr.ParserRuleContext, inv func (s *CondPortContext) GetParser() antlr.Parser { return s.parser } func (s *CondPortContext) MatchSrcPort() IMatchSrcPortContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchSrcPortContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchSrcPortContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2016,7 +2316,13 @@ func (s *CondPortContext) MatchSrcPort() IMatchSrcPortContext { } func (s *CondPortContext) MatchSrcPortRange() IMatchSrcPortRangeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchSrcPortRangeContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchSrcPortRangeContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2026,7 +2332,13 @@ func (s *CondPortContext) MatchSrcPortRange() IMatchSrcPortRangeContext { } func (s *CondPortContext) MatchDstPort() IMatchDstPortContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchDstPortContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchDstPortContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2036,7 +2348,13 @@ func (s *CondPortContext) MatchDstPort() IMatchDstPortContext { } func (s *CondPortContext) MatchDstPortRange() IMatchDstPortRangeContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*IMatchDstPortRangeContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(IMatchDstPortRangeContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2066,31 +2384,15 @@ func (s *CondPortContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) CondPort() (localctx ICondPortContext) { - this := p - _ = this - localctx = NewCondPortContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 30, TrafficClassParserRULE_condPort) - - 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) - switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 3, p.GetParserRuleContext()) { + if p.HasError() { + goto errorExit + } + + switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) { case 1: p.EnterOuterAlt(localctx, 1) { @@ -2119,9 +2421,21 @@ func (p *TrafficClassParser) CondPort() (localctx ICondPortContext) { p.MatchDstPortRange() } + case antlr.ATNInvalidAltNumber: + 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 } // ICondContext is an interface to support dynamic dispatch. @@ -2131,28 +2445,42 @@ type ICondContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + CondAll() ICondAllContext + CondAny() ICondAnyContext + CondNot() ICondNotContext + CondIPv4() ICondIPv4Context + CondPort() ICondPortContext + CondCls() ICondClsContext + CondBool() ICondBoolContext + // IsCondContext differentiates from other interfaces. IsCondContext() } type CondContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyCondContext() *CondContext { var p = new(CondContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_cond return p } +func InitEmptyCondContext(p *CondContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_cond +} + func (*CondContext) IsCondContext() {} func NewCondContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CondContext { var p = new(CondContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_cond @@ -2163,7 +2491,13 @@ func NewCondContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokin func (s *CondContext) GetParser() antlr.Parser { return s.parser } func (s *CondContext) CondAll() ICondAllContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondAllContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondAllContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2173,7 +2507,13 @@ func (s *CondContext) CondAll() ICondAllContext { } func (s *CondContext) CondAny() ICondAnyContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondAnyContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondAnyContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2183,7 +2523,13 @@ func (s *CondContext) CondAny() ICondAnyContext { } func (s *CondContext) CondNot() ICondNotContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondNotContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondNotContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2193,7 +2539,13 @@ func (s *CondContext) CondNot() ICondNotContext { } func (s *CondContext) CondIPv4() ICondIPv4Context { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondIPv4Context)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondIPv4Context); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2203,7 +2555,13 @@ func (s *CondContext) CondIPv4() ICondIPv4Context { } func (s *CondContext) CondPort() ICondPortContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondPortContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondPortContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2213,7 +2571,13 @@ func (s *CondContext) CondPort() ICondPortContext { } func (s *CondContext) CondCls() ICondClsContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondClsContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondClsContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2223,7 +2587,13 @@ func (s *CondContext) CondCls() ICondClsContext { } func (s *CondContext) CondBool() ICondBoolContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondBoolContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondBoolContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2253,30 +2623,13 @@ func (s *CondContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) Cond() (localctx ICondContext) { - this := p - _ = this - localctx = NewCondContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 32, TrafficClassParserRULE_cond) - - 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(132) p.GetErrorHandler().Sync(p) + if p.HasError() { + goto errorExit + } switch p.GetTokenStream().LA(1) { case TrafficClassParserALL: @@ -2329,10 +2682,21 @@ func (p *TrafficClassParser) Cond() (localctx ICondContext) { } 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 } // ITrafficClassContext is an interface to support dynamic dispatch. @@ -2342,28 +2706,37 @@ type ITrafficClassContext interface { // GetParser returns the parser. GetParser() antlr.Parser + // Getter signatures + Cond() ICondContext + EOF() antlr.TerminalNode + // IsTrafficClassContext differentiates from other interfaces. IsTrafficClassContext() } type TrafficClassContext struct { - *antlr.BaseParserRuleContext + antlr.BaseParserRuleContext parser antlr.Parser } func NewEmptyTrafficClassContext() *TrafficClassContext { var p = new(TrafficClassContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) p.RuleIndex = TrafficClassParserRULE_trafficClass return p } +func InitEmptyTrafficClassContext(p *TrafficClassContext) { + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) + p.RuleIndex = TrafficClassParserRULE_trafficClass +} + func (*TrafficClassContext) IsTrafficClassContext() {} func NewTrafficClassContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TrafficClassContext { var p = new(TrafficClassContext) - p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState) + antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) p.parser = parser p.RuleIndex = TrafficClassParserRULE_trafficClass @@ -2374,7 +2747,13 @@ func NewTrafficClassContext(parser antlr.Parser, parent antlr.ParserRuleContext, func (s *TrafficClassContext) GetParser() antlr.Parser { return s.parser } func (s *TrafficClassContext) Cond() ICondContext { - var t = s.GetTypedRuleContext(reflect.TypeOf((*ICondContext)(nil)).Elem(), 0) + var t antlr.RuleContext + for _, ctx := range s.GetChildren() { + if _, ok := ctx.(ICondContext); ok { + t = ctx.(antlr.RuleContext) + break + } + } if t == nil { return nil @@ -2408,28 +2787,8 @@ func (s *TrafficClassContext) ExitRule(listener antlr.ParseTreeListener) { } func (p *TrafficClassParser) TrafficClass() (localctx ITrafficClassContext) { - this := p - _ = this - localctx = NewTrafficClassContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 34, TrafficClassParserRULE_trafficClass) - - 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(134) @@ -2438,7 +2797,21 @@ func (p *TrafficClassParser) TrafficClass() (localctx ITrafficClassContext) { { p.SetState(135) p.Match(TrafficClassParserEOF) + 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 } diff --git a/gateway/pktcls/BUILD.bazel b/gateway/pktcls/BUILD.bazel index 4e47fb9826..9de0b647e9 100644 --- a/gateway/pktcls/BUILD.bazel +++ b/gateway/pktcls/BUILD.bazel @@ -19,7 +19,7 @@ go_library( "//pkg/log:go_default_library", "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", - "@com_github_antlr_antlr4_runtime_go_antlr//:go_default_library", + "@com_github_antlr4_go_antlr_v4//:go_default_library", "@com_github_google_gopacket//:go_default_library", "@com_github_google_gopacket//layers:go_default_library", ], diff --git a/gateway/pktcls/error_listener.go b/gateway/pktcls/error_listener.go index 3ffeb87af7..35b8138d98 100644 --- a/gateway/pktcls/error_listener.go +++ b/gateway/pktcls/error_listener.go @@ -17,7 +17,7 @@ package pktcls import ( "fmt" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr4-go/antlr/v4" "github.com/scionproto/scion/pkg/log" ) diff --git a/gateway/pktcls/parse.go b/gateway/pktcls/parse.go index d617cadc8a..bc1aa9cad3 100644 --- a/gateway/pktcls/parse.go +++ b/gateway/pktcls/parse.go @@ -19,7 +19,7 @@ import ( "strconv" "strings" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr4-go/antlr/v4" "github.com/google/gopacket/layers" "github.com/scionproto/scion/antlr/traffic_class" diff --git a/go.mod b/go.mod index b11d4d5b6d..dd51b009ac 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,10 @@ module github.com/scionproto/scion +go 1.22.7 + require ( connectrpc.com/connect v1.16.2 - github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220209173558-ad29539cd2e9 + github.com/antlr4-go/antlr/v4 v4.13.1 github.com/bazelbuild/rules_go v0.47.1 github.com/buildkite/go-buildkite/v2 v2.9.0 github.com/dchest/cmac v1.0.0 @@ -128,5 +130,3 @@ require ( modernc.org/strutil v1.2.0 // indirect modernc.org/token v1.1.0 // indirect ) - -go 1.22.7 diff --git a/go.sum b/go.sum index f0f6ba9db9..65e582a18f 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMz github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220209173558-ad29539cd2e9 h1:zvkJv+9Pxm1nnEMcKnShREt4qtduHKz4iw4AB4ul0Ao= -github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220209173558-ad29539cd2e9/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= +github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= +github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/bazelbuild/rules_go v0.47.1 h1:9s9FA2l8IAxCbwV97E1WLu5ai21muLNrjZRV0+agTRs= diff --git a/go_deps.bzl b/go_deps.bzl index fa9fb3e625..1f8449a4e0 100644 --- a/go_deps.bzl +++ b/go_deps.bzl @@ -56,10 +56,10 @@ def go_deps(): version = "v1.0.5", ) go_repository( - name = "com_github_antlr_antlr4_runtime_go_antlr", - importpath = "github.com/antlr/antlr4/runtime/Go/antlr", - sum = "h1:zvkJv+9Pxm1nnEMcKnShREt4qtduHKz4iw4AB4ul0Ao=", - version = "v0.0.0-20220209173558-ad29539cd2e9", + name = "com_github_antlr4_go_antlr_v4", + importpath = "github.com/antlr4-go/antlr/v4", + sum = "h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=", + version = "v4.13.1", ) go_repository( name = "com_github_apapsch_go_jsonmerge_v2", diff --git a/licenses/data/com_github_antlr4_go_antlr_v4/LICENSE b/licenses/data/com_github_antlr4_go_antlr_v4/LICENSE new file mode 100644 index 0000000000..a22292eb5a --- /dev/null +++ b/licenses/data/com_github_antlr4_go_antlr_v4/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012-2023 The ANTLR Project. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither name of copyright holders nor the names of its contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/licenses/data/com_github_antlr_antlr4_runtime_go_antlr/LICENSE b/licenses/data/com_github_antlr_antlr4_runtime_go_antlr/LICENSE deleted file mode 100644 index 52cf18e425..0000000000 --- a/licenses/data/com_github_antlr_antlr4_runtime_go_antlr/LICENSE +++ /dev/null @@ -1,26 +0,0 @@ -Copyright 2021 The ANTLR Project - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/nogo.json b/nogo.json index d4a69c7f3d..c5e2f2dc1b 100644 --- a/nogo.json +++ b/nogo.json @@ -67,8 +67,8 @@ }, "unreachable": { "exclude_files": { + "antlr": "", "gazelle/pathtools/path.go": "", - "/com_github_antlr_antlr4_runtime_go_antlr/": "", "/com_github_uber_jaeger_client_go": "", "/com_github_marten_seemann_qtls/": "", "/org_golang_google_protobuf/": "", diff --git a/private/path/pathpol/BUILD.bazel b/private/path/pathpol/BUILD.bazel index 116d06a2c9..a365e42573 100644 --- a/private/path/pathpol/BUILD.bazel +++ b/private/path/pathpol/BUILD.bazel @@ -19,7 +19,7 @@ go_library( "//pkg/private/serrors:go_default_library", "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", - "@com_github_antlr_antlr4_runtime_go_antlr//:go_default_library", + "@com_github_antlr4_go_antlr_v4//:go_default_library", ], ) diff --git a/private/path/pathpol/sequence.go b/private/path/pathpol/sequence.go index a2bfc81ed0..29f7aa2da3 100644 --- a/private/path/pathpol/sequence.go +++ b/private/path/pathpol/sequence.go @@ -23,7 +23,7 @@ import ( "regexp" "strings" - "github.com/antlr/antlr4/runtime/Go/antlr" + "github.com/antlr4-go/antlr/v4" "github.com/scionproto/scion/antlr/sequence" "github.com/scionproto/scion/pkg/addr" @@ -61,7 +61,7 @@ func NewSequence(s string) (*Sequence, error) { parser.RemoveErrorListeners() parser.AddErrorListener(errListener) listener := sequenceListener{} - antlr.ParseTreeWalkerDefault.Walk(&listener, parser.Start()) + antlr.ParseTreeWalkerDefault.Walk(&listener, parser.Start_()) if errListener.msg != "" { return nil, serrors.New("Failed to parse a sequence", "sequence", s, "msg", errListener.msg)