prism 0.18.0 → 0.19.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 +31 -1
- data/README.md +2 -1
- data/config.yml +188 -55
- data/docs/building.md +9 -2
- data/docs/configuration.md +10 -9
- data/docs/encoding.md +24 -56
- data/docs/local_variable_depth.md +229 -0
- data/docs/ruby_api.md +2 -0
- data/docs/serialization.md +18 -13
- data/ext/prism/api_node.c +337 -195
- data/ext/prism/extconf.rb +13 -7
- data/ext/prism/extension.c +96 -32
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +340 -137
- data/include/prism/defines.h +17 -0
- data/include/prism/diagnostic.h +11 -5
- data/include/prism/encoding.h +248 -0
- data/include/prism/options.h +2 -2
- data/include/prism/parser.h +62 -42
- data/include/prism/regexp.h +2 -2
- data/include/prism/util/pm_buffer.h +9 -1
- data/include/prism/util/pm_memchr.h +2 -2
- data/include/prism/util/pm_strpbrk.h +3 -3
- data/include/prism/version.h +2 -2
- data/include/prism.h +13 -15
- data/lib/prism/compiler.rb +12 -0
- data/lib/prism/debug.rb +9 -4
- data/lib/prism/desugar_compiler.rb +3 -3
- data/lib/prism/dispatcher.rb +56 -0
- data/lib/prism/dot_visitor.rb +476 -198
- data/lib/prism/dsl.rb +66 -46
- data/lib/prism/ffi.rb +16 -3
- data/lib/prism/lex_compat.rb +19 -9
- data/lib/prism/mutation_compiler.rb +20 -0
- data/lib/prism/node.rb +1173 -450
- data/lib/prism/node_ext.rb +41 -16
- data/lib/prism/parse_result.rb +12 -15
- data/lib/prism/ripper_compat.rb +49 -34
- data/lib/prism/serialize.rb +242 -212
- data/lib/prism/visitor.rb +12 -0
- data/lib/prism.rb +20 -4
- data/prism.gemspec +4 -10
- data/rbi/prism.rbi +605 -230
- data/rbi/prism_static.rbi +3 -0
- data/sig/prism.rbs +379 -124
- data/sig/prism_static.rbs +1 -0
- data/src/diagnostic.c +228 -222
- data/src/encoding.c +5137 -0
- data/src/node.c +66 -0
- data/src/options.c +21 -2
- data/src/prettyprint.c +806 -406
- data/src/prism.c +1092 -700
- data/src/regexp.c +3 -3
- data/src/serialize.c +227 -157
- data/src/util/pm_buffer.c +10 -1
- data/src/util/pm_memchr.c +1 -1
- data/src/util/pm_strpbrk.c +4 -4
- metadata +5 -11
- data/include/prism/enc/pm_encoding.h +0 -227
- data/src/enc/pm_big5.c +0 -116
- data/src/enc/pm_cp51932.c +0 -57
- data/src/enc/pm_euc_jp.c +0 -69
- data/src/enc/pm_gbk.c +0 -65
- data/src/enc/pm_shift_jis.c +0 -57
- data/src/enc/pm_tables.c +0 -2073
- data/src/enc/pm_unicode.c +0 -2369
- data/src/enc/pm_windows_31j.c +0 -57
data/src/enc/pm_shift_jis.c
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#include "prism/enc/pm_encoding.h"
|
2
|
-
|
3
|
-
static size_t
|
4
|
-
pm_encoding_shift_jis_char_width(const uint8_t *b, ptrdiff_t n) {
|
5
|
-
// These are the single byte characters.
|
6
|
-
if (*b < 0x80 || (*b >= 0xA1 && *b <= 0xDF)) {
|
7
|
-
return 1;
|
8
|
-
}
|
9
|
-
|
10
|
-
// These are the double byte characters.
|
11
|
-
if (
|
12
|
-
(n > 1) &&
|
13
|
-
((b[0] >= 0x81 && b[0] <= 0x9F) || (b[0] >= 0xE0 && b[0] <= 0xFC)) &&
|
14
|
-
(b[1] >= 0x40 && b[1] <= 0xFC)
|
15
|
-
) {
|
16
|
-
return 2;
|
17
|
-
}
|
18
|
-
|
19
|
-
return 0;
|
20
|
-
}
|
21
|
-
|
22
|
-
static size_t
|
23
|
-
pm_encoding_shift_jis_alpha_char(const uint8_t *b, ptrdiff_t n) {
|
24
|
-
if (pm_encoding_shift_jis_char_width(b, n) == 1) {
|
25
|
-
return pm_encoding_ascii_alpha_char(b, n);
|
26
|
-
} else {
|
27
|
-
return 0;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
static size_t
|
32
|
-
pm_encoding_shift_jis_alnum_char(const uint8_t *b, ptrdiff_t n) {
|
33
|
-
if (pm_encoding_shift_jis_char_width(b, n) == 1) {
|
34
|
-
return pm_encoding_ascii_alnum_char(b, n);
|
35
|
-
} else {
|
36
|
-
return 0;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
static bool
|
41
|
-
pm_encoding_shift_jis_isupper_char(const uint8_t *b, ptrdiff_t n) {
|
42
|
-
if (pm_encoding_shift_jis_char_width(b, n) == 1) {
|
43
|
-
return pm_encoding_ascii_isupper_char(b, n);
|
44
|
-
} else {
|
45
|
-
return 0;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
/** Shift_JIS encoding */
|
50
|
-
pm_encoding_t pm_encoding_shift_jis = {
|
51
|
-
.name = "shift_jis",
|
52
|
-
.char_width = pm_encoding_shift_jis_char_width,
|
53
|
-
.alnum_char = pm_encoding_shift_jis_alnum_char,
|
54
|
-
.alpha_char = pm_encoding_shift_jis_alpha_char,
|
55
|
-
.isupper_char = pm_encoding_shift_jis_isupper_char,
|
56
|
-
.multibyte = true
|
57
|
-
};
|