prism 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +172 -0
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +62 -0
  5. data/LICENSE.md +7 -0
  6. data/Makefile +84 -0
  7. data/README.md +89 -0
  8. data/config.yml +2481 -0
  9. data/docs/build_system.md +74 -0
  10. data/docs/building.md +22 -0
  11. data/docs/configuration.md +60 -0
  12. data/docs/design.md +53 -0
  13. data/docs/encoding.md +117 -0
  14. data/docs/fuzzing.md +93 -0
  15. data/docs/heredocs.md +36 -0
  16. data/docs/mapping.md +117 -0
  17. data/docs/ripper.md +36 -0
  18. data/docs/ruby_api.md +25 -0
  19. data/docs/serialization.md +181 -0
  20. data/docs/testing.md +55 -0
  21. data/ext/prism/api_node.c +4725 -0
  22. data/ext/prism/api_pack.c +256 -0
  23. data/ext/prism/extconf.rb +136 -0
  24. data/ext/prism/extension.c +626 -0
  25. data/ext/prism/extension.h +18 -0
  26. data/include/prism/ast.h +1932 -0
  27. data/include/prism/defines.h +45 -0
  28. data/include/prism/diagnostic.h +231 -0
  29. data/include/prism/enc/pm_encoding.h +95 -0
  30. data/include/prism/node.h +41 -0
  31. data/include/prism/pack.h +141 -0
  32. data/include/prism/parser.h +418 -0
  33. data/include/prism/regexp.h +19 -0
  34. data/include/prism/unescape.h +48 -0
  35. data/include/prism/util/pm_buffer.h +51 -0
  36. data/include/prism/util/pm_char.h +91 -0
  37. data/include/prism/util/pm_constant_pool.h +78 -0
  38. data/include/prism/util/pm_list.h +67 -0
  39. data/include/prism/util/pm_memchr.h +14 -0
  40. data/include/prism/util/pm_newline_list.h +61 -0
  41. data/include/prism/util/pm_state_stack.h +24 -0
  42. data/include/prism/util/pm_string.h +61 -0
  43. data/include/prism/util/pm_string_list.h +25 -0
  44. data/include/prism/util/pm_strpbrk.h +29 -0
  45. data/include/prism/version.h +4 -0
  46. data/include/prism.h +82 -0
  47. data/lib/prism/compiler.rb +465 -0
  48. data/lib/prism/debug.rb +157 -0
  49. data/lib/prism/desugar_compiler.rb +206 -0
  50. data/lib/prism/dispatcher.rb +2051 -0
  51. data/lib/prism/dsl.rb +750 -0
  52. data/lib/prism/ffi.rb +251 -0
  53. data/lib/prism/lex_compat.rb +838 -0
  54. data/lib/prism/mutation_compiler.rb +718 -0
  55. data/lib/prism/node.rb +14540 -0
  56. data/lib/prism/node_ext.rb +55 -0
  57. data/lib/prism/node_inspector.rb +68 -0
  58. data/lib/prism/pack.rb +185 -0
  59. data/lib/prism/parse_result/comments.rb +172 -0
  60. data/lib/prism/parse_result/newlines.rb +60 -0
  61. data/lib/prism/parse_result.rb +266 -0
  62. data/lib/prism/pattern.rb +239 -0
  63. data/lib/prism/ripper_compat.rb +174 -0
  64. data/lib/prism/serialize.rb +662 -0
  65. data/lib/prism/visitor.rb +470 -0
  66. data/lib/prism.rb +64 -0
  67. data/prism.gemspec +113 -0
  68. data/src/diagnostic.c +287 -0
  69. data/src/enc/pm_big5.c +52 -0
  70. data/src/enc/pm_euc_jp.c +58 -0
  71. data/src/enc/pm_gbk.c +61 -0
  72. data/src/enc/pm_shift_jis.c +56 -0
  73. data/src/enc/pm_tables.c +507 -0
  74. data/src/enc/pm_unicode.c +2324 -0
  75. data/src/enc/pm_windows_31j.c +56 -0
  76. data/src/node.c +2633 -0
  77. data/src/pack.c +493 -0
  78. data/src/prettyprint.c +2136 -0
  79. data/src/prism.c +14587 -0
  80. data/src/regexp.c +580 -0
  81. data/src/serialize.c +1899 -0
  82. data/src/token_type.c +349 -0
  83. data/src/unescape.c +637 -0
  84. data/src/util/pm_buffer.c +103 -0
  85. data/src/util/pm_char.c +272 -0
  86. data/src/util/pm_constant_pool.c +252 -0
  87. data/src/util/pm_list.c +41 -0
  88. data/src/util/pm_memchr.c +33 -0
  89. data/src/util/pm_newline_list.c +134 -0
  90. data/src/util/pm_state_stack.c +19 -0
  91. data/src/util/pm_string.c +200 -0
  92. data/src/util/pm_string_list.c +29 -0
  93. data/src/util/pm_strncasecmp.c +17 -0
  94. data/src/util/pm_strpbrk.c +66 -0
  95. metadata +138 -0
data/src/token_type.c ADDED
@@ -0,0 +1,349 @@
1
+ /******************************************************************************/
2
+ /* This file is generated by the templates/template.rb script and should not */
3
+ /* be modified manually. See */
4
+ /* templates/src/token_type.c.erb */
5
+ /* if you are looking to modify the */
6
+ /* template */
7
+ /******************************************************************************/
8
+ #include <string.h>
9
+
10
+ #include "prism/ast.h"
11
+
12
+ // Returns a string representation of the given token type.
13
+ PRISM_EXPORTED_FUNCTION const char *
14
+ pm_token_type_to_str(pm_token_type_t token_type)
15
+ {
16
+ switch (token_type) {
17
+ case PM_TOKEN_EOF:
18
+ return "EOF";
19
+ case PM_TOKEN_MISSING:
20
+ return "MISSING";
21
+ case PM_TOKEN_NOT_PROVIDED:
22
+ return "NOT_PROVIDED";
23
+ case PM_TOKEN_AMPERSAND:
24
+ return "AMPERSAND";
25
+ case PM_TOKEN_AMPERSAND_AMPERSAND:
26
+ return "AMPERSAND_AMPERSAND";
27
+ case PM_TOKEN_AMPERSAND_AMPERSAND_EQUAL:
28
+ return "AMPERSAND_AMPERSAND_EQUAL";
29
+ case PM_TOKEN_AMPERSAND_DOT:
30
+ return "AMPERSAND_DOT";
31
+ case PM_TOKEN_AMPERSAND_EQUAL:
32
+ return "AMPERSAND_EQUAL";
33
+ case PM_TOKEN_BACKTICK:
34
+ return "BACKTICK";
35
+ case PM_TOKEN_BACK_REFERENCE:
36
+ return "BACK_REFERENCE";
37
+ case PM_TOKEN_BANG:
38
+ return "BANG";
39
+ case PM_TOKEN_BANG_EQUAL:
40
+ return "BANG_EQUAL";
41
+ case PM_TOKEN_BANG_TILDE:
42
+ return "BANG_TILDE";
43
+ case PM_TOKEN_BRACE_LEFT:
44
+ return "BRACE_LEFT";
45
+ case PM_TOKEN_BRACE_RIGHT:
46
+ return "BRACE_RIGHT";
47
+ case PM_TOKEN_BRACKET_LEFT:
48
+ return "BRACKET_LEFT";
49
+ case PM_TOKEN_BRACKET_LEFT_ARRAY:
50
+ return "BRACKET_LEFT_ARRAY";
51
+ case PM_TOKEN_BRACKET_LEFT_RIGHT:
52
+ return "BRACKET_LEFT_RIGHT";
53
+ case PM_TOKEN_BRACKET_LEFT_RIGHT_EQUAL:
54
+ return "BRACKET_LEFT_RIGHT_EQUAL";
55
+ case PM_TOKEN_BRACKET_RIGHT:
56
+ return "BRACKET_RIGHT";
57
+ case PM_TOKEN_CARET:
58
+ return "CARET";
59
+ case PM_TOKEN_CARET_EQUAL:
60
+ return "CARET_EQUAL";
61
+ case PM_TOKEN_CHARACTER_LITERAL:
62
+ return "CHARACTER_LITERAL";
63
+ case PM_TOKEN_CLASS_VARIABLE:
64
+ return "CLASS_VARIABLE";
65
+ case PM_TOKEN_COLON:
66
+ return "COLON";
67
+ case PM_TOKEN_COLON_COLON:
68
+ return "COLON_COLON";
69
+ case PM_TOKEN_COMMA:
70
+ return "COMMA";
71
+ case PM_TOKEN_COMMENT:
72
+ return "COMMENT";
73
+ case PM_TOKEN_CONSTANT:
74
+ return "CONSTANT";
75
+ case PM_TOKEN_DOT:
76
+ return "DOT";
77
+ case PM_TOKEN_DOT_DOT:
78
+ return "DOT_DOT";
79
+ case PM_TOKEN_DOT_DOT_DOT:
80
+ return "DOT_DOT_DOT";
81
+ case PM_TOKEN_EMBDOC_BEGIN:
82
+ return "EMBDOC_BEGIN";
83
+ case PM_TOKEN_EMBDOC_END:
84
+ return "EMBDOC_END";
85
+ case PM_TOKEN_EMBDOC_LINE:
86
+ return "EMBDOC_LINE";
87
+ case PM_TOKEN_EMBEXPR_BEGIN:
88
+ return "EMBEXPR_BEGIN";
89
+ case PM_TOKEN_EMBEXPR_END:
90
+ return "EMBEXPR_END";
91
+ case PM_TOKEN_EMBVAR:
92
+ return "EMBVAR";
93
+ case PM_TOKEN_EQUAL:
94
+ return "EQUAL";
95
+ case PM_TOKEN_EQUAL_EQUAL:
96
+ return "EQUAL_EQUAL";
97
+ case PM_TOKEN_EQUAL_EQUAL_EQUAL:
98
+ return "EQUAL_EQUAL_EQUAL";
99
+ case PM_TOKEN_EQUAL_GREATER:
100
+ return "EQUAL_GREATER";
101
+ case PM_TOKEN_EQUAL_TILDE:
102
+ return "EQUAL_TILDE";
103
+ case PM_TOKEN_FLOAT:
104
+ return "FLOAT";
105
+ case PM_TOKEN_FLOAT_IMAGINARY:
106
+ return "FLOAT_IMAGINARY";
107
+ case PM_TOKEN_FLOAT_RATIONAL:
108
+ return "FLOAT_RATIONAL";
109
+ case PM_TOKEN_FLOAT_RATIONAL_IMAGINARY:
110
+ return "FLOAT_RATIONAL_IMAGINARY";
111
+ case PM_TOKEN_GLOBAL_VARIABLE:
112
+ return "GLOBAL_VARIABLE";
113
+ case PM_TOKEN_GREATER:
114
+ return "GREATER";
115
+ case PM_TOKEN_GREATER_EQUAL:
116
+ return "GREATER_EQUAL";
117
+ case PM_TOKEN_GREATER_GREATER:
118
+ return "GREATER_GREATER";
119
+ case PM_TOKEN_GREATER_GREATER_EQUAL:
120
+ return "GREATER_GREATER_EQUAL";
121
+ case PM_TOKEN_HEREDOC_END:
122
+ return "HEREDOC_END";
123
+ case PM_TOKEN_HEREDOC_START:
124
+ return "HEREDOC_START";
125
+ case PM_TOKEN_IDENTIFIER:
126
+ return "IDENTIFIER";
127
+ case PM_TOKEN_IGNORED_NEWLINE:
128
+ return "IGNORED_NEWLINE";
129
+ case PM_TOKEN_INSTANCE_VARIABLE:
130
+ return "INSTANCE_VARIABLE";
131
+ case PM_TOKEN_INTEGER:
132
+ return "INTEGER";
133
+ case PM_TOKEN_INTEGER_IMAGINARY:
134
+ return "INTEGER_IMAGINARY";
135
+ case PM_TOKEN_INTEGER_RATIONAL:
136
+ return "INTEGER_RATIONAL";
137
+ case PM_TOKEN_INTEGER_RATIONAL_IMAGINARY:
138
+ return "INTEGER_RATIONAL_IMAGINARY";
139
+ case PM_TOKEN_KEYWORD_ALIAS:
140
+ return "KEYWORD_ALIAS";
141
+ case PM_TOKEN_KEYWORD_AND:
142
+ return "KEYWORD_AND";
143
+ case PM_TOKEN_KEYWORD_BEGIN:
144
+ return "KEYWORD_BEGIN";
145
+ case PM_TOKEN_KEYWORD_BEGIN_UPCASE:
146
+ return "KEYWORD_BEGIN_UPCASE";
147
+ case PM_TOKEN_KEYWORD_BREAK:
148
+ return "KEYWORD_BREAK";
149
+ case PM_TOKEN_KEYWORD_CASE:
150
+ return "KEYWORD_CASE";
151
+ case PM_TOKEN_KEYWORD_CLASS:
152
+ return "KEYWORD_CLASS";
153
+ case PM_TOKEN_KEYWORD_DEF:
154
+ return "KEYWORD_DEF";
155
+ case PM_TOKEN_KEYWORD_DEFINED:
156
+ return "KEYWORD_DEFINED";
157
+ case PM_TOKEN_KEYWORD_DO:
158
+ return "KEYWORD_DO";
159
+ case PM_TOKEN_KEYWORD_DO_LOOP:
160
+ return "KEYWORD_DO_LOOP";
161
+ case PM_TOKEN_KEYWORD_ELSE:
162
+ return "KEYWORD_ELSE";
163
+ case PM_TOKEN_KEYWORD_ELSIF:
164
+ return "KEYWORD_ELSIF";
165
+ case PM_TOKEN_KEYWORD_END:
166
+ return "KEYWORD_END";
167
+ case PM_TOKEN_KEYWORD_END_UPCASE:
168
+ return "KEYWORD_END_UPCASE";
169
+ case PM_TOKEN_KEYWORD_ENSURE:
170
+ return "KEYWORD_ENSURE";
171
+ case PM_TOKEN_KEYWORD_FALSE:
172
+ return "KEYWORD_FALSE";
173
+ case PM_TOKEN_KEYWORD_FOR:
174
+ return "KEYWORD_FOR";
175
+ case PM_TOKEN_KEYWORD_IF:
176
+ return "KEYWORD_IF";
177
+ case PM_TOKEN_KEYWORD_IF_MODIFIER:
178
+ return "KEYWORD_IF_MODIFIER";
179
+ case PM_TOKEN_KEYWORD_IN:
180
+ return "KEYWORD_IN";
181
+ case PM_TOKEN_KEYWORD_MODULE:
182
+ return "KEYWORD_MODULE";
183
+ case PM_TOKEN_KEYWORD_NEXT:
184
+ return "KEYWORD_NEXT";
185
+ case PM_TOKEN_KEYWORD_NIL:
186
+ return "KEYWORD_NIL";
187
+ case PM_TOKEN_KEYWORD_NOT:
188
+ return "KEYWORD_NOT";
189
+ case PM_TOKEN_KEYWORD_OR:
190
+ return "KEYWORD_OR";
191
+ case PM_TOKEN_KEYWORD_REDO:
192
+ return "KEYWORD_REDO";
193
+ case PM_TOKEN_KEYWORD_RESCUE:
194
+ return "KEYWORD_RESCUE";
195
+ case PM_TOKEN_KEYWORD_RESCUE_MODIFIER:
196
+ return "KEYWORD_RESCUE_MODIFIER";
197
+ case PM_TOKEN_KEYWORD_RETRY:
198
+ return "KEYWORD_RETRY";
199
+ case PM_TOKEN_KEYWORD_RETURN:
200
+ return "KEYWORD_RETURN";
201
+ case PM_TOKEN_KEYWORD_SELF:
202
+ return "KEYWORD_SELF";
203
+ case PM_TOKEN_KEYWORD_SUPER:
204
+ return "KEYWORD_SUPER";
205
+ case PM_TOKEN_KEYWORD_THEN:
206
+ return "KEYWORD_THEN";
207
+ case PM_TOKEN_KEYWORD_TRUE:
208
+ return "KEYWORD_TRUE";
209
+ case PM_TOKEN_KEYWORD_UNDEF:
210
+ return "KEYWORD_UNDEF";
211
+ case PM_TOKEN_KEYWORD_UNLESS:
212
+ return "KEYWORD_UNLESS";
213
+ case PM_TOKEN_KEYWORD_UNLESS_MODIFIER:
214
+ return "KEYWORD_UNLESS_MODIFIER";
215
+ case PM_TOKEN_KEYWORD_UNTIL:
216
+ return "KEYWORD_UNTIL";
217
+ case PM_TOKEN_KEYWORD_UNTIL_MODIFIER:
218
+ return "KEYWORD_UNTIL_MODIFIER";
219
+ case PM_TOKEN_KEYWORD_WHEN:
220
+ return "KEYWORD_WHEN";
221
+ case PM_TOKEN_KEYWORD_WHILE:
222
+ return "KEYWORD_WHILE";
223
+ case PM_TOKEN_KEYWORD_WHILE_MODIFIER:
224
+ return "KEYWORD_WHILE_MODIFIER";
225
+ case PM_TOKEN_KEYWORD_YIELD:
226
+ return "KEYWORD_YIELD";
227
+ case PM_TOKEN_KEYWORD___ENCODING__:
228
+ return "KEYWORD___ENCODING__";
229
+ case PM_TOKEN_KEYWORD___FILE__:
230
+ return "KEYWORD___FILE__";
231
+ case PM_TOKEN_KEYWORD___LINE__:
232
+ return "KEYWORD___LINE__";
233
+ case PM_TOKEN_LABEL:
234
+ return "LABEL";
235
+ case PM_TOKEN_LABEL_END:
236
+ return "LABEL_END";
237
+ case PM_TOKEN_LAMBDA_BEGIN:
238
+ return "LAMBDA_BEGIN";
239
+ case PM_TOKEN_LESS:
240
+ return "LESS";
241
+ case PM_TOKEN_LESS_EQUAL:
242
+ return "LESS_EQUAL";
243
+ case PM_TOKEN_LESS_EQUAL_GREATER:
244
+ return "LESS_EQUAL_GREATER";
245
+ case PM_TOKEN_LESS_LESS:
246
+ return "LESS_LESS";
247
+ case PM_TOKEN_LESS_LESS_EQUAL:
248
+ return "LESS_LESS_EQUAL";
249
+ case PM_TOKEN_METHOD_NAME:
250
+ return "METHOD_NAME";
251
+ case PM_TOKEN_MINUS:
252
+ return "MINUS";
253
+ case PM_TOKEN_MINUS_EQUAL:
254
+ return "MINUS_EQUAL";
255
+ case PM_TOKEN_MINUS_GREATER:
256
+ return "MINUS_GREATER";
257
+ case PM_TOKEN_NEWLINE:
258
+ return "NEWLINE";
259
+ case PM_TOKEN_NUMBERED_REFERENCE:
260
+ return "NUMBERED_REFERENCE";
261
+ case PM_TOKEN_PARENTHESIS_LEFT:
262
+ return "PARENTHESIS_LEFT";
263
+ case PM_TOKEN_PARENTHESIS_LEFT_PARENTHESES:
264
+ return "PARENTHESIS_LEFT_PARENTHESES";
265
+ case PM_TOKEN_PARENTHESIS_RIGHT:
266
+ return "PARENTHESIS_RIGHT";
267
+ case PM_TOKEN_PERCENT:
268
+ return "PERCENT";
269
+ case PM_TOKEN_PERCENT_EQUAL:
270
+ return "PERCENT_EQUAL";
271
+ case PM_TOKEN_PERCENT_LOWER_I:
272
+ return "PERCENT_LOWER_I";
273
+ case PM_TOKEN_PERCENT_LOWER_W:
274
+ return "PERCENT_LOWER_W";
275
+ case PM_TOKEN_PERCENT_LOWER_X:
276
+ return "PERCENT_LOWER_X";
277
+ case PM_TOKEN_PERCENT_UPPER_I:
278
+ return "PERCENT_UPPER_I";
279
+ case PM_TOKEN_PERCENT_UPPER_W:
280
+ return "PERCENT_UPPER_W";
281
+ case PM_TOKEN_PIPE:
282
+ return "PIPE";
283
+ case PM_TOKEN_PIPE_EQUAL:
284
+ return "PIPE_EQUAL";
285
+ case PM_TOKEN_PIPE_PIPE:
286
+ return "PIPE_PIPE";
287
+ case PM_TOKEN_PIPE_PIPE_EQUAL:
288
+ return "PIPE_PIPE_EQUAL";
289
+ case PM_TOKEN_PLUS:
290
+ return "PLUS";
291
+ case PM_TOKEN_PLUS_EQUAL:
292
+ return "PLUS_EQUAL";
293
+ case PM_TOKEN_QUESTION_MARK:
294
+ return "QUESTION_MARK";
295
+ case PM_TOKEN_REGEXP_BEGIN:
296
+ return "REGEXP_BEGIN";
297
+ case PM_TOKEN_REGEXP_END:
298
+ return "REGEXP_END";
299
+ case PM_TOKEN_SEMICOLON:
300
+ return "SEMICOLON";
301
+ case PM_TOKEN_SLASH:
302
+ return "SLASH";
303
+ case PM_TOKEN_SLASH_EQUAL:
304
+ return "SLASH_EQUAL";
305
+ case PM_TOKEN_STAR:
306
+ return "STAR";
307
+ case PM_TOKEN_STAR_EQUAL:
308
+ return "STAR_EQUAL";
309
+ case PM_TOKEN_STAR_STAR:
310
+ return "STAR_STAR";
311
+ case PM_TOKEN_STAR_STAR_EQUAL:
312
+ return "STAR_STAR_EQUAL";
313
+ case PM_TOKEN_STRING_BEGIN:
314
+ return "STRING_BEGIN";
315
+ case PM_TOKEN_STRING_CONTENT:
316
+ return "STRING_CONTENT";
317
+ case PM_TOKEN_STRING_END:
318
+ return "STRING_END";
319
+ case PM_TOKEN_SYMBOL_BEGIN:
320
+ return "SYMBOL_BEGIN";
321
+ case PM_TOKEN_TILDE:
322
+ return "TILDE";
323
+ case PM_TOKEN_UAMPERSAND:
324
+ return "UAMPERSAND";
325
+ case PM_TOKEN_UCOLON_COLON:
326
+ return "UCOLON_COLON";
327
+ case PM_TOKEN_UDOT_DOT:
328
+ return "UDOT_DOT";
329
+ case PM_TOKEN_UDOT_DOT_DOT:
330
+ return "UDOT_DOT_DOT";
331
+ case PM_TOKEN_UMINUS:
332
+ return "UMINUS";
333
+ case PM_TOKEN_UMINUS_NUM:
334
+ return "UMINUS_NUM";
335
+ case PM_TOKEN_UPLUS:
336
+ return "UPLUS";
337
+ case PM_TOKEN_USTAR:
338
+ return "USTAR";
339
+ case PM_TOKEN_USTAR_STAR:
340
+ return "USTAR_STAR";
341
+ case PM_TOKEN_WORDS_SEP:
342
+ return "WORDS_SEP";
343
+ case PM_TOKEN___END__:
344
+ return "__END__";
345
+ case PM_TOKEN_MAXIMUM:
346
+ return "MAXIMUM";
347
+ }
348
+ return "\0";
349
+ }