diff --git a/src/sly/lexer/LexerBuilder.cs b/src/sly/lexer/LexerBuilder.cs index 560c1b8c..6a05dd67 100644 --- a/src/sly/lexer/LexerBuilder.cs +++ b/src/sly/lexer/LexerBuilder.cs @@ -175,7 +175,7 @@ private static BuildResult> Build(Dictionary(attributes, result); + result = BuildRegexLexer(attributes, lang, result); } } else if (hasGenericLexemes) @@ -240,10 +240,15 @@ private static bool IsGenericLexer(Dictionary lex } - private static BuildResult> BuildRegexLexer(Dictionary lexemes,List labels)> attributes, + private static BuildResult> BuildRegexLexer( + Dictionary lexemes, List labels)> attributes, + string lang, BuildResult> result) where IN : struct { - var lexer = new Lexer(); + var lexer = new Lexer() + { + I18n = lang + }; foreach (var pair in attributes) { var tokenID = pair.Key; diff --git a/tests/ParserTests/ErrorTests.cs b/tests/ParserTests/ErrorTests.cs index 880bed75..c0a82f96 100644 --- a/tests/ParserTests/ErrorTests.cs +++ b/tests/ParserTests/ErrorTests.cs @@ -110,7 +110,7 @@ public void TestLexicalError() { var exprParser = new ExpressionParser(); - var builder = new ParserBuilder(); + var builder = new ParserBuilder("en"); var Parser = builder.BuildParser(exprParser, ParserType.LL_RECURSIVE_DESCENT, "root").Result; var r = Parser.Parse("2 @ 2"); Check.That(r.IsError).IsTrue(); @@ -120,6 +120,7 @@ public void TestLexicalError() Check.That(error.Line).IsEqualTo(1); Check.That(error.Column).IsEqualTo(3); Check.That(error.UnexpectedChar).IsEqualTo('@'); + Check.That(error.ErrorMessage).IsEqualTo("Lexical Error, line 1, column 3 : Unrecognized symbol '@' (64)"); } } } \ No newline at end of file