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
data/src/token_type.c ADDED
@@ -0,0 +1,347 @@
1
+ /******************************************************************************/
2
+ /* This file is generated by the bin/template script and should not be */
3
+ /* 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 "yarp/ast.h"
11
+
12
+ // Returns a string representation of the given token type.
13
+ YP_EXPORTED_FUNCTION const char *
14
+ yp_token_type_to_str(yp_token_type_t token_type)
15
+ {
16
+ switch (token_type) {
17
+ case YP_TOKEN_EOF:
18
+ return "EOF";
19
+ case YP_TOKEN_MISSING:
20
+ return "MISSING";
21
+ case YP_TOKEN_NOT_PROVIDED:
22
+ return "NOT_PROVIDED";
23
+ case YP_TOKEN_AMPERSAND:
24
+ return "AMPERSAND";
25
+ case YP_TOKEN_AMPERSAND_AMPERSAND:
26
+ return "AMPERSAND_AMPERSAND";
27
+ case YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL:
28
+ return "AMPERSAND_AMPERSAND_EQUAL";
29
+ case YP_TOKEN_AMPERSAND_DOT:
30
+ return "AMPERSAND_DOT";
31
+ case YP_TOKEN_AMPERSAND_EQUAL:
32
+ return "AMPERSAND_EQUAL";
33
+ case YP_TOKEN_BACKTICK:
34
+ return "BACKTICK";
35
+ case YP_TOKEN_BACK_REFERENCE:
36
+ return "BACK_REFERENCE";
37
+ case YP_TOKEN_BANG:
38
+ return "BANG";
39
+ case YP_TOKEN_BANG_EQUAL:
40
+ return "BANG_EQUAL";
41
+ case YP_TOKEN_BANG_TILDE:
42
+ return "BANG_TILDE";
43
+ case YP_TOKEN_BRACE_LEFT:
44
+ return "BRACE_LEFT";
45
+ case YP_TOKEN_BRACE_RIGHT:
46
+ return "BRACE_RIGHT";
47
+ case YP_TOKEN_BRACKET_LEFT:
48
+ return "BRACKET_LEFT";
49
+ case YP_TOKEN_BRACKET_LEFT_ARRAY:
50
+ return "BRACKET_LEFT_ARRAY";
51
+ case YP_TOKEN_BRACKET_LEFT_RIGHT:
52
+ return "BRACKET_LEFT_RIGHT";
53
+ case YP_TOKEN_BRACKET_LEFT_RIGHT_EQUAL:
54
+ return "BRACKET_LEFT_RIGHT_EQUAL";
55
+ case YP_TOKEN_BRACKET_RIGHT:
56
+ return "BRACKET_RIGHT";
57
+ case YP_TOKEN_CARET:
58
+ return "CARET";
59
+ case YP_TOKEN_CARET_EQUAL:
60
+ return "CARET_EQUAL";
61
+ case YP_TOKEN_CHARACTER_LITERAL:
62
+ return "CHARACTER_LITERAL";
63
+ case YP_TOKEN_CLASS_VARIABLE:
64
+ return "CLASS_VARIABLE";
65
+ case YP_TOKEN_COLON:
66
+ return "COLON";
67
+ case YP_TOKEN_COLON_COLON:
68
+ return "COLON_COLON";
69
+ case YP_TOKEN_COMMA:
70
+ return "COMMA";
71
+ case YP_TOKEN_COMMENT:
72
+ return "COMMENT";
73
+ case YP_TOKEN_CONSTANT:
74
+ return "CONSTANT";
75
+ case YP_TOKEN_DOT:
76
+ return "DOT";
77
+ case YP_TOKEN_DOT_DOT:
78
+ return "DOT_DOT";
79
+ case YP_TOKEN_DOT_DOT_DOT:
80
+ return "DOT_DOT_DOT";
81
+ case YP_TOKEN_EMBDOC_BEGIN:
82
+ return "EMBDOC_BEGIN";
83
+ case YP_TOKEN_EMBDOC_END:
84
+ return "EMBDOC_END";
85
+ case YP_TOKEN_EMBDOC_LINE:
86
+ return "EMBDOC_LINE";
87
+ case YP_TOKEN_EMBEXPR_BEGIN:
88
+ return "EMBEXPR_BEGIN";
89
+ case YP_TOKEN_EMBEXPR_END:
90
+ return "EMBEXPR_END";
91
+ case YP_TOKEN_EMBVAR:
92
+ return "EMBVAR";
93
+ case YP_TOKEN_EQUAL:
94
+ return "EQUAL";
95
+ case YP_TOKEN_EQUAL_EQUAL:
96
+ return "EQUAL_EQUAL";
97
+ case YP_TOKEN_EQUAL_EQUAL_EQUAL:
98
+ return "EQUAL_EQUAL_EQUAL";
99
+ case YP_TOKEN_EQUAL_GREATER:
100
+ return "EQUAL_GREATER";
101
+ case YP_TOKEN_EQUAL_TILDE:
102
+ return "EQUAL_TILDE";
103
+ case YP_TOKEN_FLOAT:
104
+ return "FLOAT";
105
+ case YP_TOKEN_FLOAT_IMAGINARY:
106
+ return "FLOAT_IMAGINARY";
107
+ case YP_TOKEN_FLOAT_RATIONAL:
108
+ return "FLOAT_RATIONAL";
109
+ case YP_TOKEN_FLOAT_RATIONAL_IMAGINARY:
110
+ return "FLOAT_RATIONAL_IMAGINARY";
111
+ case YP_TOKEN_GLOBAL_VARIABLE:
112
+ return "GLOBAL_VARIABLE";
113
+ case YP_TOKEN_GREATER:
114
+ return "GREATER";
115
+ case YP_TOKEN_GREATER_EQUAL:
116
+ return "GREATER_EQUAL";
117
+ case YP_TOKEN_GREATER_GREATER:
118
+ return "GREATER_GREATER";
119
+ case YP_TOKEN_GREATER_GREATER_EQUAL:
120
+ return "GREATER_GREATER_EQUAL";
121
+ case YP_TOKEN_HEREDOC_END:
122
+ return "HEREDOC_END";
123
+ case YP_TOKEN_HEREDOC_START:
124
+ return "HEREDOC_START";
125
+ case YP_TOKEN_IDENTIFIER:
126
+ return "IDENTIFIER";
127
+ case YP_TOKEN_IGNORED_NEWLINE:
128
+ return "IGNORED_NEWLINE";
129
+ case YP_TOKEN_INSTANCE_VARIABLE:
130
+ return "INSTANCE_VARIABLE";
131
+ case YP_TOKEN_INTEGER:
132
+ return "INTEGER";
133
+ case YP_TOKEN_INTEGER_IMAGINARY:
134
+ return "INTEGER_IMAGINARY";
135
+ case YP_TOKEN_INTEGER_RATIONAL:
136
+ return "INTEGER_RATIONAL";
137
+ case YP_TOKEN_INTEGER_RATIONAL_IMAGINARY:
138
+ return "INTEGER_RATIONAL_IMAGINARY";
139
+ case YP_TOKEN_KEYWORD_ALIAS:
140
+ return "KEYWORD_ALIAS";
141
+ case YP_TOKEN_KEYWORD_AND:
142
+ return "KEYWORD_AND";
143
+ case YP_TOKEN_KEYWORD_BEGIN:
144
+ return "KEYWORD_BEGIN";
145
+ case YP_TOKEN_KEYWORD_BEGIN_UPCASE:
146
+ return "KEYWORD_BEGIN_UPCASE";
147
+ case YP_TOKEN_KEYWORD_BREAK:
148
+ return "KEYWORD_BREAK";
149
+ case YP_TOKEN_KEYWORD_CASE:
150
+ return "KEYWORD_CASE";
151
+ case YP_TOKEN_KEYWORD_CLASS:
152
+ return "KEYWORD_CLASS";
153
+ case YP_TOKEN_KEYWORD_DEF:
154
+ return "KEYWORD_DEF";
155
+ case YP_TOKEN_KEYWORD_DEFINED:
156
+ return "KEYWORD_DEFINED";
157
+ case YP_TOKEN_KEYWORD_DO:
158
+ return "KEYWORD_DO";
159
+ case YP_TOKEN_KEYWORD_DO_LOOP:
160
+ return "KEYWORD_DO_LOOP";
161
+ case YP_TOKEN_KEYWORD_ELSE:
162
+ return "KEYWORD_ELSE";
163
+ case YP_TOKEN_KEYWORD_ELSIF:
164
+ return "KEYWORD_ELSIF";
165
+ case YP_TOKEN_KEYWORD_END:
166
+ return "KEYWORD_END";
167
+ case YP_TOKEN_KEYWORD_END_UPCASE:
168
+ return "KEYWORD_END_UPCASE";
169
+ case YP_TOKEN_KEYWORD_ENSURE:
170
+ return "KEYWORD_ENSURE";
171
+ case YP_TOKEN_KEYWORD_FALSE:
172
+ return "KEYWORD_FALSE";
173
+ case YP_TOKEN_KEYWORD_FOR:
174
+ return "KEYWORD_FOR";
175
+ case YP_TOKEN_KEYWORD_IF:
176
+ return "KEYWORD_IF";
177
+ case YP_TOKEN_KEYWORD_IF_MODIFIER:
178
+ return "KEYWORD_IF_MODIFIER";
179
+ case YP_TOKEN_KEYWORD_IN:
180
+ return "KEYWORD_IN";
181
+ case YP_TOKEN_KEYWORD_MODULE:
182
+ return "KEYWORD_MODULE";
183
+ case YP_TOKEN_KEYWORD_NEXT:
184
+ return "KEYWORD_NEXT";
185
+ case YP_TOKEN_KEYWORD_NIL:
186
+ return "KEYWORD_NIL";
187
+ case YP_TOKEN_KEYWORD_NOT:
188
+ return "KEYWORD_NOT";
189
+ case YP_TOKEN_KEYWORD_OR:
190
+ return "KEYWORD_OR";
191
+ case YP_TOKEN_KEYWORD_REDO:
192
+ return "KEYWORD_REDO";
193
+ case YP_TOKEN_KEYWORD_RESCUE:
194
+ return "KEYWORD_RESCUE";
195
+ case YP_TOKEN_KEYWORD_RESCUE_MODIFIER:
196
+ return "KEYWORD_RESCUE_MODIFIER";
197
+ case YP_TOKEN_KEYWORD_RETRY:
198
+ return "KEYWORD_RETRY";
199
+ case YP_TOKEN_KEYWORD_RETURN:
200
+ return "KEYWORD_RETURN";
201
+ case YP_TOKEN_KEYWORD_SELF:
202
+ return "KEYWORD_SELF";
203
+ case YP_TOKEN_KEYWORD_SUPER:
204
+ return "KEYWORD_SUPER";
205
+ case YP_TOKEN_KEYWORD_THEN:
206
+ return "KEYWORD_THEN";
207
+ case YP_TOKEN_KEYWORD_TRUE:
208
+ return "KEYWORD_TRUE";
209
+ case YP_TOKEN_KEYWORD_UNDEF:
210
+ return "KEYWORD_UNDEF";
211
+ case YP_TOKEN_KEYWORD_UNLESS:
212
+ return "KEYWORD_UNLESS";
213
+ case YP_TOKEN_KEYWORD_UNLESS_MODIFIER:
214
+ return "KEYWORD_UNLESS_MODIFIER";
215
+ case YP_TOKEN_KEYWORD_UNTIL:
216
+ return "KEYWORD_UNTIL";
217
+ case YP_TOKEN_KEYWORD_UNTIL_MODIFIER:
218
+ return "KEYWORD_UNTIL_MODIFIER";
219
+ case YP_TOKEN_KEYWORD_WHEN:
220
+ return "KEYWORD_WHEN";
221
+ case YP_TOKEN_KEYWORD_WHILE:
222
+ return "KEYWORD_WHILE";
223
+ case YP_TOKEN_KEYWORD_WHILE_MODIFIER:
224
+ return "KEYWORD_WHILE_MODIFIER";
225
+ case YP_TOKEN_KEYWORD_YIELD:
226
+ return "KEYWORD_YIELD";
227
+ case YP_TOKEN_KEYWORD___ENCODING__:
228
+ return "KEYWORD___ENCODING__";
229
+ case YP_TOKEN_KEYWORD___FILE__:
230
+ return "KEYWORD___FILE__";
231
+ case YP_TOKEN_KEYWORD___LINE__:
232
+ return "KEYWORD___LINE__";
233
+ case YP_TOKEN_LABEL:
234
+ return "LABEL";
235
+ case YP_TOKEN_LABEL_END:
236
+ return "LABEL_END";
237
+ case YP_TOKEN_LAMBDA_BEGIN:
238
+ return "LAMBDA_BEGIN";
239
+ case YP_TOKEN_LESS:
240
+ return "LESS";
241
+ case YP_TOKEN_LESS_EQUAL:
242
+ return "LESS_EQUAL";
243
+ case YP_TOKEN_LESS_EQUAL_GREATER:
244
+ return "LESS_EQUAL_GREATER";
245
+ case YP_TOKEN_LESS_LESS:
246
+ return "LESS_LESS";
247
+ case YP_TOKEN_LESS_LESS_EQUAL:
248
+ return "LESS_LESS_EQUAL";
249
+ case YP_TOKEN_MINUS:
250
+ return "MINUS";
251
+ case YP_TOKEN_MINUS_EQUAL:
252
+ return "MINUS_EQUAL";
253
+ case YP_TOKEN_MINUS_GREATER:
254
+ return "MINUS_GREATER";
255
+ case YP_TOKEN_NEWLINE:
256
+ return "NEWLINE";
257
+ case YP_TOKEN_NUMBERED_REFERENCE:
258
+ return "NUMBERED_REFERENCE";
259
+ case YP_TOKEN_PARENTHESIS_LEFT:
260
+ return "PARENTHESIS_LEFT";
261
+ case YP_TOKEN_PARENTHESIS_LEFT_PARENTHESES:
262
+ return "PARENTHESIS_LEFT_PARENTHESES";
263
+ case YP_TOKEN_PARENTHESIS_RIGHT:
264
+ return "PARENTHESIS_RIGHT";
265
+ case YP_TOKEN_PERCENT:
266
+ return "PERCENT";
267
+ case YP_TOKEN_PERCENT_EQUAL:
268
+ return "PERCENT_EQUAL";
269
+ case YP_TOKEN_PERCENT_LOWER_I:
270
+ return "PERCENT_LOWER_I";
271
+ case YP_TOKEN_PERCENT_LOWER_W:
272
+ return "PERCENT_LOWER_W";
273
+ case YP_TOKEN_PERCENT_LOWER_X:
274
+ return "PERCENT_LOWER_X";
275
+ case YP_TOKEN_PERCENT_UPPER_I:
276
+ return "PERCENT_UPPER_I";
277
+ case YP_TOKEN_PERCENT_UPPER_W:
278
+ return "PERCENT_UPPER_W";
279
+ case YP_TOKEN_PIPE:
280
+ return "PIPE";
281
+ case YP_TOKEN_PIPE_EQUAL:
282
+ return "PIPE_EQUAL";
283
+ case YP_TOKEN_PIPE_PIPE:
284
+ return "PIPE_PIPE";
285
+ case YP_TOKEN_PIPE_PIPE_EQUAL:
286
+ return "PIPE_PIPE_EQUAL";
287
+ case YP_TOKEN_PLUS:
288
+ return "PLUS";
289
+ case YP_TOKEN_PLUS_EQUAL:
290
+ return "PLUS_EQUAL";
291
+ case YP_TOKEN_QUESTION_MARK:
292
+ return "QUESTION_MARK";
293
+ case YP_TOKEN_REGEXP_BEGIN:
294
+ return "REGEXP_BEGIN";
295
+ case YP_TOKEN_REGEXP_END:
296
+ return "REGEXP_END";
297
+ case YP_TOKEN_SEMICOLON:
298
+ return "SEMICOLON";
299
+ case YP_TOKEN_SLASH:
300
+ return "SLASH";
301
+ case YP_TOKEN_SLASH_EQUAL:
302
+ return "SLASH_EQUAL";
303
+ case YP_TOKEN_STAR:
304
+ return "STAR";
305
+ case YP_TOKEN_STAR_EQUAL:
306
+ return "STAR_EQUAL";
307
+ case YP_TOKEN_STAR_STAR:
308
+ return "STAR_STAR";
309
+ case YP_TOKEN_STAR_STAR_EQUAL:
310
+ return "STAR_STAR_EQUAL";
311
+ case YP_TOKEN_STRING_BEGIN:
312
+ return "STRING_BEGIN";
313
+ case YP_TOKEN_STRING_CONTENT:
314
+ return "STRING_CONTENT";
315
+ case YP_TOKEN_STRING_END:
316
+ return "STRING_END";
317
+ case YP_TOKEN_SYMBOL_BEGIN:
318
+ return "SYMBOL_BEGIN";
319
+ case YP_TOKEN_TILDE:
320
+ return "TILDE";
321
+ case YP_TOKEN_UAMPERSAND:
322
+ return "UAMPERSAND";
323
+ case YP_TOKEN_UCOLON_COLON:
324
+ return "UCOLON_COLON";
325
+ case YP_TOKEN_UDOT_DOT:
326
+ return "UDOT_DOT";
327
+ case YP_TOKEN_UDOT_DOT_DOT:
328
+ return "UDOT_DOT_DOT";
329
+ case YP_TOKEN_UMINUS:
330
+ return "UMINUS";
331
+ case YP_TOKEN_UMINUS_NUM:
332
+ return "UMINUS_NUM";
333
+ case YP_TOKEN_UPLUS:
334
+ return "UPLUS";
335
+ case YP_TOKEN_USTAR:
336
+ return "USTAR";
337
+ case YP_TOKEN_USTAR_STAR:
338
+ return "USTAR_STAR";
339
+ case YP_TOKEN_WORDS_SEP:
340
+ return "WORDS_SEP";
341
+ case YP_TOKEN___END__:
342
+ return "__END__";
343
+ case YP_TOKEN_MAXIMUM:
344
+ return "MAXIMUM";
345
+ }
346
+ return "\0";
347
+ }