Collapse rules that contain only a single token
This commit is contained in:
parent
04d18b56ed
commit
0985fa3008
7 changed files with 70 additions and 61 deletions
|
|
@ -34,6 +34,25 @@ describe("preparing a grammar", []() {
|
|||
rules::character('b') }) }
|
||||
})));
|
||||
});
|
||||
|
||||
it("turns entire rules into tokens when they contain no symbols", [&]() {
|
||||
auto result = prepare_grammar(Grammar({
|
||||
{ "rule1", sym("rule2") },
|
||||
{ "rule2", seq({
|
||||
character('a'),
|
||||
character('b') }) }
|
||||
}));
|
||||
|
||||
AssertThat(result.first, Equals(Grammar({
|
||||
{ "rule1", sym("rule2") }
|
||||
})));
|
||||
|
||||
AssertThat(result.second, Equals(Grammar("", {
|
||||
{ "rule2", seq({
|
||||
character('a'),
|
||||
character('b') }) }
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
||||
END_TEST
|
||||
Loading…
Add table
Add a link
Reference in a new issue