deps: update tree-sitter-cli

pull/874/head
Stephan Seitz 2025-03-15 19:12:10 +07:00 committed by Stephan Seitz
parent dfe57db650
commit 57a7c14f4f
9 changed files with 84950 additions and 85344 deletions

@ -7,6 +7,9 @@ fn main() {
.flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable") .flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs"); .flag_if_supported("-Wno-trigraphs");
#[cfg(target_env = "msvc")]
c_config.flag("-utf-8");
let parser_path = src_dir.join("parser.c"); let parser_path = src_dir.join("parser.c");
c_config.file(&parser_path); c_config.file(&parser_path);

13
package-lock.json generated

@ -15,11 +15,11 @@
}, },
"devDependencies": { "devDependencies": {
"prebuildify": "^6.0.0", "prebuildify": "^6.0.0",
"tree-sitter-cli": "^0.20.8", "tree-sitter-cli": "^0.24.4",
"tree-sitter-clojure": "git@github.com:theHamsta/tree-sitter-clojure.git#commonlisp" "tree-sitter-clojure": "git@github.com:theHamsta/tree-sitter-clojure.git#commonlisp"
}, },
"peerDependencies": { "peerDependencies": {
"tree-sitter": "^0.21.0" "tree-sitter": "^0.21.1"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"tree_sitter": { "tree_sitter": {
@ -357,13 +357,16 @@
} }
}, },
"node_modules/tree-sitter-cli": { "node_modules/tree-sitter-cli": {
"version": "0.20.8", "version": "0.24.7",
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.8.tgz", "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.24.7.tgz",
"integrity": "sha512-XjTcS3wdTy/2cc/ptMLc/WRyOLECRYcMTrSWyhZnj1oGSOWbHLTklgsgRICU3cPfb0vy+oZCC33M43u6R1HSCA==", "integrity": "sha512-o4gnE82pVmMMhJbWwD6+I9yr4lXii5Ci5qEQ2pFpUbVy1YiD8cizTJaqdcznA0qEbo7l2OneI1GocChPrI4YGQ==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"bin": { "bin": {
"tree-sitter": "cli.js" "tree-sitter": "cli.js"
},
"engines": {
"node": ">=12.0.0"
} }
}, },
"node_modules/tree-sitter-clojure": { "node_modules/tree-sitter-clojure": {

@ -24,7 +24,7 @@
"node-gyp-build": "^4.8.0" "node-gyp-build": "^4.8.0"
}, },
"peerDependencies": { "peerDependencies": {
"tree-sitter": "^0.21.0" "tree-sitter": "^0.21.1"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"tree_sitter": { "tree_sitter": {
@ -36,7 +36,7 @@
"url": "git://github.com/theHamsta/tree-sitter-commonlisp" "url": "git://github.com/theHamsta/tree-sitter-commonlisp"
}, },
"devDependencies": { "devDependencies": {
"tree-sitter-cli": "^0.20.8", "tree-sitter-cli": "^0.24.4",
"tree-sitter-clojure": "git@github.com:theHamsta/tree-sitter-clojure.git#commonlisp", "tree-sitter-clojure": "git@github.com:theHamsta/tree-sitter-clojure.git#commonlisp",
"prebuildify": "^6.0.0" "prebuildify": "^6.0.0"
}, },

3
src/grammar.json generated

@ -1,5 +1,7 @@
{ {
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
"name": "commonlisp", "name": "commonlisp",
"inherits": "clojure",
"rules": { "rules": {
"source": { "source": {
"type": "REPEAT", "type": "REPEAT",
@ -4468,4 +4470,3 @@
"inline": [], "inline": [],
"supertypes": [] "supertypes": []
} }

22
src/node-types.json generated

@ -131,11 +131,6 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "auto_res_mark",
"named": true,
"fields": {}
},
{ {
"type": "char_lit", "type": "char_lit",
"named": true, "named": true,
@ -2923,6 +2918,7 @@
{ {
"type": "source", "type": "source",
"named": true, "named": true,
"root": true,
"fields": { "fields": {
"open": { "open": {
"multiple": true, "multiple": true,
@ -4524,10 +4520,6 @@
"type": "#", "type": "#",
"named": false "named": false
}, },
{
"type": "##",
"named": false
},
{ {
"type": "#'", "type": "#'",
"named": false "named": false
@ -4548,10 +4540,6 @@
"type": "#0a", "type": "#0a",
"named": false "named": false
}, },
{
"type": "#=",
"named": false
},
{ {
"type": "#?", "type": "#?",
"named": false "named": false
@ -4664,14 +4652,6 @@
"type": "V", "type": "V",
"named": false "named": false
}, },
{
"type": "[",
"named": false
},
{
"type": "]",
"named": false
},
{ {
"type": "^", "type": "^",
"named": false "named": false

170170
src/parser.c generated

File diff suppressed because it is too large Load Diff

@ -12,10 +12,10 @@ extern "C" {
// Allow clients to override allocation functions // Allow clients to override allocation functions
#ifdef TREE_SITTER_REUSE_ALLOCATOR #ifdef TREE_SITTER_REUSE_ALLOCATOR
extern void *(*ts_current_malloc)(size_t); extern void *(*ts_current_malloc)(size_t size);
extern void *(*ts_current_calloc)(size_t, size_t); extern void *(*ts_current_calloc)(size_t count, size_t size);
extern void *(*ts_current_realloc)(void *, size_t); extern void *(*ts_current_realloc)(void *ptr, size_t size);
extern void (*ts_current_free)(void *); extern void (*ts_current_free)(void *ptr);
#ifndef ts_malloc #ifndef ts_malloc
#define ts_malloc ts_current_malloc #define ts_malloc ts_current_malloc

@ -14,6 +14,7 @@ extern "C" {
#include <string.h> #include <string.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4101) #pragma warning(disable : 4101)
#elif defined(__GNUC__) || defined(__clang__) #elif defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -278,7 +279,7 @@ static inline void _array__splice(Array *self, size_t element_size,
#define _compare_int(a, b) ((int)*(a) - (int)(b)) #define _compare_int(a, b) ((int)*(a) - (int)(b))
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(default : 4101) #pragma warning(pop)
#elif defined(__GNUC__) || defined(__clang__) #elif defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif

@ -13,9 +13,8 @@ extern "C" {
#define ts_builtin_sym_end 0 #define ts_builtin_sym_end 0
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
typedef uint16_t TSStateId;
#ifndef TREE_SITTER_API_H_ #ifndef TREE_SITTER_API_H_
typedef uint16_t TSStateId;
typedef uint16_t TSSymbol; typedef uint16_t TSSymbol;
typedef uint16_t TSFieldId; typedef uint16_t TSFieldId;
typedef struct TSLanguage TSLanguage; typedef struct TSLanguage TSLanguage;
@ -48,6 +47,7 @@ struct TSLexer {
uint32_t (*get_column)(TSLexer *); uint32_t (*get_column)(TSLexer *);
bool (*is_at_included_range_start)(const TSLexer *); bool (*is_at_included_range_start)(const TSLexer *);
bool (*eof)(const TSLexer *); bool (*eof)(const TSLexer *);
void (*log)(const TSLexer *, const char *, ...);
}; };
typedef enum { typedef enum {
@ -87,6 +87,11 @@ typedef union {
} entry; } entry;
} TSParseActionEntry; } TSParseActionEntry;
typedef struct {
int32_t start;
int32_t end;
} TSCharacterRange;
struct TSLanguage { struct TSLanguage {
uint32_t version; uint32_t version;
uint32_t symbol_count; uint32_t symbol_count;
@ -126,13 +131,38 @@ struct TSLanguage {
const TSStateId *primary_state_ids; const TSStateId *primary_state_ids;
}; };
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
uint32_t index = 0;
uint32_t size = len - index;
while (size > 1) {
uint32_t half_size = size / 2;
uint32_t mid_index = index + half_size;
TSCharacterRange *range = &ranges[mid_index];
if (lookahead >= range->start && lookahead <= range->end) {
return true;
} else if (lookahead > range->end) {
index = mid_index;
}
size -= half_size;
}
TSCharacterRange *range = &ranges[index];
return (lookahead >= range->start && lookahead <= range->end);
}
/* /*
* Lexer Macros * Lexer Macros
*/ */
#ifdef _MSC_VER
#define UNUSED __pragma(warning(suppress : 4101))
#else
#define UNUSED __attribute__((unused))
#endif
#define START_LEXER() \ #define START_LEXER() \
bool result = false; \ bool result = false; \
bool skip = false; \ bool skip = false; \
UNUSED \
bool eof = false; \ bool eof = false; \
int32_t lookahead; \ int32_t lookahead; \
goto start; \ goto start; \
@ -148,6 +178,17 @@ struct TSLanguage {
goto next_state; \ goto next_state; \
} }
#define ADVANCE_MAP(...) \
{ \
static const uint16_t map[] = { __VA_ARGS__ }; \
for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \
if (map[i] == lookahead) { \
state = map[i + 1]; \
goto next_state; \
} \
} \
}
#define SKIP(state_value) \ #define SKIP(state_value) \
{ \ { \
skip = true; \ skip = true; \
@ -166,7 +207,7 @@ struct TSLanguage {
* Parse Table Macros * Parse Table Macros
*/ */
#define SMALL_STATE(id) id - LARGE_STATE_COUNT #define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)
#define STATE(id) id #define STATE(id) id
@ -176,7 +217,7 @@ struct TSLanguage {
{{ \ {{ \
.shift = { \ .shift = { \
.type = TSParseActionTypeShift, \ .type = TSParseActionTypeShift, \
.state = state_value \ .state = (state_value) \
} \ } \
}} }}
@ -184,7 +225,7 @@ struct TSLanguage {
{{ \ {{ \
.shift = { \ .shift = { \
.type = TSParseActionTypeShift, \ .type = TSParseActionTypeShift, \
.state = state_value, \ .state = (state_value), \
.repetition = true \ .repetition = true \
} \ } \
}} }}
@ -197,14 +238,15 @@ struct TSLanguage {
} \ } \
}} }}
#define REDUCE(symbol_val, child_count_val, ...) \ #define REDUCE(symbol_name, children, precedence, prod_id) \
{{ \ {{ \
.reduce = { \ .reduce = { \
.type = TSParseActionTypeReduce, \ .type = TSParseActionTypeReduce, \
.symbol = symbol_val, \ .symbol = symbol_name, \
.child_count = child_count_val, \ .child_count = children, \
__VA_ARGS__ \ .dynamic_precedence = precedence, \
}, \ .production_id = prod_id \
}, \
}} }}
#define RECOVER() \ #define RECOVER() \