tree-sitter/spec/compiler/build_tables/next_symbols_spec.cpp
2014-01-13 12:57:48 -08:00

38 lines
No EOL
872 B
C++

#include "spec_helper.h"
#include "build_tables/next_symbols.h"
#include "grammar.h"
#include "rules.h"
using std::set;
using namespace build_tables;
using namespace rules;
START_TEST
describe("computing FIRST sets", []() {
Grammar grammar({
{ "A", choice({
seq({
sym("B"),
sym("x"),
sym("B") }),
sym("B") }) },
{ "B", choice({
seq({
sym("y"),
sym("z"),
sym("y") }),
sym("y") }) },
});
describe("for a rule", [&]() {
it("searches the tree for terminals", [&]() {
auto terminals = next_terminals(grammar.rules.find("A")->second, grammar);
AssertThat(terminals, Equals(set<Symbol>({
Symbol("y")
})));
});
});
});
END_TEST