/// <inheritdoc /> public List <ConfigValuePart> Parse(string text) { if (_logger.IsEnabled(LogLevel.Trace)) { _logger.LogTrace($"parsing: {text}"); } var errorListener = new AntlrErrorListener(_logger); var inputStream = new AntlrInputStream(text); var lexer = new ConfigReferenceLexer(inputStream); lexer.RemoveErrorListeners(); lexer.AddErrorListener(errorListener); var commonTokenStream = new CommonTokenStream(lexer); var parser = new ConfigReferenceParser(commonTokenStream); parser.RemoveErrorListeners(); parser.AddErrorListener(errorListener); parser.Context = parser.input(); var result = Visit(parser.Context)?.ToList() ?? new List <ConfigValuePart>(); return(result); }
public void LogSyntaxErrorBasic() { var loggerMock = new Mock <ILogger>(); var writerMock = new Mock <TextWriter>(); var recognizerMock = new Mock <IRecognizer>(); var charStreamMock = new Mock <ICharStream>(); var lexer = new ConfigReferenceLexer(charStreamMock.Object); var listener = new AntlrErrorListener(loggerMock.Object); listener.SyntaxError(writerMock.Object, recognizerMock.Object, 0, 4711, 42, "some message to write", new RecognitionException(lexer, charStreamMock.Object)); Assert.NotNull(listener); }