yarp 0.8.0 → 0.9.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 +34 -1
- data/README.md +4 -3
- data/config.yml +332 -52
- data/docs/configuration.md +1 -0
- data/docs/ruby_api.md +2 -0
- data/docs/serialization.md +1 -1
- data/docs/testing.md +2 -2
- data/ext/yarp/api_node.c +703 -136
- data/ext/yarp/extension.c +73 -24
- data/ext/yarp/extension.h +2 -2
- data/include/yarp/ast.h +331 -137
- data/include/yarp/node.h +10 -0
- data/include/yarp/unescape.h +4 -2
- data/include/yarp/util/yp_newline_list.h +3 -0
- data/include/yarp/version.h +2 -2
- data/include/yarp.h +10 -0
- data/lib/yarp/desugar_visitor.rb +267 -0
- data/lib/yarp/ffi.rb +27 -1
- data/lib/yarp/lex_compat.rb +93 -25
- data/lib/yarp/mutation_visitor.rb +683 -0
- data/lib/yarp/node.rb +3042 -508
- data/lib/yarp/serialize.rb +198 -126
- data/lib/yarp.rb +48 -2
- data/src/node.c +421 -185
- data/src/prettyprint.c +262 -80
- data/src/serialize.c +410 -270
- data/src/token_type.c +2 -2
- data/src/unescape.c +69 -51
- data/src/util/yp_newline_list.c +10 -0
- data/src/yarp.c +1208 -458
- data/yarp.gemspec +3 -1
- metadata +4 -2
data/include/yarp/ast.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/******************************************************************************/
|
2
|
-
/* This file is generated by the
|
3
|
-
/* modified manually. See
|
2
|
+
/* This file is generated by the templates/template.rb script and should not */
|
3
|
+
/* be modified manually. See */
|
4
4
|
/* templates/include/yarp/ast.h.erb */
|
5
5
|
/* if you are looking to modify the */
|
6
6
|
/* template */
|
@@ -217,116 +217,138 @@ enum yp_node_type {
|
|
217
217
|
YP_NODE_ALIAS_NODE = 1,
|
218
218
|
YP_NODE_ALTERNATION_PATTERN_NODE = 2,
|
219
219
|
YP_NODE_AND_NODE = 3,
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
220
|
+
YP_NODE_ARGUMENTS_NODE = 4,
|
221
|
+
YP_NODE_ARRAY_NODE = 5,
|
222
|
+
YP_NODE_ARRAY_PATTERN_NODE = 6,
|
223
|
+
YP_NODE_ASSOC_NODE = 7,
|
224
|
+
YP_NODE_ASSOC_SPLAT_NODE = 8,
|
225
|
+
YP_NODE_BACK_REFERENCE_READ_NODE = 9,
|
226
|
+
YP_NODE_BEGIN_NODE = 10,
|
227
|
+
YP_NODE_BLOCK_ARGUMENT_NODE = 11,
|
228
|
+
YP_NODE_BLOCK_NODE = 12,
|
229
|
+
YP_NODE_BLOCK_PARAMETER_NODE = 13,
|
230
|
+
YP_NODE_BLOCK_PARAMETERS_NODE = 14,
|
231
|
+
YP_NODE_BREAK_NODE = 15,
|
232
|
+
YP_NODE_CALL_NODE = 16,
|
233
|
+
YP_NODE_CALL_OPERATOR_AND_WRITE_NODE = 17,
|
234
|
+
YP_NODE_CALL_OPERATOR_OR_WRITE_NODE = 18,
|
235
|
+
YP_NODE_CALL_OPERATOR_WRITE_NODE = 19,
|
236
|
+
YP_NODE_CAPTURE_PATTERN_NODE = 20,
|
237
|
+
YP_NODE_CASE_NODE = 21,
|
238
|
+
YP_NODE_CLASS_NODE = 22,
|
239
|
+
YP_NODE_CLASS_VARIABLE_AND_WRITE_NODE = 23,
|
240
|
+
YP_NODE_CLASS_VARIABLE_OPERATOR_WRITE_NODE = 24,
|
241
|
+
YP_NODE_CLASS_VARIABLE_OR_WRITE_NODE = 25,
|
242
|
+
YP_NODE_CLASS_VARIABLE_READ_NODE = 26,
|
243
|
+
YP_NODE_CLASS_VARIABLE_TARGET_NODE = 27,
|
244
|
+
YP_NODE_CLASS_VARIABLE_WRITE_NODE = 28,
|
245
|
+
YP_NODE_CONSTANT_AND_WRITE_NODE = 29,
|
246
|
+
YP_NODE_CONSTANT_OPERATOR_WRITE_NODE = 30,
|
247
|
+
YP_NODE_CONSTANT_OR_WRITE_NODE = 31,
|
248
|
+
YP_NODE_CONSTANT_PATH_AND_WRITE_NODE = 32,
|
249
|
+
YP_NODE_CONSTANT_PATH_NODE = 33,
|
250
|
+
YP_NODE_CONSTANT_PATH_OPERATOR_WRITE_NODE = 34,
|
251
|
+
YP_NODE_CONSTANT_PATH_OR_WRITE_NODE = 35,
|
252
|
+
YP_NODE_CONSTANT_PATH_TARGET_NODE = 36,
|
253
|
+
YP_NODE_CONSTANT_PATH_WRITE_NODE = 37,
|
254
|
+
YP_NODE_CONSTANT_READ_NODE = 38,
|
255
|
+
YP_NODE_CONSTANT_TARGET_NODE = 39,
|
256
|
+
YP_NODE_CONSTANT_WRITE_NODE = 40,
|
257
|
+
YP_NODE_DEF_NODE = 41,
|
258
|
+
YP_NODE_DEFINED_NODE = 42,
|
259
|
+
YP_NODE_ELSE_NODE = 43,
|
260
|
+
YP_NODE_EMBEDDED_STATEMENTS_NODE = 44,
|
261
|
+
YP_NODE_EMBEDDED_VARIABLE_NODE = 45,
|
262
|
+
YP_NODE_ENSURE_NODE = 46,
|
263
|
+
YP_NODE_FALSE_NODE = 47,
|
264
|
+
YP_NODE_FIND_PATTERN_NODE = 48,
|
265
|
+
YP_NODE_FLIP_FLOP_NODE = 49,
|
266
|
+
YP_NODE_FLOAT_NODE = 50,
|
267
|
+
YP_NODE_FOR_NODE = 51,
|
268
|
+
YP_NODE_FORWARDING_ARGUMENTS_NODE = 52,
|
269
|
+
YP_NODE_FORWARDING_PARAMETER_NODE = 53,
|
270
|
+
YP_NODE_FORWARDING_SUPER_NODE = 54,
|
271
|
+
YP_NODE_GLOBAL_VARIABLE_AND_WRITE_NODE = 55,
|
272
|
+
YP_NODE_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE = 56,
|
273
|
+
YP_NODE_GLOBAL_VARIABLE_OR_WRITE_NODE = 57,
|
274
|
+
YP_NODE_GLOBAL_VARIABLE_READ_NODE = 58,
|
275
|
+
YP_NODE_GLOBAL_VARIABLE_TARGET_NODE = 59,
|
276
|
+
YP_NODE_GLOBAL_VARIABLE_WRITE_NODE = 60,
|
277
|
+
YP_NODE_HASH_NODE = 61,
|
278
|
+
YP_NODE_HASH_PATTERN_NODE = 62,
|
279
|
+
YP_NODE_IF_NODE = 63,
|
280
|
+
YP_NODE_IMAGINARY_NODE = 64,
|
281
|
+
YP_NODE_IN_NODE = 65,
|
282
|
+
YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE = 66,
|
283
|
+
YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE = 67,
|
284
|
+
YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE = 68,
|
285
|
+
YP_NODE_INSTANCE_VARIABLE_READ_NODE = 69,
|
286
|
+
YP_NODE_INSTANCE_VARIABLE_TARGET_NODE = 70,
|
287
|
+
YP_NODE_INSTANCE_VARIABLE_WRITE_NODE = 71,
|
288
|
+
YP_NODE_INTEGER_NODE = 72,
|
289
|
+
YP_NODE_INTERPOLATED_REGULAR_EXPRESSION_NODE = 73,
|
290
|
+
YP_NODE_INTERPOLATED_STRING_NODE = 74,
|
291
|
+
YP_NODE_INTERPOLATED_SYMBOL_NODE = 75,
|
292
|
+
YP_NODE_INTERPOLATED_X_STRING_NODE = 76,
|
293
|
+
YP_NODE_KEYWORD_HASH_NODE = 77,
|
294
|
+
YP_NODE_KEYWORD_PARAMETER_NODE = 78,
|
295
|
+
YP_NODE_KEYWORD_REST_PARAMETER_NODE = 79,
|
296
|
+
YP_NODE_LAMBDA_NODE = 80,
|
297
|
+
YP_NODE_LOCAL_VARIABLE_AND_WRITE_NODE = 81,
|
298
|
+
YP_NODE_LOCAL_VARIABLE_OPERATOR_WRITE_NODE = 82,
|
299
|
+
YP_NODE_LOCAL_VARIABLE_OR_WRITE_NODE = 83,
|
300
|
+
YP_NODE_LOCAL_VARIABLE_READ_NODE = 84,
|
301
|
+
YP_NODE_LOCAL_VARIABLE_TARGET_NODE = 85,
|
302
|
+
YP_NODE_LOCAL_VARIABLE_WRITE_NODE = 86,
|
303
|
+
YP_NODE_MATCH_PREDICATE_NODE = 87,
|
304
|
+
YP_NODE_MATCH_REQUIRED_NODE = 88,
|
305
|
+
YP_NODE_MISSING_NODE = 89,
|
306
|
+
YP_NODE_MODULE_NODE = 90,
|
307
|
+
YP_NODE_MULTI_WRITE_NODE = 91,
|
308
|
+
YP_NODE_NEXT_NODE = 92,
|
309
|
+
YP_NODE_NIL_NODE = 93,
|
310
|
+
YP_NODE_NO_KEYWORDS_PARAMETER_NODE = 94,
|
311
|
+
YP_NODE_NUMBERED_REFERENCE_READ_NODE = 95,
|
312
|
+
YP_NODE_OPTIONAL_PARAMETER_NODE = 96,
|
313
|
+
YP_NODE_OR_NODE = 97,
|
314
|
+
YP_NODE_PARAMETERS_NODE = 98,
|
315
|
+
YP_NODE_PARENTHESES_NODE = 99,
|
316
|
+
YP_NODE_PINNED_EXPRESSION_NODE = 100,
|
317
|
+
YP_NODE_PINNED_VARIABLE_NODE = 101,
|
318
|
+
YP_NODE_POST_EXECUTION_NODE = 102,
|
319
|
+
YP_NODE_PRE_EXECUTION_NODE = 103,
|
320
|
+
YP_NODE_PROGRAM_NODE = 104,
|
321
|
+
YP_NODE_RANGE_NODE = 105,
|
322
|
+
YP_NODE_RATIONAL_NODE = 106,
|
323
|
+
YP_NODE_REDO_NODE = 107,
|
324
|
+
YP_NODE_REGULAR_EXPRESSION_NODE = 108,
|
325
|
+
YP_NODE_REQUIRED_DESTRUCTURED_PARAMETER_NODE = 109,
|
326
|
+
YP_NODE_REQUIRED_PARAMETER_NODE = 110,
|
327
|
+
YP_NODE_RESCUE_MODIFIER_NODE = 111,
|
328
|
+
YP_NODE_RESCUE_NODE = 112,
|
329
|
+
YP_NODE_REST_PARAMETER_NODE = 113,
|
330
|
+
YP_NODE_RETRY_NODE = 114,
|
331
|
+
YP_NODE_RETURN_NODE = 115,
|
332
|
+
YP_NODE_SELF_NODE = 116,
|
333
|
+
YP_NODE_SINGLETON_CLASS_NODE = 117,
|
334
|
+
YP_NODE_SOURCE_ENCODING_NODE = 118,
|
335
|
+
YP_NODE_SOURCE_FILE_NODE = 119,
|
336
|
+
YP_NODE_SOURCE_LINE_NODE = 120,
|
337
|
+
YP_NODE_SPLAT_NODE = 121,
|
338
|
+
YP_NODE_STATEMENTS_NODE = 122,
|
339
|
+
YP_NODE_STRING_CONCAT_NODE = 123,
|
340
|
+
YP_NODE_STRING_NODE = 124,
|
341
|
+
YP_NODE_SUPER_NODE = 125,
|
342
|
+
YP_NODE_SYMBOL_NODE = 126,
|
343
|
+
YP_NODE_TRUE_NODE = 127,
|
344
|
+
YP_NODE_UNDEF_NODE = 128,
|
345
|
+
YP_NODE_UNLESS_NODE = 129,
|
346
|
+
YP_NODE_UNTIL_NODE = 130,
|
347
|
+
YP_NODE_WHEN_NODE = 131,
|
348
|
+
YP_NODE_WHILE_NODE = 132,
|
349
|
+
YP_NODE_X_STRING_NODE = 133,
|
350
|
+
YP_NODE_YIELD_NODE = 134,
|
351
|
+
YP_NODE_SCOPE_NODE
|
330
352
|
};
|
331
353
|
|
332
354
|
typedef uint16_t yp_node_type_t;
|
@@ -379,14 +401,6 @@ typedef struct yp_and_node {
|
|
379
401
|
yp_location_t operator_loc;
|
380
402
|
} yp_and_node_t;
|
381
403
|
|
382
|
-
// AndWriteNode
|
383
|
-
typedef struct yp_and_write_node {
|
384
|
-
yp_node_t base;
|
385
|
-
struct yp_node *target;
|
386
|
-
struct yp_node *value;
|
387
|
-
yp_location_t operator_loc;
|
388
|
-
} yp_and_write_node_t;
|
389
|
-
|
390
404
|
// ArgumentsNode
|
391
405
|
typedef struct yp_arguments_node {
|
392
406
|
yp_node_t base;
|
@@ -549,13 +563,44 @@ typedef struct yp_class_node {
|
|
549
563
|
struct yp_node *superclass;
|
550
564
|
struct yp_node *body;
|
551
565
|
yp_location_t end_keyword_loc;
|
566
|
+
yp_string_t name;
|
552
567
|
} yp_class_node_t;
|
553
568
|
|
569
|
+
// ClassVariableAndWriteNode
|
570
|
+
typedef struct yp_class_variable_and_write_node {
|
571
|
+
yp_node_t base;
|
572
|
+
yp_location_t name_loc;
|
573
|
+
yp_location_t operator_loc;
|
574
|
+
struct yp_node *value;
|
575
|
+
} yp_class_variable_and_write_node_t;
|
576
|
+
|
577
|
+
// ClassVariableOperatorWriteNode
|
578
|
+
typedef struct yp_class_variable_operator_write_node {
|
579
|
+
yp_node_t base;
|
580
|
+
yp_location_t name_loc;
|
581
|
+
yp_location_t operator_loc;
|
582
|
+
struct yp_node *value;
|
583
|
+
yp_constant_id_t operator;
|
584
|
+
} yp_class_variable_operator_write_node_t;
|
585
|
+
|
586
|
+
// ClassVariableOrWriteNode
|
587
|
+
typedef struct yp_class_variable_or_write_node {
|
588
|
+
yp_node_t base;
|
589
|
+
yp_location_t name_loc;
|
590
|
+
yp_location_t operator_loc;
|
591
|
+
struct yp_node *value;
|
592
|
+
} yp_class_variable_or_write_node_t;
|
593
|
+
|
554
594
|
// ClassVariableReadNode
|
555
595
|
typedef struct yp_class_variable_read_node {
|
556
596
|
yp_node_t base;
|
557
597
|
} yp_class_variable_read_node_t;
|
558
598
|
|
599
|
+
// ClassVariableTargetNode
|
600
|
+
typedef struct yp_class_variable_target_node {
|
601
|
+
yp_node_t base;
|
602
|
+
} yp_class_variable_target_node_t;
|
603
|
+
|
559
604
|
// ClassVariableWriteNode
|
560
605
|
typedef struct yp_class_variable_write_node {
|
561
606
|
yp_node_t base;
|
@@ -564,6 +609,39 @@ typedef struct yp_class_variable_write_node {
|
|
564
609
|
yp_location_t operator_loc;
|
565
610
|
} yp_class_variable_write_node_t;
|
566
611
|
|
612
|
+
// ConstantAndWriteNode
|
613
|
+
typedef struct yp_constant_and_write_node {
|
614
|
+
yp_node_t base;
|
615
|
+
yp_location_t name_loc;
|
616
|
+
yp_location_t operator_loc;
|
617
|
+
struct yp_node *value;
|
618
|
+
} yp_constant_and_write_node_t;
|
619
|
+
|
620
|
+
// ConstantOperatorWriteNode
|
621
|
+
typedef struct yp_constant_operator_write_node {
|
622
|
+
yp_node_t base;
|
623
|
+
yp_location_t name_loc;
|
624
|
+
yp_location_t operator_loc;
|
625
|
+
struct yp_node *value;
|
626
|
+
yp_constant_id_t operator;
|
627
|
+
} yp_constant_operator_write_node_t;
|
628
|
+
|
629
|
+
// ConstantOrWriteNode
|
630
|
+
typedef struct yp_constant_or_write_node {
|
631
|
+
yp_node_t base;
|
632
|
+
yp_location_t name_loc;
|
633
|
+
yp_location_t operator_loc;
|
634
|
+
struct yp_node *value;
|
635
|
+
} yp_constant_or_write_node_t;
|
636
|
+
|
637
|
+
// ConstantPathAndWriteNode
|
638
|
+
typedef struct yp_constant_path_and_write_node {
|
639
|
+
yp_node_t base;
|
640
|
+
struct yp_constant_path_node *target;
|
641
|
+
yp_location_t operator_loc;
|
642
|
+
struct yp_node *value;
|
643
|
+
} yp_constant_path_and_write_node_t;
|
644
|
+
|
567
645
|
// ConstantPathNode
|
568
646
|
typedef struct yp_constant_path_node {
|
569
647
|
yp_node_t base;
|
@@ -572,6 +650,31 @@ typedef struct yp_constant_path_node {
|
|
572
650
|
yp_location_t delimiter_loc;
|
573
651
|
} yp_constant_path_node_t;
|
574
652
|
|
653
|
+
// ConstantPathOperatorWriteNode
|
654
|
+
typedef struct yp_constant_path_operator_write_node {
|
655
|
+
yp_node_t base;
|
656
|
+
struct yp_constant_path_node *target;
|
657
|
+
yp_location_t operator_loc;
|
658
|
+
struct yp_node *value;
|
659
|
+
yp_constant_id_t operator;
|
660
|
+
} yp_constant_path_operator_write_node_t;
|
661
|
+
|
662
|
+
// ConstantPathOrWriteNode
|
663
|
+
typedef struct yp_constant_path_or_write_node {
|
664
|
+
yp_node_t base;
|
665
|
+
struct yp_constant_path_node *target;
|
666
|
+
yp_location_t operator_loc;
|
667
|
+
struct yp_node *value;
|
668
|
+
} yp_constant_path_or_write_node_t;
|
669
|
+
|
670
|
+
// ConstantPathTargetNode
|
671
|
+
typedef struct yp_constant_path_target_node {
|
672
|
+
yp_node_t base;
|
673
|
+
struct yp_node *parent;
|
674
|
+
struct yp_node *child;
|
675
|
+
yp_location_t delimiter_loc;
|
676
|
+
} yp_constant_path_target_node_t;
|
677
|
+
|
575
678
|
// ConstantPathWriteNode
|
576
679
|
typedef struct yp_constant_path_write_node {
|
577
680
|
yp_node_t base;
|
@@ -585,6 +688,11 @@ typedef struct yp_constant_read_node {
|
|
585
688
|
yp_node_t base;
|
586
689
|
} yp_constant_read_node_t;
|
587
690
|
|
691
|
+
// ConstantTargetNode
|
692
|
+
typedef struct yp_constant_target_node {
|
693
|
+
yp_node_t base;
|
694
|
+
} yp_constant_target_node_t;
|
695
|
+
|
588
696
|
// ConstantWriteNode
|
589
697
|
typedef struct yp_constant_write_node {
|
590
698
|
yp_node_t base;
|
@@ -706,11 +814,41 @@ typedef struct yp_forwarding_super_node {
|
|
706
814
|
struct yp_block_node *block;
|
707
815
|
} yp_forwarding_super_node_t;
|
708
816
|
|
817
|
+
// GlobalVariableAndWriteNode
|
818
|
+
typedef struct yp_global_variable_and_write_node {
|
819
|
+
yp_node_t base;
|
820
|
+
yp_location_t name_loc;
|
821
|
+
yp_location_t operator_loc;
|
822
|
+
struct yp_node *value;
|
823
|
+
} yp_global_variable_and_write_node_t;
|
824
|
+
|
825
|
+
// GlobalVariableOperatorWriteNode
|
826
|
+
typedef struct yp_global_variable_operator_write_node {
|
827
|
+
yp_node_t base;
|
828
|
+
yp_location_t name_loc;
|
829
|
+
yp_location_t operator_loc;
|
830
|
+
struct yp_node *value;
|
831
|
+
yp_constant_id_t operator;
|
832
|
+
} yp_global_variable_operator_write_node_t;
|
833
|
+
|
834
|
+
// GlobalVariableOrWriteNode
|
835
|
+
typedef struct yp_global_variable_or_write_node {
|
836
|
+
yp_node_t base;
|
837
|
+
yp_location_t name_loc;
|
838
|
+
yp_location_t operator_loc;
|
839
|
+
struct yp_node *value;
|
840
|
+
} yp_global_variable_or_write_node_t;
|
841
|
+
|
709
842
|
// GlobalVariableReadNode
|
710
843
|
typedef struct yp_global_variable_read_node {
|
711
844
|
yp_node_t base;
|
712
845
|
} yp_global_variable_read_node_t;
|
713
846
|
|
847
|
+
// GlobalVariableTargetNode
|
848
|
+
typedef struct yp_global_variable_target_node {
|
849
|
+
yp_node_t base;
|
850
|
+
} yp_global_variable_target_node_t;
|
851
|
+
|
714
852
|
// GlobalVariableWriteNode
|
715
853
|
typedef struct yp_global_variable_write_node {
|
716
854
|
yp_node_t base;
|
@@ -762,11 +900,41 @@ typedef struct yp_in_node {
|
|
762
900
|
yp_location_t then_loc;
|
763
901
|
} yp_in_node_t;
|
764
902
|
|
903
|
+
// InstanceVariableAndWriteNode
|
904
|
+
typedef struct yp_instance_variable_and_write_node {
|
905
|
+
yp_node_t base;
|
906
|
+
yp_location_t name_loc;
|
907
|
+
yp_location_t operator_loc;
|
908
|
+
struct yp_node *value;
|
909
|
+
} yp_instance_variable_and_write_node_t;
|
910
|
+
|
911
|
+
// InstanceVariableOperatorWriteNode
|
912
|
+
typedef struct yp_instance_variable_operator_write_node {
|
913
|
+
yp_node_t base;
|
914
|
+
yp_location_t name_loc;
|
915
|
+
yp_location_t operator_loc;
|
916
|
+
struct yp_node *value;
|
917
|
+
yp_constant_id_t operator;
|
918
|
+
} yp_instance_variable_operator_write_node_t;
|
919
|
+
|
920
|
+
// InstanceVariableOrWriteNode
|
921
|
+
typedef struct yp_instance_variable_or_write_node {
|
922
|
+
yp_node_t base;
|
923
|
+
yp_location_t name_loc;
|
924
|
+
yp_location_t operator_loc;
|
925
|
+
struct yp_node *value;
|
926
|
+
} yp_instance_variable_or_write_node_t;
|
927
|
+
|
765
928
|
// InstanceVariableReadNode
|
766
929
|
typedef struct yp_instance_variable_read_node {
|
767
930
|
yp_node_t base;
|
768
931
|
} yp_instance_variable_read_node_t;
|
769
932
|
|
933
|
+
// InstanceVariableTargetNode
|
934
|
+
typedef struct yp_instance_variable_target_node {
|
935
|
+
yp_node_t base;
|
936
|
+
} yp_instance_variable_target_node_t;
|
937
|
+
|
770
938
|
// InstanceVariableWriteNode
|
771
939
|
typedef struct yp_instance_variable_write_node {
|
772
940
|
yp_node_t base;
|
@@ -836,11 +1004,44 @@ typedef struct yp_keyword_rest_parameter_node {
|
|
836
1004
|
typedef struct yp_lambda_node {
|
837
1005
|
yp_node_t base;
|
838
1006
|
yp_constant_id_list_t locals;
|
1007
|
+
yp_location_t operator_loc;
|
839
1008
|
yp_location_t opening_loc;
|
1009
|
+
yp_location_t closing_loc;
|
840
1010
|
struct yp_block_parameters_node *parameters;
|
841
1011
|
struct yp_node *body;
|
842
1012
|
} yp_lambda_node_t;
|
843
1013
|
|
1014
|
+
// LocalVariableAndWriteNode
|
1015
|
+
typedef struct yp_local_variable_and_write_node {
|
1016
|
+
yp_node_t base;
|
1017
|
+
yp_location_t name_loc;
|
1018
|
+
yp_location_t operator_loc;
|
1019
|
+
struct yp_node *value;
|
1020
|
+
yp_constant_id_t constant_id;
|
1021
|
+
uint32_t depth;
|
1022
|
+
} yp_local_variable_and_write_node_t;
|
1023
|
+
|
1024
|
+
// LocalVariableOperatorWriteNode
|
1025
|
+
typedef struct yp_local_variable_operator_write_node {
|
1026
|
+
yp_node_t base;
|
1027
|
+
yp_location_t name_loc;
|
1028
|
+
yp_location_t operator_loc;
|
1029
|
+
struct yp_node *value;
|
1030
|
+
yp_constant_id_t constant_id;
|
1031
|
+
yp_constant_id_t operator_id;
|
1032
|
+
uint32_t depth;
|
1033
|
+
} yp_local_variable_operator_write_node_t;
|
1034
|
+
|
1035
|
+
// LocalVariableOrWriteNode
|
1036
|
+
typedef struct yp_local_variable_or_write_node {
|
1037
|
+
yp_node_t base;
|
1038
|
+
yp_location_t name_loc;
|
1039
|
+
yp_location_t operator_loc;
|
1040
|
+
struct yp_node *value;
|
1041
|
+
yp_constant_id_t constant_id;
|
1042
|
+
uint32_t depth;
|
1043
|
+
} yp_local_variable_or_write_node_t;
|
1044
|
+
|
844
1045
|
// LocalVariableReadNode
|
845
1046
|
typedef struct yp_local_variable_read_node {
|
846
1047
|
yp_node_t base;
|
@@ -848,6 +1049,13 @@ typedef struct yp_local_variable_read_node {
|
|
848
1049
|
uint32_t depth;
|
849
1050
|
} yp_local_variable_read_node_t;
|
850
1051
|
|
1052
|
+
// LocalVariableTargetNode
|
1053
|
+
typedef struct yp_local_variable_target_node {
|
1054
|
+
yp_node_t base;
|
1055
|
+
yp_constant_id_t constant_id;
|
1056
|
+
uint32_t depth;
|
1057
|
+
} yp_local_variable_target_node_t;
|
1058
|
+
|
851
1059
|
// LocalVariableWriteNode
|
852
1060
|
typedef struct yp_local_variable_write_node {
|
853
1061
|
yp_node_t base;
|
@@ -887,6 +1095,7 @@ typedef struct yp_module_node {
|
|
887
1095
|
struct yp_node *constant_path;
|
888
1096
|
struct yp_node *body;
|
889
1097
|
yp_location_t end_keyword_loc;
|
1098
|
+
yp_string_t name;
|
890
1099
|
} yp_module_node_t;
|
891
1100
|
|
892
1101
|
// MultiWriteNode
|
@@ -923,15 +1132,6 @@ typedef struct yp_numbered_reference_read_node {
|
|
923
1132
|
yp_node_t base;
|
924
1133
|
} yp_numbered_reference_read_node_t;
|
925
1134
|
|
926
|
-
// OperatorWriteNode
|
927
|
-
typedef struct yp_operator_write_node {
|
928
|
-
yp_node_t base;
|
929
|
-
struct yp_node *target;
|
930
|
-
yp_location_t operator_loc;
|
931
|
-
yp_constant_id_t operator;
|
932
|
-
struct yp_node *value;
|
933
|
-
} yp_operator_write_node_t;
|
934
|
-
|
935
1135
|
// OptionalParameterNode
|
936
1136
|
typedef struct yp_optional_parameter_node {
|
937
1137
|
yp_node_t base;
|
@@ -949,14 +1149,6 @@ typedef struct yp_or_node {
|
|
949
1149
|
yp_location_t operator_loc;
|
950
1150
|
} yp_or_node_t;
|
951
1151
|
|
952
|
-
// OrWriteNode
|
953
|
-
typedef struct yp_or_write_node {
|
954
|
-
yp_node_t base;
|
955
|
-
struct yp_node *target;
|
956
|
-
struct yp_node *value;
|
957
|
-
yp_location_t operator_loc;
|
958
|
-
} yp_or_write_node_t;
|
959
|
-
|
960
1152
|
// ParametersNode
|
961
1153
|
typedef struct yp_parameters_node {
|
962
1154
|
yp_node_t base;
|
@@ -1204,6 +1396,7 @@ typedef struct yp_unless_node {
|
|
1204
1396
|
typedef struct yp_until_node {
|
1205
1397
|
yp_node_t base;
|
1206
1398
|
yp_location_t keyword_loc;
|
1399
|
+
yp_location_t closing_loc;
|
1207
1400
|
struct yp_node *predicate;
|
1208
1401
|
struct yp_statements_node *statements;
|
1209
1402
|
} yp_until_node_t;
|
@@ -1220,6 +1413,7 @@ typedef struct yp_when_node {
|
|
1220
1413
|
typedef struct yp_while_node {
|
1221
1414
|
yp_node_t base;
|
1222
1415
|
yp_location_t keyword_loc;
|
1416
|
+
yp_location_t closing_loc;
|
1223
1417
|
struct yp_node *predicate;
|
1224
1418
|
struct yp_statements_node *statements;
|
1225
1419
|
} yp_while_node_t;
|
data/include/yarp/node.h
CHANGED
@@ -34,3 +34,13 @@ YP_EXPORTED_FUNCTION const char * yp_node_type_to_str(yp_node_type_t node_type);
|
|
34
34
|
#define YP_EMPTY_LOCATION_LIST ((yp_location_list_t) { .locations = NULL, .size = 0, .capacity = 0 })
|
35
35
|
|
36
36
|
#endif // YARP_NODE_H
|
37
|
+
|
38
|
+
// ScopeNodes are helper nodes, and will never
|
39
|
+
// be part of the AST. We manually declare them
|
40
|
+
// here to avoid generating them
|
41
|
+
typedef struct yp_scope_node {
|
42
|
+
yp_node_t base;
|
43
|
+
struct yp_parameters_node *parameters;
|
44
|
+
yp_node_t *body;
|
45
|
+
yp_constant_id_list_t locals;
|
46
|
+
} yp_scope_node_t;
|
data/include/yarp/unescape.h
CHANGED
@@ -31,12 +31,14 @@ typedef enum {
|
|
31
31
|
|
32
32
|
// Unescape the contents of the given token into the given string using the
|
33
33
|
// given unescape mode.
|
34
|
-
YP_EXPORTED_FUNCTION void yp_unescape_manipulate_string(yp_parser_t *parser, yp_string_t *string, yp_unescape_type_t unescape_type
|
34
|
+
YP_EXPORTED_FUNCTION void yp_unescape_manipulate_string(yp_parser_t *parser, yp_string_t *string, yp_unescape_type_t unescape_type);
|
35
35
|
|
36
36
|
// Accepts a source string and a type of unescaping and returns the unescaped version.
|
37
37
|
// The caller must yp_string_free(result); after calling this function.
|
38
38
|
YP_EXPORTED_FUNCTION bool yp_unescape_string(const char *start, size_t length, yp_unescape_type_t unescape_type, yp_string_t *result);
|
39
39
|
|
40
|
-
|
40
|
+
// Returns the number of bytes that encompass the first escape sequence in the
|
41
|
+
// given string.
|
42
|
+
size_t yp_unescape_calculate_difference(yp_parser_t *parser, const char *value, yp_unescape_type_t unescape_type, bool expect_single_codepoint);
|
41
43
|
|
42
44
|
#endif
|
@@ -47,6 +47,9 @@ bool yp_newline_list_init(yp_newline_list_t *list, const char *start, size_t cap
|
|
47
47
|
// the offsets succeeds (if one was necessary), otherwise returns false.
|
48
48
|
bool yp_newline_list_append(yp_newline_list_t *list, const char *cursor);
|
49
49
|
|
50
|
+
// Conditionally append a new offset to the newline list, if the value passed in is a newline.
|
51
|
+
bool yp_newline_list_check_append(yp_newline_list_t *list, const char *cursor);
|
52
|
+
|
50
53
|
// Returns the line and column of the given offset. If the offset is not in the
|
51
54
|
// list, the line and column of the closest offset less than the given offset
|
52
55
|
// are returned.
|
data/include/yarp/version.h
CHANGED
data/include/yarp.h
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
#include "yarp/util/yp_char.h"
|
14
14
|
#include "yarp/util/yp_memchr.h"
|
15
15
|
#include "yarp/util/yp_strpbrk.h"
|
16
|
+
#include "yarp/version.h"
|
16
17
|
|
17
18
|
#include <assert.h>
|
18
19
|
#include <stdarg.h>
|
@@ -30,6 +31,11 @@ void yp_serialize_content(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buf
|
|
30
31
|
|
31
32
|
void yp_print_node(yp_parser_t *parser, yp_node_t *node);
|
32
33
|
|
34
|
+
void yp_parser_metadata(yp_parser_t *parser, const char *metadata);
|
35
|
+
|
36
|
+
// Generate a scope node from the given node.
|
37
|
+
void yp_scope_node_init(yp_node_t *node, yp_scope_node_t *dest);
|
38
|
+
|
33
39
|
// The YARP version and the serialization format.
|
34
40
|
YP_EXPORTED_FUNCTION const char * yp_version(void);
|
35
41
|
|
@@ -65,6 +71,10 @@ YP_EXPORTED_FUNCTION void yp_parse_serialize(const char *source, size_t size, yp
|
|
65
71
|
// Lex the given source and serialize to the given buffer.
|
66
72
|
YP_EXPORTED_FUNCTION void yp_lex_serialize(const char *source, size_t size, const char *filepath, yp_buffer_t *buffer);
|
67
73
|
|
74
|
+
// Parse and serialize both the AST and the tokens represented by the given
|
75
|
+
// source to the given buffer.
|
76
|
+
YP_EXPORTED_FUNCTION void yp_parse_lex_serialize(const char *source, size_t size, yp_buffer_t *buffer, const char *metadata);
|
77
|
+
|
68
78
|
// Returns a string representation of the given token type.
|
69
79
|
YP_EXPORTED_FUNCTION const char * yp_token_type_to_str(yp_token_type_t token_type);
|
70
80
|
|