yarp 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -8
  3. data/CONTRIBUTING.md +2 -2
  4. data/Makefile +5 -5
  5. data/README.md +11 -12
  6. data/config.yml +6 -2
  7. data/docs/build_system.md +21 -21
  8. data/docs/building.md +4 -4
  9. data/docs/configuration.md +25 -21
  10. data/docs/design.md +2 -2
  11. data/docs/encoding.md +17 -17
  12. data/docs/fuzzing.md +4 -4
  13. data/docs/heredocs.md +3 -3
  14. data/docs/mapping.md +94 -94
  15. data/docs/ripper.md +4 -4
  16. data/docs/ruby_api.md +11 -11
  17. data/docs/serialization.md +17 -16
  18. data/docs/testing.md +6 -6
  19. data/ext/prism/api_node.c +4725 -0
  20. data/ext/{yarp → prism}/api_pack.c +82 -82
  21. data/ext/{yarp → prism}/extconf.rb +13 -13
  22. data/ext/{yarp → prism}/extension.c +175 -168
  23. data/ext/prism/extension.h +18 -0
  24. data/include/prism/ast.h +1932 -0
  25. data/include/prism/defines.h +45 -0
  26. data/include/prism/diagnostic.h +231 -0
  27. data/include/{yarp/enc/yp_encoding.h → prism/enc/pm_encoding.h} +40 -40
  28. data/include/prism/node.h +41 -0
  29. data/include/prism/pack.h +141 -0
  30. data/include/{yarp → prism}/parser.h +143 -142
  31. data/include/prism/regexp.h +19 -0
  32. data/include/prism/unescape.h +48 -0
  33. data/include/prism/util/pm_buffer.h +51 -0
  34. data/include/{yarp/util/yp_char.h → prism/util/pm_char.h} +20 -20
  35. data/include/{yarp/util/yp_constant_pool.h → prism/util/pm_constant_pool.h} +26 -22
  36. data/include/{yarp/util/yp_list.h → prism/util/pm_list.h} +21 -21
  37. data/include/prism/util/pm_memchr.h +14 -0
  38. data/include/{yarp/util/yp_newline_list.h → prism/util/pm_newline_list.h} +11 -11
  39. data/include/prism/util/pm_state_stack.h +24 -0
  40. data/include/{yarp/util/yp_string.h → prism/util/pm_string.h} +20 -20
  41. data/include/prism/util/pm_string_list.h +25 -0
  42. data/include/{yarp/util/yp_strpbrk.h → prism/util/pm_strpbrk.h} +7 -7
  43. data/include/prism/version.h +4 -0
  44. data/include/prism.h +82 -0
  45. data/lib/prism/compiler.rb +465 -0
  46. data/lib/prism/debug.rb +157 -0
  47. data/lib/{yarp/desugar_visitor.rb → prism/desugar_compiler.rb} +4 -2
  48. data/lib/prism/dispatcher.rb +2051 -0
  49. data/lib/prism/dsl.rb +750 -0
  50. data/lib/{yarp → prism}/ffi.rb +66 -67
  51. data/lib/{yarp → prism}/lex_compat.rb +40 -43
  52. data/lib/{yarp/mutation_visitor.rb → prism/mutation_compiler.rb} +3 -3
  53. data/lib/{yarp → prism}/node.rb +2012 -2593
  54. data/lib/prism/node_ext.rb +55 -0
  55. data/lib/prism/node_inspector.rb +68 -0
  56. data/lib/{yarp → prism}/pack.rb +1 -1
  57. data/lib/{yarp → prism}/parse_result/comments.rb +1 -1
  58. data/lib/{yarp → prism}/parse_result/newlines.rb +1 -1
  59. data/lib/prism/parse_result.rb +266 -0
  60. data/lib/{yarp → prism}/pattern.rb +14 -14
  61. data/lib/{yarp → prism}/ripper_compat.rb +5 -5
  62. data/lib/{yarp → prism}/serialize.rb +12 -7
  63. data/lib/prism/visitor.rb +470 -0
  64. data/lib/prism.rb +64 -0
  65. data/lib/yarp.rb +2 -614
  66. data/src/diagnostic.c +213 -208
  67. data/src/enc/pm_big5.c +52 -0
  68. data/src/enc/pm_euc_jp.c +58 -0
  69. data/src/enc/{yp_gbk.c → pm_gbk.c} +16 -16
  70. data/src/enc/pm_shift_jis.c +56 -0
  71. data/src/enc/{yp_tables.c → pm_tables.c} +69 -69
  72. data/src/enc/{yp_unicode.c → pm_unicode.c} +40 -40
  73. data/src/enc/pm_windows_31j.c +56 -0
  74. data/src/node.c +1293 -1233
  75. data/src/pack.c +247 -247
  76. data/src/prettyprint.c +1479 -1479
  77. data/src/{yarp.c → prism.c} +5205 -5083
  78. data/src/regexp.c +132 -132
  79. data/src/serialize.c +1121 -1121
  80. data/src/token_type.c +169 -167
  81. data/src/unescape.c +106 -87
  82. data/src/util/pm_buffer.c +103 -0
  83. data/src/util/{yp_char.c → pm_char.c} +72 -72
  84. data/src/util/{yp_constant_pool.c → pm_constant_pool.c} +85 -64
  85. data/src/util/{yp_list.c → pm_list.c} +10 -10
  86. data/src/util/{yp_memchr.c → pm_memchr.c} +6 -4
  87. data/src/util/{yp_newline_list.c → pm_newline_list.c} +21 -21
  88. data/src/util/{yp_state_stack.c → pm_state_stack.c} +4 -4
  89. data/src/util/{yp_string.c → pm_string.c} +38 -38
  90. data/src/util/pm_string_list.c +29 -0
  91. data/src/util/{yp_strncasecmp.c → pm_strncasecmp.c} +1 -1
  92. data/src/util/{yp_strpbrk.c → pm_strpbrk.c} +8 -8
  93. data/yarp.gemspec +68 -59
  94. metadata +70 -61
  95. data/ext/yarp/api_node.c +0 -4728
  96. data/ext/yarp/extension.h +0 -18
  97. data/include/yarp/ast.h +0 -1929
  98. data/include/yarp/defines.h +0 -45
  99. data/include/yarp/diagnostic.h +0 -226
  100. data/include/yarp/node.h +0 -42
  101. data/include/yarp/pack.h +0 -141
  102. data/include/yarp/regexp.h +0 -19
  103. data/include/yarp/unescape.h +0 -44
  104. data/include/yarp/util/yp_buffer.h +0 -51
  105. data/include/yarp/util/yp_memchr.h +0 -14
  106. data/include/yarp/util/yp_state_stack.h +0 -24
  107. data/include/yarp/util/yp_string_list.h +0 -25
  108. data/include/yarp/version.h +0 -4
  109. data/include/yarp.h +0 -82
  110. data/src/enc/yp_big5.c +0 -52
  111. data/src/enc/yp_euc_jp.c +0 -58
  112. data/src/enc/yp_shift_jis.c +0 -56
  113. data/src/enc/yp_windows_31j.c +0 -56
  114. data/src/util/yp_buffer.c +0 -101
  115. data/src/util/yp_string_list.c +0 -29
@@ -1,9 +1,9 @@
1
- #include "yarp/util/yp_newline_list.h"
1
+ #include "prism/util/pm_newline_list.h"
2
2
 
3
3
  // Initialize a new newline list with the given capacity. Returns true if the
4
4
  // allocation of the offsets succeeds, otherwise returns false.
5
5
  bool
6
- yp_newline_list_init(yp_newline_list_t *list, const uint8_t *start, size_t capacity) {
6
+ pm_newline_list_init(pm_newline_list_t *list, const uint8_t *start, size_t capacity) {
7
7
  list->offsets = (size_t *) calloc(capacity, sizeof(size_t));
8
8
  if (list->offsets == NULL) return false;
9
9
 
@@ -23,7 +23,7 @@ yp_newline_list_init(yp_newline_list_t *list, const uint8_t *start, size_t capac
23
23
  // Append a new offset to the newline list. Returns true if the reallocation of
24
24
  // the offsets succeeds (if one was necessary), otherwise returns false.
25
25
  bool
26
- yp_newline_list_append(yp_newline_list_t *list, const uint8_t *cursor) {
26
+ pm_newline_list_append(pm_newline_list_t *list, const uint8_t *cursor) {
27
27
  if (list->size == list->capacity) {
28
28
  size_t *original_offsets = list->offsets;
29
29
 
@@ -46,17 +46,17 @@ yp_newline_list_append(yp_newline_list_t *list, const uint8_t *cursor) {
46
46
 
47
47
  // Conditionally append a new offset to the newline list, if the value passed in is a newline.
48
48
  bool
49
- yp_newline_list_check_append(yp_newline_list_t *list, const uint8_t *cursor) {
49
+ pm_newline_list_check_append(pm_newline_list_t *list, const uint8_t *cursor) {
50
50
  if (*cursor != '\n') {
51
51
  return true;
52
52
  }
53
- return yp_newline_list_append(list, cursor);
53
+ return pm_newline_list_append(list, cursor);
54
54
  }
55
55
 
56
56
  // Returns the line and column of the given offset, assuming we don't have any
57
57
  // information about the previous index that we found.
58
- static yp_line_column_t
59
- yp_newline_list_line_column_search(yp_newline_list_t *list, size_t offset) {
58
+ static pm_line_column_t
59
+ pm_newline_list_line_column_search(pm_newline_list_t *list, size_t offset) {
60
60
  size_t left = 0;
61
61
  size_t right = list->size - 1;
62
62
 
@@ -64,7 +64,7 @@ yp_newline_list_line_column_search(yp_newline_list_t *list, size_t offset) {
64
64
  size_t mid = left + (right - left) / 2;
65
65
 
66
66
  if (list->offsets[mid] == offset) {
67
- return ((yp_line_column_t) { mid, 0 });
67
+ return ((pm_line_column_t) { mid, 0 });
68
68
  }
69
69
 
70
70
  if (list->offsets[mid] < offset) {
@@ -74,13 +74,13 @@ yp_newline_list_line_column_search(yp_newline_list_t *list, size_t offset) {
74
74
  }
75
75
  }
76
76
 
77
- return ((yp_line_column_t) { left - 1, offset - list->offsets[left - 1] });
77
+ return ((pm_line_column_t) { left - 1, offset - list->offsets[left - 1] });
78
78
  }
79
79
 
80
80
  // Returns the line and column of the given offset, assuming we know the last
81
81
  // index that we found.
82
- static yp_line_column_t
83
- yp_newline_list_line_column_scan(yp_newline_list_t *list, size_t offset) {
82
+ static pm_line_column_t
83
+ pm_newline_list_line_column_scan(pm_newline_list_t *list, size_t offset) {
84
84
  if (offset > list->last_offset) {
85
85
  size_t index = list->last_index;
86
86
  while (index < list->size && list->offsets[index] < offset) {
@@ -88,10 +88,10 @@ yp_newline_list_line_column_scan(yp_newline_list_t *list, size_t offset) {
88
88
  }
89
89
 
90
90
  if (index == list->size) {
91
- return ((yp_line_column_t) { index - 1, offset - list->offsets[index - 1] });
91
+ return ((pm_line_column_t) { index - 1, offset - list->offsets[index - 1] });
92
92
  }
93
93
 
94
- return ((yp_line_column_t) { index, 0 });
94
+ return ((pm_line_column_t) { index, 0 });
95
95
  } else {
96
96
  size_t index = list->last_index;
97
97
  while (index > 0 && list->offsets[index] > offset) {
@@ -99,26 +99,26 @@ yp_newline_list_line_column_scan(yp_newline_list_t *list, size_t offset) {
99
99
  }
100
100
 
101
101
  if (index == 0) {
102
- return ((yp_line_column_t) { 0, offset });
102
+ return ((pm_line_column_t) { 0, offset });
103
103
  }
104
104
 
105
- return ((yp_line_column_t) { index, offset - list->offsets[index - 1] });
105
+ return ((pm_line_column_t) { index, offset - list->offsets[index - 1] });
106
106
  }
107
107
  }
108
108
 
109
109
  // Returns the line and column of the given offset. If the offset is not in the
110
110
  // list, the line and column of the closest offset less than the given offset
111
111
  // are returned.
112
- yp_line_column_t
113
- yp_newline_list_line_column(yp_newline_list_t *list, const uint8_t *cursor) {
112
+ pm_line_column_t
113
+ pm_newline_list_line_column(pm_newline_list_t *list, const uint8_t *cursor) {
114
114
  assert(cursor >= list->start);
115
115
  size_t offset = (size_t) (cursor - list->start);
116
- yp_line_column_t result;
116
+ pm_line_column_t result;
117
117
 
118
118
  if (list->last_offset == 0) {
119
- result = yp_newline_list_line_column_search(list, offset);
119
+ result = pm_newline_list_line_column_search(list, offset);
120
120
  } else {
121
- result = yp_newline_list_line_column_scan(list, offset);
121
+ result = pm_newline_list_line_column_scan(list, offset);
122
122
  }
123
123
 
124
124
  list->last_index = result.line;
@@ -129,6 +129,6 @@ yp_newline_list_line_column(yp_newline_list_t *list, const uint8_t *cursor) {
129
129
 
130
130
  // Free the internal memory allocated for the newline list.
131
131
  void
132
- yp_newline_list_free(yp_newline_list_t *list) {
132
+ pm_newline_list_free(pm_newline_list_t *list) {
133
133
  free(list->offsets);
134
134
  }
@@ -1,19 +1,19 @@
1
- #include "yarp/util/yp_state_stack.h"
1
+ #include "prism/util/pm_state_stack.h"
2
2
 
3
3
  // Pushes a value onto the stack.
4
4
  void
5
- yp_state_stack_push(yp_state_stack_t *stack, bool value) {
5
+ pm_state_stack_push(pm_state_stack_t *stack, bool value) {
6
6
  *stack = (*stack << 1) | (value & 1);
7
7
  }
8
8
 
9
9
  // Pops a value off the stack.
10
10
  void
11
- yp_state_stack_pop(yp_state_stack_t *stack) {
11
+ pm_state_stack_pop(pm_state_stack_t *stack) {
12
12
  *stack >>= 1;
13
13
  }
14
14
 
15
15
  // Returns the value at the top of the stack.
16
16
  bool
17
- yp_state_stack_p(yp_state_stack_t *stack) {
17
+ pm_state_stack_p(pm_state_stack_t *stack) {
18
18
  return *stack & 1;
19
19
  }
@@ -1,4 +1,4 @@
1
- #include "yarp/util/yp_string.h"
1
+ #include "prism/util/pm_string.h"
2
2
 
3
3
  // The following headers are necessary to read files using demand paging.
4
4
  #ifdef _WIN32
@@ -12,11 +12,11 @@
12
12
 
13
13
  // Initialize a shared string that is based on initial input.
14
14
  void
15
- yp_string_shared_init(yp_string_t *string, const uint8_t *start, const uint8_t *end) {
15
+ pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *end) {
16
16
  assert(start <= end);
17
17
 
18
- *string = (yp_string_t) {
19
- .type = YP_STRING_SHARED,
18
+ *string = (pm_string_t) {
19
+ .type = PM_STRING_SHARED,
20
20
  .source = start,
21
21
  .length = (size_t) (end - start)
22
22
  };
@@ -24,9 +24,9 @@ yp_string_shared_init(yp_string_t *string, const uint8_t *start, const uint8_t *
24
24
 
25
25
  // Initialize an owned string that is responsible for freeing allocated memory.
26
26
  void
27
- yp_string_owned_init(yp_string_t *string, uint8_t *source, size_t length) {
28
- *string = (yp_string_t) {
29
- .type = YP_STRING_OWNED,
27
+ pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length) {
28
+ *string = (pm_string_t) {
29
+ .type = PM_STRING_OWNED,
30
30
  .source = source,
31
31
  .length = length
32
32
  };
@@ -34,18 +34,18 @@ yp_string_owned_init(yp_string_t *string, uint8_t *source, size_t length) {
34
34
 
35
35
  // Initialize a constant string that doesn't own its memory source.
36
36
  void
37
- yp_string_constant_init(yp_string_t *string, const char *source, size_t length) {
38
- *string = (yp_string_t) {
39
- .type = YP_STRING_CONSTANT,
37
+ pm_string_constant_init(pm_string_t *string, const char *source, size_t length) {
38
+ *string = (pm_string_t) {
39
+ .type = PM_STRING_CONSTANT,
40
40
  .source = (const uint8_t *) source,
41
41
  .length = length
42
42
  };
43
43
  }
44
44
 
45
45
  static void
46
- yp_string_mapped_init_internal(yp_string_t *string, uint8_t *source, size_t length) {
47
- *string = (yp_string_t) {
48
- .type = YP_STRING_MAPPED,
46
+ pm_string_mapped_init_internal(pm_string_t *string, uint8_t *source, size_t length) {
47
+ *string = (pm_string_t) {
48
+ .type = PM_STRING_MAPPED,
49
49
  .source = source,
50
50
  .length = length
51
51
  };
@@ -53,9 +53,9 @@ yp_string_mapped_init_internal(yp_string_t *string, uint8_t *source, size_t leng
53
53
 
54
54
  // Returns the memory size associated with the string.
55
55
  size_t
56
- yp_string_memsize(const yp_string_t *string) {
57
- size_t size = sizeof(yp_string_t);
58
- if (string->type == YP_STRING_OWNED) {
56
+ pm_string_memsize(const pm_string_t *string) {
57
+ size_t size = sizeof(pm_string_t);
58
+ if (string->type == PM_STRING_OWNED) {
59
59
  size += string->length;
60
60
  }
61
61
  return size;
@@ -64,39 +64,39 @@ yp_string_memsize(const yp_string_t *string) {
64
64
  // Ensure the string is owned. If it is not, then reinitialize it as owned and
65
65
  // copy over the previous source.
66
66
  void
67
- yp_string_ensure_owned(yp_string_t *string) {
68
- if (string->type == YP_STRING_OWNED) return;
67
+ pm_string_ensure_owned(pm_string_t *string) {
68
+ if (string->type == PM_STRING_OWNED) return;
69
69
 
70
- size_t length = yp_string_length(string);
71
- const uint8_t *source = yp_string_source(string);
70
+ size_t length = pm_string_length(string);
71
+ const uint8_t *source = pm_string_source(string);
72
72
 
73
73
  uint8_t *memory = malloc(length);
74
74
  if (!memory) return;
75
75
 
76
- yp_string_owned_init(string, memory, length);
76
+ pm_string_owned_init(string, memory, length);
77
77
  memcpy((void *) string->source, source, length);
78
78
  }
79
79
 
80
80
  // Returns the length associated with the string.
81
- YP_EXPORTED_FUNCTION size_t
82
- yp_string_length(const yp_string_t *string) {
81
+ PRISM_EXPORTED_FUNCTION size_t
82
+ pm_string_length(const pm_string_t *string) {
83
83
  return string->length;
84
84
  }
85
85
 
86
86
  // Returns the start pointer associated with the string.
87
- YP_EXPORTED_FUNCTION const uint8_t *
88
- yp_string_source(const yp_string_t *string) {
87
+ PRISM_EXPORTED_FUNCTION const uint8_t *
88
+ pm_string_source(const pm_string_t *string) {
89
89
  return string->source;
90
90
  }
91
91
 
92
92
  // Free the associated memory of the given string.
93
- YP_EXPORTED_FUNCTION void
94
- yp_string_free(yp_string_t *string) {
93
+ PRISM_EXPORTED_FUNCTION void
94
+ pm_string_free(pm_string_t *string) {
95
95
  void *memory = (void *) string->source;
96
96
 
97
- if (string->type == YP_STRING_OWNED) {
97
+ if (string->type == PM_STRING_OWNED) {
98
98
  free(memory);
99
- } else if (string->type == YP_STRING_MAPPED && string->length) {
99
+ } else if (string->type == PM_STRING_MAPPED && string->length) {
100
100
  #if defined(_WIN32)
101
101
  UnmapViewOfFile(memory);
102
102
  #else
@@ -106,7 +106,7 @@ yp_string_free(yp_string_t *string) {
106
106
  }
107
107
 
108
108
  bool
109
- yp_string_mapped_init(yp_string_t *string, const char *filepath) {
109
+ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
110
110
  #ifdef _WIN32
111
111
  // Open the file for reading.
112
112
  HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -129,7 +129,7 @@ yp_string_mapped_init(yp_string_t *string, const char *filepath) {
129
129
  if (file_size == 0) {
130
130
  CloseHandle(file);
131
131
  uint8_t empty[] = "";
132
- yp_string_mapped_init_internal(string, empty, 0);
132
+ pm_string_mapped_init_internal(string, empty, 0);
133
133
  return true;
134
134
  }
135
135
 
@@ -151,7 +151,7 @@ yp_string_mapped_init(yp_string_t *string, const char *filepath) {
151
151
  return false;
152
152
  }
153
153
 
154
- yp_string_mapped_init_internal(string, source, (size_t) file_size);
154
+ pm_string_mapped_init_internal(string, source, (size_t) file_size);
155
155
  return true;
156
156
  #else
157
157
  // Open the file for reading
@@ -176,7 +176,7 @@ yp_string_mapped_init(yp_string_t *string, const char *filepath) {
176
176
  if (size == 0) {
177
177
  close(fd);
178
178
  uint8_t empty[] = "";
179
- yp_string_mapped_init_internal(string, empty, 0);
179
+ pm_string_mapped_init_internal(string, empty, 0);
180
180
  return true;
181
181
  }
182
182
 
@@ -187,14 +187,14 @@ yp_string_mapped_init(yp_string_t *string, const char *filepath) {
187
187
  }
188
188
 
189
189
  close(fd);
190
- yp_string_mapped_init_internal(string, source, size);
190
+ pm_string_mapped_init_internal(string, source, size);
191
191
  return true;
192
192
  #endif
193
193
  }
194
194
 
195
- // Returns the size of the yp_string_t struct. This is necessary to allocate the
195
+ // Returns the size of the pm_string_t struct. This is necessary to allocate the
196
196
  // correct amount of memory in the FFI backend.
197
- YP_EXPORTED_FUNCTION size_t
198
- yp_string_sizeof(void) {
199
- return sizeof(yp_string_t);
197
+ PRISM_EXPORTED_FUNCTION size_t
198
+ pm_string_sizeof(void) {
199
+ return sizeof(pm_string_t);
200
200
  }
@@ -0,0 +1,29 @@
1
+ #include "prism/util/pm_string_list.h"
2
+
3
+ // Initialize a pm_string_list_t with its default values.
4
+ void
5
+ pm_string_list_init(pm_string_list_t *string_list) {
6
+ string_list->strings = (pm_string_t *) malloc(sizeof(pm_string_t));
7
+ string_list->length = 0;
8
+ string_list->capacity = 1;
9
+ }
10
+
11
+ // Append a pm_string_t to the given string list.
12
+ void
13
+ pm_string_list_append(pm_string_list_t *string_list, pm_string_t *string) {
14
+ if (string_list->length + 1 > string_list->capacity) {
15
+ pm_string_t *original_string = string_list->strings;
16
+ string_list->capacity *= 2;
17
+ string_list->strings = (pm_string_t *) malloc(string_list->capacity * sizeof(pm_string_t));
18
+ memcpy(string_list->strings, original_string, (string_list->length) * sizeof(pm_string_t));
19
+ free(original_string);
20
+ }
21
+
22
+ string_list->strings[string_list->length++] = *string;
23
+ }
24
+
25
+ // Free the memory associated with the string list.
26
+ void
27
+ pm_string_list_free(pm_string_list_t *string_list) {
28
+ free(string_list->strings);
29
+ }
@@ -3,7 +3,7 @@
3
3
  #include <stdint.h>
4
4
 
5
5
  int
6
- yp_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length) {
6
+ pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length) {
7
7
  size_t offset = 0;
8
8
  int difference = 0;
9
9
 
@@ -1,8 +1,8 @@
1
- #include "yarp/util/yp_strpbrk.h"
1
+ #include "prism/util/pm_strpbrk.h"
2
2
 
3
3
  // This is the slow path that does care about the encoding.
4
4
  static inline const uint8_t *
5
- yp_strpbrk_multi_byte(yp_parser_t *parser, const uint8_t *source, const uint8_t *charset, size_t maximum) {
5
+ pm_strpbrk_multi_byte(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, size_t maximum) {
6
6
  size_t index = 0;
7
7
 
8
8
  while (index < maximum) {
@@ -23,7 +23,7 @@ yp_strpbrk_multi_byte(yp_parser_t *parser, const uint8_t *source, const uint8_t
23
23
 
24
24
  // This is the fast path that does not care about the encoding.
25
25
  static inline const uint8_t *
26
- yp_strpbrk_single_byte(const uint8_t *source, const uint8_t *charset, size_t maximum) {
26
+ pm_strpbrk_single_byte(const uint8_t *source, const uint8_t *charset, size_t maximum) {
27
27
  size_t index = 0;
28
28
 
29
29
  while (index < maximum) {
@@ -39,9 +39,9 @@ yp_strpbrk_single_byte(const uint8_t *source, const uint8_t *charset, size_t max
39
39
 
40
40
  // Here we have rolled our own version of strpbrk. The standard library strpbrk
41
41
  // has undefined behavior when the source string is not null-terminated. We want
42
- // to support strings that are not null-terminated because yp_parse does not
42
+ // to support strings that are not null-terminated because pm_parse does not
43
43
  // have the contract that the string is null-terminated. (This is desirable
44
- // because it means the extension can call yp_parse with the result of a call to
44
+ // because it means the extension can call pm_parse with the result of a call to
45
45
  // mmap).
46
46
  //
47
47
  // The standard library strpbrk also does not support passing a maximum length
@@ -55,12 +55,12 @@ yp_strpbrk_single_byte(const uint8_t *source, const uint8_t *charset, size_t max
55
55
  // Shift-JIS, the backslash character can be a trailing byte. In that case we
56
56
  // need to take a slower path and iterate one multi-byte character at a time.
57
57
  const uint8_t *
58
- yp_strpbrk(yp_parser_t *parser, const uint8_t *source, const uint8_t *charset, ptrdiff_t length) {
58
+ pm_strpbrk(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, ptrdiff_t length) {
59
59
  if (length <= 0) {
60
60
  return NULL;
61
61
  } else if (parser->encoding_changed && parser->encoding.multibyte) {
62
- return yp_strpbrk_multi_byte(parser, source, charset, (size_t) length);
62
+ return pm_strpbrk_multi_byte(parser, source, charset, (size_t) length);
63
63
  } else {
64
- return yp_strpbrk_single_byte(source, charset, (size_t) length);
64
+ return pm_strpbrk_single_byte(source, charset, (size_t) length);
65
65
  }
66
66
  }
data/yarp.gemspec CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "yarp"
5
- spec.version = "0.12.0"
5
+ spec.version = "0.13.0"
6
6
  spec.authors = ["Shopify"]
7
7
  spec.email = ["ruby@shopify.com"]
8
8
 
9
- spec.summary = "Yet Another Ruby Parser"
10
- spec.homepage = "https://github.com/ruby/yarp"
9
+ spec.summary = "Prism Ruby parser"
10
+ spec.homepage = "https://github.com/ruby/prism"
11
11
  spec.license = "MIT"
12
12
 
13
13
  spec.required_ruby_version = ">= 3.0.0"
@@ -33,51 +33,60 @@ Gem::Specification.new do |spec|
33
33
  "docs/ruby_api.md",
34
34
  "docs/serialization.md",
35
35
  "docs/testing.md",
36
- "ext/yarp/api_node.c",
37
- "ext/yarp/api_pack.c",
38
- "ext/yarp/extension.c",
39
- "ext/yarp/extension.h",
40
- "include/yarp.h",
41
- "include/yarp/ast.h",
42
- "include/yarp/defines.h",
43
- "include/yarp/diagnostic.h",
44
- "include/yarp/enc/yp_encoding.h",
45
- "include/yarp/node.h",
46
- "include/yarp/pack.h",
47
- "include/yarp/parser.h",
48
- "include/yarp/regexp.h",
49
- "include/yarp/unescape.h",
50
- "include/yarp/util/yp_buffer.h",
51
- "include/yarp/util/yp_char.h",
52
- "include/yarp/util/yp_constant_pool.h",
53
- "include/yarp/util/yp_list.h",
54
- "include/yarp/util/yp_memchr.h",
55
- "include/yarp/util/yp_newline_list.h",
56
- "include/yarp/util/yp_state_stack.h",
57
- "include/yarp/util/yp_string.h",
58
- "include/yarp/util/yp_string_list.h",
59
- "include/yarp/util/yp_strpbrk.h",
60
- "include/yarp/version.h",
36
+ "ext/prism/api_node.c",
37
+ "ext/prism/api_pack.c",
38
+ "ext/prism/extension.c",
39
+ "ext/prism/extension.h",
40
+ "include/prism.h",
41
+ "include/prism/ast.h",
42
+ "include/prism/defines.h",
43
+ "include/prism/diagnostic.h",
44
+ "include/prism/enc/pm_encoding.h",
45
+ "include/prism/node.h",
46
+ "include/prism/pack.h",
47
+ "include/prism/parser.h",
48
+ "include/prism/regexp.h",
49
+ "include/prism/unescape.h",
50
+ "include/prism/util/pm_buffer.h",
51
+ "include/prism/util/pm_char.h",
52
+ "include/prism/util/pm_constant_pool.h",
53
+ "include/prism/util/pm_list.h",
54
+ "include/prism/util/pm_memchr.h",
55
+ "include/prism/util/pm_newline_list.h",
56
+ "include/prism/util/pm_state_stack.h",
57
+ "include/prism/util/pm_string.h",
58
+ "include/prism/util/pm_string_list.h",
59
+ "include/prism/util/pm_strpbrk.h",
60
+ "include/prism/version.h",
61
61
  "lib/yarp.rb",
62
- "lib/yarp/desugar_visitor.rb",
63
- "lib/yarp/ffi.rb",
64
- "lib/yarp/lex_compat.rb",
65
- "lib/yarp/mutation_visitor.rb",
66
- "lib/yarp/node.rb",
67
- "lib/yarp/pack.rb",
68
- "lib/yarp/pattern.rb",
69
- "lib/yarp/ripper_compat.rb",
70
- "lib/yarp/serialize.rb",
71
- "lib/yarp/parse_result/comments.rb",
72
- "lib/yarp/parse_result/newlines.rb",
62
+ "lib/prism.rb",
63
+ "lib/prism/compiler.rb",
64
+ "lib/prism/debug.rb",
65
+ "lib/prism/desugar_compiler.rb",
66
+ "lib/prism/dispatcher.rb",
67
+ "lib/prism/dsl.rb",
68
+ "lib/prism/ffi.rb",
69
+ "lib/prism/lex_compat.rb",
70
+ "lib/prism/mutation_compiler.rb",
71
+ "lib/prism/node.rb",
72
+ "lib/prism/node_ext.rb",
73
+ "lib/prism/node_inspector.rb",
74
+ "lib/prism/pack.rb",
75
+ "lib/prism/parse_result.rb",
76
+ "lib/prism/pattern.rb",
77
+ "lib/prism/ripper_compat.rb",
78
+ "lib/prism/serialize.rb",
79
+ "lib/prism/parse_result/comments.rb",
80
+ "lib/prism/parse_result/newlines.rb",
81
+ "lib/prism/visitor.rb",
73
82
  "src/diagnostic.c",
74
- "src/enc/yp_big5.c",
75
- "src/enc/yp_euc_jp.c",
76
- "src/enc/yp_gbk.c",
77
- "src/enc/yp_shift_jis.c",
78
- "src/enc/yp_tables.c",
79
- "src/enc/yp_unicode.c",
80
- "src/enc/yp_windows_31j.c",
83
+ "src/enc/pm_big5.c",
84
+ "src/enc/pm_euc_jp.c",
85
+ "src/enc/pm_gbk.c",
86
+ "src/enc/pm_shift_jis.c",
87
+ "src/enc/pm_tables.c",
88
+ "src/enc/pm_unicode.c",
89
+ "src/enc/pm_windows_31j.c",
81
90
  "src/node.c",
82
91
  "src/pack.c",
83
92
  "src/prettyprint.c",
@@ -85,21 +94,21 @@ Gem::Specification.new do |spec|
85
94
  "src/serialize.c",
86
95
  "src/token_type.c",
87
96
  "src/unescape.c",
88
- "src/util/yp_buffer.c",
89
- "src/util/yp_char.c",
90
- "src/util/yp_constant_pool.c",
91
- "src/util/yp_list.c",
92
- "src/util/yp_memchr.c",
93
- "src/util/yp_newline_list.c",
94
- "src/util/yp_state_stack.c",
95
- "src/util/yp_string.c",
96
- "src/util/yp_string_list.c",
97
- "src/util/yp_strncasecmp.c",
98
- "src/util/yp_strpbrk.c",
99
- "src/yarp.c",
97
+ "src/util/pm_buffer.c",
98
+ "src/util/pm_char.c",
99
+ "src/util/pm_constant_pool.c",
100
+ "src/util/pm_list.c",
101
+ "src/util/pm_memchr.c",
102
+ "src/util/pm_newline_list.c",
103
+ "src/util/pm_state_stack.c",
104
+ "src/util/pm_string.c",
105
+ "src/util/pm_string_list.c",
106
+ "src/util/pm_strncasecmp.c",
107
+ "src/util/pm_strpbrk.c",
108
+ "src/prism.c",
100
109
  "yarp.gemspec",
101
110
  ]
102
111
 
103
- spec.extensions = ["ext/yarp/extconf.rb"]
112
+ spec.extensions = ["ext/prism/extconf.rb"]
104
113
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
105
114
  end