prism 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/Makefile +6 -0
- data/README.md +1 -1
- data/config.yml +50 -35
- data/docs/fuzzing.md +1 -1
- data/docs/serialization.md +28 -29
- data/ext/prism/api_node.c +802 -770
- data/ext/prism/api_pack.c +20 -9
- data/ext/prism/extension.c +464 -162
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +3173 -763
- data/include/prism/defines.h +32 -9
- data/include/prism/diagnostic.h +36 -3
- data/include/prism/enc/pm_encoding.h +118 -28
- data/include/prism/node.h +38 -13
- data/include/prism/options.h +204 -0
- data/include/prism/pack.h +44 -33
- data/include/prism/parser.h +445 -200
- data/include/prism/prettyprint.h +12 -1
- data/include/prism/regexp.h +16 -2
- data/include/prism/util/pm_buffer.h +94 -16
- data/include/prism/util/pm_char.h +162 -48
- data/include/prism/util/pm_constant_pool.h +126 -32
- data/include/prism/util/pm_list.h +68 -38
- data/include/prism/util/pm_memchr.h +18 -3
- data/include/prism/util/pm_newline_list.h +70 -27
- data/include/prism/util/pm_state_stack.h +25 -7
- data/include/prism/util/pm_string.h +115 -27
- data/include/prism/util/pm_string_list.h +25 -6
- data/include/prism/util/pm_strncasecmp.h +32 -0
- data/include/prism/util/pm_strpbrk.h +31 -17
- data/include/prism/version.h +27 -2
- data/include/prism.h +224 -31
- data/lib/prism/compiler.rb +6 -3
- data/lib/prism/debug.rb +23 -7
- data/lib/prism/dispatcher.rb +33 -18
- data/lib/prism/dsl.rb +10 -5
- data/lib/prism/ffi.rb +132 -80
- data/lib/prism/lex_compat.rb +25 -15
- data/lib/prism/mutation_compiler.rb +10 -5
- data/lib/prism/node.rb +370 -135
- data/lib/prism/node_ext.rb +1 -1
- data/lib/prism/node_inspector.rb +1 -1
- data/lib/prism/pack.rb +79 -40
- data/lib/prism/parse_result/comments.rb +7 -2
- data/lib/prism/parse_result/newlines.rb +4 -0
- data/lib/prism/parse_result.rb +150 -30
- data/lib/prism/pattern.rb +11 -0
- data/lib/prism/ripper_compat.rb +28 -10
- data/lib/prism/serialize.rb +86 -54
- data/lib/prism/visitor.rb +10 -3
- data/lib/prism.rb +20 -2
- data/prism.gemspec +4 -2
- data/rbi/prism.rbi +104 -60
- data/rbi/prism_static.rbi +16 -2
- data/sig/prism.rbs +72 -43
- data/sig/prism_static.rbs +14 -1
- data/src/diagnostic.c +56 -53
- data/src/enc/pm_big5.c +1 -0
- data/src/enc/pm_euc_jp.c +1 -0
- data/src/enc/pm_gbk.c +1 -0
- data/src/enc/pm_shift_jis.c +1 -0
- data/src/enc/pm_tables.c +316 -80
- data/src/enc/pm_unicode.c +53 -8
- data/src/enc/pm_windows_31j.c +1 -0
- data/src/node.c +334 -321
- data/src/options.c +170 -0
- data/src/prettyprint.c +74 -47
- data/src/prism.c +1642 -856
- data/src/regexp.c +151 -95
- data/src/serialize.c +44 -20
- data/src/token_type.c +3 -1
- data/src/util/pm_buffer.c +45 -15
- data/src/util/pm_char.c +103 -57
- data/src/util/pm_constant_pool.c +51 -21
- data/src/util/pm_list.c +12 -4
- data/src/util/pm_memchr.c +5 -3
- data/src/util/pm_newline_list.c +20 -12
- data/src/util/pm_state_stack.c +9 -3
- data/src/util/pm_string.c +95 -85
- data/src/util/pm_string_list.c +14 -15
- data/src/util/pm_strncasecmp.c +10 -3
- data/src/util/pm_strpbrk.c +25 -19
- metadata +5 -3
- data/docs/prism.png +0 -0
data/ext/prism/api_pack.c
CHANGED
@@ -164,6 +164,12 @@ pack_encoding_to_ruby(pm_pack_encoding encoding) {
|
|
164
164
|
return rb_enc_from_encoding(rb_enc_from_index(index));
|
165
165
|
}
|
166
166
|
|
167
|
+
/**
|
168
|
+
* call-seq:
|
169
|
+
* Pack::parse(version, variant, source) -> Format
|
170
|
+
*
|
171
|
+
* Parse the given source and return a format object.
|
172
|
+
*/
|
167
173
|
static VALUE
|
168
174
|
pack_parse(VALUE self, VALUE version_symbol, VALUE variant_symbol, VALUE format_string) {
|
169
175
|
if (version_symbol != v3_2_0_symbol) {
|
@@ -223,15 +229,17 @@ pack_parse(VALUE self, VALUE version_symbol, VALUE variant_symbol, VALUE format_
|
|
223
229
|
break;
|
224
230
|
}
|
225
231
|
|
226
|
-
VALUE directive_args[9] = {
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
232
|
+
VALUE directive_args[9] = {
|
233
|
+
version_symbol,
|
234
|
+
variant_symbol,
|
235
|
+
rb_usascii_str_new(directive_start, directive_end - directive_start),
|
236
|
+
pack_type_to_symbol(type),
|
237
|
+
pack_signed_to_symbol(signed_type),
|
238
|
+
pack_endian_to_symbol(endian),
|
239
|
+
pack_size_to_symbol(size),
|
240
|
+
pack_length_type_to_symbol(length_type),
|
241
|
+
UINT64T2NUM(length)
|
242
|
+
};
|
235
243
|
|
236
244
|
rb_ary_push(directives_array, rb_class_new_instance(9, directive_args, rb_cPrismPackDirective));
|
237
245
|
}
|
@@ -242,6 +250,9 @@ pack_parse(VALUE self, VALUE version_symbol, VALUE variant_symbol, VALUE format_
|
|
242
250
|
return rb_class_new_instance(2, format_args, rb_cPrismPackFormat);
|
243
251
|
}
|
244
252
|
|
253
|
+
/**
|
254
|
+
* The function that gets called when Ruby initializes the prism extension.
|
255
|
+
*/
|
245
256
|
void
|
246
257
|
Init_prism_pack(void) {
|
247
258
|
rb_cPrism = rb_define_module("Prism");
|