Put rule transitions in LR namespace
This commit is contained in:
parent
656f6b0819
commit
30315a78d2
10 changed files with 177 additions and 144 deletions
|
|
@ -5,14 +5,27 @@ using namespace tree_sitter::lr;
|
|||
START_TEST
|
||||
|
||||
describe("items", []() {
|
||||
Grammar grammar = test_grammars::arithmetic();
|
||||
|
||||
describe("transitions", [&]() {
|
||||
describe("construction", [&]() {
|
||||
it("finds the item at the start of a rule", [&]() {
|
||||
Grammar grammar = test_grammars::arithmetic();
|
||||
Item item = Item::at_beginning_of_rule("expression", grammar);
|
||||
AssertThat(item, Equals(Item("expression", grammar.rule("expression"), 0)));
|
||||
});
|
||||
});
|
||||
|
||||
describe("transitions", [&]() {
|
||||
it("computes the possible advancements", [&]() {
|
||||
auto char1 = rules::character('a');
|
||||
auto char2 = rules::character('b');
|
||||
Item item = Item("my-rule", rules::seq({ char1, char2 }), 2);
|
||||
|
||||
AssertThat(
|
||||
item.transitions(),
|
||||
Equals(transition_map<rules::Rule, Item>({
|
||||
{ char1, make_shared<Item>("my-rule", char2, 3) }
|
||||
})));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
END_TEST
|
||||
Loading…
Add table
Add a link
Reference in a new issue