Skip to content

Commit

Permalink
fluent : test lexer post processing
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Dec 23, 2024
1 parent f9aaac9 commit a58cc84
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/ParserTests/FluentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,19 @@ public void TestFluentSubNodeNames()
.IgnoreKeywordCase(true)
.AlphaNumDashId(FluentToken.ID)
.Date(FluentToken.DATE, DateFormat.YYYYMMDD, '-')
.AlphaNumDashId(FluentToken.ID);
.AlphaNumDashId(FluentToken.ID)
.UseLexerPostProcessor(tokens =>
{
return tokens.Select<Token<FluentToken>, Token<FluentToken>>(x =>
{
if (x.TokenID == FluentToken.ID)
{
x.SpanValue = x.Value.ToUpper().AsMemory();
}

return x;
}).ToList();
});

var build = FluentEBNFParserBuilder<FluentToken, string>.NewBuilder(new FluentTests(), "root", "en")
.Production("root : (l 'SEP'[d] r)*", args =>
Expand All @@ -433,7 +445,7 @@ public void TestFluentSubNodeNames()
Check.That(build).IsOk();
var parsed = build.Result.Parse("a SEP b c SEP d ");
Check.That(parsed).IsOkParsing();
Check.That(parsed.Result).IsEqualTo("a|b,c|d");
Check.That(parsed.Result).IsEqualTo("A|B,C|D");
var tree = parsed.SyntaxTree as SyntaxNode<FluentToken, string>;
Check.That(tree).IsNotNull();
Check.That(tree.Children).IsSingle();
Expand Down

0 comments on commit a58cc84

Please sign in to comment.