-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
using sly.lexer; | ||
|
||
namespace ParserTests.Issue527; | ||
|
||
public enum Issue527Lexer | ||
{ | ||
[Keyword("a")] | ||
A = 1, | ||
|
||
[Keyword("b")] | ||
B = 2, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,38 @@ | ||
using NFluent; | ||
using sly.parser; | ||
using sly.parser.generator; | ||
using Xunit; | ||
|
||
namespace ParserTests.Issue527; | ||
|
||
public class Issue527Test | ||
{ | ||
|
||
private Parser<Issue527Lexer, string> BuildParser() | ||
{ | ||
var builder = new ParserBuilder<Issue527Lexer, string>("en"); | ||
var result = builder.BuildParser(new Issue527Parser(), ParserType.EBNF_LL_RECURSIVE_DESCENT,"root"); | ||
Check.That(result).IsOk(); | ||
return result.Result; | ||
} | ||
|
||
[Fact] | ||
public void Issue527Test_OK_with_ParseWithoutContext() | ||
{ | ||
var parser = BuildParser(); | ||
var result = parser.Parse("a a b"); | ||
Check.That(result).IsOkParsing(); | ||
Check.That(result.Result).IsEqualTo("any(a,a) and boo(b)"); | ||
} | ||
|
||
[Fact] | ||
public void Issue527Test_KO_with_ParseWithContext() | ||
{ | ||
var parser = BuildParser(); | ||
var lexed = parser.Lexer.Tokenize("a a b"); | ||
Check.That(lexed).IsOkLexing(); | ||
var result = parser.ParseWithContext(lexed.Tokens.MainTokens()); | ||
Check.That(result).IsOkParsing(); | ||
Check.That(result.Result).IsEqualTo("any(a,a) and boo(b)"); | ||
} | ||
} |