ruby_tree_sitter 2.0.0-arm-linux-musl → 2.1.0-arm-linux-musl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/tree_sitter/encoding.c +2 -1
- data/ext/tree_sitter/extconf.rb +19 -17
- data/ext/tree_sitter/language.c +23 -13
- data/ext/tree_sitter/parser.c +25 -33
- data/ext/tree_sitter/query_cursor.c +2 -7
- data/ext/tree_sitter/repo.rb +5 -5
- data/lib/tree_sitter/3.1/tree_sitter.so +0 -0
- data/lib/tree_sitter/3.2/tree_sitter.so +0 -0
- data/lib/tree_sitter/3.3/tree_sitter.so +0 -0
- data/lib/tree_sitter/3.4/tree_sitter.so +0 -0
- data/lib/tree_sitter/query.rb +1 -5
- data/lib/tree_sitter/version.rb +2 -2
- data/lib/tree_sitter.rb +0 -2
- data/tree_sitter.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c3a0fe927a84a092d5b6749707a9a2ee7887e67a67083af08b8a3f223882800
|
|
4
|
+
data.tar.gz: 3874947e51b0f1c6474c6e847e1414ad75e935235805cba07fa423a6bd10052f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e193d1c3c0559e0de0b55683f22898d4610c98164b5a4b2bb8d61ec91cac21af7ae0fe911d00f77765c37cf3aedb4ec8179e57171a76390931123876c527201
|
|
7
|
+
data.tar.gz: f73fb772c113f7b194758ee22b31f355d2070fa62bf4ebc163285518e3272304b9d0f0f912de7e2ba4866f1fecb47699a6917baa0d1655c65606cef91532bf5d
|
data/ext/tree_sitter/encoding.c
CHANGED
|
@@ -14,7 +14,8 @@ TSInputEncoding value_to_encoding(VALUE encoding) {
|
|
|
14
14
|
|
|
15
15
|
// NOTE: should we emit a warning instead of defaulting to UTF8?
|
|
16
16
|
if (enc == u16) {
|
|
17
|
-
|
|
17
|
+
// tree-sitter 0.26+ split UTF16 into UTF16LE and UTF16BE
|
|
18
|
+
return TSInputEncodingUTF16LE;
|
|
18
19
|
} else {
|
|
19
20
|
return TSInputEncodingUTF8;
|
|
20
21
|
}
|
data/ext/tree_sitter/extconf.rb
CHANGED
|
@@ -121,25 +121,27 @@ if sanitizers
|
|
|
121
121
|
$warnflags.gsub!(/#{r}/, '')
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
cflags.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
124
|
+
cflags.push(*
|
|
125
|
+
%W[
|
|
126
|
+
-fms-extensions
|
|
127
|
+
-fdeclspec
|
|
128
|
+
-fsanitize=#{sanitizers}
|
|
129
|
+
-fsanitize-blacklist=../../../../.asanignore
|
|
130
|
+
-fsanitize-recover=#{sanitizers}
|
|
131
|
+
-fno-sanitize-recover=all
|
|
132
|
+
-fno-sanitize=null
|
|
133
|
+
-fno-sanitize=alignment
|
|
134
|
+
-fno-omit-frame-pointer
|
|
135
|
+
])
|
|
136
|
+
|
|
137
|
+
ldflags.push(*
|
|
138
|
+
%W[
|
|
139
|
+
-fsanitize=#{sanitizers}
|
|
140
|
+
-dynamic-libasan
|
|
141
|
+
])
|
|
140
142
|
end
|
|
141
143
|
|
|
142
|
-
cflags.
|
|
144
|
+
cflags.push(*%w[-std=c99 -fPIC -Wall])
|
|
143
145
|
|
|
144
146
|
append_cflags(cflags)
|
|
145
147
|
append_ldflags(ldflags)
|
data/ext/tree_sitter/language.c
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
#include <stdint.h>
|
|
4
4
|
#include <stdio.h>
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// tree-sitter 0.26+ returns const TSLanguage*
|
|
7
|
+
typedef const TSLanguage *(tree_sitter_lang)(void);
|
|
7
8
|
const char *tree_sitter_prefix = "tree_sitter_";
|
|
8
9
|
|
|
9
10
|
extern VALUE mTreeSitter;
|
|
@@ -40,26 +41,32 @@ static VALUE language_load(VALUE self, VALUE name, VALUE path) {
|
|
|
40
41
|
VALUE path_s = rb_funcall(path, rb_intern("to_s"), 0);
|
|
41
42
|
char *path_cstr = StringValueCStr(path_s);
|
|
42
43
|
void *lib = dlopen(path_cstr, RTLD_NOW);
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (lib == NULL) {
|
|
45
|
+
const char *err = dlerror();
|
|
45
46
|
VALUE parser_not_found = rb_const_get(mTreeSitter, rb_intern("ParserNotFoundError"));
|
|
46
47
|
rb_raise(parser_not_found,
|
|
47
|
-
"Could not load shared library `%s'.\nReason: %s", path_cstr, err);
|
|
48
|
+
"Could not load shared library `%s'.\nReason: %s", path_cstr, err ? err : "unknown error");
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
VALUE symbol_name = rb_sprintf("tree_sitter_%s", StringValueCStr(name));
|
|
52
|
+
char *buf = StringValueCStr(symbol_name);
|
|
53
|
+
|
|
54
|
+
// Clear any previous error before dlsym (POSIX requirement)
|
|
55
|
+
dlerror();
|
|
56
|
+
|
|
52
57
|
tree_sitter_lang *make_ts_language = dlsym(lib, buf);
|
|
53
|
-
|
|
54
|
-
if
|
|
58
|
+
|
|
59
|
+
// Only check dlerror if dlsym returned NULL
|
|
60
|
+
if (make_ts_language == NULL) {
|
|
61
|
+
const char *err = dlerror();
|
|
55
62
|
dlclose(lib);
|
|
56
63
|
VALUE symbol_not_found = rb_const_get(mTreeSitter, rb_intern("SymbolNotFoundError"));
|
|
57
64
|
rb_raise(symbol_not_found,
|
|
58
|
-
"Could not load symbol `%s' from library `%s'.\nReason
|
|
59
|
-
|
|
65
|
+
"Could not load symbol `%s' from library `%s'.\nReason: %s",
|
|
66
|
+
buf, path_cstr, err ? err : "symbol not found");
|
|
60
67
|
}
|
|
61
68
|
|
|
62
|
-
TSLanguage *lang = make_ts_language();
|
|
69
|
+
const TSLanguage *lang = make_ts_language();
|
|
63
70
|
if (lang == NULL) {
|
|
64
71
|
dlclose(lib);
|
|
65
72
|
VALUE language_load_error = rb_const_get(mTreeSitter, rb_intern("LanguageLoadError"));
|
|
@@ -69,7 +76,8 @@ static VALUE language_load(VALUE self, VALUE name, VALUE path) {
|
|
|
69
76
|
StringValueCStr(name), path_cstr);
|
|
70
77
|
}
|
|
71
78
|
|
|
72
|
-
|
|
79
|
+
// tree-sitter 0.26+ renamed ts_language_version to ts_language_abi_version
|
|
80
|
+
uint32_t version = ts_language_abi_version(lang);
|
|
73
81
|
if (version < TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION) {
|
|
74
82
|
VALUE version_error = rb_const_get(mTreeSitter, rb_intern("ParserVersionError"));
|
|
75
83
|
rb_raise(version_error,
|
|
@@ -194,7 +202,8 @@ static VALUE language_symbol_type(VALUE self, VALUE symbol) {
|
|
|
194
202
|
* @see Parser#language=
|
|
195
203
|
*/
|
|
196
204
|
static VALUE language_version(VALUE self) {
|
|
197
|
-
|
|
205
|
+
// tree-sitter 0.26+ renamed ts_language_version to ts_language_abi_version
|
|
206
|
+
return UINT2NUM(ts_language_abi_version(SELF));
|
|
198
207
|
}
|
|
199
208
|
|
|
200
209
|
void init_language(void) {
|
|
@@ -220,4 +229,5 @@ void init_language(void) {
|
|
|
220
229
|
rb_define_method(cLanguage, "symbol_name", language_symbol_name, 1);
|
|
221
230
|
rb_define_method(cLanguage, "symbol_type", language_symbol_type, 1);
|
|
222
231
|
rb_define_method(cLanguage, "version", language_version, 0);
|
|
232
|
+
rb_define_method(cLanguage, "abi_version", language_version, 0);
|
|
223
233
|
}
|
data/ext/tree_sitter/parser.c
CHANGED
|
@@ -7,6 +7,7 @@ VALUE cParser;
|
|
|
7
7
|
typedef struct {
|
|
8
8
|
TSParser *data;
|
|
9
9
|
size_t cancellation_flag;
|
|
10
|
+
VALUE logger;
|
|
10
11
|
} parser_t;
|
|
11
12
|
|
|
12
13
|
static void parser_free(void *ptr) {
|
|
@@ -19,14 +20,24 @@ static size_t parser_memsize(const void *ptr) {
|
|
|
19
20
|
return sizeof(type);
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
static void parser_mark(void *ptr) {
|
|
24
|
+
parser_t *parser = (parser_t *)ptr;
|
|
25
|
+
rb_gc_mark_movable(parser->logger);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static void parser_compact(void *ptr) {
|
|
29
|
+
parser_t *parser = (parser_t *)ptr;
|
|
30
|
+
parser->logger = rb_gc_location(parser->logger);
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
const rb_data_type_t parser_data_type = {
|
|
23
34
|
.wrap_struct_name = "parser",
|
|
24
35
|
.function =
|
|
25
36
|
{
|
|
26
|
-
.dmark =
|
|
37
|
+
.dmark = parser_mark,
|
|
27
38
|
.dfree = parser_free,
|
|
28
39
|
.dsize = parser_memsize,
|
|
29
|
-
.dcompact =
|
|
40
|
+
.dcompact = parser_compact,
|
|
30
41
|
},
|
|
31
42
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
|
32
43
|
};
|
|
@@ -37,6 +48,7 @@ static VALUE parser_allocate(VALUE klass) {
|
|
|
37
48
|
parser_t *parser;
|
|
38
49
|
VALUE res = TypedData_Make_Struct(klass, parser_t, &parser_data_type, parser);
|
|
39
50
|
parser->data = ts_parser_new();
|
|
51
|
+
parser->logger = Qnil;
|
|
40
52
|
return res;
|
|
41
53
|
}
|
|
42
54
|
|
|
@@ -44,9 +56,14 @@ static VALUE parser_allocate(VALUE klass) {
|
|
|
44
56
|
* Get the parser's current cancellation flag pointer.
|
|
45
57
|
*
|
|
46
58
|
* @return [Integer]
|
|
59
|
+
*
|
|
60
|
+
* @note DEPRECATED in tree-sitter 0.26+. This API was removed.
|
|
61
|
+
* Use TSParseOptions with progress_callback instead.
|
|
47
62
|
*/
|
|
48
63
|
static VALUE parser_get_cancellation_flag(VALUE self) {
|
|
49
|
-
|
|
64
|
+
// tree-sitter 0.26+ removed cancellation_flag API
|
|
65
|
+
// Return the stored value for backward compatibility
|
|
66
|
+
return SIZET2NUM(unwrap(self)->cancellation_flag);
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
/**
|
|
@@ -58,13 +75,15 @@ static VALUE parser_get_cancellation_flag(VALUE self) {
|
|
|
58
75
|
*
|
|
59
76
|
* @see parse
|
|
60
77
|
*
|
|
61
|
-
* @note
|
|
78
|
+
* @note DEPRECATED in tree-sitter 0.26+. This API was removed.
|
|
79
|
+
* Use TSParseOptions with progress_callback instead.
|
|
62
80
|
*
|
|
63
81
|
* @return nil
|
|
64
82
|
*/
|
|
65
83
|
static VALUE parser_set_cancellation_flag(VALUE self, VALUE flag) {
|
|
84
|
+
// tree-sitter 0.26+ removed cancellation_flag API
|
|
85
|
+
// Store the value for backward compatibility but it won't affect parsing
|
|
66
86
|
unwrap(self)->cancellation_flag = NUM2SIZET(flag);
|
|
67
|
-
ts_parser_set_cancellation_flag(SELF, &unwrap(self)->cancellation_flag);
|
|
68
87
|
return Qnil;
|
|
69
88
|
}
|
|
70
89
|
|
|
@@ -171,6 +190,7 @@ static VALUE parser_get_logger(VALUE self) {
|
|
|
171
190
|
*/
|
|
172
191
|
static VALUE parser_set_logger(VALUE self, VALUE logger) {
|
|
173
192
|
ts_parser_set_logger(SELF, value_to_logger(logger));
|
|
193
|
+
unwrap(self)->logger = logger;
|
|
174
194
|
return Qnil;
|
|
175
195
|
}
|
|
176
196
|
|
|
@@ -345,32 +365,6 @@ static VALUE parser_reset(VALUE self) {
|
|
|
345
365
|
return Qnil;
|
|
346
366
|
}
|
|
347
367
|
|
|
348
|
-
/**
|
|
349
|
-
* Get the duration in microseconds that parsing is allowed to take.
|
|
350
|
-
*
|
|
351
|
-
* @return [Integer]
|
|
352
|
-
*/
|
|
353
|
-
static VALUE parser_get_timeout_micros(VALUE self) {
|
|
354
|
-
return ULL2NUM(ts_parser_timeout_micros(SELF));
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Set the maximum duration in microseconds that parsing should be allowed to
|
|
359
|
-
* take before halting.
|
|
360
|
-
*
|
|
361
|
-
* If parsing takes longer than this, it will halt early, returning +nil+.
|
|
362
|
-
*
|
|
363
|
-
* @see parse
|
|
364
|
-
*
|
|
365
|
-
* @param timeout [Integer]
|
|
366
|
-
*
|
|
367
|
-
* @return [nil]
|
|
368
|
-
*/
|
|
369
|
-
static VALUE parser_set_timeout_micros(VALUE self, VALUE timeout) {
|
|
370
|
-
ts_parser_set_timeout_micros(SELF, NUM2ULL(timeout));
|
|
371
|
-
return Qnil;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
368
|
void init_parser(void) {
|
|
375
369
|
cParser = rb_define_class_under(mTreeSitter, "Parser", rb_cObject);
|
|
376
370
|
|
|
@@ -393,6 +387,4 @@ void init_parser(void) {
|
|
|
393
387
|
parser_parse_string_encoding, 3);
|
|
394
388
|
rb_define_method(cParser, "print_dot_graphs", parser_print_dot_graphs, 1);
|
|
395
389
|
rb_define_method(cParser, "reset", parser_reset, 0);
|
|
396
|
-
rb_define_method(cParser, "timeout_micros", parser_get_timeout_micros, 0);
|
|
397
|
-
rb_define_method(cParser, "timeout_micros=", parser_set_timeout_micros, 1);
|
|
398
390
|
}
|
|
@@ -204,10 +204,9 @@ void init_query_cursor(void) {
|
|
|
204
204
|
|
|
205
205
|
rb_define_alloc_func(cQueryCursor, query_cursor_allocate);
|
|
206
206
|
|
|
207
|
-
/* Module methods */
|
|
208
|
-
rb_define_module_function(cQueryCursor, "exec", query_cursor_exec_static, 2);
|
|
209
|
-
|
|
210
207
|
/* Class methods */
|
|
208
|
+
rb_define_singleton_method(cQueryCursor, "exec", query_cursor_exec_static, 2);
|
|
209
|
+
|
|
211
210
|
// Accessors
|
|
212
211
|
DECLARE_ACCESSOR(cQueryCursor, query_cursor, match_limit)
|
|
213
212
|
|
|
@@ -215,10 +214,6 @@ void init_query_cursor(void) {
|
|
|
215
214
|
rb_define_method(cQueryCursor, "exec", query_cursor_exec, 2);
|
|
216
215
|
rb_define_method(cQueryCursor, "exceed_match_limit?",
|
|
217
216
|
query_cursor_did_exceed_match_limit, 0);
|
|
218
|
-
rb_define_method(cQueryCursor, "match_limit", query_cursor_get_match_limit,
|
|
219
|
-
0);
|
|
220
|
-
rb_define_method(cQueryCursor, "match_limit=", query_cursor_set_match_limit,
|
|
221
|
-
1);
|
|
222
217
|
rb_define_method(cQueryCursor,
|
|
223
218
|
"max_start_depth=", query_cursor_set_max_start_depth, 1);
|
|
224
219
|
rb_define_method(cQueryCursor, "next_capture", query_cursor_next_capture, 0);
|
data/ext/tree_sitter/repo.rb
CHANGED
|
@@ -39,7 +39,7 @@ module TreeSitter
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def extract?
|
|
42
|
-
|
|
42
|
+
exe.any? { |k, v| %i[tar zip].include?(k) && v }
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def download
|
|
@@ -50,7 +50,7 @@ module TreeSitter
|
|
|
50
50
|
%w[git curl wget].each do |cmd|
|
|
51
51
|
res =
|
|
52
52
|
if find_executable(cmd)
|
|
53
|
-
send("sources_from_#{cmd}")
|
|
53
|
+
send("sources_from_#{cmd}?")
|
|
54
54
|
else
|
|
55
55
|
false
|
|
56
56
|
end
|
|
@@ -76,7 +76,7 @@ module TreeSitter
|
|
|
76
76
|
MSG
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
def sources_from_curl
|
|
79
|
+
def sources_from_curl?
|
|
80
80
|
return false if !exe?(:curl) || !extract?
|
|
81
81
|
|
|
82
82
|
if exe?(:tar)
|
|
@@ -90,7 +90,7 @@ module TreeSitter
|
|
|
90
90
|
true
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
def sources_from_git
|
|
93
|
+
def sources_from_git?
|
|
94
94
|
return false if !exe?(:git)
|
|
95
95
|
|
|
96
96
|
sh <<~SHELL.chomp
|
|
@@ -104,7 +104,7 @@ module TreeSitter
|
|
|
104
104
|
true
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
-
def sources_from_wget
|
|
107
|
+
def sources_from_wget?
|
|
108
108
|
return false if !exe?(:wget) || !extract?
|
|
109
109
|
|
|
110
110
|
if exe?(:tar)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/tree_sitter/query.rb
CHANGED
|
@@ -45,11 +45,7 @@ module TreeSitter
|
|
|
45
45
|
pattern_count.times do |i| # rubocop:disable Metrics/BlockLength
|
|
46
46
|
predicate_steps = predicates_for_pattern(i)
|
|
47
47
|
byte_offset = start_byte_for_pattern(i)
|
|
48
|
-
row =
|
|
49
|
-
source.chars.map.with_index
|
|
50
|
-
.take_while { |_, i| i < byte_offset } # rubocop:disable Lint/ShadowingOuterLocalVariable
|
|
51
|
-
.filter { |c, _| c == "\n" }
|
|
52
|
-
.size
|
|
48
|
+
row = source[0...byte_offset].count("\n")
|
|
53
49
|
text_predicates = []
|
|
54
50
|
property_predicates = []
|
|
55
51
|
property_settings = []
|
data/lib/tree_sitter/version.rb
CHANGED
data/lib/tree_sitter.rb
CHANGED
data/tree_sitter.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib)
|
|
|
6
6
|
require 'tree_sitter/version'
|
|
7
7
|
|
|
8
8
|
Gem::Specification.new do |spec|
|
|
9
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 3.
|
|
9
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.2.0')
|
|
10
10
|
|
|
11
11
|
spec.authors = ['Firas al-Khalil', 'Derek Stride']
|
|
12
12
|
spec.email = ['firasalkhalil@gmail.com', 'derek@stride.host']
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_tree_sitter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: arm-linux-musl
|
|
6
6
|
authors:
|
|
7
7
|
- Firas al-Khalil
|
|
8
8
|
- Derek Stride
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: oppen
|
|
@@ -56,8 +56,8 @@ email:
|
|
|
56
56
|
- firasalkhalil@gmail.com
|
|
57
57
|
- derek@stride.host
|
|
58
58
|
executables:
|
|
59
|
-
- rbts
|
|
60
59
|
- print_matches
|
|
60
|
+
- rbts
|
|
61
61
|
extensions: []
|
|
62
62
|
extra_rdoc_files: []
|
|
63
63
|
files:
|
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
145
145
|
- !ruby/object:Gem::Version
|
|
146
146
|
version: 3.3.22
|
|
147
147
|
requirements: []
|
|
148
|
-
rubygems_version:
|
|
148
|
+
rubygems_version: 4.0.3
|
|
149
149
|
specification_version: 4
|
|
150
150
|
summary: Ruby bindings for Tree-Sitter
|
|
151
151
|
test_files: []
|