yarp 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +51 -0
- data/LICENSE.md +7 -0
- data/Makefile.in +79 -0
- data/README.md +86 -0
- data/config.h.in +25 -0
- data/config.yml +2147 -0
- data/configure +4487 -0
- data/docs/build_system.md +85 -0
- data/docs/building.md +26 -0
- data/docs/configuration.md +56 -0
- data/docs/design.md +53 -0
- data/docs/encoding.md +116 -0
- data/docs/extension.md +20 -0
- data/docs/fuzzing.md +93 -0
- data/docs/heredocs.md +36 -0
- data/docs/mapping.md +117 -0
- data/docs/ripper.md +36 -0
- data/docs/serialization.md +130 -0
- data/docs/testing.md +55 -0
- data/ext/yarp/api_node.c +3680 -0
- data/ext/yarp/api_pack.c +256 -0
- data/ext/yarp/extconf.rb +131 -0
- data/ext/yarp/extension.c +547 -0
- data/ext/yarp/extension.h +18 -0
- data/include/yarp/ast.h +1412 -0
- data/include/yarp/defines.h +54 -0
- data/include/yarp/diagnostic.h +24 -0
- data/include/yarp/enc/yp_encoding.h +94 -0
- data/include/yarp/node.h +36 -0
- data/include/yarp/pack.h +141 -0
- data/include/yarp/parser.h +389 -0
- data/include/yarp/regexp.h +19 -0
- data/include/yarp/unescape.h +42 -0
- data/include/yarp/util/yp_buffer.h +39 -0
- data/include/yarp/util/yp_char.h +75 -0
- data/include/yarp/util/yp_constant_pool.h +64 -0
- data/include/yarp/util/yp_list.h +67 -0
- data/include/yarp/util/yp_memchr.h +14 -0
- data/include/yarp/util/yp_newline_list.h +54 -0
- data/include/yarp/util/yp_state_stack.h +24 -0
- data/include/yarp/util/yp_string.h +57 -0
- data/include/yarp/util/yp_string_list.h +28 -0
- data/include/yarp/util/yp_strpbrk.h +29 -0
- data/include/yarp/version.h +5 -0
- data/include/yarp.h +69 -0
- data/lib/yarp/lex_compat.rb +759 -0
- data/lib/yarp/node.rb +7428 -0
- data/lib/yarp/pack.rb +185 -0
- data/lib/yarp/ripper_compat.rb +174 -0
- data/lib/yarp/serialize.rb +389 -0
- data/lib/yarp.rb +330 -0
- data/src/diagnostic.c +25 -0
- data/src/enc/yp_big5.c +79 -0
- data/src/enc/yp_euc_jp.c +85 -0
- data/src/enc/yp_gbk.c +88 -0
- data/src/enc/yp_shift_jis.c +83 -0
- data/src/enc/yp_tables.c +509 -0
- data/src/enc/yp_unicode.c +2320 -0
- data/src/enc/yp_windows_31j.c +83 -0
- data/src/node.c +2011 -0
- data/src/pack.c +493 -0
- data/src/prettyprint.c +1782 -0
- data/src/regexp.c +580 -0
- data/src/serialize.c +1576 -0
- data/src/token_type.c +347 -0
- data/src/unescape.c +576 -0
- data/src/util/yp_buffer.c +78 -0
- data/src/util/yp_char.c +229 -0
- data/src/util/yp_constant_pool.c +147 -0
- data/src/util/yp_list.c +50 -0
- data/src/util/yp_memchr.c +31 -0
- data/src/util/yp_newline_list.c +119 -0
- data/src/util/yp_state_stack.c +25 -0
- data/src/util/yp_string.c +207 -0
- data/src/util/yp_string_list.c +32 -0
- data/src/util/yp_strncasecmp.c +20 -0
- data/src/util/yp_strpbrk.c +66 -0
- data/src/yarp.c +13211 -0
- data/yarp.gemspec +100 -0
- metadata +125 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
#include "yarp/enc/yp_encoding.h"
|
2
|
+
|
3
|
+
typedef uint16_t yp_windows_31j_codepoint_t;
|
4
|
+
|
5
|
+
static yp_windows_31j_codepoint_t
|
6
|
+
yp_windows_31j_codepoint(const char *c, ptrdiff_t n, size_t *width) {
|
7
|
+
const unsigned char *uc = (const unsigned char *) c;
|
8
|
+
|
9
|
+
// These are the single byte characters.
|
10
|
+
if (*uc < 0x80 || (*uc >= 0xA1 && *uc <= 0xDF)) {
|
11
|
+
*width = 1;
|
12
|
+
return *uc;
|
13
|
+
}
|
14
|
+
|
15
|
+
// These are the double byte characters.
|
16
|
+
if (
|
17
|
+
(n > 1) &&
|
18
|
+
((uc[0] >= 0x81 && uc[0] <= 0x9F) || (uc[0] >= 0xE0 && uc[0] <= 0xFC)) &&
|
19
|
+
(uc[1] >= 0x40 && uc[1] <= 0xFC)
|
20
|
+
) {
|
21
|
+
*width = 2;
|
22
|
+
return (yp_windows_31j_codepoint_t) (uc[0] << 8 | uc[1]);
|
23
|
+
}
|
24
|
+
|
25
|
+
*width = 0;
|
26
|
+
return 0;
|
27
|
+
}
|
28
|
+
|
29
|
+
static size_t
|
30
|
+
yp_encoding_windows_31j_char_width(const char *c, ptrdiff_t n) {
|
31
|
+
size_t width;
|
32
|
+
yp_windows_31j_codepoint(c, n, &width);
|
33
|
+
|
34
|
+
return width;
|
35
|
+
}
|
36
|
+
|
37
|
+
static size_t
|
38
|
+
yp_encoding_windows_31j_alpha_char(const char *c, ptrdiff_t n) {
|
39
|
+
size_t width;
|
40
|
+
yp_windows_31j_codepoint_t codepoint = yp_windows_31j_codepoint(c, n, &width);
|
41
|
+
|
42
|
+
if (width == 1) {
|
43
|
+
const char value = (const char) codepoint;
|
44
|
+
return yp_encoding_ascii_alpha_char(&value, n);
|
45
|
+
} else {
|
46
|
+
return 0;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
static size_t
|
51
|
+
yp_encoding_windows_31j_alnum_char(const char *c, ptrdiff_t n) {
|
52
|
+
size_t width;
|
53
|
+
yp_windows_31j_codepoint_t codepoint = yp_windows_31j_codepoint(c, n, &width);
|
54
|
+
|
55
|
+
if (width == 1) {
|
56
|
+
const char value = (const char) codepoint;
|
57
|
+
return yp_encoding_ascii_alnum_char(&value, n);
|
58
|
+
} else {
|
59
|
+
return 0;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
static bool
|
64
|
+
yp_encoding_windows_31j_isupper_char(const char *c, ptrdiff_t n) {
|
65
|
+
size_t width;
|
66
|
+
yp_windows_31j_codepoint_t codepoint = yp_windows_31j_codepoint(c, n, &width);
|
67
|
+
|
68
|
+
if (width == 1) {
|
69
|
+
const char value = (const char) codepoint;
|
70
|
+
return yp_encoding_ascii_isupper_char(&value, n);
|
71
|
+
} else {
|
72
|
+
return false;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
yp_encoding_t yp_encoding_windows_31j = {
|
77
|
+
.name = "windows-31j",
|
78
|
+
.char_width = yp_encoding_windows_31j_char_width,
|
79
|
+
.alnum_char = yp_encoding_windows_31j_alnum_char,
|
80
|
+
.alpha_char = yp_encoding_windows_31j_alpha_char,
|
81
|
+
.isupper_char = yp_encoding_windows_31j_isupper_char,
|
82
|
+
.multibyte = true
|
83
|
+
};
|