diff --git a/handlers/aliases/ast/listener.go b/handlers/aliases/ast/listener.go index 0ccd6b9..3a5c112 100644 --- a/handlers/aliases/ast/listener.go +++ b/handlers/aliases/ast/listener.go @@ -2,7 +2,7 @@ package ast import ( "config-lsp/common" - "config-lsp/handlers/aliases/parser" + "config-lsp/handlers/aliases/ast/parser" "github.com/antlr4-go/antlr/v4" ) diff --git a/handlers/aliases/ast/parser.go b/handlers/aliases/ast/parser.go index e0384c9..44bcdec 100644 --- a/handlers/aliases/ast/parser.go +++ b/handlers/aliases/ast/parser.go @@ -2,7 +2,7 @@ package ast import ( "config-lsp/common" - "config-lsp/handlers/aliases/parser" + "config-lsp/handlers/aliases/ast/parser" "config-lsp/utils" "regexp" diff --git a/handlers/aliases/parser/Aliases.interp b/handlers/aliases/ast/parser/Aliases.interp similarity index 100% rename from handlers/aliases/parser/Aliases.interp rename to handlers/aliases/ast/parser/Aliases.interp diff --git a/handlers/aliases/parser/Aliases.tokens b/handlers/aliases/ast/parser/Aliases.tokens similarity index 100% rename from handlers/aliases/parser/Aliases.tokens rename to handlers/aliases/ast/parser/Aliases.tokens diff --git a/handlers/aliases/parser/AliasesLexer.interp b/handlers/aliases/ast/parser/AliasesLexer.interp similarity index 100% rename from handlers/aliases/parser/AliasesLexer.interp rename to handlers/aliases/ast/parser/AliasesLexer.interp diff --git a/handlers/aliases/parser/AliasesLexer.tokens b/handlers/aliases/ast/parser/AliasesLexer.tokens similarity index 100% rename from handlers/aliases/parser/AliasesLexer.tokens rename to handlers/aliases/ast/parser/AliasesLexer.tokens diff --git a/handlers/aliases/parser/aliases_base_listener.go b/handlers/aliases/ast/parser/aliases_base_listener.go similarity index 100% rename from handlers/aliases/parser/aliases_base_listener.go rename to handlers/aliases/ast/parser/aliases_base_listener.go diff --git a/handlers/aliases/parser/aliases_lexer.go b/handlers/aliases/ast/parser/aliases_lexer.go similarity index 100% rename from handlers/aliases/parser/aliases_lexer.go rename to handlers/aliases/ast/parser/aliases_lexer.go diff --git a/handlers/aliases/parser/aliases_listener.go b/handlers/aliases/ast/parser/aliases_listener.go similarity index 100% rename from handlers/aliases/parser/aliases_listener.go rename to handlers/aliases/ast/parser/aliases_listener.go diff --git a/handlers/aliases/parser/aliases_parser.go b/handlers/aliases/ast/parser/aliases_parser.go similarity index 100% rename from handlers/aliases/parser/aliases_parser.go rename to handlers/aliases/ast/parser/aliases_parser.go diff --git a/handlers/sshd_config/analyzer/match.go b/handlers/sshd_config/analyzer/match.go index 9a2bb63..b508e86 100644 --- a/handlers/sshd_config/analyzer/match.go +++ b/handlers/sshd_config/analyzer/match.go @@ -54,11 +54,11 @@ func analyzeMatchBlocks( } func analyzeMatchValueNegation( - value *matchparser.matchparser, + value *matchparser.MatchValue, ) []common.LSPError { errs := make([]common.LSPError, 0) - positionsAsList := utils.AllIndexes(value.Value.Value, "!") + positionsAsList := utils.AllIndexes(value.Value.Raw, "!") positions := utils.SliceToMap(positionsAsList, struct{}{}) delete(positions, 0) diff --git a/handlers/sshd_config/ast/parser_test.go b/handlers/sshd_config/ast/parser_test.go index ca2ceb8..28081ff 100644 --- a/handlers/sshd_config/ast/parser_test.go +++ b/handlers/sshd_config/ast/parser_test.go @@ -59,7 +59,7 @@ PasswordAuthentication yes } } -func TestMatchSimpleBlock( +func TestSimpleMatchBlock( t *testing.T, ) { input := utils.Dedent(` @@ -92,6 +92,10 @@ Match Address 192.168.0.1 t.Errorf("Expected second entry to be 'Match Address 192.168.0.1', but got: %v", secondEntry.MatchOption.Value) } + if !(secondEntry.Options.Size() == 1) { + t.Errorf("Expected 1 option in match block, but got: %v", secondEntry.Options) + } + if !(secondEntry.Start.Line == 2 && secondEntry.Start.Character == 0 && secondEntry.End.Line == 3 && secondEntry.End.Character == 27) { t.Errorf("Expected second entry's location to be 2:0-3:25, but got: %v", secondEntry.LocationRange) } @@ -201,6 +205,10 @@ Match Address 192.168.0.2 t.Errorf("Expected 2 options in second match block, but got: %v", secondEntry.Options) } + if !(secondEntry.Options.Size() == 2) { + t.Errorf("Expected 2 options in second match block, but got: %v", secondEntry.Options) + } + rawThirdEntry, _ := secondEntry.Options.Get(uint32(3)) thirdEntry := rawThirdEntry.(*SSHDOption) if !(thirdEntry.Key.Value.Value == "PasswordAuthentication" && thirdEntry.OptionValue.Value.Value == "yes" && thirdEntry.LocationRange.Start.Line == 3) { diff --git a/handlers/sshd_config/ast/sshd_config.go b/handlers/sshd_config/ast/sshd_config.go index 28fbb75..73513e2 100644 --- a/handlers/sshd_config/ast/sshd_config.go +++ b/handlers/sshd_config/ast/sshd_config.go @@ -47,7 +47,7 @@ type SSHDOption struct { type SSHDMatchBlock struct { common.LocationRange MatchOption *SSHDOption - MatchValue *matchparser.matchparser + MatchValue *matchparser.Match // [uint32]*SSHDOption -> line number -> *SSHDOption Options *treemap.Map diff --git a/handlers/sshd_config/handlers/completions_match.go b/handlers/sshd_config/handlers/completions_match.go index 9d225a1..a5dfa73 100644 --- a/handlers/sshd_config/handlers/completions_match.go +++ b/handlers/sshd_config/handlers/completions_match.go @@ -11,7 +11,7 @@ import ( func getMatchCompletions( d *sshdconfig.SSHDDocument, cursor common.CursorPosition, - match *matchparser.matchparser, + match *matchparser.Match, ) ([]protocol.CompletionItem, error) { if match == nil || len(match.Entries) == 0 { completions := getMatchCriteriaCompletions() diff --git a/handlers/sshd_config/handlers/formatting_nodes.go b/handlers/sshd_config/handlers/formatting_nodes.go index 1f521f7..b94b27d 100644 --- a/handlers/sshd_config/handlers/formatting_nodes.go +++ b/handlers/sshd_config/handlers/formatting_nodes.go @@ -80,7 +80,7 @@ func formatSSHDMatchBlock( } func formatMatchToString( - match *matchparser.matchparser, + match *matchparser.Match, ) string { entriesAsStrings := utils.Map( match.Entries, diff --git a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/Match.interp b/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/Match.interp deleted file mode 100644 index 491bdd3..0000000 --- a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/Match.interp +++ /dev/null @@ -1,23 +0,0 @@ -token literal names: -null -',' -null -null - -token symbolic names: -null -COMMA -STRING -WHITESPACE - -rule names: -root -matchEntry -separator -criteria -values -value - - -atn: -[4, 1, 3, 52, 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, 3, 0, 14, 8, 0, 1, 0, 1, 0, 3, 0, 18, 8, 0, 5, 0, 20, 8, 0, 10, 0, 12, 0, 23, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 29, 8, 1, 1, 1, 3, 1, 32, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 3, 4, 39, 8, 4, 1, 4, 1, 4, 3, 4, 43, 8, 4, 5, 4, 45, 8, 4, 10, 4, 12, 4, 48, 9, 4, 1, 5, 1, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 0, 53, 0, 13, 1, 0, 0, 0, 2, 26, 1, 0, 0, 0, 4, 33, 1, 0, 0, 0, 6, 35, 1, 0, 0, 0, 8, 38, 1, 0, 0, 0, 10, 49, 1, 0, 0, 0, 12, 14, 3, 2, 1, 0, 13, 12, 1, 0, 0, 0, 13, 14, 1, 0, 0, 0, 14, 21, 1, 0, 0, 0, 15, 17, 5, 3, 0, 0, 16, 18, 3, 2, 1, 0, 17, 16, 1, 0, 0, 0, 17, 18, 1, 0, 0, 0, 18, 20, 1, 0, 0, 0, 19, 15, 1, 0, 0, 0, 20, 23, 1, 0, 0, 0, 21, 19, 1, 0, 0, 0, 21, 22, 1, 0, 0, 0, 22, 24, 1, 0, 0, 0, 23, 21, 1, 0, 0, 0, 24, 25, 5, 0, 0, 1, 25, 1, 1, 0, 0, 0, 26, 28, 3, 6, 3, 0, 27, 29, 3, 4, 2, 0, 28, 27, 1, 0, 0, 0, 28, 29, 1, 0, 0, 0, 29, 31, 1, 0, 0, 0, 30, 32, 3, 8, 4, 0, 31, 30, 1, 0, 0, 0, 31, 32, 1, 0, 0, 0, 32, 3, 1, 0, 0, 0, 33, 34, 5, 3, 0, 0, 34, 5, 1, 0, 0, 0, 35, 36, 5, 2, 0, 0, 36, 7, 1, 0, 0, 0, 37, 39, 3, 10, 5, 0, 38, 37, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 46, 1, 0, 0, 0, 40, 42, 5, 1, 0, 0, 41, 43, 3, 10, 5, 0, 42, 41, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 45, 1, 0, 0, 0, 44, 40, 1, 0, 0, 0, 45, 48, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 46, 47, 1, 0, 0, 0, 47, 9, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 49, 50, 5, 2, 0, 0, 50, 11, 1, 0, 0, 0, 8, 13, 17, 21, 28, 31, 38, 42, 46] \ No newline at end of file diff --git a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/Match.tokens b/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/Match.tokens deleted file mode 100644 index 9172656..0000000 --- a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/Match.tokens +++ /dev/null @@ -1,4 +0,0 @@ -COMMA=1 -STRING=2 -WHITESPACE=3 -','=1 diff --git a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/MatchLexer.interp b/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/MatchLexer.interp deleted file mode 100644 index 90a8247..0000000 --- a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/MatchLexer.interp +++ /dev/null @@ -1,26 +0,0 @@ -token literal names: -null -',' -null -null - -token symbolic names: -null -COMMA -STRING -WHITESPACE - -rule names: -COMMA -STRING -WHITESPACE - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 3, 19, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 1, 0, 1, 0, 1, 1, 4, 1, 11, 8, 1, 11, 1, 12, 1, 12, 1, 2, 4, 2, 16, 8, 2, 11, 2, 12, 2, 17, 0, 0, 3, 1, 1, 3, 2, 5, 3, 1, 0, 2, 5, 0, 9, 10, 13, 13, 32, 32, 35, 35, 44, 44, 2, 0, 9, 9, 32, 32, 20, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 1, 7, 1, 0, 0, 0, 3, 10, 1, 0, 0, 0, 5, 15, 1, 0, 0, 0, 7, 8, 5, 44, 0, 0, 8, 2, 1, 0, 0, 0, 9, 11, 8, 0, 0, 0, 10, 9, 1, 0, 0, 0, 11, 12, 1, 0, 0, 0, 12, 10, 1, 0, 0, 0, 12, 13, 1, 0, 0, 0, 13, 4, 1, 0, 0, 0, 14, 16, 7, 1, 0, 0, 15, 14, 1, 0, 0, 0, 16, 17, 1, 0, 0, 0, 17, 15, 1, 0, 0, 0, 17, 18, 1, 0, 0, 0, 18, 6, 1, 0, 0, 0, 3, 0, 12, 17, 0] \ No newline at end of file diff --git a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/MatchLexer.tokens b/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/MatchLexer.tokens deleted file mode 100644 index 9172656..0000000 --- a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/MatchLexer.tokens +++ /dev/null @@ -1,4 +0,0 @@ -COMMA=1 -STRING=2 -WHITESPACE=3 -','=1 diff --git a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_base_listener.go b/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_base_listener.go deleted file mode 100644 index f9cb3e5..0000000 --- a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_base_listener.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated from handlers/sshd_config/match-parser/Match.g4 by ANTLR 4.13.0. DO NOT EDIT. - -package parser // Match - -import "github.com/antlr4-go/antlr/v4" - -// BaseMatchListener is a complete listener for a parse tree produced by MatchParser. -type BaseMatchListener struct{} - -var _ MatchListener = &BaseMatchListener{} - -// VisitTerminal is called when a terminal node is visited. -func (s *BaseMatchListener) VisitTerminal(node antlr.TerminalNode) {} - -// VisitErrorNode is called when an error node is visited. -func (s *BaseMatchListener) VisitErrorNode(node antlr.ErrorNode) {} - -// EnterEveryRule is called when any rule is entered. -func (s *BaseMatchListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} - -// ExitEveryRule is called when any rule is exited. -func (s *BaseMatchListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} - -// EnterRoot is called when production root is entered. -func (s *BaseMatchListener) EnterRoot(ctx *RootContext) {} - -// ExitRoot is called when production root is exited. -func (s *BaseMatchListener) ExitRoot(ctx *RootContext) {} - -// EnterMatchEntry is called when production matchEntry is entered. -func (s *BaseMatchListener) EnterMatchEntry(ctx *MatchEntryContext) {} - -// ExitMatchEntry is called when production matchEntry is exited. -func (s *BaseMatchListener) ExitMatchEntry(ctx *MatchEntryContext) {} - -// EnterSeparator is called when production separator is entered. -func (s *BaseMatchListener) EnterSeparator(ctx *SeparatorContext) {} - -// ExitSeparator is called when production separator is exited. -func (s *BaseMatchListener) ExitSeparator(ctx *SeparatorContext) {} - -// EnterCriteria is called when production criteria is entered. -func (s *BaseMatchListener) EnterCriteria(ctx *CriteriaContext) {} - -// ExitCriteria is called when production criteria is exited. -func (s *BaseMatchListener) ExitCriteria(ctx *CriteriaContext) {} - -// EnterValues is called when production values is entered. -func (s *BaseMatchListener) EnterValues(ctx *ValuesContext) {} - -// ExitValues is called when production values is exited. -func (s *BaseMatchListener) ExitValues(ctx *ValuesContext) {} - -// EnterValue is called when production value is entered. -func (s *BaseMatchListener) EnterValue(ctx *ValueContext) {} - -// ExitValue is called when production value is exited. -func (s *BaseMatchListener) ExitValue(ctx *ValueContext) {} diff --git a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_lexer.go b/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_lexer.go deleted file mode 100644 index 42d3891..0000000 --- a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_lexer.go +++ /dev/null @@ -1,109 +0,0 @@ -// Code generated from handlers/sshd_config/match-parser/Match.g4 by ANTLR 4.13.0. DO NOT EDIT. - -package parser - -import ( - "fmt" - "github.com/antlr4-go/antlr/v4" - "sync" - "unicode" -) - -// Suppress unused import error -var _ = fmt.Printf -var _ = sync.Once{} -var _ = unicode.IsLetter - -type MatchLexer struct { - *antlr.BaseLexer - channelNames []string - modeNames []string - // TODO: EOF string -} - -var MatchLexerLexerStaticData 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 -} - -func matchlexerLexerInit() { - staticData := &MatchLexerLexerStaticData - staticData.ChannelNames = []string{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", - } - staticData.ModeNames = []string{ - "DEFAULT_MODE", - } - staticData.LiteralNames = []string{ - "", "','", - } - staticData.SymbolicNames = []string{ - "", "COMMA", "STRING", "WHITESPACE", - } - staticData.RuleNames = []string{ - "COMMA", "STRING", "WHITESPACE", - } - staticData.PredictionContextCache = antlr.NewPredictionContextCache() - staticData.serializedATN = []int32{ - 4, 0, 3, 19, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 1, 0, 1, 0, 1, - 1, 4, 1, 11, 8, 1, 11, 1, 12, 1, 12, 1, 2, 4, 2, 16, 8, 2, 11, 2, 12, 2, - 17, 0, 0, 3, 1, 1, 3, 2, 5, 3, 1, 0, 2, 5, 0, 9, 10, 13, 13, 32, 32, 35, - 35, 44, 44, 2, 0, 9, 9, 32, 32, 20, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, - 0, 5, 1, 0, 0, 0, 1, 7, 1, 0, 0, 0, 3, 10, 1, 0, 0, 0, 5, 15, 1, 0, 0, - 0, 7, 8, 5, 44, 0, 0, 8, 2, 1, 0, 0, 0, 9, 11, 8, 0, 0, 0, 10, 9, 1, 0, - 0, 0, 11, 12, 1, 0, 0, 0, 12, 10, 1, 0, 0, 0, 12, 13, 1, 0, 0, 0, 13, 4, - 1, 0, 0, 0, 14, 16, 7, 1, 0, 0, 15, 14, 1, 0, 0, 0, 16, 17, 1, 0, 0, 0, - 17, 15, 1, 0, 0, 0, 17, 18, 1, 0, 0, 0, 18, 6, 1, 0, 0, 0, 3, 0, 12, 17, - 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) - } -} - -// MatchLexerInit initializes any static state used to implement MatchLexer. By default the -// static state used to implement the lexer is lazily initialized during the first call to -// NewMatchLexer(). You can call this function if you wish to initialize the static state ahead -// of time. -func MatchLexerInit() { - staticData := &MatchLexerLexerStaticData - staticData.once.Do(matchlexerLexerInit) -} - -// NewMatchLexer produces a new lexer instance for the optional input antlr.CharStream. -func NewMatchLexer(input antlr.CharStream) *MatchLexer { - MatchLexerInit() - l := new(MatchLexer) - l.BaseLexer = antlr.NewBaseLexer(input) - staticData := &MatchLexerLexerStaticData - 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 = "Match.g4" - // TODO: l.EOF = antlr.TokenEOF - - return l -} - -// MatchLexer tokens. -const ( - MatchLexerCOMMA = 1 - MatchLexerSTRING = 2 - MatchLexerWHITESPACE = 3 -) diff --git a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_listener.go b/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_listener.go deleted file mode 100644 index d13801e..0000000 --- a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_listener.go +++ /dev/null @@ -1,46 +0,0 @@ -// Code generated from handlers/sshd_config/match-parser/Match.g4 by ANTLR 4.13.0. DO NOT EDIT. - -package parser // Match - -import "github.com/antlr4-go/antlr/v4" - -// MatchListener is a complete listener for a parse tree produced by MatchParser. -type MatchListener interface { - antlr.ParseTreeListener - - // EnterRoot is called when entering the root production. - EnterRoot(c *RootContext) - - // EnterMatchEntry is called when entering the matchEntry production. - EnterMatchEntry(c *MatchEntryContext) - - // EnterSeparator is called when entering the separator production. - EnterSeparator(c *SeparatorContext) - - // EnterCriteria is called when entering the criteria production. - EnterCriteria(c *CriteriaContext) - - // EnterValues is called when entering the values production. - EnterValues(c *ValuesContext) - - // EnterValue is called when entering the value production. - EnterValue(c *ValueContext) - - // ExitRoot is called when exiting the root production. - ExitRoot(c *RootContext) - - // ExitMatchEntry is called when exiting the matchEntry production. - ExitMatchEntry(c *MatchEntryContext) - - // ExitSeparator is called when exiting the separator production. - ExitSeparator(c *SeparatorContext) - - // ExitCriteria is called when exiting the criteria production. - ExitCriteria(c *CriteriaContext) - - // ExitValues is called when exiting the values production. - ExitValues(c *ValuesContext) - - // ExitValue is called when exiting the value production. - ExitValue(c *ValueContext) -} diff --git a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_parser.go b/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_parser.go deleted file mode 100644 index bde60cb..0000000 --- a/handlers/sshd_config/match-parser/handlers/sshd_config/match-parser/match_parser.go +++ /dev/null @@ -1,961 +0,0 @@ -// Code generated from handlers/sshd_config/match-parser/Match.g4 by ANTLR 4.13.0. DO NOT EDIT. - -package parser // Match - -import ( - "fmt" - "strconv" - "sync" - - "github.com/antlr4-go/antlr/v4" -) - -// Suppress unused import errors -var _ = fmt.Printf -var _ = strconv.Itoa -var _ = sync.Once{} - -type MatchParser struct { - *antlr.BaseParser -} - -var MatchParserStaticData struct { - once sync.Once - serializedATN []int32 - LiteralNames []string - SymbolicNames []string - RuleNames []string - PredictionContextCache *antlr.PredictionContextCache - atn *antlr.ATN - decisionToDFA []*antlr.DFA -} - -func matchParserInit() { - staticData := &MatchParserStaticData - staticData.LiteralNames = []string{ - "", "','", - } - staticData.SymbolicNames = []string{ - "", "COMMA", "STRING", "WHITESPACE", - } - staticData.RuleNames = []string{ - "root", "matchEntry", "separator", "criteria", "values", "value", - } - staticData.PredictionContextCache = antlr.NewPredictionContextCache() - staticData.serializedATN = []int32{ - 4, 1, 3, 52, 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, 3, 0, 14, 8, 0, 1, 0, 1, 0, 3, 0, 18, 8, 0, 5, 0, 20, - 8, 0, 10, 0, 12, 0, 23, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 3, 1, 29, 8, 1, 1, - 1, 3, 1, 32, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 3, 4, 39, 8, 4, 1, 4, - 1, 4, 3, 4, 43, 8, 4, 5, 4, 45, 8, 4, 10, 4, 12, 4, 48, 9, 4, 1, 5, 1, - 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 0, 53, 0, 13, 1, 0, 0, 0, 2, 26, - 1, 0, 0, 0, 4, 33, 1, 0, 0, 0, 6, 35, 1, 0, 0, 0, 8, 38, 1, 0, 0, 0, 10, - 49, 1, 0, 0, 0, 12, 14, 3, 2, 1, 0, 13, 12, 1, 0, 0, 0, 13, 14, 1, 0, 0, - 0, 14, 21, 1, 0, 0, 0, 15, 17, 5, 3, 0, 0, 16, 18, 3, 2, 1, 0, 17, 16, - 1, 0, 0, 0, 17, 18, 1, 0, 0, 0, 18, 20, 1, 0, 0, 0, 19, 15, 1, 0, 0, 0, - 20, 23, 1, 0, 0, 0, 21, 19, 1, 0, 0, 0, 21, 22, 1, 0, 0, 0, 22, 24, 1, - 0, 0, 0, 23, 21, 1, 0, 0, 0, 24, 25, 5, 0, 0, 1, 25, 1, 1, 0, 0, 0, 26, - 28, 3, 6, 3, 0, 27, 29, 3, 4, 2, 0, 28, 27, 1, 0, 0, 0, 28, 29, 1, 0, 0, - 0, 29, 31, 1, 0, 0, 0, 30, 32, 3, 8, 4, 0, 31, 30, 1, 0, 0, 0, 31, 32, - 1, 0, 0, 0, 32, 3, 1, 0, 0, 0, 33, 34, 5, 3, 0, 0, 34, 5, 1, 0, 0, 0, 35, - 36, 5, 2, 0, 0, 36, 7, 1, 0, 0, 0, 37, 39, 3, 10, 5, 0, 38, 37, 1, 0, 0, - 0, 38, 39, 1, 0, 0, 0, 39, 46, 1, 0, 0, 0, 40, 42, 5, 1, 0, 0, 41, 43, - 3, 10, 5, 0, 42, 41, 1, 0, 0, 0, 42, 43, 1, 0, 0, 0, 43, 45, 1, 0, 0, 0, - 44, 40, 1, 0, 0, 0, 45, 48, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 46, 47, 1, - 0, 0, 0, 47, 9, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 49, 50, 5, 2, 0, 0, 50, - 11, 1, 0, 0, 0, 8, 13, 17, 21, 28, 31, 38, 42, 46, - } - 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) - } -} - -// MatchParserInit initializes any static state used to implement MatchParser. By default the -// static state used to implement the parser is lazily initialized during the first call to -// NewMatchParser(). You can call this function if you wish to initialize the static state ahead -// of time. -func MatchParserInit() { - staticData := &MatchParserStaticData - staticData.once.Do(matchParserInit) -} - -// NewMatchParser produces a new parser instance for the optional input antlr.TokenStream. -func NewMatchParser(input antlr.TokenStream) *MatchParser { - MatchParserInit() - this := new(MatchParser) - this.BaseParser = antlr.NewBaseParser(input) - staticData := &MatchParserStaticData - 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 = "Match.g4" - - return this -} - -// MatchParser tokens. -const ( - MatchParserEOF = antlr.TokenEOF - MatchParserCOMMA = 1 - MatchParserSTRING = 2 - MatchParserWHITESPACE = 3 -) - -// MatchParser rules. -const ( - MatchParserRULE_root = 0 - MatchParserRULE_matchEntry = 1 - MatchParserRULE_separator = 2 - MatchParserRULE_criteria = 3 - MatchParserRULE_values = 4 - MatchParserRULE_value = 5 -) - -// IRootContext is an interface to support dynamic dispatch. -type IRootContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - EOF() antlr.TerminalNode - AllMatchEntry() []IMatchEntryContext - MatchEntry(i int) IMatchEntryContext - AllWHITESPACE() []antlr.TerminalNode - WHITESPACE(i int) antlr.TerminalNode - - // IsRootContext differentiates from other interfaces. - IsRootContext() -} - -type RootContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyRootContext() *RootContext { - var p = new(RootContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_root - return p -} - -func InitEmptyRootContext(p *RootContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_root -} - -func (*RootContext) IsRootContext() {} - -func NewRootContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RootContext { - var p = new(RootContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = MatchParserRULE_root - - return p -} - -func (s *RootContext) GetParser() antlr.Parser { return s.parser } - -func (s *RootContext) EOF() antlr.TerminalNode { - return s.GetToken(MatchParserEOF, 0) -} - -func (s *RootContext) AllMatchEntry() []IMatchEntryContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IMatchEntryContext); ok { - len++ - } - } - - tst := make([]IMatchEntryContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IMatchEntryContext); ok { - tst[i] = t.(IMatchEntryContext) - i++ - } - } - - return tst -} - -func (s *RootContext) MatchEntry(i int) IMatchEntryContext { - var t antlr.RuleContext - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IMatchEntryContext); ok { - if j == i { - t = ctx.(antlr.RuleContext) - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IMatchEntryContext) -} - -func (s *RootContext) AllWHITESPACE() []antlr.TerminalNode { - return s.GetTokens(MatchParserWHITESPACE) -} - -func (s *RootContext) WHITESPACE(i int) antlr.TerminalNode { - return s.GetToken(MatchParserWHITESPACE, i) -} - -func (s *RootContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *RootContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *RootContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.EnterRoot(s) - } -} - -func (s *RootContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.ExitRoot(s) - } -} - -func (p *MatchParser) Root() (localctx IRootContext) { - localctx = NewRootContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 0, MatchParserRULE_root) - var _la int - - p.EnterOuterAlt(localctx, 1) - p.SetState(13) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == MatchParserSTRING { - { - p.SetState(12) - p.MatchEntry() - } - - } - p.SetState(21) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - for _la == MatchParserWHITESPACE { - { - p.SetState(15) - p.Match(MatchParserWHITESPACE) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(17) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == MatchParserSTRING { - { - p.SetState(16) - p.MatchEntry() - } - - } - - p.SetState(23) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - { - p.SetState(24) - p.Match(MatchParserEOF) - 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 -} - -// IMatchEntryContext is an interface to support dynamic dispatch. -type IMatchEntryContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - Criteria() ICriteriaContext - Separator() ISeparatorContext - Values() IValuesContext - - // IsMatchEntryContext differentiates from other interfaces. - IsMatchEntryContext() -} - -type MatchEntryContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyMatchEntryContext() *MatchEntryContext { - var p = new(MatchEntryContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_matchEntry - return p -} - -func InitEmptyMatchEntryContext(p *MatchEntryContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_matchEntry -} - -func (*MatchEntryContext) IsMatchEntryContext() {} - -func NewMatchEntryContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MatchEntryContext { - var p = new(MatchEntryContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = MatchParserRULE_matchEntry - - return p -} - -func (s *MatchEntryContext) GetParser() antlr.Parser { return s.parser } - -func (s *MatchEntryContext) Criteria() ICriteriaContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(ICriteriaContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(ICriteriaContext) -} - -func (s *MatchEntryContext) Separator() ISeparatorContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(ISeparatorContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(ISeparatorContext) -} - -func (s *MatchEntryContext) Values() IValuesContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IValuesContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(IValuesContext) -} - -func (s *MatchEntryContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *MatchEntryContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *MatchEntryContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.EnterMatchEntry(s) - } -} - -func (s *MatchEntryContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.ExitMatchEntry(s) - } -} - -func (p *MatchParser) MatchEntry() (localctx IMatchEntryContext) { - localctx = NewMatchEntryContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 2, MatchParserRULE_matchEntry) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(26) - p.Criteria() - } - p.SetState(28) - p.GetErrorHandler().Sync(p) - - if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) == 1 { - { - p.SetState(27) - p.Separator() - } - - } else if p.HasError() { // JIM - goto errorExit - } - p.SetState(31) - p.GetErrorHandler().Sync(p) - - if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) == 1 { - { - p.SetState(30) - p.Values() - } - - } else if p.HasError() { // JIM - 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 -} - -// ISeparatorContext is an interface to support dynamic dispatch. -type ISeparatorContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - WHITESPACE() antlr.TerminalNode - - // IsSeparatorContext differentiates from other interfaces. - IsSeparatorContext() -} - -type SeparatorContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptySeparatorContext() *SeparatorContext { - var p = new(SeparatorContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_separator - return p -} - -func InitEmptySeparatorContext(p *SeparatorContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_separator -} - -func (*SeparatorContext) IsSeparatorContext() {} - -func NewSeparatorContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SeparatorContext { - var p = new(SeparatorContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = MatchParserRULE_separator - - return p -} - -func (s *SeparatorContext) GetParser() antlr.Parser { return s.parser } - -func (s *SeparatorContext) WHITESPACE() antlr.TerminalNode { - return s.GetToken(MatchParserWHITESPACE, 0) -} - -func (s *SeparatorContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *SeparatorContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *SeparatorContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.EnterSeparator(s) - } -} - -func (s *SeparatorContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.ExitSeparator(s) - } -} - -func (p *MatchParser) Separator() (localctx ISeparatorContext) { - localctx = NewSeparatorContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 4, MatchParserRULE_separator) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(33) - p.Match(MatchParserWHITESPACE) - 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 -} - -// ICriteriaContext is an interface to support dynamic dispatch. -type ICriteriaContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - STRING() antlr.TerminalNode - - // IsCriteriaContext differentiates from other interfaces. - IsCriteriaContext() -} - -type CriteriaContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyCriteriaContext() *CriteriaContext { - var p = new(CriteriaContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_criteria - return p -} - -func InitEmptyCriteriaContext(p *CriteriaContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_criteria -} - -func (*CriteriaContext) IsCriteriaContext() {} - -func NewCriteriaContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *CriteriaContext { - var p = new(CriteriaContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = MatchParserRULE_criteria - - return p -} - -func (s *CriteriaContext) GetParser() antlr.Parser { return s.parser } - -func (s *CriteriaContext) STRING() antlr.TerminalNode { - return s.GetToken(MatchParserSTRING, 0) -} - -func (s *CriteriaContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *CriteriaContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *CriteriaContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.EnterCriteria(s) - } -} - -func (s *CriteriaContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.ExitCriteria(s) - } -} - -func (p *MatchParser) Criteria() (localctx ICriteriaContext) { - localctx = NewCriteriaContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 6, MatchParserRULE_criteria) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(35) - p.Match(MatchParserSTRING) - 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 -} - -// IValuesContext is an interface to support dynamic dispatch. -type IValuesContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - AllValue() []IValueContext - Value(i int) IValueContext - AllCOMMA() []antlr.TerminalNode - COMMA(i int) antlr.TerminalNode - - // IsValuesContext differentiates from other interfaces. - IsValuesContext() -} - -type ValuesContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyValuesContext() *ValuesContext { - var p = new(ValuesContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_values - return p -} - -func InitEmptyValuesContext(p *ValuesContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_values -} - -func (*ValuesContext) IsValuesContext() {} - -func NewValuesContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ValuesContext { - var p = new(ValuesContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = MatchParserRULE_values - - return p -} - -func (s *ValuesContext) GetParser() antlr.Parser { return s.parser } - -func (s *ValuesContext) AllValue() []IValueContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IValueContext); ok { - len++ - } - } - - tst := make([]IValueContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IValueContext); ok { - tst[i] = t.(IValueContext) - i++ - } - } - - return tst -} - -func (s *ValuesContext) Value(i int) IValueContext { - var t antlr.RuleContext - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IValueContext); ok { - if j == i { - t = ctx.(antlr.RuleContext) - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IValueContext) -} - -func (s *ValuesContext) AllCOMMA() []antlr.TerminalNode { - return s.GetTokens(MatchParserCOMMA) -} - -func (s *ValuesContext) COMMA(i int) antlr.TerminalNode { - return s.GetToken(MatchParserCOMMA, i) -} - -func (s *ValuesContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ValuesContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *ValuesContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.EnterValues(s) - } -} - -func (s *ValuesContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.ExitValues(s) - } -} - -func (p *MatchParser) Values() (localctx IValuesContext) { - localctx = NewValuesContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 8, MatchParserRULE_values) - var _la int - - p.EnterOuterAlt(localctx, 1) - p.SetState(38) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == MatchParserSTRING { - { - p.SetState(37) - p.Value() - } - - } - p.SetState(46) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - for _la == MatchParserCOMMA { - { - p.SetState(40) - p.Match(MatchParserCOMMA) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(42) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == MatchParserSTRING { - { - p.SetState(41) - p.Value() - } - - } - - p.SetState(48) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - -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 -} - -// IValueContext is an interface to support dynamic dispatch. -type IValueContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - STRING() antlr.TerminalNode - - // IsValueContext differentiates from other interfaces. - IsValueContext() -} - -type ValueContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyValueContext() *ValueContext { - var p = new(ValueContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_value - return p -} - -func InitEmptyValueContext(p *ValueContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = MatchParserRULE_value -} - -func (*ValueContext) IsValueContext() {} - -func NewValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ValueContext { - var p = new(ValueContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = MatchParserRULE_value - - return p -} - -func (s *ValueContext) GetParser() antlr.Parser { return s.parser } - -func (s *ValueContext) STRING() antlr.TerminalNode { - return s.GetToken(MatchParserSTRING, 0) -} - -func (s *ValueContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *ValueContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.EnterValue(s) - } -} - -func (s *ValueContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(MatchListener); ok { - listenerT.ExitValue(s) - } -} - -func (p *MatchParser) Value() (localctx IValueContext) { - localctx = NewValueContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 10, MatchParserRULE_value) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(49) - p.Match(MatchParserSTRING) - 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/handlers/sshd_config/parser/handlers/sshd_config/Config.interp b/handlers/sshd_config/parser/handlers/sshd_config/Config.interp deleted file mode 100644 index e02ab96..0000000 --- a/handlers/sshd_config/parser/handlers/sshd_config/Config.interp +++ /dev/null @@ -1,28 +0,0 @@ -token literal names: -null -'#' -null -null -null -null - -token symbolic names: -null -HASH -WHITESPACE -STRING -NEWLINE -QUOTED_STRING - -rule names: -lineStatement -entry -separator -key -value -leadingComment -string - - -atn: -[4, 1, 5, 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, 2, 6, 7, 6, 1, 0, 1, 0, 1, 0, 3, 0, 18, 8, 0, 3, 0, 20, 8, 0, 1, 0, 1, 0, 1, 1, 3, 1, 25, 8, 1, 1, 1, 3, 1, 28, 8, 1, 1, 1, 3, 1, 31, 8, 1, 1, 1, 3, 1, 34, 8, 1, 1, 1, 3, 1, 37, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 5, 4, 46, 8, 4, 10, 4, 12, 4, 49, 9, 4, 1, 4, 3, 4, 52, 8, 4, 1, 4, 3, 4, 55, 8, 4, 1, 5, 1, 5, 3, 5, 59, 8, 5, 1, 5, 1, 5, 3, 5, 63, 8, 5, 4, 5, 65, 8, 5, 11, 5, 12, 5, 66, 1, 6, 1, 6, 1, 6, 0, 0, 7, 0, 2, 4, 6, 8, 10, 12, 0, 1, 2, 0, 3, 3, 5, 5, 77, 0, 19, 1, 0, 0, 0, 2, 24, 1, 0, 0, 0, 4, 38, 1, 0, 0, 0, 6, 40, 1, 0, 0, 0, 8, 47, 1, 0, 0, 0, 10, 56, 1, 0, 0, 0, 12, 68, 1, 0, 0, 0, 14, 20, 3, 2, 1, 0, 15, 20, 3, 10, 5, 0, 16, 18, 5, 2, 0, 0, 17, 16, 1, 0, 0, 0, 17, 18, 1, 0, 0, 0, 18, 20, 1, 0, 0, 0, 19, 14, 1, 0, 0, 0, 19, 15, 1, 0, 0, 0, 19, 17, 1, 0, 0, 0, 20, 21, 1, 0, 0, 0, 21, 22, 5, 0, 0, 1, 22, 1, 1, 0, 0, 0, 23, 25, 5, 2, 0, 0, 24, 23, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 27, 1, 0, 0, 0, 26, 28, 3, 6, 3, 0, 27, 26, 1, 0, 0, 0, 27, 28, 1, 0, 0, 0, 28, 30, 1, 0, 0, 0, 29, 31, 3, 4, 2, 0, 30, 29, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 33, 1, 0, 0, 0, 32, 34, 3, 8, 4, 0, 33, 32, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 36, 1, 0, 0, 0, 35, 37, 3, 10, 5, 0, 36, 35, 1, 0, 0, 0, 36, 37, 1, 0, 0, 0, 37, 3, 1, 0, 0, 0, 38, 39, 5, 2, 0, 0, 39, 5, 1, 0, 0, 0, 40, 41, 3, 12, 6, 0, 41, 7, 1, 0, 0, 0, 42, 43, 3, 12, 6, 0, 43, 44, 5, 2, 0, 0, 44, 46, 1, 0, 0, 0, 45, 42, 1, 0, 0, 0, 46, 49, 1, 0, 0, 0, 47, 45, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 51, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 50, 52, 3, 12, 6, 0, 51, 50, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 54, 1, 0, 0, 0, 53, 55, 5, 2, 0, 0, 54, 53, 1, 0, 0, 0, 54, 55, 1, 0, 0, 0, 55, 9, 1, 0, 0, 0, 56, 58, 5, 1, 0, 0, 57, 59, 5, 2, 0, 0, 58, 57, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 64, 1, 0, 0, 0, 60, 62, 3, 12, 6, 0, 61, 63, 5, 2, 0, 0, 62, 61, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 65, 1, 0, 0, 0, 64, 60, 1, 0, 0, 0, 65, 66, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 66, 67, 1, 0, 0, 0, 67, 11, 1, 0, 0, 0, 68, 69, 7, 0, 0, 0, 69, 13, 1, 0, 0, 0, 13, 17, 19, 24, 27, 30, 33, 36, 47, 51, 54, 58, 62, 66] \ No newline at end of file diff --git a/handlers/sshd_config/parser/handlers/sshd_config/Config.tokens b/handlers/sshd_config/parser/handlers/sshd_config/Config.tokens deleted file mode 100644 index fa8c415..0000000 --- a/handlers/sshd_config/parser/handlers/sshd_config/Config.tokens +++ /dev/null @@ -1,6 +0,0 @@ -HASH=1 -WHITESPACE=2 -STRING=3 -NEWLINE=4 -QUOTED_STRING=5 -'#'=1 diff --git a/handlers/sshd_config/parser/handlers/sshd_config/ConfigLexer.interp b/handlers/sshd_config/parser/handlers/sshd_config/ConfigLexer.interp deleted file mode 100644 index c093cfb..0000000 --- a/handlers/sshd_config/parser/handlers/sshd_config/ConfigLexer.interp +++ /dev/null @@ -1,32 +0,0 @@ -token literal names: -null -'#' -null -null -null -null - -token symbolic names: -null -HASH -WHITESPACE -STRING -NEWLINE -QUOTED_STRING - -rule names: -HASH -WHITESPACE -STRING -NEWLINE -QUOTED_STRING - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 5, 46, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 1, 0, 1, 0, 1, 1, 4, 1, 15, 8, 1, 11, 1, 12, 1, 16, 1, 2, 4, 2, 20, 8, 2, 11, 2, 12, 2, 21, 1, 3, 3, 3, 25, 8, 3, 1, 3, 1, 3, 1, 4, 1, 4, 3, 4, 31, 8, 4, 1, 4, 1, 4, 1, 4, 5, 4, 36, 8, 4, 10, 4, 12, 4, 39, 9, 4, 1, 4, 3, 4, 42, 8, 4, 1, 4, 3, 4, 45, 8, 4, 0, 0, 5, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 1, 0, 2, 2, 0, 9, 9, 32, 32, 4, 0, 9, 10, 13, 13, 32, 32, 34, 35, 52, 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, 1, 11, 1, 0, 0, 0, 3, 14, 1, 0, 0, 0, 5, 19, 1, 0, 0, 0, 7, 24, 1, 0, 0, 0, 9, 28, 1, 0, 0, 0, 11, 12, 5, 35, 0, 0, 12, 2, 1, 0, 0, 0, 13, 15, 7, 0, 0, 0, 14, 13, 1, 0, 0, 0, 15, 16, 1, 0, 0, 0, 16, 14, 1, 0, 0, 0, 16, 17, 1, 0, 0, 0, 17, 4, 1, 0, 0, 0, 18, 20, 8, 1, 0, 0, 19, 18, 1, 0, 0, 0, 20, 21, 1, 0, 0, 0, 21, 19, 1, 0, 0, 0, 21, 22, 1, 0, 0, 0, 22, 6, 1, 0, 0, 0, 23, 25, 5, 13, 0, 0, 24, 23, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 27, 5, 10, 0, 0, 27, 8, 1, 0, 0, 0, 28, 30, 5, 34, 0, 0, 29, 31, 3, 3, 1, 0, 30, 29, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 37, 1, 0, 0, 0, 32, 33, 3, 5, 2, 0, 33, 34, 3, 3, 1, 0, 34, 36, 1, 0, 0, 0, 35, 32, 1, 0, 0, 0, 36, 39, 1, 0, 0, 0, 37, 35, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 41, 1, 0, 0, 0, 39, 37, 1, 0, 0, 0, 40, 42, 3, 5, 2, 0, 41, 40, 1, 0, 0, 0, 41, 42, 1, 0, 0, 0, 42, 44, 1, 0, 0, 0, 43, 45, 5, 34, 0, 0, 44, 43, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 10, 1, 0, 0, 0, 8, 0, 16, 21, 24, 30, 37, 41, 44, 0] \ No newline at end of file diff --git a/handlers/sshd_config/parser/handlers/sshd_config/ConfigLexer.tokens b/handlers/sshd_config/parser/handlers/sshd_config/ConfigLexer.tokens deleted file mode 100644 index fa8c415..0000000 --- a/handlers/sshd_config/parser/handlers/sshd_config/ConfigLexer.tokens +++ /dev/null @@ -1,6 +0,0 @@ -HASH=1 -WHITESPACE=2 -STRING=3 -NEWLINE=4 -QUOTED_STRING=5 -'#'=1 diff --git a/handlers/sshd_config/parser/handlers/sshd_config/config_base_listener.go b/handlers/sshd_config/parser/handlers/sshd_config/config_base_listener.go deleted file mode 100644 index 00727a5..0000000 --- a/handlers/sshd_config/parser/handlers/sshd_config/config_base_listener.go +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated from handlers/sshd_config/Config.g4 by ANTLR 4.13.0. DO NOT EDIT. - -package parser // Config - -import "github.com/antlr4-go/antlr/v4" - -// BaseConfigListener is a complete listener for a parse tree produced by ConfigParser. -type BaseConfigListener struct{} - -var _ ConfigListener = &BaseConfigListener{} - -// VisitTerminal is called when a terminal node is visited. -func (s *BaseConfigListener) VisitTerminal(node antlr.TerminalNode) {} - -// VisitErrorNode is called when an error node is visited. -func (s *BaseConfigListener) VisitErrorNode(node antlr.ErrorNode) {} - -// EnterEveryRule is called when any rule is entered. -func (s *BaseConfigListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} - -// ExitEveryRule is called when any rule is exited. -func (s *BaseConfigListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} - -// EnterLineStatement is called when production lineStatement is entered. -func (s *BaseConfigListener) EnterLineStatement(ctx *LineStatementContext) {} - -// ExitLineStatement is called when production lineStatement is exited. -func (s *BaseConfigListener) ExitLineStatement(ctx *LineStatementContext) {} - -// EnterEntry is called when production entry is entered. -func (s *BaseConfigListener) EnterEntry(ctx *EntryContext) {} - -// ExitEntry is called when production entry is exited. -func (s *BaseConfigListener) ExitEntry(ctx *EntryContext) {} - -// EnterSeparator is called when production separator is entered. -func (s *BaseConfigListener) EnterSeparator(ctx *SeparatorContext) {} - -// ExitSeparator is called when production separator is exited. -func (s *BaseConfigListener) ExitSeparator(ctx *SeparatorContext) {} - -// EnterKey is called when production key is entered. -func (s *BaseConfigListener) EnterKey(ctx *KeyContext) {} - -// ExitKey is called when production key is exited. -func (s *BaseConfigListener) ExitKey(ctx *KeyContext) {} - -// EnterValue is called when production value is entered. -func (s *BaseConfigListener) EnterValue(ctx *ValueContext) {} - -// ExitValue is called when production value is exited. -func (s *BaseConfigListener) ExitValue(ctx *ValueContext) {} - -// EnterLeadingComment is called when production leadingComment is entered. -func (s *BaseConfigListener) EnterLeadingComment(ctx *LeadingCommentContext) {} - -// ExitLeadingComment is called when production leadingComment is exited. -func (s *BaseConfigListener) ExitLeadingComment(ctx *LeadingCommentContext) {} - -// EnterString is called when production string is entered. -func (s *BaseConfigListener) EnterString(ctx *StringContext) {} - -// ExitString is called when production string is exited. -func (s *BaseConfigListener) ExitString(ctx *StringContext) {} diff --git a/handlers/sshd_config/parser/handlers/sshd_config/config_lexer.go b/handlers/sshd_config/parser/handlers/sshd_config/config_lexer.go deleted file mode 100644 index 2852942..0000000 --- a/handlers/sshd_config/parser/handlers/sshd_config/config_lexer.go +++ /dev/null @@ -1,122 +0,0 @@ -// Code generated from handlers/sshd_config/Config.g4 by ANTLR 4.13.0. DO NOT EDIT. - -package parser - -import ( - "fmt" - "github.com/antlr4-go/antlr/v4" - "sync" - "unicode" -) - -// Suppress unused import error -var _ = fmt.Printf -var _ = sync.Once{} -var _ = unicode.IsLetter - -type ConfigLexer struct { - *antlr.BaseLexer - channelNames []string - modeNames []string - // TODO: EOF string -} - -var ConfigLexerLexerStaticData 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 -} - -func configlexerLexerInit() { - staticData := &ConfigLexerLexerStaticData - staticData.ChannelNames = []string{ - "DEFAULT_TOKEN_CHANNEL", "HIDDEN", - } - staticData.ModeNames = []string{ - "DEFAULT_MODE", - } - staticData.LiteralNames = []string{ - "", "'#'", - } - staticData.SymbolicNames = []string{ - "", "HASH", "WHITESPACE", "STRING", "NEWLINE", "QUOTED_STRING", - } - staticData.RuleNames = []string{ - "HASH", "WHITESPACE", "STRING", "NEWLINE", "QUOTED_STRING", - } - staticData.PredictionContextCache = antlr.NewPredictionContextCache() - staticData.serializedATN = []int32{ - 4, 0, 5, 46, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, - 4, 7, 4, 1, 0, 1, 0, 1, 1, 4, 1, 15, 8, 1, 11, 1, 12, 1, 16, 1, 2, 4, 2, - 20, 8, 2, 11, 2, 12, 2, 21, 1, 3, 3, 3, 25, 8, 3, 1, 3, 1, 3, 1, 4, 1, - 4, 3, 4, 31, 8, 4, 1, 4, 1, 4, 1, 4, 5, 4, 36, 8, 4, 10, 4, 12, 4, 39, - 9, 4, 1, 4, 3, 4, 42, 8, 4, 1, 4, 3, 4, 45, 8, 4, 0, 0, 5, 1, 1, 3, 2, - 5, 3, 7, 4, 9, 5, 1, 0, 2, 2, 0, 9, 9, 32, 32, 4, 0, 9, 10, 13, 13, 32, - 32, 34, 35, 52, 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, 1, 11, 1, 0, 0, 0, 3, 14, 1, 0, 0, 0, - 5, 19, 1, 0, 0, 0, 7, 24, 1, 0, 0, 0, 9, 28, 1, 0, 0, 0, 11, 12, 5, 35, - 0, 0, 12, 2, 1, 0, 0, 0, 13, 15, 7, 0, 0, 0, 14, 13, 1, 0, 0, 0, 15, 16, - 1, 0, 0, 0, 16, 14, 1, 0, 0, 0, 16, 17, 1, 0, 0, 0, 17, 4, 1, 0, 0, 0, - 18, 20, 8, 1, 0, 0, 19, 18, 1, 0, 0, 0, 20, 21, 1, 0, 0, 0, 21, 19, 1, - 0, 0, 0, 21, 22, 1, 0, 0, 0, 22, 6, 1, 0, 0, 0, 23, 25, 5, 13, 0, 0, 24, - 23, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 27, 5, 10, - 0, 0, 27, 8, 1, 0, 0, 0, 28, 30, 5, 34, 0, 0, 29, 31, 3, 3, 1, 0, 30, 29, - 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 37, 1, 0, 0, 0, 32, 33, 3, 5, 2, 0, - 33, 34, 3, 3, 1, 0, 34, 36, 1, 0, 0, 0, 35, 32, 1, 0, 0, 0, 36, 39, 1, - 0, 0, 0, 37, 35, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 41, 1, 0, 0, 0, 39, - 37, 1, 0, 0, 0, 40, 42, 3, 5, 2, 0, 41, 40, 1, 0, 0, 0, 41, 42, 1, 0, 0, - 0, 42, 44, 1, 0, 0, 0, 43, 45, 5, 34, 0, 0, 44, 43, 1, 0, 0, 0, 44, 45, - 1, 0, 0, 0, 45, 10, 1, 0, 0, 0, 8, 0, 16, 21, 24, 30, 37, 41, 44, 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) - } -} - -// ConfigLexerInit initializes any static state used to implement ConfigLexer. By default the -// static state used to implement the lexer is lazily initialized during the first call to -// NewConfigLexer(). You can call this function if you wish to initialize the static state ahead -// of time. -func ConfigLexerInit() { - staticData := &ConfigLexerLexerStaticData - staticData.once.Do(configlexerLexerInit) -} - -// NewConfigLexer produces a new lexer instance for the optional input antlr.CharStream. -func NewConfigLexer(input antlr.CharStream) *ConfigLexer { - ConfigLexerInit() - l := new(ConfigLexer) - l.BaseLexer = antlr.NewBaseLexer(input) - staticData := &ConfigLexerLexerStaticData - 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 = "Config.g4" - // TODO: l.EOF = antlr.TokenEOF - - return l -} - -// ConfigLexer tokens. -const ( - ConfigLexerHASH = 1 - ConfigLexerWHITESPACE = 2 - ConfigLexerSTRING = 3 - ConfigLexerNEWLINE = 4 - ConfigLexerQUOTED_STRING = 5 -) diff --git a/handlers/sshd_config/parser/handlers/sshd_config/config_listener.go b/handlers/sshd_config/parser/handlers/sshd_config/config_listener.go deleted file mode 100644 index b6e827b..0000000 --- a/handlers/sshd_config/parser/handlers/sshd_config/config_listener.go +++ /dev/null @@ -1,52 +0,0 @@ -// Code generated from handlers/sshd_config/Config.g4 by ANTLR 4.13.0. DO NOT EDIT. - -package parser // Config - -import "github.com/antlr4-go/antlr/v4" - -// ConfigListener is a complete listener for a parse tree produced by ConfigParser. -type ConfigListener interface { - antlr.ParseTreeListener - - // EnterLineStatement is called when entering the lineStatement production. - EnterLineStatement(c *LineStatementContext) - - // EnterEntry is called when entering the entry production. - EnterEntry(c *EntryContext) - - // EnterSeparator is called when entering the separator production. - EnterSeparator(c *SeparatorContext) - - // EnterKey is called when entering the key production. - EnterKey(c *KeyContext) - - // EnterValue is called when entering the value production. - EnterValue(c *ValueContext) - - // EnterLeadingComment is called when entering the leadingComment production. - EnterLeadingComment(c *LeadingCommentContext) - - // EnterString is called when entering the string production. - EnterString(c *StringContext) - - // ExitLineStatement is called when exiting the lineStatement production. - ExitLineStatement(c *LineStatementContext) - - // ExitEntry is called when exiting the entry production. - ExitEntry(c *EntryContext) - - // ExitSeparator is called when exiting the separator production. - ExitSeparator(c *SeparatorContext) - - // ExitKey is called when exiting the key production. - ExitKey(c *KeyContext) - - // ExitValue is called when exiting the value production. - ExitValue(c *ValueContext) - - // ExitLeadingComment is called when exiting the leadingComment production. - ExitLeadingComment(c *LeadingCommentContext) - - // ExitString is called when exiting the string production. - ExitString(c *StringContext) -} diff --git a/handlers/sshd_config/parser/handlers/sshd_config/config_parser.go b/handlers/sshd_config/parser/handlers/sshd_config/config_parser.go deleted file mode 100644 index 50f9bab..0000000 --- a/handlers/sshd_config/parser/handlers/sshd_config/config_parser.go +++ /dev/null @@ -1,1254 +0,0 @@ -// Code generated from handlers/sshd_config/Config.g4 by ANTLR 4.13.0. DO NOT EDIT. - -package parser // Config - -import ( - "fmt" - "strconv" - "sync" - - "github.com/antlr4-go/antlr/v4" -) - -// Suppress unused import errors -var _ = fmt.Printf -var _ = strconv.Itoa -var _ = sync.Once{} - -type ConfigParser struct { - *antlr.BaseParser -} - -var ConfigParserStaticData struct { - once sync.Once - serializedATN []int32 - LiteralNames []string - SymbolicNames []string - RuleNames []string - PredictionContextCache *antlr.PredictionContextCache - atn *antlr.ATN - decisionToDFA []*antlr.DFA -} - -func configParserInit() { - staticData := &ConfigParserStaticData - staticData.LiteralNames = []string{ - "", "'#'", - } - staticData.SymbolicNames = []string{ - "", "HASH", "WHITESPACE", "STRING", "NEWLINE", "QUOTED_STRING", - } - staticData.RuleNames = []string{ - "lineStatement", "entry", "separator", "key", "value", "leadingComment", - "string", - } - staticData.PredictionContextCache = antlr.NewPredictionContextCache() - staticData.serializedATN = []int32{ - 4, 1, 5, 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, 2, 6, 7, 6, 1, 0, 1, 0, 1, 0, 3, 0, 18, 8, 0, 3, 0, 20, 8, - 0, 1, 0, 1, 0, 1, 1, 3, 1, 25, 8, 1, 1, 1, 3, 1, 28, 8, 1, 1, 1, 3, 1, - 31, 8, 1, 1, 1, 3, 1, 34, 8, 1, 1, 1, 3, 1, 37, 8, 1, 1, 2, 1, 2, 1, 3, - 1, 3, 1, 4, 1, 4, 1, 4, 5, 4, 46, 8, 4, 10, 4, 12, 4, 49, 9, 4, 1, 4, 3, - 4, 52, 8, 4, 1, 4, 3, 4, 55, 8, 4, 1, 5, 1, 5, 3, 5, 59, 8, 5, 1, 5, 1, - 5, 3, 5, 63, 8, 5, 4, 5, 65, 8, 5, 11, 5, 12, 5, 66, 1, 6, 1, 6, 1, 6, - 0, 0, 7, 0, 2, 4, 6, 8, 10, 12, 0, 1, 2, 0, 3, 3, 5, 5, 77, 0, 19, 1, 0, - 0, 0, 2, 24, 1, 0, 0, 0, 4, 38, 1, 0, 0, 0, 6, 40, 1, 0, 0, 0, 8, 47, 1, - 0, 0, 0, 10, 56, 1, 0, 0, 0, 12, 68, 1, 0, 0, 0, 14, 20, 3, 2, 1, 0, 15, - 20, 3, 10, 5, 0, 16, 18, 5, 2, 0, 0, 17, 16, 1, 0, 0, 0, 17, 18, 1, 0, - 0, 0, 18, 20, 1, 0, 0, 0, 19, 14, 1, 0, 0, 0, 19, 15, 1, 0, 0, 0, 19, 17, - 1, 0, 0, 0, 20, 21, 1, 0, 0, 0, 21, 22, 5, 0, 0, 1, 22, 1, 1, 0, 0, 0, - 23, 25, 5, 2, 0, 0, 24, 23, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 27, 1, - 0, 0, 0, 26, 28, 3, 6, 3, 0, 27, 26, 1, 0, 0, 0, 27, 28, 1, 0, 0, 0, 28, - 30, 1, 0, 0, 0, 29, 31, 3, 4, 2, 0, 30, 29, 1, 0, 0, 0, 30, 31, 1, 0, 0, - 0, 31, 33, 1, 0, 0, 0, 32, 34, 3, 8, 4, 0, 33, 32, 1, 0, 0, 0, 33, 34, - 1, 0, 0, 0, 34, 36, 1, 0, 0, 0, 35, 37, 3, 10, 5, 0, 36, 35, 1, 0, 0, 0, - 36, 37, 1, 0, 0, 0, 37, 3, 1, 0, 0, 0, 38, 39, 5, 2, 0, 0, 39, 5, 1, 0, - 0, 0, 40, 41, 3, 12, 6, 0, 41, 7, 1, 0, 0, 0, 42, 43, 3, 12, 6, 0, 43, - 44, 5, 2, 0, 0, 44, 46, 1, 0, 0, 0, 45, 42, 1, 0, 0, 0, 46, 49, 1, 0, 0, - 0, 47, 45, 1, 0, 0, 0, 47, 48, 1, 0, 0, 0, 48, 51, 1, 0, 0, 0, 49, 47, - 1, 0, 0, 0, 50, 52, 3, 12, 6, 0, 51, 50, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, - 52, 54, 1, 0, 0, 0, 53, 55, 5, 2, 0, 0, 54, 53, 1, 0, 0, 0, 54, 55, 1, - 0, 0, 0, 55, 9, 1, 0, 0, 0, 56, 58, 5, 1, 0, 0, 57, 59, 5, 2, 0, 0, 58, - 57, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 64, 1, 0, 0, 0, 60, 62, 3, 12, - 6, 0, 61, 63, 5, 2, 0, 0, 62, 61, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 65, - 1, 0, 0, 0, 64, 60, 1, 0, 0, 0, 65, 66, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, - 66, 67, 1, 0, 0, 0, 67, 11, 1, 0, 0, 0, 68, 69, 7, 0, 0, 0, 69, 13, 1, - 0, 0, 0, 13, 17, 19, 24, 27, 30, 33, 36, 47, 51, 54, 58, 62, 66, - } - 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) - } -} - -// ConfigParserInit initializes any static state used to implement ConfigParser. By default the -// static state used to implement the parser is lazily initialized during the first call to -// NewConfigParser(). You can call this function if you wish to initialize the static state ahead -// of time. -func ConfigParserInit() { - staticData := &ConfigParserStaticData - staticData.once.Do(configParserInit) -} - -// NewConfigParser produces a new parser instance for the optional input antlr.TokenStream. -func NewConfigParser(input antlr.TokenStream) *ConfigParser { - ConfigParserInit() - this := new(ConfigParser) - this.BaseParser = antlr.NewBaseParser(input) - staticData := &ConfigParserStaticData - 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 = "Config.g4" - - return this -} - -// ConfigParser tokens. -const ( - ConfigParserEOF = antlr.TokenEOF - ConfigParserHASH = 1 - ConfigParserWHITESPACE = 2 - ConfigParserSTRING = 3 - ConfigParserNEWLINE = 4 - ConfigParserQUOTED_STRING = 5 -) - -// ConfigParser rules. -const ( - ConfigParserRULE_lineStatement = 0 - ConfigParserRULE_entry = 1 - ConfigParserRULE_separator = 2 - ConfigParserRULE_key = 3 - ConfigParserRULE_value = 4 - ConfigParserRULE_leadingComment = 5 - ConfigParserRULE_string = 6 -) - -// ILineStatementContext is an interface to support dynamic dispatch. -type ILineStatementContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - EOF() antlr.TerminalNode - Entry() IEntryContext - LeadingComment() ILeadingCommentContext - WHITESPACE() antlr.TerminalNode - - // IsLineStatementContext differentiates from other interfaces. - IsLineStatementContext() -} - -type LineStatementContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyLineStatementContext() *LineStatementContext { - var p = new(LineStatementContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_lineStatement - return p -} - -func InitEmptyLineStatementContext(p *LineStatementContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_lineStatement -} - -func (*LineStatementContext) IsLineStatementContext() {} - -func NewLineStatementContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *LineStatementContext { - var p = new(LineStatementContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = ConfigParserRULE_lineStatement - - return p -} - -func (s *LineStatementContext) GetParser() antlr.Parser { return s.parser } - -func (s *LineStatementContext) EOF() antlr.TerminalNode { - return s.GetToken(ConfigParserEOF, 0) -} - -func (s *LineStatementContext) Entry() IEntryContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IEntryContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(IEntryContext) -} - -func (s *LineStatementContext) LeadingComment() ILeadingCommentContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(ILeadingCommentContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(ILeadingCommentContext) -} - -func (s *LineStatementContext) WHITESPACE() antlr.TerminalNode { - return s.GetToken(ConfigParserWHITESPACE, 0) -} - -func (s *LineStatementContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *LineStatementContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *LineStatementContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.EnterLineStatement(s) - } -} - -func (s *LineStatementContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.ExitLineStatement(s) - } -} - -func (p *ConfigParser) LineStatement() (localctx ILineStatementContext) { - localctx = NewLineStatementContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 0, ConfigParserRULE_lineStatement) - var _la int - - p.EnterOuterAlt(localctx, 1) - p.SetState(19) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - - switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 1, p.GetParserRuleContext()) { - case 1: - { - p.SetState(14) - p.Entry() - } - - case 2: - { - p.SetState(15) - p.LeadingComment() - } - - case 3: - p.SetState(17) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == ConfigParserWHITESPACE { - { - p.SetState(16) - p.Match(ConfigParserWHITESPACE) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - - case antlr.ATNInvalidAltNumber: - goto errorExit - } - { - p.SetState(21) - p.Match(ConfigParserEOF) - 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 -} - -// IEntryContext is an interface to support dynamic dispatch. -type IEntryContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - WHITESPACE() antlr.TerminalNode - Key() IKeyContext - Separator() ISeparatorContext - Value() IValueContext - LeadingComment() ILeadingCommentContext - - // IsEntryContext differentiates from other interfaces. - IsEntryContext() -} - -type EntryContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyEntryContext() *EntryContext { - var p = new(EntryContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_entry - return p -} - -func InitEmptyEntryContext(p *EntryContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_entry -} - -func (*EntryContext) IsEntryContext() {} - -func NewEntryContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *EntryContext { - var p = new(EntryContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = ConfigParserRULE_entry - - return p -} - -func (s *EntryContext) GetParser() antlr.Parser { return s.parser } - -func (s *EntryContext) WHITESPACE() antlr.TerminalNode { - return s.GetToken(ConfigParserWHITESPACE, 0) -} - -func (s *EntryContext) Key() IKeyContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IKeyContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(IKeyContext) -} - -func (s *EntryContext) Separator() ISeparatorContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(ISeparatorContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(ISeparatorContext) -} - -func (s *EntryContext) Value() IValueContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IValueContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(IValueContext) -} - -func (s *EntryContext) LeadingComment() ILeadingCommentContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(ILeadingCommentContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(ILeadingCommentContext) -} - -func (s *EntryContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *EntryContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *EntryContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.EnterEntry(s) - } -} - -func (s *EntryContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.ExitEntry(s) - } -} - -func (p *ConfigParser) Entry() (localctx IEntryContext) { - localctx = NewEntryContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 2, ConfigParserRULE_entry) - var _la int - - p.EnterOuterAlt(localctx, 1) - p.SetState(24) - p.GetErrorHandler().Sync(p) - - if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) == 1 { - { - p.SetState(23) - p.Match(ConfigParserWHITESPACE) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } else if p.HasError() { // JIM - goto errorExit - } - p.SetState(27) - p.GetErrorHandler().Sync(p) - - if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 3, p.GetParserRuleContext()) == 1 { - { - p.SetState(26) - p.Key() - } - - } else if p.HasError() { // JIM - goto errorExit - } - p.SetState(30) - p.GetErrorHandler().Sync(p) - - if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) == 1 { - { - p.SetState(29) - p.Separator() - } - - } else if p.HasError() { // JIM - goto errorExit - } - p.SetState(33) - p.GetErrorHandler().Sync(p) - - if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 5, p.GetParserRuleContext()) == 1 { - { - p.SetState(32) - p.Value() - } - - } else if p.HasError() { // JIM - goto errorExit - } - p.SetState(36) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == ConfigParserHASH { - { - p.SetState(35) - p.LeadingComment() - } - - } - -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 -} - -// ISeparatorContext is an interface to support dynamic dispatch. -type ISeparatorContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - WHITESPACE() antlr.TerminalNode - - // IsSeparatorContext differentiates from other interfaces. - IsSeparatorContext() -} - -type SeparatorContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptySeparatorContext() *SeparatorContext { - var p = new(SeparatorContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_separator - return p -} - -func InitEmptySeparatorContext(p *SeparatorContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_separator -} - -func (*SeparatorContext) IsSeparatorContext() {} - -func NewSeparatorContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SeparatorContext { - var p = new(SeparatorContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = ConfigParserRULE_separator - - return p -} - -func (s *SeparatorContext) GetParser() antlr.Parser { return s.parser } - -func (s *SeparatorContext) WHITESPACE() antlr.TerminalNode { - return s.GetToken(ConfigParserWHITESPACE, 0) -} - -func (s *SeparatorContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *SeparatorContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *SeparatorContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.EnterSeparator(s) - } -} - -func (s *SeparatorContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.ExitSeparator(s) - } -} - -func (p *ConfigParser) Separator() (localctx ISeparatorContext) { - localctx = NewSeparatorContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 4, ConfigParserRULE_separator) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(38) - p.Match(ConfigParserWHITESPACE) - 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 -} - -// IKeyContext is an interface to support dynamic dispatch. -type IKeyContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - String_() IStringContext - - // IsKeyContext differentiates from other interfaces. - IsKeyContext() -} - -type KeyContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyKeyContext() *KeyContext { - var p = new(KeyContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_key - return p -} - -func InitEmptyKeyContext(p *KeyContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_key -} - -func (*KeyContext) IsKeyContext() {} - -func NewKeyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *KeyContext { - var p = new(KeyContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = ConfigParserRULE_key - - return p -} - -func (s *KeyContext) GetParser() antlr.Parser { return s.parser } - -func (s *KeyContext) String_() IStringContext { - var t antlr.RuleContext - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IStringContext); ok { - t = ctx.(antlr.RuleContext) - break - } - } - - if t == nil { - return nil - } - - return t.(IStringContext) -} - -func (s *KeyContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *KeyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *KeyContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.EnterKey(s) - } -} - -func (s *KeyContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.ExitKey(s) - } -} - -func (p *ConfigParser) Key() (localctx IKeyContext) { - localctx = NewKeyContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 6, ConfigParserRULE_key) - p.EnterOuterAlt(localctx, 1) - { - p.SetState(40) - p.String_() - } - -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 -} - -// IValueContext is an interface to support dynamic dispatch. -type IValueContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - AllString_() []IStringContext - String_(i int) IStringContext - AllWHITESPACE() []antlr.TerminalNode - WHITESPACE(i int) antlr.TerminalNode - - // IsValueContext differentiates from other interfaces. - IsValueContext() -} - -type ValueContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyValueContext() *ValueContext { - var p = new(ValueContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_value - return p -} - -func InitEmptyValueContext(p *ValueContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_value -} - -func (*ValueContext) IsValueContext() {} - -func NewValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ValueContext { - var p = new(ValueContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = ConfigParserRULE_value - - return p -} - -func (s *ValueContext) GetParser() antlr.Parser { return s.parser } - -func (s *ValueContext) AllString_() []IStringContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IStringContext); ok { - len++ - } - } - - tst := make([]IStringContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IStringContext); ok { - tst[i] = t.(IStringContext) - i++ - } - } - - return tst -} - -func (s *ValueContext) String_(i int) IStringContext { - var t antlr.RuleContext - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IStringContext); ok { - if j == i { - t = ctx.(antlr.RuleContext) - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IStringContext) -} - -func (s *ValueContext) AllWHITESPACE() []antlr.TerminalNode { - return s.GetTokens(ConfigParserWHITESPACE) -} - -func (s *ValueContext) WHITESPACE(i int) antlr.TerminalNode { - return s.GetToken(ConfigParserWHITESPACE, i) -} - -func (s *ValueContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *ValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *ValueContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.EnterValue(s) - } -} - -func (s *ValueContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.ExitValue(s) - } -} - -func (p *ConfigParser) Value() (localctx IValueContext) { - localctx = NewValueContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 8, ConfigParserRULE_value) - var _la int - - var _alt int - - p.EnterOuterAlt(localctx, 1) - p.SetState(47) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - for _alt != 2 && _alt != antlr.ATNInvalidAltNumber { - if _alt == 1 { - { - p.SetState(42) - p.String_() - } - { - p.SetState(43) - p.Match(ConfigParserWHITESPACE) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - p.SetState(49) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 7, p.GetParserRuleContext()) - if p.HasError() { - goto errorExit - } - } - p.SetState(51) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == ConfigParserSTRING || _la == ConfigParserQUOTED_STRING { - { - p.SetState(50) - p.String_() - } - - } - p.SetState(54) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == ConfigParserWHITESPACE { - { - p.SetState(53) - p.Match(ConfigParserWHITESPACE) - 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 -} - -// ILeadingCommentContext is an interface to support dynamic dispatch. -type ILeadingCommentContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - HASH() antlr.TerminalNode - AllWHITESPACE() []antlr.TerminalNode - WHITESPACE(i int) antlr.TerminalNode - AllString_() []IStringContext - String_(i int) IStringContext - - // IsLeadingCommentContext differentiates from other interfaces. - IsLeadingCommentContext() -} - -type LeadingCommentContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyLeadingCommentContext() *LeadingCommentContext { - var p = new(LeadingCommentContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_leadingComment - return p -} - -func InitEmptyLeadingCommentContext(p *LeadingCommentContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_leadingComment -} - -func (*LeadingCommentContext) IsLeadingCommentContext() {} - -func NewLeadingCommentContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *LeadingCommentContext { - var p = new(LeadingCommentContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = ConfigParserRULE_leadingComment - - return p -} - -func (s *LeadingCommentContext) GetParser() antlr.Parser { return s.parser } - -func (s *LeadingCommentContext) HASH() antlr.TerminalNode { - return s.GetToken(ConfigParserHASH, 0) -} - -func (s *LeadingCommentContext) AllWHITESPACE() []antlr.TerminalNode { - return s.GetTokens(ConfigParserWHITESPACE) -} - -func (s *LeadingCommentContext) WHITESPACE(i int) antlr.TerminalNode { - return s.GetToken(ConfigParserWHITESPACE, i) -} - -func (s *LeadingCommentContext) AllString_() []IStringContext { - children := s.GetChildren() - len := 0 - for _, ctx := range children { - if _, ok := ctx.(IStringContext); ok { - len++ - } - } - - tst := make([]IStringContext, len) - i := 0 - for _, ctx := range children { - if t, ok := ctx.(IStringContext); ok { - tst[i] = t.(IStringContext) - i++ - } - } - - return tst -} - -func (s *LeadingCommentContext) String_(i int) IStringContext { - var t antlr.RuleContext - j := 0 - for _, ctx := range s.GetChildren() { - if _, ok := ctx.(IStringContext); ok { - if j == i { - t = ctx.(antlr.RuleContext) - break - } - j++ - } - } - - if t == nil { - return nil - } - - return t.(IStringContext) -} - -func (s *LeadingCommentContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *LeadingCommentContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *LeadingCommentContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.EnterLeadingComment(s) - } -} - -func (s *LeadingCommentContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.ExitLeadingComment(s) - } -} - -func (p *ConfigParser) LeadingComment() (localctx ILeadingCommentContext) { - localctx = NewLeadingCommentContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 10, ConfigParserRULE_leadingComment) - var _la int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(56) - p.Match(ConfigParserHASH) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - p.SetState(58) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == ConfigParserWHITESPACE { - { - p.SetState(57) - p.Match(ConfigParserWHITESPACE) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - p.SetState(64) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - for ok := true; ok; ok = _la == ConfigParserSTRING || _la == ConfigParserQUOTED_STRING { - { - p.SetState(60) - p.String_() - } - p.SetState(62) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - - if _la == ConfigParserWHITESPACE { - { - p.SetState(61) - p.Match(ConfigParserWHITESPACE) - if p.HasError() { - // Recognition error - abort rule - goto errorExit - } - } - - } - - p.SetState(66) - p.GetErrorHandler().Sync(p) - if p.HasError() { - goto errorExit - } - _la = p.GetTokenStream().LA(1) - } - -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 -} - -// IStringContext is an interface to support dynamic dispatch. -type IStringContext interface { - antlr.ParserRuleContext - - // GetParser returns the parser. - GetParser() antlr.Parser - - // Getter signatures - QUOTED_STRING() antlr.TerminalNode - STRING() antlr.TerminalNode - - // IsStringContext differentiates from other interfaces. - IsStringContext() -} - -type StringContext struct { - antlr.BaseParserRuleContext - parser antlr.Parser -} - -func NewEmptyStringContext() *StringContext { - var p = new(StringContext) - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_string - return p -} - -func InitEmptyStringContext(p *StringContext) { - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, nil, -1) - p.RuleIndex = ConfigParserRULE_string -} - -func (*StringContext) IsStringContext() {} - -func NewStringContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *StringContext { - var p = new(StringContext) - - antlr.InitBaseParserRuleContext(&p.BaseParserRuleContext, parent, invokingState) - - p.parser = parser - p.RuleIndex = ConfigParserRULE_string - - return p -} - -func (s *StringContext) GetParser() antlr.Parser { return s.parser } - -func (s *StringContext) QUOTED_STRING() antlr.TerminalNode { - return s.GetToken(ConfigParserQUOTED_STRING, 0) -} - -func (s *StringContext) STRING() antlr.TerminalNode { - return s.GetToken(ConfigParserSTRING, 0) -} - -func (s *StringContext) GetRuleContext() antlr.RuleContext { - return s -} - -func (s *StringContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string { - return antlr.TreesStringTree(s, ruleNames, recog) -} - -func (s *StringContext) EnterRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.EnterString(s) - } -} - -func (s *StringContext) ExitRule(listener antlr.ParseTreeListener) { - if listenerT, ok := listener.(ConfigListener); ok { - listenerT.ExitString(s) - } -} - -func (p *ConfigParser) String_() (localctx IStringContext) { - localctx = NewStringContext(p, p.GetParserRuleContext(), p.GetState()) - p.EnterRule(localctx, 12, ConfigParserRULE_string) - var _la int - - p.EnterOuterAlt(localctx, 1) - { - p.SetState(68) - _la = p.GetTokenStream().LA(1) - - if !(_la == ConfigParserSTRING || _la == ConfigParserQUOTED_STRING) { - p.GetErrorHandler().RecoverInline(p) - } else { - p.GetErrorHandler().ReportMatch(p) - p.Consume() - } - } - -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 -}