yarp 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +76 -0
  3. data/CONTRIBUTING.md +51 -0
  4. data/LICENSE.md +7 -0
  5. data/Makefile.in +79 -0
  6. data/README.md +86 -0
  7. data/config.h.in +25 -0
  8. data/config.yml +2147 -0
  9. data/configure +4487 -0
  10. data/docs/build_system.md +85 -0
  11. data/docs/building.md +26 -0
  12. data/docs/configuration.md +56 -0
  13. data/docs/design.md +53 -0
  14. data/docs/encoding.md +116 -0
  15. data/docs/extension.md +20 -0
  16. data/docs/fuzzing.md +93 -0
  17. data/docs/heredocs.md +36 -0
  18. data/docs/mapping.md +117 -0
  19. data/docs/ripper.md +36 -0
  20. data/docs/serialization.md +130 -0
  21. data/docs/testing.md +55 -0
  22. data/ext/yarp/api_node.c +3680 -0
  23. data/ext/yarp/api_pack.c +256 -0
  24. data/ext/yarp/extconf.rb +131 -0
  25. data/ext/yarp/extension.c +547 -0
  26. data/ext/yarp/extension.h +18 -0
  27. data/include/yarp/ast.h +1412 -0
  28. data/include/yarp/defines.h +54 -0
  29. data/include/yarp/diagnostic.h +24 -0
  30. data/include/yarp/enc/yp_encoding.h +94 -0
  31. data/include/yarp/node.h +36 -0
  32. data/include/yarp/pack.h +141 -0
  33. data/include/yarp/parser.h +389 -0
  34. data/include/yarp/regexp.h +19 -0
  35. data/include/yarp/unescape.h +42 -0
  36. data/include/yarp/util/yp_buffer.h +39 -0
  37. data/include/yarp/util/yp_char.h +75 -0
  38. data/include/yarp/util/yp_constant_pool.h +64 -0
  39. data/include/yarp/util/yp_list.h +67 -0
  40. data/include/yarp/util/yp_memchr.h +14 -0
  41. data/include/yarp/util/yp_newline_list.h +54 -0
  42. data/include/yarp/util/yp_state_stack.h +24 -0
  43. data/include/yarp/util/yp_string.h +57 -0
  44. data/include/yarp/util/yp_string_list.h +28 -0
  45. data/include/yarp/util/yp_strpbrk.h +29 -0
  46. data/include/yarp/version.h +5 -0
  47. data/include/yarp.h +69 -0
  48. data/lib/yarp/lex_compat.rb +759 -0
  49. data/lib/yarp/node.rb +7428 -0
  50. data/lib/yarp/pack.rb +185 -0
  51. data/lib/yarp/ripper_compat.rb +174 -0
  52. data/lib/yarp/serialize.rb +389 -0
  53. data/lib/yarp.rb +330 -0
  54. data/src/diagnostic.c +25 -0
  55. data/src/enc/yp_big5.c +79 -0
  56. data/src/enc/yp_euc_jp.c +85 -0
  57. data/src/enc/yp_gbk.c +88 -0
  58. data/src/enc/yp_shift_jis.c +83 -0
  59. data/src/enc/yp_tables.c +509 -0
  60. data/src/enc/yp_unicode.c +2320 -0
  61. data/src/enc/yp_windows_31j.c +83 -0
  62. data/src/node.c +2011 -0
  63. data/src/pack.c +493 -0
  64. data/src/prettyprint.c +1782 -0
  65. data/src/regexp.c +580 -0
  66. data/src/serialize.c +1576 -0
  67. data/src/token_type.c +347 -0
  68. data/src/unescape.c +576 -0
  69. data/src/util/yp_buffer.c +78 -0
  70. data/src/util/yp_char.c +229 -0
  71. data/src/util/yp_constant_pool.c +147 -0
  72. data/src/util/yp_list.c +50 -0
  73. data/src/util/yp_memchr.c +31 -0
  74. data/src/util/yp_newline_list.c +119 -0
  75. data/src/util/yp_state_stack.c +25 -0
  76. data/src/util/yp_string.c +207 -0
  77. data/src/util/yp_string_list.c +32 -0
  78. data/src/util/yp_strncasecmp.c +20 -0
  79. data/src/util/yp_strpbrk.c +66 -0
  80. data/src/yarp.c +13211 -0
  81. data/yarp.gemspec +100 -0
  82. 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
+ };