Skip to content

Commit a58cc84

Browse files
committed
fluent : test lexer post processing
1 parent f9aaac9 commit a58cc84

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tests/ParserTests/FluentTests.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,19 @@ public void TestFluentSubNodeNames()
410410
.IgnoreKeywordCase(true)
411411
.AlphaNumDashId(FluentToken.ID)
412412
.Date(FluentToken.DATE, DateFormat.YYYYMMDD, '-')
413-
.AlphaNumDashId(FluentToken.ID);
413+
.AlphaNumDashId(FluentToken.ID)
414+
.UseLexerPostProcessor(tokens =>
415+
{
416+
return tokens.Select<Token<FluentToken>, Token<FluentToken>>(x =>
417+
{
418+
if (x.TokenID == FluentToken.ID)
419+
{
420+
x.SpanValue = x.Value.ToUpper().AsMemory();
421+
}
422+
423+
return x;
424+
}).ToList();
425+
});
414426

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

0 commit comments

Comments
 (0)