Reorganize runtime header files
This commit is contained in:
parent
fb1ef60f7d
commit
dbbb446082
12 changed files with 77 additions and 103 deletions
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef __tree_sitter_document_h__
|
||||
#define __tree_sitter_document_h__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./tree.h"
|
||||
#include "./parse_config.h"
|
||||
|
||||
typedef struct TSDocument TSDocument;
|
||||
|
||||
TSDocument * TSDocumentMake();
|
||||
void TSDocumentSetUp(TSDocument *document, TSParseConfig config);
|
||||
void TSDocumentSetText(TSDocument *document, const char *text);
|
||||
TSTree * TSDocumentTree(const TSDocument *document);
|
||||
const char * TSDocumentToString(const TSDocument *document);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef __tree_sitter_parse_config_h__
|
||||
#define __tree_sitter_parse_config_h__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tree.h"
|
||||
|
||||
typedef struct {
|
||||
const char **expected_inputs;
|
||||
size_t expected_input_count;
|
||||
size_t position;
|
||||
long lookahead_sym;
|
||||
} TSParseError;
|
||||
|
||||
const char * TSParseErrorToString(const TSParseError *error, const char *input_string, const char **symbol_names);
|
||||
|
||||
typedef struct {
|
||||
TSParseError error;
|
||||
TSTree *tree;
|
||||
} TSParseResult;
|
||||
|
||||
typedef TSParseResult TSParseFn(const char *);
|
||||
|
||||
typedef struct {
|
||||
TSParseFn *parse_fn;
|
||||
const char **symbol_names;
|
||||
} TSParseConfig;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef __tree_sitter_parser_h__
|
||||
#define __tree_sitter_parser_h__
|
||||
#ifndef tree_sitter_parser_h
|
||||
#define tree_sitter_parser_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tree.h"
|
||||
#include "parse_config.h"
|
||||
#include "runtime.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
#else
|
||||
#define DEBUG_PARSE(...)
|
||||
#endif
|
||||
|
||||
|
||||
static int INITIAL_STACK_SIZE = 100;
|
||||
static const char *ts_symbol_names[];
|
||||
|
||||
|
|
@ -220,4 +220,5 @@ done:
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
59
include/runtime.h
Normal file
59
include/runtime.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#ifndef tree_sitter_runtime_h
|
||||
#define tree_sitter_runtime_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
const char **expected_inputs;
|
||||
size_t expected_input_count;
|
||||
size_t position;
|
||||
long lookahead_sym;
|
||||
} TSParseError;
|
||||
|
||||
const char * TSParseErrorToString(const TSParseError *error, const char *input_string, const char **symbol_names);
|
||||
|
||||
typedef size_t TSSymbol;
|
||||
|
||||
typedef struct TSTree {
|
||||
TSSymbol value;
|
||||
struct TSTree **children;
|
||||
size_t child_count;
|
||||
size_t ref_count;
|
||||
} TSTree;
|
||||
|
||||
TSTree * TSTreeMake(TSSymbol value, size_t child_count, TSTree **children);
|
||||
void TSTreeRetain(TSTree *tree);
|
||||
void TSTreeRelease(TSTree *tree);
|
||||
int TSTreeEquals(const TSTree *tree1, const TSTree *tree2);
|
||||
char * TSTreeToString(const TSTree *tree, const char **names);
|
||||
|
||||
typedef struct {
|
||||
TSParseError error;
|
||||
TSTree *tree;
|
||||
} TSParseResult;
|
||||
|
||||
typedef TSParseResult TSParseFn(const char *);
|
||||
|
||||
typedef struct {
|
||||
TSParseFn *parse_fn;
|
||||
const char **symbol_names;
|
||||
} TSParseConfig;
|
||||
|
||||
typedef struct TSDocument TSDocument;
|
||||
|
||||
TSDocument * TSDocumentMake();
|
||||
void TSDocumentSetUp(TSDocument *document, TSParseConfig config);
|
||||
void TSDocumentSetText(TSDocument *document, const char *text);
|
||||
TSTree * TSDocumentTree(const TSDocument *document);
|
||||
const char * TSDocumentToString(const TSDocument *document);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef __tree_sitter_tree_h__
|
||||
#define __tree_sitter_tree_h__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef size_t TSSymbol;
|
||||
typedef struct TSTree {
|
||||
TSSymbol value;
|
||||
struct TSTree **children;
|
||||
size_t child_count;
|
||||
size_t ref_count;
|
||||
} TSTree;
|
||||
|
||||
TSTree * TSTreeMake(TSSymbol value, size_t child_count, TSTree **children);
|
||||
void TSTreeRetain(TSTree *tree);
|
||||
void TSTreeRelease(TSTree *tree);
|
||||
|
||||
int TSTreeEquals(const TSTree *tree1, const TSTree *tree2);
|
||||
char * TSTreeToString(const TSTree *tree, const char **names);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#include "spec_helper.h"
|
||||
#include "document.h"
|
||||
#include "runtime.h"
|
||||
|
||||
extern TSParseConfig ts_parse_config_arithmetic;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "spec_helper.h"
|
||||
#include "document.h"
|
||||
#include "runtime.h"
|
||||
|
||||
extern TSParseConfig ts_parse_config_json;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "spec_helper.h"
|
||||
#include "tree.h"
|
||||
#include "runtime.h"
|
||||
|
||||
START_TEST
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "document.h"
|
||||
#include "runtime.h"
|
||||
|
||||
struct TSDocument {
|
||||
TSParseFn *parse_fn;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "parse_config.h"
|
||||
#include "runtime.h"
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "tree.h"
|
||||
#include "runtime.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
127528B518AACB70006B682B /* rule_can_be_blank_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 127528B418AACB70006B682B /* rule_can_be_blank_spec.cpp */; };
|
||||
12AB465F188BD03E00DE79DF /* follow_sets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12AB465D188BD03E00DE79DF /* follow_sets.cpp */; };
|
||||
12AB4661188CB3A300DE79DF /* item_set_closure_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12AB4660188CB3A300DE79DF /* item_set_closure_spec.cpp */; };
|
||||
12BC470518822B27005AC502 /* parse_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12BC470318822A17005AC502 /* parse_config.cpp */; };
|
||||
12BC470518822B27005AC502 /* error.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12BC470318822A17005AC502 /* error.cpp */; };
|
||||
12BC470718830BC5005AC502 /* first_set_spec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12BC470618830BC5005AC502 /* first_set_spec.cpp */; };
|
||||
12D136A4183678A2005F3369 /* repeat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12D136A2183678A2005F3369 /* repeat.cpp */; };
|
||||
12E75A971891BD32001B8F10 /* json.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12E75A961891BD32001B8F10 /* json.cpp */; };
|
||||
|
|
@ -107,11 +107,12 @@
|
|||
127528B118AACAAA006B682B /* rule_can_be_blank.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rule_can_be_blank.cpp; sourceTree = "<group>"; };
|
||||
127528B218AACAAA006B682B /* rule_can_be_blank.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rule_can_be_blank.h; sourceTree = "<group>"; };
|
||||
127528B418AACB70006B682B /* rule_can_be_blank_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rule_can_be_blank_spec.cpp; sourceTree = "<group>"; };
|
||||
127528B918B041B6006B682B /* runtime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = runtime.h; sourceTree = "<group>"; };
|
||||
12AB465D188BD03E00DE79DF /* follow_sets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = follow_sets.cpp; sourceTree = "<group>"; };
|
||||
12AB465E188BD03E00DE79DF /* follow_sets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = follow_sets.h; sourceTree = "<group>"; };
|
||||
12AB4660188CB3A300DE79DF /* item_set_closure_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = item_set_closure_spec.cpp; sourceTree = "<group>"; };
|
||||
12AB4663188DCB9800DE79DF /* stream_methods.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stream_methods.h; sourceTree = "<group>"; };
|
||||
12BC470318822A17005AC502 /* parse_config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_config.cpp; sourceTree = "<group>"; };
|
||||
12BC470318822A17005AC502 /* error.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = error.cpp; sourceTree = "<group>"; };
|
||||
12BC470618830BC5005AC502 /* first_set_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = first_set_spec.cpp; sourceTree = "<group>"; };
|
||||
12D1369E18342088005F3369 /* todo.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = todo.md; sourceTree = "<group>"; };
|
||||
12D136A0183570F5005F3369 /* pattern_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pattern_spec.cpp; path = spec/compiler/rules/pattern_spec.cpp; sourceTree = SOURCE_ROOT; };
|
||||
|
|
@ -125,9 +126,7 @@
|
|||
12E75AA018930931001B8F10 /* expand_repeats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = expand_repeats.cpp; path = src/compiler/prepare_grammar/expand_repeats.cpp; sourceTree = SOURCE_ROOT; };
|
||||
12E75AA118930931001B8F10 /* expand_repeats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = expand_repeats.h; path = src/compiler/prepare_grammar/expand_repeats.h; sourceTree = SOURCE_ROOT; };
|
||||
12EDCF89187B498C005A7A07 /* tree_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tree_spec.cpp; sourceTree = "<group>"; };
|
||||
12EDCF8B187C6251005A7A07 /* document.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = document.h; sourceTree = "<group>"; };
|
||||
12EDCF8C187C6282005A7A07 /* document.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = document.c; sourceTree = "<group>"; };
|
||||
12EDCF8E187DB33E005A7A07 /* parse_config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = parse_config.h; sourceTree = "<group>"; };
|
||||
12EDCF8F1881FCCA005A7A07 /* extract_tokens.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = extract_tokens.cpp; path = src/compiler/prepare_grammar/extract_tokens.cpp; sourceTree = SOURCE_ROOT; };
|
||||
12EDCF901881FCCA005A7A07 /* extract_tokens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = extract_tokens.h; path = src/compiler/prepare_grammar/extract_tokens.h; sourceTree = SOURCE_ROOT; };
|
||||
12EDCF911881FCCA005A7A07 /* perform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = perform.cpp; path = src/compiler/prepare_grammar/perform.cpp; sourceTree = SOURCE_ROOT; };
|
||||
|
|
@ -162,7 +161,6 @@
|
|||
12FD4063185E75290041A84E /* compile_fixtures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = compile_fixtures.cpp; path = spec/compiler/compile_fixtures.cpp; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
12FD4065185E7C2F0041A84E /* arithmetic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = arithmetic.c; path = spec/fixtures/parsers/arithmetic.c; sourceTree = SOURCE_ROOT; };
|
||||
12FD40D1185EEB5E0041A84E /* runtime_specs */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = runtime_specs; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
12FD40D4185FED9A0041A84E /* tree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = "<group>"; };
|
||||
12FD40DA185FEF0D0041A84E /* arithmetic_spec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = arithmetic_spec.cpp; sourceTree = "<group>"; };
|
||||
12FD40DE1860064C0041A84E /* tree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tree.c; sourceTree = "<group>"; };
|
||||
12FD40E41862B3530041A84E /* visitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = visitor.h; sourceTree = "<group>"; };
|
||||
|
|
@ -386,7 +384,7 @@
|
|||
children = (
|
||||
12FD40DE1860064C0041A84E /* tree.c */,
|
||||
12EDCF8C187C6282005A7A07 /* document.c */,
|
||||
12BC470318822A17005AC502 /* parse_config.cpp */,
|
||||
12BC470318822A17005AC502 /* error.cpp */,
|
||||
);
|
||||
path = runtime;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -424,10 +422,8 @@
|
|||
12FD40D3185FED630041A84E /* include */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
12FD40D4185FED9A0041A84E /* tree.h */,
|
||||
121D8B3018795CC0003CF44B /* parser.h */,
|
||||
12EDCF8B187C6251005A7A07 /* document.h */,
|
||||
12EDCF8E187DB33E005A7A07 /* parse_config.h */,
|
||||
127528B918B041B6006B682B /* runtime.h */,
|
||||
);
|
||||
path = include;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -557,7 +553,7 @@
|
|||
12E75A9C1891C17D001B8F10 /* json_spec.cpp in Sources */,
|
||||
12FD40DB185FEF0D0041A84E /* arithmetic_spec.cpp in Sources */,
|
||||
12FD40C2185EEB5E0041A84E /* main.cpp in Sources */,
|
||||
12BC470518822B27005AC502 /* parse_config.cpp in Sources */,
|
||||
12BC470518822B27005AC502 /* error.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue