Update runtime code naming
Also, add macros so that code generator doesn't need to know about any runtime variables names or types
This commit is contained in:
parent
1b56832cb7
commit
6ed6aa05cc
11 changed files with 579 additions and 575 deletions
|
|
@ -1,37 +1,37 @@
|
|||
#include "tree_sitter/runtime.h"
|
||||
|
||||
struct TSDocument {
|
||||
TSParseFn *parse_fn;
|
||||
struct ts_document {
|
||||
ts_parse_fn *parse_fn;
|
||||
const char **symbol_names;
|
||||
const char *text;
|
||||
TSParseError error;
|
||||
TSTree *tree;
|
||||
ts_error error;
|
||||
ts_tree *tree;
|
||||
};
|
||||
|
||||
TSDocument * TSDocumentMake() {
|
||||
return new TSDocument();
|
||||
ts_document * ts_document_make() {
|
||||
return new ts_document();
|
||||
}
|
||||
|
||||
void TSDocumentSetUp(TSDocument *document, TSParseConfig config) {
|
||||
void ts_document_set_parser(ts_document *document, ts_parse_config config) {
|
||||
document->parse_fn = config.parse_fn;
|
||||
document->symbol_names = config.symbol_names;
|
||||
}
|
||||
|
||||
void TSDocumentSetText(TSDocument *document, const char *text) {
|
||||
TSParseResult result = document->parse_fn(text);
|
||||
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;
|
||||
}
|
||||
|
||||
TSTree * TSDocumentTree(const TSDocument *document) {
|
||||
ts_tree * ts_document_tree(const ts_document *document) {
|
||||
return document->tree;
|
||||
}
|
||||
|
||||
const char * TSDocumentToString(const TSDocument *document) {
|
||||
const char * ts_document_string(const ts_document *document) {
|
||||
if (document->error.expected_inputs != NULL) {
|
||||
return TSParseErrorToString(&document->error, document->text, document->symbol_names);
|
||||
return ts_error_string(&document->error, document->text, document->symbol_names);
|
||||
} else {
|
||||
return TSTreeToString(document->tree, document->symbol_names);
|
||||
return ts_tree_string(document->tree, document->symbol_names);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue