Make ts_compile_grammar take an optional log file, start logging to it
This commit is contained in:
parent
69d8c6f5e6
commit
6fca8f2f4d
13 changed files with 164 additions and 25 deletions
|
|
@ -223,7 +223,7 @@ const TSLanguage *load_real_language(const string &language_name) {
|
|||
printf("\n" "Regenerating the %s parser...\n", language_name.c_str());
|
||||
|
||||
string grammar_json = read_file(grammar_filename);
|
||||
TSCompileResult result = ts_compile_grammar(grammar_json.c_str());
|
||||
TSCompileResult result = ts_compile_grammar(grammar_json.c_str(), nullptr);
|
||||
if (result.error_type != TSCompileErrorTypeNone) {
|
||||
fprintf(stderr, "Failed to compile %s grammar: %s\n", language_name.c_str(), result.error_message);
|
||||
return nullptr;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ for (auto &language_name : test_languages) {
|
|||
|
||||
if (file_exists(expected_error_path)) {
|
||||
it("fails with the correct error message", [&]() {
|
||||
TSCompileResult compile_result = ts_compile_grammar(grammar_json.c_str());
|
||||
TSCompileResult compile_result = ts_compile_grammar(grammar_json.c_str(), nullptr);
|
||||
string expected_error = read_file(expected_error_path);
|
||||
AssertThat((void *)compile_result.error_message, !Equals<void *>(nullptr));
|
||||
AssertThat(compile_result.error_message, Equals(expected_error));
|
||||
|
|
@ -43,7 +43,7 @@ for (auto &language_name : test_languages) {
|
|||
string external_scanner_path = join_path({directory_path, "scanner.c"});
|
||||
if (!file_exists(external_scanner_path)) external_scanner_path = "";
|
||||
|
||||
TSCompileResult compile_result = ts_compile_grammar(grammar_json.c_str());
|
||||
TSCompileResult compile_result = ts_compile_grammar(grammar_json.c_str(), nullptr);
|
||||
|
||||
language = load_test_language(
|
||||
language_name,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ describe("Language", []() {
|
|||
"value": "b"
|
||||
}
|
||||
}
|
||||
})JSON");
|
||||
})JSON", nullptr);
|
||||
|
||||
TSParser *parser = ts_parser_new();
|
||||
const TSLanguage *language = load_test_language("aliased_rules", compile_result);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ string grammar_with_aliases_and_extras = R"JSON({
|
|||
|
||||
const TSLanguage *language_with_aliases_and_extras = load_test_language(
|
||||
"aliases_and_extras",
|
||||
ts_compile_grammar(grammar_with_aliases_and_extras.c_str())
|
||||
ts_compile_grammar(grammar_with_aliases_and_extras.c_str(), nullptr)
|
||||
);
|
||||
|
||||
describe("Node", [&]() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue