2017-07-14 10:42:01 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
#include "tree_sitter/runtime.h"
|
|
|
|
|
|
|
|
|
|
void test_log(void *payload, TSLogType type, const char *string) { }
|
|
|
|
|
|
|
|
|
|
TSLogger logger = {
|
|
|
|
|
.log = test_log,
|
|
|
|
|
};
|
|
|
|
|
|
2018-03-02 09:10:52 -08:00
|
|
|
extern "C" const TSLanguage *TS_LANG();
|
2017-07-14 10:42:01 -07:00
|
|
|
|
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
|
|
|
const char *str = reinterpret_cast<const char *>(data);
|
|
|
|
|
|
|
|
|
|
TSDocument *document = ts_document_new();
|
2018-03-02 09:10:52 -08:00
|
|
|
ts_document_set_language(document, TS_LANG());
|
2017-07-14 10:42:01 -07:00
|
|
|
ts_document_set_input_string_with_length(document, str, size);
|
|
|
|
|
|
|
|
|
|
TSParseOptions options = {};
|
2018-03-02 09:10:52 -08:00
|
|
|
options.halt_on_error = TS_HALT_ON_ERROR;
|
2017-07-14 10:42:01 -07:00
|
|
|
ts_document_parse_with_options(document, options);
|
|
|
|
|
|
|
|
|
|
TSNode root_node = ts_document_root_node(document);
|
|
|
|
|
ts_document_free(document);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|