2014-01-11 15:14:17 -08:00
|
|
|
#include "compile.h"
|
|
|
|
|
|
|
|
|
|
#include "grammar.h"
|
|
|
|
|
#include "prepare_grammar/perform.h"
|
|
|
|
|
#include "build_tables/perform.h"
|
|
|
|
|
#include "generate_code/c_code.h"
|
|
|
|
|
|
|
|
|
|
namespace tree_sitter {
|
2014-01-23 13:44:49 -08:00
|
|
|
std::string compile(const Grammar &grammar, std::string name) {
|
2014-01-11 15:14:17 -08:00
|
|
|
auto grammars = prepare_grammar::perform(grammar);
|
|
|
|
|
auto tables = build_tables::perform(grammars.first, grammars.second);
|
|
|
|
|
auto rule_names = grammars.first.rule_names();
|
|
|
|
|
auto token_names = grammars.second.rule_names();
|
|
|
|
|
rule_names.insert(rule_names.end(), token_names.begin(), token_names.end());
|
2014-01-23 13:44:49 -08:00
|
|
|
return generate_code::c_code(name, rule_names, tables.first, tables.second);
|
2014-01-11 15:14:17 -08:00
|
|
|
}
|
|
|
|
|
}
|