Don't store text on documents

This commit is contained in:
Max Brunsfeld 2014-02-20 18:38:31 -08:00
parent 6ed6aa05cc
commit ceee7eefd0
5 changed files with 21 additions and 13 deletions

View file

@ -3,7 +3,6 @@
struct ts_document {
ts_parse_fn *parse_fn;
const char **symbol_names;
const char *text;
ts_error error;
ts_tree *tree;
};
@ -12,6 +11,10 @@ ts_document * ts_document_make() {
return new ts_document();
}
void ts_document_free(ts_document *document) {
delete document;
}
void ts_document_set_parser(ts_document *document, ts_parse_config config) {
document->parse_fn = config.parse_fn;
document->symbol_names = config.symbol_names;
@ -19,7 +22,6 @@ void ts_document_set_parser(ts_document *document, ts_parse_config config) {
void ts_document_set_text(ts_document *document, const char *text) {
ts_parse_result result = document->parse_fn(text);
document->text = text;
document->tree = result.tree;
document->error = result.error;
}
@ -30,7 +32,7 @@ ts_tree * ts_document_tree(const ts_document *document) {
const char * ts_document_string(const ts_document *document) {
if (document->error.expected_inputs != NULL) {
return ts_error_string(&document->error, document->text, document->symbol_names);
return ts_error_string(&document->error);
} else {
return ts_tree_string(document->tree, document->symbol_names);
}