From 0f2347b3189503c768fc070a373d33407f9c4db6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 10 Jan 2019 15:22:39 -0800 Subject: [PATCH] Just call the C lib 'the library' everywhere, don't call it a 'runtime' --- lib/include/tree_sitter/{runtime.h => api.h} | 6 ++-- lib/include/tree_sitter/compiler.h | 38 -------------------- lib/include/tree_sitter/parser.h | 2 +- lib/src/alloc.h | 6 ++-- lib/src/array.h | 6 ++-- lib/src/atomic.h | 6 ++-- lib/src/error_costs.h | 4 +-- lib/src/get_changed_ranges.h | 6 ++-- lib/src/language.h | 6 ++-- lib/src/length.h | 6 ++-- lib/src/lexer.h | 8 ++--- lib/src/{runtime.c => lib.c} | 0 lib/src/parser.c | 2 +- lib/src/point.h | 6 ++-- lib/src/reduce_action.h | 8 ++--- lib/src/stack.h | 6 ++-- lib/src/subtree.h | 8 ++--- lib/src/tree.c | 2 +- lib/src/tree.h | 6 ++-- lib/src/tree_cursor.c | 2 +- lib/src/tree_cursor.h | 6 ++-- lib/src/utf16.h | 6 ++-- script/bindgen.sh | 2 +- script/{build-runtime => build-lib} | 2 +- test/fuzz/fuzzer.cc | 2 +- 25 files changed, 57 insertions(+), 95 deletions(-) rename lib/include/tree_sitter/{runtime.h => api.h} (98%) delete mode 100644 lib/include/tree_sitter/compiler.h rename lib/src/{runtime.c => lib.c} (100%) rename script/{build-runtime => build-lib} (93%) diff --git a/lib/include/tree_sitter/runtime.h b/lib/include/tree_sitter/api.h similarity index 98% rename from lib/include/tree_sitter/runtime.h rename to lib/include/tree_sitter/api.h index ab69a0b5..16841c8e 100644 --- a/lib/include/tree_sitter/runtime.h +++ b/lib/include/tree_sitter/api.h @@ -1,5 +1,5 @@ -#ifndef TREE_SITTER_RUNTIME_H_ -#define TREE_SITTER_RUNTIME_H_ +#ifndef TREE_SITTER_API_H_ +#define TREE_SITTER_API_H_ #ifdef __cplusplus extern "C" { @@ -153,4 +153,4 @@ uint32_t ts_language_version(const TSLanguage *); } #endif -#endif // TREE_SITTER_RUNTIME_H_ +#endif // TREE_SITTER_API_H_ diff --git a/lib/include/tree_sitter/compiler.h b/lib/include/tree_sitter/compiler.h deleted file mode 100644 index a84d8a75..00000000 --- a/lib/include/tree_sitter/compiler.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef TREE_SITTER_COMPILER_H_ -#define TREE_SITTER_COMPILER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef enum { - TSCompileErrorTypeNone, - TSCompileErrorTypeInvalidGrammar, - TSCompileErrorTypeInvalidRegex, - TSCompileErrorTypeUndefinedSymbol, - TSCompileErrorTypeInvalidExtraToken, - TSCompileErrorTypeInvalidExternalToken, - TSCompileErrorTypeLexConflict, - TSCompileErrorTypeParseConflict, - TSCompileErrorTypeEpsilonRule, - TSCompileErrorTypeInvalidTokenContents, - TSCompileErrorTypeInvalidRuleName, - TSCompileErrorTypeInvalidWordRule, -} TSCompileErrorType; - -typedef struct { - char *code; - char *error_message; - TSCompileErrorType error_type; -} TSCompileResult; - -TSCompileResult ts_compile_grammar(const char *input, FILE *log_file); -TSCompileResult ts_compile_property_sheet(const char *input, FILE *log_file); - -#ifdef __cplusplus -} -#endif - -#endif // TREE_SITTER_COMPILER_H_ diff --git a/lib/include/tree_sitter/parser.h b/lib/include/tree_sitter/parser.h index a757eac0..e5037062 100644 --- a/lib/include/tree_sitter/parser.h +++ b/lib/include/tree_sitter/parser.h @@ -13,7 +13,7 @@ extern "C" { #define ts_builtin_sym_end 0 #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 -#ifndef TREE_SITTER_RUNTIME_H_ +#ifndef TREE_SITTER_API_H_ typedef uint16_t TSSymbol; typedef struct TSLanguage TSLanguage; #endif diff --git a/lib/src/alloc.h b/lib/src/alloc.h index 6f3fa347..8e027a99 100644 --- a/lib/src/alloc.h +++ b/lib/src/alloc.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_ALLOC_H_ -#define RUNTIME_ALLOC_H_ +#ifndef TREE_SITTER_ALLOC_H_ +#define TREE_SITTER_ALLOC_H_ #ifdef __cplusplus extern "C" { @@ -82,4 +82,4 @@ static inline void ts_free(void *buffer) { } #endif -#endif // RUNTIME_ALLOC_H_ +#endif // TREE_SITTER_ALLOC_H_ diff --git a/lib/src/array.h b/lib/src/array.h index 3f5b6b29..04565f33 100644 --- a/lib/src/array.h +++ b/lib/src/array.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_ARRAY_H_ -#define RUNTIME_ARRAY_H_ +#ifndef TREE_SITTER_ARRAY_H_ +#define TREE_SITTER_ARRAY_H_ #ifdef __cplusplus extern "C" { @@ -132,4 +132,4 @@ static inline void array__splice(VoidArray *self, size_t element_size, } #endif -#endif // RUNTIME_ARRAY_H_ +#endif // TREE_SITTER_ARRAY_H_ diff --git a/lib/src/atomic.h b/lib/src/atomic.h index d1ab1f23..78a4d7d8 100644 --- a/lib/src/atomic.h +++ b/lib/src/atomic.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_ATOMIC_H_ -#define RUNTIME_ATOMIC_H_ +#ifndef TREE_SITTER_ATOMIC_H_ +#define TREE_SITTER_ATOMIC_H_ #include @@ -27,4 +27,4 @@ static inline uint32_t atomic_dec(volatile uint32_t *p) { #endif -#endif // RUNTIME_ATOMIC_H_ +#endif // TREE_SITTER_ATOMIC_H_ diff --git a/lib/src/error_costs.h b/lib/src/error_costs.h index d6420488..32d3666a 100644 --- a/lib/src/error_costs.h +++ b/lib/src/error_costs.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_ERROR_COSTS_H_ -#define RUNTIME_ERROR_COSTS_H_ +#ifndef TREE_SITTER_ERROR_COSTS_H_ +#define TREE_SITTER_ERROR_COSTS_H_ #define ERROR_STATE 0 #define ERROR_COST_PER_RECOVERY 500 diff --git a/lib/src/get_changed_ranges.h b/lib/src/get_changed_ranges.h index 2764b55f..a1f1dbb4 100644 --- a/lib/src/get_changed_ranges.h +++ b/lib/src/get_changed_ranges.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_GET_CHANGED_RANGES_H_ -#define RUNTIME_GET_CHANGED_RANGES_H_ +#ifndef TREE_SITTER_GET_CHANGED_RANGES_H_ +#define TREE_SITTER_GET_CHANGED_RANGES_H_ #ifdef __cplusplus extern "C" { @@ -33,4 +33,4 @@ unsigned ts_subtree_get_changed_ranges( } #endif -#endif // RUNTIME_GET_CHANGED_RANGES_H_ +#endif // TREE_SITTER_GET_CHANGED_RANGES_H_ diff --git a/lib/src/language.h b/lib/src/language.h index c8e5e8a1..0a0f108f 100644 --- a/lib/src/language.h +++ b/lib/src/language.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_LANGUAGE_H_ -#define RUNTIME_LANGUAGE_H_ +#ifndef TREE_SITTER_LANGUAGE_H_ +#define TREE_SITTER_LANGUAGE_H_ #ifdef __cplusplus extern "C" { @@ -91,4 +91,4 @@ ts_language_alias_sequence(const TSLanguage *self, unsigned id) { } #endif -#endif // RUNTIME_LANGUAGE_H_ +#endif // TREE_SITTER_LANGUAGE_H_ diff --git a/lib/src/length.h b/lib/src/length.h index db325f7a..ffe0c7f4 100644 --- a/lib/src/length.h +++ b/lib/src/length.h @@ -1,10 +1,10 @@ -#ifndef RUNTIME_LENGTH_H_ -#define RUNTIME_LENGTH_H_ +#ifndef TREE_SITTER_LENGTH_H_ +#define TREE_SITTER_LENGTH_H_ #include #include #include "./point.h" -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" typedef struct { uint32_t bytes; diff --git a/lib/src/lexer.h b/lib/src/lexer.h index 327350f6..f523d88f 100644 --- a/lib/src/lexer.h +++ b/lib/src/lexer.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_LEXER_H_ -#define RUNTIME_LEXER_H_ +#ifndef TREE_SITTER_LEXER_H_ +#define TREE_SITTER_LEXER_H_ #ifdef __cplusplus extern "C" { @@ -7,7 +7,7 @@ extern "C" { #include "./length.h" #include "./subtree.h" -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" #include "tree_sitter/parser.h" typedef struct { @@ -45,4 +45,4 @@ TSRange *ts_lexer_included_ranges(const Lexer *self, uint32_t *count); } #endif -#endif // RUNTIME_LEXER_H_ +#endif // TREE_SITTER_LEXER_H_ diff --git a/lib/src/runtime.c b/lib/src/lib.c similarity index 100% rename from lib/src/runtime.c rename to lib/src/lib.c diff --git a/lib/src/parser.c b/lib/src/parser.c index a33dbc6f..c2ebfeeb 100644 --- a/lib/src/parser.c +++ b/lib/src/parser.c @@ -2,7 +2,7 @@ #include #include #include -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" #include "./subtree.h" #include "./lexer.h" #include "./length.h" diff --git a/lib/src/point.h b/lib/src/point.h index 0c4941d5..4d0aed18 100644 --- a/lib/src/point.h +++ b/lib/src/point.h @@ -1,7 +1,7 @@ -#ifndef RUNTIME_POINT_H_ -#define RUNTIME_POINT_H_ +#ifndef TREE_SITTER_POINT_H_ +#define TREE_SITTER_POINT_H_ -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" #define POINT_MAX ((TSPoint) {UINT32_MAX, UINT32_MAX}) diff --git a/lib/src/reduce_action.h b/lib/src/reduce_action.h index 91835c39..5956fb5d 100644 --- a/lib/src/reduce_action.h +++ b/lib/src/reduce_action.h @@ -1,12 +1,12 @@ -#ifndef RUNTIME_REDUCE_ACTION_H_ -#define RUNTIME_REDUCE_ACTION_H_ +#ifndef TREE_SITTER_REDUCE_ACTION_H_ +#define TREE_SITTER_REDUCE_ACTION_H_ #ifdef __cplusplus extern "C" { #endif #include "./array.h" -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" typedef struct { uint32_t count; @@ -31,4 +31,4 @@ static inline void ts_reduce_action_set_add(ReduceActionSet *self, } #endif -#endif // RUNTIME_REDUCE_ACTION_H_ +#endif // TREE_SITTER_REDUCE_ACTION_H_ diff --git a/lib/src/stack.h b/lib/src/stack.h index d476d763..1ccd98cd 100644 --- a/lib/src/stack.h +++ b/lib/src/stack.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_PARSE_STACK_H_ -#define RUNTIME_PARSE_STACK_H_ +#ifndef TREE_SITTER_PARSE_STACK_H_ +#define TREE_SITTER_PARSE_STACK_H_ #ifdef __cplusplus extern "C" { @@ -132,4 +132,4 @@ void ts_stack_iterate(Stack *, StackVersion, StackIterateCallback, void *); } #endif -#endif // RUNTIME_PARSE_STACK_H_ +#endif // TREE_SITTER_PARSE_STACK_H_ diff --git a/lib/src/subtree.h b/lib/src/subtree.h index cc5c79aa..039494b5 100644 --- a/lib/src/subtree.h +++ b/lib/src/subtree.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_SUBTREE_H_ -#define RUNTIME_SUBTREE_H_ +#ifndef TREE_SITTER_SUBTREE_H_ +#define TREE_SITTER_SUBTREE_H_ #ifdef __cplusplus extern "C" { @@ -10,7 +10,7 @@ extern "C" { #include "./length.h" #include "./array.h" #include "./error_costs.h" -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" #include "tree_sitter/parser.h" extern TSStateId TS_TREE_STATE_NONE; @@ -285,4 +285,4 @@ static inline MutableSubtree ts_subtree_to_mut_unsafe(Subtree self) { } #endif -#endif // RUNTIME_SUBTREE_H_ +#endif // TREE_SITTER_SUBTREE_H_ diff --git a/lib/src/tree.c b/lib/src/tree.c index b729c8c7..9f294412 100644 --- a/lib/src/tree.c +++ b/lib/src/tree.c @@ -1,4 +1,4 @@ -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" #include "./array.h" #include "./get_changed_ranges.h" #include "./subtree.h" diff --git a/lib/src/tree.h b/lib/src/tree.h index dd4f3184..92a7e641 100644 --- a/lib/src/tree.h +++ b/lib/src/tree.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_TREE_H_ -#define RUNTIME_TREE_H_ +#ifndef TREE_SITTER_TREE_H_ +#define TREE_SITTER_TREE_H_ #ifdef __cplusplus extern "C" { @@ -31,4 +31,4 @@ void ts_tree_set_cached_parent(const TSTree *, const TSNode *, const TSNode *); } #endif -#endif // RUNTIME_TREE_H_ +#endif // TREE_SITTER_TREE_H_ diff --git a/lib/src/tree_cursor.c b/lib/src/tree_cursor.c index d352c32b..5ccf4501 100644 --- a/lib/src/tree_cursor.c +++ b/lib/src/tree_cursor.c @@ -1,4 +1,4 @@ -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" #include "./alloc.h" #include "./tree_cursor.h" #include "./language.h" diff --git a/lib/src/tree_cursor.h b/lib/src/tree_cursor.h index 6e46b7dd..55bdad86 100644 --- a/lib/src/tree_cursor.h +++ b/lib/src/tree_cursor.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_TREE_CURSOR_H_ -#define RUNTIME_TREE_CURSOR_H_ +#ifndef TREE_SITTER_TREE_CURSOR_H_ +#define TREE_SITTER_TREE_CURSOR_H_ #include "./subtree.h" @@ -17,4 +17,4 @@ typedef struct { void ts_tree_cursor_init(TreeCursor *, TSNode); -#endif // RUNTIME_TREE_CURSOR_H_ +#endif // TREE_SITTER_TREE_CURSOR_H_ diff --git a/lib/src/utf16.h b/lib/src/utf16.h index 0cf69218..32fd05e6 100644 --- a/lib/src/utf16.h +++ b/lib/src/utf16.h @@ -1,5 +1,5 @@ -#ifndef RUNTIME_UTF16_H_ -#define RUNTIME_UTF16_H_ +#ifndef TREE_SITTER_UTF16_H_ +#define TREE_SITTER_UTF16_H_ #ifdef __cplusplus extern "C" { @@ -18,4 +18,4 @@ utf8proc_ssize_t utf16_iterate(const utf8proc_uint8_t *, utf8proc_ssize_t, utf8p } #endif -#endif // RUNTIME_UTF16_H_ +#endif // TREE_SITTER_UTF16_H_ diff --git a/script/bindgen.sh b/script/bindgen.sh index 0a536d20..f9299095 100755 --- a/script/bindgen.sh +++ b/script/bindgen.sh @@ -1,7 +1,7 @@ #!/bin/bash output_path=lib/binding/bindings.rs -header_path='lib/include/tree_sitter/runtime.h' +header_path='lib/include/tree_sitter/api.h' bindgen \ --no-layout-tests \ diff --git a/script/build-runtime b/script/build-lib similarity index 93% rename from script/build-runtime rename to script/build-lib index 7b2e99f2..b81a4b0a 100755 --- a/script/build-runtime +++ b/script/build-lib @@ -14,7 +14,7 @@ ${CC} \ -I lib/src \ -I lib/include \ -I lib/utf8proc \ - lib/src/runtime.c \ + lib/src/lib.c \ -o tree-sitter.o ar rcs libtree-sitter.a tree-sitter.o diff --git a/test/fuzz/fuzzer.cc b/test/fuzz/fuzzer.cc index 2ed7683f..8d6f9cef 100644 --- a/test/fuzz/fuzzer.cc +++ b/test/fuzz/fuzzer.cc @@ -1,5 +1,5 @@ #include -#include "tree_sitter/runtime.h" +#include "tree_sitter/api.h" extern "C" const TSLanguage *TS_LANG();