kanayago 0.8.1 → 0.9.0
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/CHANGELOG.md +11 -0
- data/ext/kanayago/kanayago.c +7 -1
- data/lib/kanayago/version.rb +1 -1
- data/patch/3.4.9/copy_target.rb +79 -0
- data/patch/3.4.9/kanayago.patch +228 -0
- data/patch/4.0.2/copy_target.rb +86 -0
- data/patch/4.0.2/kanayago.patch +300 -0
- data/patch/4.0.2/macos.patch +46 -0
- data/patch/4.0.3/copy_target.rb +86 -0
- data/patch/4.0.3/kanayago.patch +300 -0
- data/patch/4.0.3/macos.patch +46 -0
- data/patch/4.0.4/copy_target.rb +86 -0
- data/patch/4.0.4/kanayago.patch +300 -0
- data/patch/4.0.4/macos.patch +46 -0
- data/patch/head/copy_target.rb +1 -0
- data/patch/head/kanayago.patch +33 -0
- data/sample/rules/traversal.rb +3 -3
- metadata +128 -114
- data/ext/kanayago/parse.c.orig +0 -27403
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13db62f01cd9f9d5f618ed64debcecb103b4ed157653793553709c4cf909d15f
|
|
4
|
+
data.tar.gz: 688c25d026b36d28bdf389094c1b13f4df9a6f1e6b1945ec5878ed0c47fc52aa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87e13a17ad62be75939f68210dccdf906d62b6b18b07ce1298d0ab102f084f46ea24564a0e5cf9ff0d4d290bdff8aabd404bc70127dc19c7729938ad633a210b
|
|
7
|
+
data.tar.gz: 680bca7a5802860dd249821fd7ca2052ec0ad0de8c71a953bfb53cd64dfdd97671ecf0a47c929e57aafde3a52de613dc054b79f6fb0a267712b62117cd23b76d
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.0] - 2026-05-15
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Fix support Ruby version
|
|
14
|
+
- Support Ruby 3.4 or 4.0
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- Add support for Ruby 3.4.9
|
|
18
|
+
- Add support for Ruby 4.0.2, 4.0.3 and 4.0.4
|
|
19
|
+
- Add Ruby 3.4.9, 4.0.2, 4.0.3 and 4.0.4 to the CI test matrix
|
|
20
|
+
|
|
10
21
|
## [0.8.1] - 2026-03-06
|
|
11
22
|
|
|
12
23
|
### Fixed
|
data/ext/kanayago/kanayago.c
CHANGED
|
@@ -367,6 +367,12 @@ kanayago_gc_guard(VALUE obj)
|
|
|
367
367
|
RB_GC_GUARD(obj);
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
+
static void
|
|
371
|
+
kanayago_sized_xfree(void *ptr, size_t size)
|
|
372
|
+
{
|
|
373
|
+
ruby_sized_xfree(ptr, size);
|
|
374
|
+
}
|
|
375
|
+
|
|
370
376
|
static VALUE
|
|
371
377
|
kanayago_arg_error(void)
|
|
372
378
|
{
|
|
@@ -596,7 +602,7 @@ static const rb_parser_config_t kanayago_parser_config = {
|
|
|
596
602
|
.set_errinfo = rb_set_errinfo,
|
|
597
603
|
.make_exception = rb_make_exception,
|
|
598
604
|
|
|
599
|
-
.sized_xfree =
|
|
605
|
+
.sized_xfree = kanayago_sized_xfree,
|
|
600
606
|
.sized_realloc_n = ruby_sized_realloc_n,
|
|
601
607
|
.gc_guard = kanayago_gc_guard,
|
|
602
608
|
.gc_mark = rb_gc_mark,
|
data/lib/kanayago/version.rb
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RUBY_PARSER_COPY_TARGETS = %w[
|
|
4
|
+
ccan/check_type/check_type.h
|
|
5
|
+
ccan/container_of/container_of.h
|
|
6
|
+
ccan/list/list.h
|
|
7
|
+
ccan/str/str.h
|
|
8
|
+
constant.h
|
|
9
|
+
id.h
|
|
10
|
+
id_table.h
|
|
11
|
+
internal/array.h
|
|
12
|
+
internal/basic_operators.h
|
|
13
|
+
internal/bignum.h
|
|
14
|
+
internal/bits.h
|
|
15
|
+
internal/compile.h
|
|
16
|
+
internal/compilers.h
|
|
17
|
+
internal/complex.h
|
|
18
|
+
internal/encoding.h
|
|
19
|
+
internal/error.h
|
|
20
|
+
internal/fixnum.h
|
|
21
|
+
internal/gc.h
|
|
22
|
+
internal/hash.h
|
|
23
|
+
internal/imemo.h
|
|
24
|
+
internal/io.h
|
|
25
|
+
internal/numeric.h
|
|
26
|
+
internal/parse.h
|
|
27
|
+
internal/rational.h
|
|
28
|
+
internal/re.h
|
|
29
|
+
internal/ruby_parser.h
|
|
30
|
+
internal/sanitizers.h
|
|
31
|
+
internal/serial.h
|
|
32
|
+
internal/static_assert.h
|
|
33
|
+
internal/string.h
|
|
34
|
+
internal/symbol.h
|
|
35
|
+
internal/thread.h
|
|
36
|
+
internal/variable.h
|
|
37
|
+
internal/warnings.h
|
|
38
|
+
internal/vm.h
|
|
39
|
+
internal.h
|
|
40
|
+
lex.c
|
|
41
|
+
method.h
|
|
42
|
+
node.c
|
|
43
|
+
node.h
|
|
44
|
+
node_name.inc
|
|
45
|
+
parse.c
|
|
46
|
+
parse.h
|
|
47
|
+
parser_bits.h
|
|
48
|
+
parser_node.h
|
|
49
|
+
parser_st.c
|
|
50
|
+
parser_st.h
|
|
51
|
+
parser_value.h
|
|
52
|
+
ruby_assert.h
|
|
53
|
+
ruby_atomic.h
|
|
54
|
+
ruby_parser.c
|
|
55
|
+
rubyparser.h
|
|
56
|
+
shape.h
|
|
57
|
+
st.c
|
|
58
|
+
symbol.h
|
|
59
|
+
thread_pthread.h
|
|
60
|
+
thread_win32.h
|
|
61
|
+
universal_parser.c
|
|
62
|
+
vm_core.h
|
|
63
|
+
vm_opts.h
|
|
64
|
+
].freeze
|
|
65
|
+
|
|
66
|
+
MAKE_DIRECTORIES = [
|
|
67
|
+
'ccan',
|
|
68
|
+
'ccan/check_type',
|
|
69
|
+
'ccan/container',
|
|
70
|
+
'ccan/container_of',
|
|
71
|
+
'ccan/list',
|
|
72
|
+
'ccan/str',
|
|
73
|
+
'internal'
|
|
74
|
+
].freeze
|
|
75
|
+
|
|
76
|
+
DELETE_DIRECTORIES = %w[
|
|
77
|
+
ccan
|
|
78
|
+
internal
|
|
79
|
+
].freeze
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
diff -ruN a/ext/kanayago/internal/ruby_parser.h b/ext/kanayago/internal/ruby_parser.h
|
|
2
|
+
--- a/ext/kanayago/internal/ruby_parser.h 2025-12-17 19:50:40.592959132 +0900
|
|
3
|
+
+++ b/ext/kanayago/internal/ruby_parser.h 2025-12-17 19:50:40.592959132 +0900
|
|
4
|
+
@@ -10,11 +10,35 @@
|
|
5
|
+
#include "rubyparser.h"
|
|
6
|
+
#include "vm.h"
|
|
7
|
+
|
|
8
|
+
-struct lex_pointer_string {
|
|
9
|
+
+ struct lex_pointer_string {
|
|
10
|
+
VALUE str;
|
|
11
|
+
long ptr;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
+
|
|
15
|
+
+// Add Ruby's Parser struct and enum for Kanayago
|
|
16
|
+
+enum lex_type {
|
|
17
|
+
+ lex_type_str,
|
|
18
|
+
+ lex_type_io,
|
|
19
|
+
+ lex_type_array,
|
|
20
|
+
+ lex_type_generic,
|
|
21
|
+
+};
|
|
22
|
+
+
|
|
23
|
+
+struct ruby_parser {
|
|
24
|
+
+ rb_parser_t *parser_params;
|
|
25
|
+
+ enum lex_type type;
|
|
26
|
+
+ union {
|
|
27
|
+
+ struct lex_pointer_string lex_str;
|
|
28
|
+
+ struct {
|
|
29
|
+
+ VALUE file;
|
|
30
|
+
+ } lex_io;
|
|
31
|
+
+ struct {
|
|
32
|
+
+ VALUE ary;
|
|
33
|
+
+ } lex_array;
|
|
34
|
+
+ } data;
|
|
35
|
+
+};
|
|
36
|
+
+// End for Kanayago
|
|
37
|
+
+
|
|
38
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
|
39
|
+
#ifdef UNIVERSAL_PARSER
|
|
40
|
+
const rb_parser_config_t *rb_ruby_parser_config(void);
|
|
41
|
+
diff -ruN a/ext/kanayago/parse.c b/ext/kanayago/parse.c
|
|
42
|
+
--- a/ext/kanayago/parse.c 2025-12-17 19:50:40.592959132 +0900
|
|
43
|
+
+++ b/ext/kanayago/parse.c 2025-12-17 19:50:40.592959132 +0900
|
|
44
|
+
@@ -26941,6 +26941,16 @@
|
|
45
|
+
return p->value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
+#else /* !RIPPER */
|
|
49
|
+
+
|
|
50
|
+
+// Accessor function for error_buffer (for Kanayago)
|
|
51
|
+
+VALUE
|
|
52
|
+
+rb_ruby_parser_error_buffer_get(rb_parser_t *p)
|
|
53
|
+
+{
|
|
54
|
+
+ return p->error_buffer;
|
|
55
|
+
+}
|
|
56
|
+
+
|
|
57
|
+
+
|
|
58
|
+
#endif /* RIPPER */
|
|
59
|
+
/*
|
|
60
|
+
* Local variables:
|
|
61
|
+
diff -ruN a/ext/kanayago/ruby_parser.c b/ext/kanayago/ruby_parser.c
|
|
62
|
+
--- a/ext/kanayago/ruby_parser.c 2025-12-17 19:50:40.592959132 +0900
|
|
63
|
+
+++ b/ext/kanayago/ruby_parser.c 2025-12-17 19:50:40.592959132 +0900
|
|
64
|
+
@@ -326,6 +326,51 @@
|
|
65
|
+
|
|
66
|
+
extern VALUE rb_eArgError;
|
|
67
|
+
|
|
68
|
+
+// Add for Kanayago - wrapper functions to avoid unexported symbols
|
|
69
|
+
+static void *
|
|
70
|
+
+xmalloc_mul_add(size_t x, size_t y, size_t z)
|
|
71
|
+
+{
|
|
72
|
+
+ size_t size;
|
|
73
|
+
+ if (y != 0 && x > (SIZE_MAX - z) / y) {
|
|
74
|
+
+ rb_raise(rb_eArgError, "allocation size overflow");
|
|
75
|
+
+ }
|
|
76
|
+
+ size = x * y + z;
|
|
77
|
+
+ return ruby_xmalloc(size);
|
|
78
|
+
+}
|
|
79
|
+
+
|
|
80
|
+
+static VALUE
|
|
81
|
+
+suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
|
|
82
|
+
+{
|
|
83
|
+
+ return func(arg);
|
|
84
|
+
+}
|
|
85
|
+
+
|
|
86
|
+
+static ID
|
|
87
|
+
+make_temporary_id(size_t n)
|
|
88
|
+
+{
|
|
89
|
+
+ char buf[64];
|
|
90
|
+
+ snprintf(buf, sizeof(buf), "@kanayago_tmp_%zu", n);
|
|
91
|
+
+ return rb_intern(buf);
|
|
92
|
+
+}
|
|
93
|
+
+
|
|
94
|
+
+static int
|
|
95
|
+
+stderr_tty_p(void)
|
|
96
|
+
+{
|
|
97
|
+
+ return isatty(fileno(stderr));
|
|
98
|
+
+}
|
|
99
|
+
+
|
|
100
|
+
+static VALUE
|
|
101
|
+
+reg_compile(VALUE str, int options, const char *sourcefile, int sourceline)
|
|
102
|
+
+{
|
|
103
|
+
+ return rb_reg_new_str(str, options);
|
|
104
|
+
+}
|
|
105
|
+
+
|
|
106
|
+
+static VALUE
|
|
107
|
+
+reg_check_preprocess(VALUE val)
|
|
108
|
+
+{
|
|
109
|
+
+ return Qnil;
|
|
110
|
+
+}
|
|
111
|
+
+// End of Add for Kanayago
|
|
112
|
+
+
|
|
113
|
+
static const rb_parser_config_t rb_global_parser_config = {
|
|
114
|
+
.malloc = ruby_xmalloc,
|
|
115
|
+
.calloc = ruby_xcalloc,
|
|
116
|
+
@@ -337,9 +382,9 @@
|
|
117
|
+
.zalloc = zalloc,
|
|
118
|
+
.rb_memmove = memmove2,
|
|
119
|
+
.nonempty_memcpy = nonempty_memcpy,
|
|
120
|
+
- .xmalloc_mul_add = rb_xmalloc_mul_add,
|
|
121
|
+
+ .xmalloc_mul_add = xmalloc_mul_add,
|
|
122
|
+
|
|
123
|
+
- .compile_callback = rb_suppress_tracing,
|
|
124
|
+
+ .compile_callback = suppress_tracing,
|
|
125
|
+
.reg_named_capture_assign = reg_named_capture_assign,
|
|
126
|
+
|
|
127
|
+
.attr_get = rb_attr_get,
|
|
128
|
+
@@ -348,7 +393,7 @@
|
|
129
|
+
.ary_new_from_args = rb_ary_new_from_args,
|
|
130
|
+
.ary_unshift = rb_ary_unshift,
|
|
131
|
+
|
|
132
|
+
- .make_temporary_id = rb_make_temporary_id,
|
|
133
|
+
+ .make_temporary_id = make_temporary_id,
|
|
134
|
+
.is_local_id = is_local_id2,
|
|
135
|
+
.is_attrset_id = is_attrset_id2,
|
|
136
|
+
.is_global_name_punct = is_global_name_punct,
|
|
137
|
+
@@ -380,7 +425,7 @@
|
|
138
|
+
|
|
139
|
+
.int2num = rb_int2num_inline,
|
|
140
|
+
|
|
141
|
+
- .stderr_tty_p = rb_stderr_tty_p,
|
|
142
|
+
+ .stderr_tty_p = stderr_tty_p,
|
|
143
|
+
.write_error_str = rb_write_error_str,
|
|
144
|
+
.io_write = rb_io_write,
|
|
145
|
+
.io_flush = rb_io_flush,
|
|
146
|
+
@@ -430,8 +475,8 @@
|
|
147
|
+
.gc_guard = gc_guard,
|
|
148
|
+
.gc_mark = rb_gc_mark,
|
|
149
|
+
|
|
150
|
+
- .reg_compile = rb_reg_compile,
|
|
151
|
+
- .reg_check_preprocess = rb_reg_check_preprocess,
|
|
152
|
+
+ .reg_compile = reg_compile,
|
|
153
|
+
+ .reg_check_preprocess = reg_check_preprocess,
|
|
154
|
+
.memcicmp = rb_memcicmp,
|
|
155
|
+
|
|
156
|
+
.compile_warn = rb_compile_warn,
|
|
157
|
+
@@ -461,26 +506,6 @@
|
|
158
|
+
};
|
|
159
|
+
#endif
|
|
160
|
+
|
|
161
|
+
-enum lex_type {
|
|
162
|
+
- lex_type_str,
|
|
163
|
+
- lex_type_io,
|
|
164
|
+
- lex_type_array,
|
|
165
|
+
- lex_type_generic,
|
|
166
|
+
-};
|
|
167
|
+
-
|
|
168
|
+
-struct ruby_parser {
|
|
169
|
+
- rb_parser_t *parser_params;
|
|
170
|
+
- enum lex_type type;
|
|
171
|
+
- union {
|
|
172
|
+
- struct lex_pointer_string lex_str;
|
|
173
|
+
- struct {
|
|
174
|
+
- VALUE file;
|
|
175
|
+
- } lex_io;
|
|
176
|
+
- struct {
|
|
177
|
+
- VALUE ary;
|
|
178
|
+
- } lex_array;
|
|
179
|
+
- } data;
|
|
180
|
+
-};
|
|
181
|
+
|
|
182
|
+
static void
|
|
183
|
+
parser_mark(void *ptr)
|
|
184
|
+
@@ -519,7 +544,7 @@
|
|
185
|
+
return rb_ruby_parser_memsize(parser->parser_params);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
-static const rb_data_type_t ruby_parser_data_type = {
|
|
189
|
+
+const rb_data_type_t ruby_parser_data_type = {
|
|
190
|
+
"parser",
|
|
191
|
+
{
|
|
192
|
+
parser_mark,
|
|
193
|
+
@@ -891,7 +916,7 @@
|
|
194
|
+
VALUE
|
|
195
|
+
rb_str_new_parser_string(rb_parser_string_t *str)
|
|
196
|
+
{
|
|
197
|
+
- VALUE string = rb_enc_literal_str(str->ptr, str->len, str->enc);
|
|
198
|
+
+ VALUE string = rb_enc_str_new(str->ptr, str->len, str->enc);
|
|
199
|
+
rb_enc_str_coderange(string);
|
|
200
|
+
return string;
|
|
201
|
+
}
|
|
202
|
+
@@ -1073,7 +1098,7 @@
|
|
203
|
+
rb_parser_string_t *string = node_reg->string;
|
|
204
|
+
VALUE str = rb_enc_str_new(string->ptr, string->len, string->enc);
|
|
205
|
+
|
|
206
|
+
- return rb_reg_compile(str, node_reg->options, NULL, 0);
|
|
207
|
+
+ return rb_reg_new_str(str, node_reg->options);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
VALUE
|
|
211
|
+
|
|
212
|
+
diff --git a/ext/kanayago/universal_parser.c b/ext/kanayago/universal_parser.c
|
|
213
|
+
--- a/ext/kanayago/universal_parser.c
|
|
214
|
+
+++ b/ext/kanayago/universal_parser.c
|
|
215
|
+
@@ -1,4 +1,12 @@
|
|
216
|
+
-#include <alloca.h>
|
|
217
|
+
+#if defined(_WIN32)
|
|
218
|
+
+#include <malloc.h>
|
|
219
|
+
+#ifndef alloca
|
|
220
|
+
+#define alloca _alloca
|
|
221
|
+
+#endif
|
|
222
|
+
+#else
|
|
223
|
+
+#include <alloca.h>
|
|
224
|
+
+#endif
|
|
225
|
+
+
|
|
226
|
+
#include <string.h>
|
|
227
|
+
#include <stdarg.h>
|
|
228
|
+
#include <stdbool.h>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RUBY_PARSER_COPY_TARGETS = %w[
|
|
4
|
+
ccan/check_type/check_type.h
|
|
5
|
+
ccan/container_of/container_of.h
|
|
6
|
+
ccan/list/list.h
|
|
7
|
+
ccan/str/str.h
|
|
8
|
+
constant.h
|
|
9
|
+
id.h
|
|
10
|
+
id_table.h
|
|
11
|
+
include/ruby/st.h
|
|
12
|
+
internal/array.h
|
|
13
|
+
internal/basic_operators.h
|
|
14
|
+
internal/bignum.h
|
|
15
|
+
internal/bits.h
|
|
16
|
+
internal/box.h
|
|
17
|
+
internal/compile.h
|
|
18
|
+
internal/compilers.h
|
|
19
|
+
internal/complex.h
|
|
20
|
+
internal/encoding.h
|
|
21
|
+
internal/error.h
|
|
22
|
+
internal/fixnum.h
|
|
23
|
+
internal/gc.h
|
|
24
|
+
internal/hash.h
|
|
25
|
+
internal/imemo.h
|
|
26
|
+
internal/io.h
|
|
27
|
+
internal/namespace.h
|
|
28
|
+
internal/numeric.h
|
|
29
|
+
internal/parse.h
|
|
30
|
+
internal/rational.h
|
|
31
|
+
internal/re.h
|
|
32
|
+
internal/ruby_parser.h
|
|
33
|
+
internal/sanitizers.h
|
|
34
|
+
internal/serial.h
|
|
35
|
+
internal/set_table.h
|
|
36
|
+
internal/static_assert.h
|
|
37
|
+
internal/string.h
|
|
38
|
+
internal/symbol.h
|
|
39
|
+
internal/thread.h
|
|
40
|
+
internal/variable.h
|
|
41
|
+
internal/warnings.h
|
|
42
|
+
internal/vm.h
|
|
43
|
+
internal.h
|
|
44
|
+
lex.c
|
|
45
|
+
method.h
|
|
46
|
+
node.c
|
|
47
|
+
node.h
|
|
48
|
+
node_name.inc
|
|
49
|
+
parse.c
|
|
50
|
+
parse.h
|
|
51
|
+
parser_bits.h
|
|
52
|
+
parser_node.h
|
|
53
|
+
parser_st.c
|
|
54
|
+
parser_st.h
|
|
55
|
+
parser_value.h
|
|
56
|
+
ruby_assert.h
|
|
57
|
+
ruby_atomic.h
|
|
58
|
+
ruby_parser.c
|
|
59
|
+
rubyparser.h
|
|
60
|
+
shape.h
|
|
61
|
+
st.c
|
|
62
|
+
symbol.h
|
|
63
|
+
thread_pthread.h
|
|
64
|
+
thread_win32.h
|
|
65
|
+
universal_parser.c
|
|
66
|
+
vm_core.h
|
|
67
|
+
vm_opts.h
|
|
68
|
+
].freeze
|
|
69
|
+
|
|
70
|
+
MAKE_DIRECTORIES = [
|
|
71
|
+
'ccan',
|
|
72
|
+
'ccan/check_type',
|
|
73
|
+
'ccan/container',
|
|
74
|
+
'ccan/container_of',
|
|
75
|
+
'ccan/list',
|
|
76
|
+
'ccan/str',
|
|
77
|
+
'internal',
|
|
78
|
+
'include',
|
|
79
|
+
'include/ruby'
|
|
80
|
+
].freeze
|
|
81
|
+
|
|
82
|
+
DELETE_DIRECTORIES = %w[
|
|
83
|
+
ccan
|
|
84
|
+
internal
|
|
85
|
+
include
|
|
86
|
+
].freeze
|