prism 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/README.md +4 -1
- data/config.yml +10 -14
- data/docs/fuzzing.md +5 -10
- data/docs/prism.png +0 -0
- data/docs/serialization.md +10 -0
- data/ext/prism/api_node.c +35 -28
- data/ext/prism/extension.c +35 -48
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +38 -36
- data/include/prism/node.h +1 -0
- data/include/prism/parser.h +26 -0
- data/include/prism/util/pm_buffer.h +3 -0
- data/include/prism/util/pm_constant_pool.h +5 -0
- data/include/prism/util/pm_string.h +2 -1
- data/include/prism/version.h +2 -2
- data/include/prism.h +0 -1
- data/lib/prism/compiler.rb +141 -141
- data/lib/prism/ffi.rb +2 -2
- data/lib/prism/lex_compat.rb +42 -8
- data/lib/prism/node.rb +1456 -46
- data/lib/prism/node_ext.rb +44 -0
- data/lib/prism/parse_result.rb +32 -5
- data/lib/prism/pattern.rb +1 -1
- data/lib/prism/serialize.rb +16 -14
- data/prism.gemspec +2 -3
- data/src/diagnostic.c +1 -1
- data/src/node.c +0 -14
- data/src/prettyprint.c +35 -35
- data/src/prism.c +1728 -811
- data/src/serialize.c +45 -22
- data/src/util/pm_buffer.c +9 -7
- metadata +3 -4
- data/include/prism/unescape.h +0 -48
- data/src/unescape.c +0 -637
data/lib/prism/compiler.rb
CHANGED
@@ -39,426 +39,426 @@ module Prism
|
|
39
39
|
node.compact_child_nodes.map { |node| node.accept(self) }
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
# Compile a AliasGlobalVariableNode node
|
43
43
|
alias visit_alias_global_variable_node visit_child_nodes
|
44
|
-
|
44
|
+
|
45
45
|
# Compile a AliasMethodNode node
|
46
46
|
alias visit_alias_method_node visit_child_nodes
|
47
|
-
|
47
|
+
|
48
48
|
# Compile a AlternationPatternNode node
|
49
49
|
alias visit_alternation_pattern_node visit_child_nodes
|
50
|
-
|
50
|
+
|
51
51
|
# Compile a AndNode node
|
52
52
|
alias visit_and_node visit_child_nodes
|
53
|
-
|
53
|
+
|
54
54
|
# Compile a ArgumentsNode node
|
55
55
|
alias visit_arguments_node visit_child_nodes
|
56
|
-
|
56
|
+
|
57
57
|
# Compile a ArrayNode node
|
58
58
|
alias visit_array_node visit_child_nodes
|
59
|
-
|
59
|
+
|
60
60
|
# Compile a ArrayPatternNode node
|
61
61
|
alias visit_array_pattern_node visit_child_nodes
|
62
|
-
|
62
|
+
|
63
63
|
# Compile a AssocNode node
|
64
64
|
alias visit_assoc_node visit_child_nodes
|
65
|
-
|
65
|
+
|
66
66
|
# Compile a AssocSplatNode node
|
67
67
|
alias visit_assoc_splat_node visit_child_nodes
|
68
|
-
|
68
|
+
|
69
69
|
# Compile a BackReferenceReadNode node
|
70
70
|
alias visit_back_reference_read_node visit_child_nodes
|
71
|
-
|
71
|
+
|
72
72
|
# Compile a BeginNode node
|
73
73
|
alias visit_begin_node visit_child_nodes
|
74
|
-
|
74
|
+
|
75
75
|
# Compile a BlockArgumentNode node
|
76
76
|
alias visit_block_argument_node visit_child_nodes
|
77
|
-
|
77
|
+
|
78
78
|
# Compile a BlockLocalVariableNode node
|
79
79
|
alias visit_block_local_variable_node visit_child_nodes
|
80
|
-
|
80
|
+
|
81
81
|
# Compile a BlockNode node
|
82
82
|
alias visit_block_node visit_child_nodes
|
83
|
-
|
83
|
+
|
84
84
|
# Compile a BlockParameterNode node
|
85
85
|
alias visit_block_parameter_node visit_child_nodes
|
86
|
-
|
86
|
+
|
87
87
|
# Compile a BlockParametersNode node
|
88
88
|
alias visit_block_parameters_node visit_child_nodes
|
89
|
-
|
89
|
+
|
90
90
|
# Compile a BreakNode node
|
91
91
|
alias visit_break_node visit_child_nodes
|
92
|
-
|
92
|
+
|
93
93
|
# Compile a CallAndWriteNode node
|
94
94
|
alias visit_call_and_write_node visit_child_nodes
|
95
|
-
|
95
|
+
|
96
96
|
# Compile a CallNode node
|
97
97
|
alias visit_call_node visit_child_nodes
|
98
|
-
|
98
|
+
|
99
99
|
# Compile a CallOperatorWriteNode node
|
100
100
|
alias visit_call_operator_write_node visit_child_nodes
|
101
|
-
|
101
|
+
|
102
102
|
# Compile a CallOrWriteNode node
|
103
103
|
alias visit_call_or_write_node visit_child_nodes
|
104
|
-
|
104
|
+
|
105
105
|
# Compile a CapturePatternNode node
|
106
106
|
alias visit_capture_pattern_node visit_child_nodes
|
107
|
-
|
107
|
+
|
108
108
|
# Compile a CaseNode node
|
109
109
|
alias visit_case_node visit_child_nodes
|
110
|
-
|
110
|
+
|
111
111
|
# Compile a ClassNode node
|
112
112
|
alias visit_class_node visit_child_nodes
|
113
|
-
|
113
|
+
|
114
114
|
# Compile a ClassVariableAndWriteNode node
|
115
115
|
alias visit_class_variable_and_write_node visit_child_nodes
|
116
|
-
|
116
|
+
|
117
117
|
# Compile a ClassVariableOperatorWriteNode node
|
118
118
|
alias visit_class_variable_operator_write_node visit_child_nodes
|
119
|
-
|
119
|
+
|
120
120
|
# Compile a ClassVariableOrWriteNode node
|
121
121
|
alias visit_class_variable_or_write_node visit_child_nodes
|
122
|
-
|
122
|
+
|
123
123
|
# Compile a ClassVariableReadNode node
|
124
124
|
alias visit_class_variable_read_node visit_child_nodes
|
125
|
-
|
125
|
+
|
126
126
|
# Compile a ClassVariableTargetNode node
|
127
127
|
alias visit_class_variable_target_node visit_child_nodes
|
128
|
-
|
128
|
+
|
129
129
|
# Compile a ClassVariableWriteNode node
|
130
130
|
alias visit_class_variable_write_node visit_child_nodes
|
131
|
-
|
131
|
+
|
132
132
|
# Compile a ConstantAndWriteNode node
|
133
133
|
alias visit_constant_and_write_node visit_child_nodes
|
134
|
-
|
134
|
+
|
135
135
|
# Compile a ConstantOperatorWriteNode node
|
136
136
|
alias visit_constant_operator_write_node visit_child_nodes
|
137
|
-
|
137
|
+
|
138
138
|
# Compile a ConstantOrWriteNode node
|
139
139
|
alias visit_constant_or_write_node visit_child_nodes
|
140
|
-
|
140
|
+
|
141
141
|
# Compile a ConstantPathAndWriteNode node
|
142
142
|
alias visit_constant_path_and_write_node visit_child_nodes
|
143
|
-
|
143
|
+
|
144
144
|
# Compile a ConstantPathNode node
|
145
145
|
alias visit_constant_path_node visit_child_nodes
|
146
|
-
|
146
|
+
|
147
147
|
# Compile a ConstantPathOperatorWriteNode node
|
148
148
|
alias visit_constant_path_operator_write_node visit_child_nodes
|
149
|
-
|
149
|
+
|
150
150
|
# Compile a ConstantPathOrWriteNode node
|
151
151
|
alias visit_constant_path_or_write_node visit_child_nodes
|
152
|
-
|
152
|
+
|
153
153
|
# Compile a ConstantPathTargetNode node
|
154
154
|
alias visit_constant_path_target_node visit_child_nodes
|
155
|
-
|
155
|
+
|
156
156
|
# Compile a ConstantPathWriteNode node
|
157
157
|
alias visit_constant_path_write_node visit_child_nodes
|
158
|
-
|
158
|
+
|
159
159
|
# Compile a ConstantReadNode node
|
160
160
|
alias visit_constant_read_node visit_child_nodes
|
161
|
-
|
161
|
+
|
162
162
|
# Compile a ConstantTargetNode node
|
163
163
|
alias visit_constant_target_node visit_child_nodes
|
164
|
-
|
164
|
+
|
165
165
|
# Compile a ConstantWriteNode node
|
166
166
|
alias visit_constant_write_node visit_child_nodes
|
167
|
-
|
167
|
+
|
168
168
|
# Compile a DefNode node
|
169
169
|
alias visit_def_node visit_child_nodes
|
170
|
-
|
170
|
+
|
171
171
|
# Compile a DefinedNode node
|
172
172
|
alias visit_defined_node visit_child_nodes
|
173
|
-
|
173
|
+
|
174
174
|
# Compile a ElseNode node
|
175
175
|
alias visit_else_node visit_child_nodes
|
176
|
-
|
176
|
+
|
177
177
|
# Compile a EmbeddedStatementsNode node
|
178
178
|
alias visit_embedded_statements_node visit_child_nodes
|
179
|
-
|
179
|
+
|
180
180
|
# Compile a EmbeddedVariableNode node
|
181
181
|
alias visit_embedded_variable_node visit_child_nodes
|
182
|
-
|
182
|
+
|
183
183
|
# Compile a EnsureNode node
|
184
184
|
alias visit_ensure_node visit_child_nodes
|
185
|
-
|
185
|
+
|
186
186
|
# Compile a FalseNode node
|
187
187
|
alias visit_false_node visit_child_nodes
|
188
|
-
|
188
|
+
|
189
189
|
# Compile a FindPatternNode node
|
190
190
|
alias visit_find_pattern_node visit_child_nodes
|
191
|
-
|
191
|
+
|
192
192
|
# Compile a FlipFlopNode node
|
193
193
|
alias visit_flip_flop_node visit_child_nodes
|
194
|
-
|
194
|
+
|
195
195
|
# Compile a FloatNode node
|
196
196
|
alias visit_float_node visit_child_nodes
|
197
|
-
|
197
|
+
|
198
198
|
# Compile a ForNode node
|
199
199
|
alias visit_for_node visit_child_nodes
|
200
|
-
|
200
|
+
|
201
201
|
# Compile a ForwardingArgumentsNode node
|
202
202
|
alias visit_forwarding_arguments_node visit_child_nodes
|
203
|
-
|
203
|
+
|
204
204
|
# Compile a ForwardingParameterNode node
|
205
205
|
alias visit_forwarding_parameter_node visit_child_nodes
|
206
|
-
|
206
|
+
|
207
207
|
# Compile a ForwardingSuperNode node
|
208
208
|
alias visit_forwarding_super_node visit_child_nodes
|
209
|
-
|
209
|
+
|
210
210
|
# Compile a GlobalVariableAndWriteNode node
|
211
211
|
alias visit_global_variable_and_write_node visit_child_nodes
|
212
|
-
|
212
|
+
|
213
213
|
# Compile a GlobalVariableOperatorWriteNode node
|
214
214
|
alias visit_global_variable_operator_write_node visit_child_nodes
|
215
|
-
|
215
|
+
|
216
216
|
# Compile a GlobalVariableOrWriteNode node
|
217
217
|
alias visit_global_variable_or_write_node visit_child_nodes
|
218
|
-
|
218
|
+
|
219
219
|
# Compile a GlobalVariableReadNode node
|
220
220
|
alias visit_global_variable_read_node visit_child_nodes
|
221
|
-
|
221
|
+
|
222
222
|
# Compile a GlobalVariableTargetNode node
|
223
223
|
alias visit_global_variable_target_node visit_child_nodes
|
224
|
-
|
224
|
+
|
225
225
|
# Compile a GlobalVariableWriteNode node
|
226
226
|
alias visit_global_variable_write_node visit_child_nodes
|
227
|
-
|
227
|
+
|
228
228
|
# Compile a HashNode node
|
229
229
|
alias visit_hash_node visit_child_nodes
|
230
|
-
|
230
|
+
|
231
231
|
# Compile a HashPatternNode node
|
232
232
|
alias visit_hash_pattern_node visit_child_nodes
|
233
|
-
|
233
|
+
|
234
234
|
# Compile a IfNode node
|
235
235
|
alias visit_if_node visit_child_nodes
|
236
|
-
|
236
|
+
|
237
237
|
# Compile a ImaginaryNode node
|
238
238
|
alias visit_imaginary_node visit_child_nodes
|
239
|
-
|
239
|
+
|
240
240
|
# Compile a ImplicitNode node
|
241
241
|
alias visit_implicit_node visit_child_nodes
|
242
|
-
|
242
|
+
|
243
243
|
# Compile a InNode node
|
244
244
|
alias visit_in_node visit_child_nodes
|
245
|
-
|
245
|
+
|
246
246
|
# Compile a InstanceVariableAndWriteNode node
|
247
247
|
alias visit_instance_variable_and_write_node visit_child_nodes
|
248
|
-
|
248
|
+
|
249
249
|
# Compile a InstanceVariableOperatorWriteNode node
|
250
250
|
alias visit_instance_variable_operator_write_node visit_child_nodes
|
251
|
-
|
251
|
+
|
252
252
|
# Compile a InstanceVariableOrWriteNode node
|
253
253
|
alias visit_instance_variable_or_write_node visit_child_nodes
|
254
|
-
|
254
|
+
|
255
255
|
# Compile a InstanceVariableReadNode node
|
256
256
|
alias visit_instance_variable_read_node visit_child_nodes
|
257
|
-
|
257
|
+
|
258
258
|
# Compile a InstanceVariableTargetNode node
|
259
259
|
alias visit_instance_variable_target_node visit_child_nodes
|
260
|
-
|
260
|
+
|
261
261
|
# Compile a InstanceVariableWriteNode node
|
262
262
|
alias visit_instance_variable_write_node visit_child_nodes
|
263
|
-
|
263
|
+
|
264
264
|
# Compile a IntegerNode node
|
265
265
|
alias visit_integer_node visit_child_nodes
|
266
|
-
|
266
|
+
|
267
267
|
# Compile a InterpolatedMatchLastLineNode node
|
268
268
|
alias visit_interpolated_match_last_line_node visit_child_nodes
|
269
|
-
|
269
|
+
|
270
270
|
# Compile a InterpolatedRegularExpressionNode node
|
271
271
|
alias visit_interpolated_regular_expression_node visit_child_nodes
|
272
|
-
|
272
|
+
|
273
273
|
# Compile a InterpolatedStringNode node
|
274
274
|
alias visit_interpolated_string_node visit_child_nodes
|
275
|
-
|
275
|
+
|
276
276
|
# Compile a InterpolatedSymbolNode node
|
277
277
|
alias visit_interpolated_symbol_node visit_child_nodes
|
278
|
-
|
278
|
+
|
279
279
|
# Compile a InterpolatedXStringNode node
|
280
280
|
alias visit_interpolated_x_string_node visit_child_nodes
|
281
|
-
|
281
|
+
|
282
282
|
# Compile a KeywordHashNode node
|
283
283
|
alias visit_keyword_hash_node visit_child_nodes
|
284
|
-
|
284
|
+
|
285
285
|
# Compile a KeywordParameterNode node
|
286
286
|
alias visit_keyword_parameter_node visit_child_nodes
|
287
|
-
|
287
|
+
|
288
288
|
# Compile a KeywordRestParameterNode node
|
289
289
|
alias visit_keyword_rest_parameter_node visit_child_nodes
|
290
|
-
|
290
|
+
|
291
291
|
# Compile a LambdaNode node
|
292
292
|
alias visit_lambda_node visit_child_nodes
|
293
|
-
|
293
|
+
|
294
294
|
# Compile a LocalVariableAndWriteNode node
|
295
295
|
alias visit_local_variable_and_write_node visit_child_nodes
|
296
|
-
|
296
|
+
|
297
297
|
# Compile a LocalVariableOperatorWriteNode node
|
298
298
|
alias visit_local_variable_operator_write_node visit_child_nodes
|
299
|
-
|
299
|
+
|
300
300
|
# Compile a LocalVariableOrWriteNode node
|
301
301
|
alias visit_local_variable_or_write_node visit_child_nodes
|
302
|
-
|
302
|
+
|
303
303
|
# Compile a LocalVariableReadNode node
|
304
304
|
alias visit_local_variable_read_node visit_child_nodes
|
305
|
-
|
305
|
+
|
306
306
|
# Compile a LocalVariableTargetNode node
|
307
307
|
alias visit_local_variable_target_node visit_child_nodes
|
308
|
-
|
308
|
+
|
309
309
|
# Compile a LocalVariableWriteNode node
|
310
310
|
alias visit_local_variable_write_node visit_child_nodes
|
311
|
-
|
311
|
+
|
312
312
|
# Compile a MatchLastLineNode node
|
313
313
|
alias visit_match_last_line_node visit_child_nodes
|
314
|
-
|
314
|
+
|
315
315
|
# Compile a MatchPredicateNode node
|
316
316
|
alias visit_match_predicate_node visit_child_nodes
|
317
|
-
|
317
|
+
|
318
318
|
# Compile a MatchRequiredNode node
|
319
319
|
alias visit_match_required_node visit_child_nodes
|
320
|
-
|
320
|
+
|
321
321
|
# Compile a MatchWriteNode node
|
322
322
|
alias visit_match_write_node visit_child_nodes
|
323
|
-
|
323
|
+
|
324
324
|
# Compile a MissingNode node
|
325
325
|
alias visit_missing_node visit_child_nodes
|
326
|
-
|
326
|
+
|
327
327
|
# Compile a ModuleNode node
|
328
328
|
alias visit_module_node visit_child_nodes
|
329
|
-
|
329
|
+
|
330
330
|
# Compile a MultiTargetNode node
|
331
331
|
alias visit_multi_target_node visit_child_nodes
|
332
|
-
|
332
|
+
|
333
333
|
# Compile a MultiWriteNode node
|
334
334
|
alias visit_multi_write_node visit_child_nodes
|
335
|
-
|
335
|
+
|
336
336
|
# Compile a NextNode node
|
337
337
|
alias visit_next_node visit_child_nodes
|
338
|
-
|
338
|
+
|
339
339
|
# Compile a NilNode node
|
340
340
|
alias visit_nil_node visit_child_nodes
|
341
|
-
|
341
|
+
|
342
342
|
# Compile a NoKeywordsParameterNode node
|
343
343
|
alias visit_no_keywords_parameter_node visit_child_nodes
|
344
|
-
|
344
|
+
|
345
345
|
# Compile a NumberedReferenceReadNode node
|
346
346
|
alias visit_numbered_reference_read_node visit_child_nodes
|
347
|
-
|
347
|
+
|
348
348
|
# Compile a OptionalParameterNode node
|
349
349
|
alias visit_optional_parameter_node visit_child_nodes
|
350
|
-
|
350
|
+
|
351
351
|
# Compile a OrNode node
|
352
352
|
alias visit_or_node visit_child_nodes
|
353
|
-
|
353
|
+
|
354
354
|
# Compile a ParametersNode node
|
355
355
|
alias visit_parameters_node visit_child_nodes
|
356
|
-
|
356
|
+
|
357
357
|
# Compile a ParenthesesNode node
|
358
358
|
alias visit_parentheses_node visit_child_nodes
|
359
|
-
|
359
|
+
|
360
360
|
# Compile a PinnedExpressionNode node
|
361
361
|
alias visit_pinned_expression_node visit_child_nodes
|
362
|
-
|
362
|
+
|
363
363
|
# Compile a PinnedVariableNode node
|
364
364
|
alias visit_pinned_variable_node visit_child_nodes
|
365
|
-
|
365
|
+
|
366
366
|
# Compile a PostExecutionNode node
|
367
367
|
alias visit_post_execution_node visit_child_nodes
|
368
|
-
|
368
|
+
|
369
369
|
# Compile a PreExecutionNode node
|
370
370
|
alias visit_pre_execution_node visit_child_nodes
|
371
|
-
|
371
|
+
|
372
372
|
# Compile a ProgramNode node
|
373
373
|
alias visit_program_node visit_child_nodes
|
374
|
-
|
374
|
+
|
375
375
|
# Compile a RangeNode node
|
376
376
|
alias visit_range_node visit_child_nodes
|
377
|
-
|
377
|
+
|
378
378
|
# Compile a RationalNode node
|
379
379
|
alias visit_rational_node visit_child_nodes
|
380
|
-
|
380
|
+
|
381
381
|
# Compile a RedoNode node
|
382
382
|
alias visit_redo_node visit_child_nodes
|
383
|
-
|
383
|
+
|
384
384
|
# Compile a RegularExpressionNode node
|
385
385
|
alias visit_regular_expression_node visit_child_nodes
|
386
|
-
|
386
|
+
|
387
387
|
# Compile a RequiredDestructuredParameterNode node
|
388
388
|
alias visit_required_destructured_parameter_node visit_child_nodes
|
389
|
-
|
389
|
+
|
390
390
|
# Compile a RequiredParameterNode node
|
391
391
|
alias visit_required_parameter_node visit_child_nodes
|
392
|
-
|
392
|
+
|
393
393
|
# Compile a RescueModifierNode node
|
394
394
|
alias visit_rescue_modifier_node visit_child_nodes
|
395
|
-
|
395
|
+
|
396
396
|
# Compile a RescueNode node
|
397
397
|
alias visit_rescue_node visit_child_nodes
|
398
|
-
|
398
|
+
|
399
399
|
# Compile a RestParameterNode node
|
400
400
|
alias visit_rest_parameter_node visit_child_nodes
|
401
|
-
|
401
|
+
|
402
402
|
# Compile a RetryNode node
|
403
403
|
alias visit_retry_node visit_child_nodes
|
404
|
-
|
404
|
+
|
405
405
|
# Compile a ReturnNode node
|
406
406
|
alias visit_return_node visit_child_nodes
|
407
|
-
|
407
|
+
|
408
408
|
# Compile a SelfNode node
|
409
409
|
alias visit_self_node visit_child_nodes
|
410
|
-
|
410
|
+
|
411
411
|
# Compile a SingletonClassNode node
|
412
412
|
alias visit_singleton_class_node visit_child_nodes
|
413
|
-
|
413
|
+
|
414
414
|
# Compile a SourceEncodingNode node
|
415
415
|
alias visit_source_encoding_node visit_child_nodes
|
416
|
-
|
416
|
+
|
417
417
|
# Compile a SourceFileNode node
|
418
418
|
alias visit_source_file_node visit_child_nodes
|
419
|
-
|
419
|
+
|
420
420
|
# Compile a SourceLineNode node
|
421
421
|
alias visit_source_line_node visit_child_nodes
|
422
|
-
|
422
|
+
|
423
423
|
# Compile a SplatNode node
|
424
424
|
alias visit_splat_node visit_child_nodes
|
425
|
-
|
425
|
+
|
426
426
|
# Compile a StatementsNode node
|
427
427
|
alias visit_statements_node visit_child_nodes
|
428
|
-
|
428
|
+
|
429
429
|
# Compile a StringConcatNode node
|
430
430
|
alias visit_string_concat_node visit_child_nodes
|
431
|
-
|
431
|
+
|
432
432
|
# Compile a StringNode node
|
433
433
|
alias visit_string_node visit_child_nodes
|
434
|
-
|
434
|
+
|
435
435
|
# Compile a SuperNode node
|
436
436
|
alias visit_super_node visit_child_nodes
|
437
|
-
|
437
|
+
|
438
438
|
# Compile a SymbolNode node
|
439
439
|
alias visit_symbol_node visit_child_nodes
|
440
|
-
|
440
|
+
|
441
441
|
# Compile a TrueNode node
|
442
442
|
alias visit_true_node visit_child_nodes
|
443
|
-
|
443
|
+
|
444
444
|
# Compile a UndefNode node
|
445
445
|
alias visit_undef_node visit_child_nodes
|
446
|
-
|
446
|
+
|
447
447
|
# Compile a UnlessNode node
|
448
448
|
alias visit_unless_node visit_child_nodes
|
449
|
-
|
449
|
+
|
450
450
|
# Compile a UntilNode node
|
451
451
|
alias visit_until_node visit_child_nodes
|
452
|
-
|
452
|
+
|
453
453
|
# Compile a WhenNode node
|
454
454
|
alias visit_when_node visit_child_nodes
|
455
|
-
|
455
|
+
|
456
456
|
# Compile a WhileNode node
|
457
457
|
alias visit_while_node visit_child_nodes
|
458
|
-
|
458
|
+
|
459
459
|
# Compile a XStringNode node
|
460
460
|
alias visit_x_string_node visit_child_nodes
|
461
|
-
|
461
|
+
|
462
462
|
# Compile a YieldNode node
|
463
463
|
alias visit_yield_node visit_child_nodes
|
464
464
|
end
|
data/lib/prism/ffi.rb
CHANGED
@@ -234,11 +234,11 @@ module Prism
|
|
234
234
|
loader = Serialize::Loader.new(source, buffer.read)
|
235
235
|
|
236
236
|
tokens = loader.load_tokens
|
237
|
-
node, comments, errors, warnings = loader.load_nodes
|
237
|
+
node, comments, magic_comments, errors, warnings = loader.load_nodes
|
238
238
|
|
239
239
|
tokens.each { |token,| token.value.force_encoding(loader.encoding) }
|
240
240
|
|
241
|
-
ParseResult.new([node, tokens], comments, errors, warnings, source)
|
241
|
+
ParseResult.new([node, tokens], comments, magic_comments, errors, warnings, source)
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
data/lib/prism/lex_compat.rb
CHANGED
@@ -370,10 +370,9 @@ module Prism
|
|
370
370
|
@embexpr_balance -= 1
|
371
371
|
when :on_tstring_content
|
372
372
|
if embexpr_balance == 0
|
373
|
-
token.value
|
374
|
-
next if line.strip.empty? && line.end_with?("\n")
|
375
|
-
next if !(dedent_next || index > 0)
|
373
|
+
line = token.value
|
376
374
|
|
375
|
+
if !(line.strip.empty? && line.end_with?("\n")) && dedent_next
|
377
376
|
leading = line[/\A(\s*)\n?/, 1]
|
378
377
|
next_dedent = 0
|
379
378
|
|
@@ -430,6 +429,45 @@ module Prism
|
|
430
429
|
return results
|
431
430
|
end
|
432
431
|
|
432
|
+
# If the minimum common whitespace is 0, then we need to concatenate
|
433
|
+
# string nodes together that are immediately adjacent.
|
434
|
+
if dedent == 0
|
435
|
+
results = []
|
436
|
+
embexpr_balance = 0
|
437
|
+
|
438
|
+
index = 0
|
439
|
+
max_index = tokens.length
|
440
|
+
|
441
|
+
while index < max_index
|
442
|
+
token = tokens[index]
|
443
|
+
index += 1
|
444
|
+
|
445
|
+
case token.event
|
446
|
+
when :on_embexpr_beg, :on_heredoc_beg
|
447
|
+
embexpr_balance += 1
|
448
|
+
results << token
|
449
|
+
when :on_embexpr_end, :on_heredoc_end
|
450
|
+
embexpr_balance -= 1
|
451
|
+
results << token
|
452
|
+
when :on_tstring_content
|
453
|
+
if embexpr_balance == 0
|
454
|
+
results << token
|
455
|
+
|
456
|
+
while index < max_index && tokens[index].event == :on_tstring_content
|
457
|
+
token.value << tokens[index].value
|
458
|
+
index += 1
|
459
|
+
end
|
460
|
+
else
|
461
|
+
results << token
|
462
|
+
end
|
463
|
+
else
|
464
|
+
results << token
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
return results
|
469
|
+
end
|
470
|
+
|
433
471
|
# Otherwise, we're going to run through each token in the list and
|
434
472
|
# insert on_ignored_sp tokens for the amount of dedent that we need to
|
435
473
|
# perform. We also need to remove the dedent from the beginning of
|
@@ -787,11 +825,7 @@ module Prism
|
|
787
825
|
# We sort by location to compare against Ripper's output
|
788
826
|
tokens.sort_by!(&:location)
|
789
827
|
|
790
|
-
|
791
|
-
raise StandardError, "Lost tokens when performing lex_compat"
|
792
|
-
end
|
793
|
-
|
794
|
-
ParseResult.new(tokens, result.comments, result.errors, result.warnings, [])
|
828
|
+
ParseResult.new(tokens, result.comments, result.magic_comments, result.errors, result.warnings, [])
|
795
829
|
end
|
796
830
|
end
|
797
831
|
|