prism 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -1
  3. data/README.md +2 -1
  4. data/config.yml +188 -55
  5. data/docs/building.md +9 -2
  6. data/docs/configuration.md +10 -9
  7. data/docs/encoding.md +24 -56
  8. data/docs/local_variable_depth.md +229 -0
  9. data/docs/ruby_api.md +2 -0
  10. data/docs/serialization.md +18 -13
  11. data/ext/prism/api_node.c +337 -195
  12. data/ext/prism/extconf.rb +13 -7
  13. data/ext/prism/extension.c +96 -32
  14. data/ext/prism/extension.h +1 -1
  15. data/include/prism/ast.h +340 -137
  16. data/include/prism/defines.h +17 -0
  17. data/include/prism/diagnostic.h +11 -5
  18. data/include/prism/encoding.h +248 -0
  19. data/include/prism/options.h +2 -2
  20. data/include/prism/parser.h +62 -42
  21. data/include/prism/regexp.h +2 -2
  22. data/include/prism/util/pm_buffer.h +9 -1
  23. data/include/prism/util/pm_memchr.h +2 -2
  24. data/include/prism/util/pm_strpbrk.h +3 -3
  25. data/include/prism/version.h +2 -2
  26. data/include/prism.h +13 -15
  27. data/lib/prism/compiler.rb +12 -0
  28. data/lib/prism/debug.rb +9 -4
  29. data/lib/prism/desugar_compiler.rb +3 -3
  30. data/lib/prism/dispatcher.rb +56 -0
  31. data/lib/prism/dot_visitor.rb +476 -198
  32. data/lib/prism/dsl.rb +66 -46
  33. data/lib/prism/ffi.rb +16 -3
  34. data/lib/prism/lex_compat.rb +19 -9
  35. data/lib/prism/mutation_compiler.rb +20 -0
  36. data/lib/prism/node.rb +1173 -450
  37. data/lib/prism/node_ext.rb +41 -16
  38. data/lib/prism/parse_result.rb +12 -15
  39. data/lib/prism/ripper_compat.rb +49 -34
  40. data/lib/prism/serialize.rb +242 -212
  41. data/lib/prism/visitor.rb +12 -0
  42. data/lib/prism.rb +20 -4
  43. data/prism.gemspec +4 -10
  44. data/rbi/prism.rbi +605 -230
  45. data/rbi/prism_static.rbi +3 -0
  46. data/sig/prism.rbs +379 -124
  47. data/sig/prism_static.rbs +1 -0
  48. data/src/diagnostic.c +228 -222
  49. data/src/encoding.c +5137 -0
  50. data/src/node.c +66 -0
  51. data/src/options.c +21 -2
  52. data/src/prettyprint.c +806 -406
  53. data/src/prism.c +1092 -700
  54. data/src/regexp.c +3 -3
  55. data/src/serialize.c +227 -157
  56. data/src/util/pm_buffer.c +10 -1
  57. data/src/util/pm_memchr.c +1 -1
  58. data/src/util/pm_strpbrk.c +4 -4
  59. metadata +5 -11
  60. data/include/prism/enc/pm_encoding.h +0 -227
  61. data/src/enc/pm_big5.c +0 -116
  62. data/src/enc/pm_cp51932.c +0 -57
  63. data/src/enc/pm_euc_jp.c +0 -69
  64. data/src/enc/pm_gbk.c +0 -65
  65. data/src/enc/pm_shift_jis.c +0 -57
  66. data/src/enc/pm_tables.c +0 -2073
  67. data/src/enc/pm_unicode.c +0 -2369
  68. data/src/enc/pm_windows_31j.c +0 -57
@@ -1,57 +0,0 @@
1
- #include "prism/enc/pm_encoding.h"
2
-
3
- static size_t
4
- pm_encoding_windows_31j_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_windows_31j_alpha_char(const uint8_t *b, ptrdiff_t n) {
24
- if (pm_encoding_windows_31j_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_windows_31j_alnum_char(const uint8_t *b, ptrdiff_t n) {
33
- if (pm_encoding_windows_31j_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_windows_31j_isupper_char(const uint8_t *b, ptrdiff_t n) {
42
- if (pm_encoding_windows_31j_char_width(b, n) == 1) {
43
- return pm_encoding_ascii_isupper_char(b, n);
44
- } else {
45
- return false;
46
- }
47
- }
48
-
49
- /** Windows-31J */
50
- pm_encoding_t pm_encoding_windows_31j = {
51
- .name = "windows-31j",
52
- .char_width = pm_encoding_windows_31j_char_width,
53
- .alnum_char = pm_encoding_windows_31j_alnum_char,
54
- .alpha_char = pm_encoding_windows_31j_alpha_char,
55
- .isupper_char = pm_encoding_windows_31j_isupper_char,
56
- .multibyte = true
57
- };