yarp 0.7.0 → 0.9.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +54 -2
- data/Makefile +2 -0
- data/README.md +9 -5
- data/config.yml +160 -93
- 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 +361 -238
- data/ext/yarp/extension.c +75 -26
- data/ext/yarp/extension.h +2 -2
- data/include/yarp/ast.h +226 -175
- data/include/yarp/defines.h +5 -0
- data/include/yarp/node.h +10 -0
- data/include/yarp/unescape.h +4 -2
- data/include/yarp/util/yp_buffer.h +9 -1
- data/include/yarp/util/yp_constant_pool.h +3 -0
- data/include/yarp/util/yp_list.h +7 -7
- data/include/yarp/util/yp_newline_list.h +7 -0
- data/include/yarp/util/yp_state_stack.h +1 -1
- 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 +89 -48
- data/lib/yarp/lex_compat.rb +93 -25
- data/lib/yarp/mutation_visitor.rb +683 -0
- data/lib/yarp/node.rb +2061 -422
- data/lib/yarp/serialize.rb +162 -120
- data/lib/yarp.rb +54 -8
- data/src/node.c +360 -304
- data/src/prettyprint.c +190 -152
- data/src/serialize.c +382 -340
- data/src/token_type.c +2 -2
- data/src/unescape.c +89 -77
- data/src/util/yp_buffer.c +18 -0
- data/src/util/yp_list.c +7 -16
- data/src/util/yp_newline_list.c +10 -0
- data/src/util/yp_state_stack.c +0 -6
- data/src/yarp.c +941 -596
- 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 */
|
@@ -236,112 +236,119 @@ enum yp_node_type {
|
|
236
236
|
YP_NODE_CAPTURE_PATTERN_NODE = 20,
|
237
237
|
YP_NODE_CASE_NODE = 21,
|
238
238
|
YP_NODE_CLASS_NODE = 22,
|
239
|
-
|
240
|
-
|
241
|
-
|
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
242
|
YP_NODE_CLASS_VARIABLE_READ_NODE = 26,
|
243
|
-
|
244
|
-
|
245
|
-
|
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
246
|
YP_NODE_CONSTANT_OPERATOR_WRITE_NODE = 30,
|
247
|
-
|
248
|
-
|
249
|
-
|
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
250
|
YP_NODE_CONSTANT_PATH_OPERATOR_WRITE_NODE = 34,
|
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
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
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
|
345
352
|
};
|
346
353
|
|
347
354
|
typedef uint16_t yp_node_type_t;
|
@@ -462,7 +469,7 @@ typedef struct yp_block_node {
|
|
462
469
|
yp_node_t base;
|
463
470
|
yp_constant_id_list_t locals;
|
464
471
|
struct yp_block_parameters_node *parameters;
|
465
|
-
struct yp_node *
|
472
|
+
struct yp_node *body;
|
466
473
|
yp_location_t opening_loc;
|
467
474
|
yp_location_t closing_loc;
|
468
475
|
} yp_block_node_t;
|
@@ -554,40 +561,46 @@ typedef struct yp_class_node {
|
|
554
561
|
struct yp_node *constant_path;
|
555
562
|
yp_location_t inheritance_operator_loc;
|
556
563
|
struct yp_node *superclass;
|
557
|
-
struct yp_node *
|
564
|
+
struct yp_node *body;
|
558
565
|
yp_location_t end_keyword_loc;
|
566
|
+
yp_string_t name;
|
559
567
|
} yp_class_node_t;
|
560
568
|
|
561
|
-
//
|
562
|
-
typedef struct
|
569
|
+
// ClassVariableAndWriteNode
|
570
|
+
typedef struct yp_class_variable_and_write_node {
|
563
571
|
yp_node_t base;
|
564
572
|
yp_location_t name_loc;
|
565
573
|
yp_location_t operator_loc;
|
566
574
|
struct yp_node *value;
|
567
|
-
}
|
575
|
+
} yp_class_variable_and_write_node_t;
|
568
576
|
|
569
|
-
//
|
570
|
-
typedef struct
|
577
|
+
// ClassVariableOperatorWriteNode
|
578
|
+
typedef struct yp_class_variable_operator_write_node {
|
571
579
|
yp_node_t base;
|
572
580
|
yp_location_t name_loc;
|
573
581
|
yp_location_t operator_loc;
|
574
582
|
struct yp_node *value;
|
575
|
-
|
583
|
+
yp_constant_id_t operator;
|
584
|
+
} yp_class_variable_operator_write_node_t;
|
576
585
|
|
577
|
-
//
|
578
|
-
typedef struct
|
586
|
+
// ClassVariableOrWriteNode
|
587
|
+
typedef struct yp_class_variable_or_write_node {
|
579
588
|
yp_node_t base;
|
580
589
|
yp_location_t name_loc;
|
581
590
|
yp_location_t operator_loc;
|
582
591
|
struct yp_node *value;
|
583
|
-
|
584
|
-
} yp_class_variable_operator_write_node_t;
|
592
|
+
} yp_class_variable_or_write_node_t;
|
585
593
|
|
586
594
|
// ClassVariableReadNode
|
587
595
|
typedef struct yp_class_variable_read_node {
|
588
596
|
yp_node_t base;
|
589
597
|
} yp_class_variable_read_node_t;
|
590
598
|
|
599
|
+
// ClassVariableTargetNode
|
600
|
+
typedef struct yp_class_variable_target_node {
|
601
|
+
yp_node_t base;
|
602
|
+
} yp_class_variable_target_node_t;
|
603
|
+
|
591
604
|
// ClassVariableWriteNode
|
592
605
|
typedef struct yp_class_variable_write_node {
|
593
606
|
yp_node_t base;
|
@@ -596,30 +609,38 @@ typedef struct yp_class_variable_write_node {
|
|
596
609
|
yp_location_t operator_loc;
|
597
610
|
} yp_class_variable_write_node_t;
|
598
611
|
|
599
|
-
//
|
600
|
-
typedef struct
|
612
|
+
// ConstantAndWriteNode
|
613
|
+
typedef struct yp_constant_and_write_node {
|
601
614
|
yp_node_t base;
|
602
615
|
yp_location_t name_loc;
|
603
616
|
yp_location_t operator_loc;
|
604
617
|
struct yp_node *value;
|
605
|
-
}
|
618
|
+
} yp_constant_and_write_node_t;
|
606
619
|
|
607
|
-
//
|
608
|
-
typedef struct
|
620
|
+
// ConstantOperatorWriteNode
|
621
|
+
typedef struct yp_constant_operator_write_node {
|
609
622
|
yp_node_t base;
|
610
623
|
yp_location_t name_loc;
|
611
624
|
yp_location_t operator_loc;
|
612
625
|
struct yp_node *value;
|
613
|
-
|
626
|
+
yp_constant_id_t operator;
|
627
|
+
} yp_constant_operator_write_node_t;
|
614
628
|
|
615
|
-
//
|
616
|
-
typedef struct
|
629
|
+
// ConstantOrWriteNode
|
630
|
+
typedef struct yp_constant_or_write_node {
|
617
631
|
yp_node_t base;
|
618
632
|
yp_location_t name_loc;
|
619
633
|
yp_location_t operator_loc;
|
620
634
|
struct yp_node *value;
|
621
|
-
|
622
|
-
|
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;
|
623
644
|
|
624
645
|
// ConstantPathNode
|
625
646
|
typedef struct yp_constant_path_node {
|
@@ -629,30 +650,30 @@ typedef struct yp_constant_path_node {
|
|
629
650
|
yp_location_t delimiter_loc;
|
630
651
|
} yp_constant_path_node_t;
|
631
652
|
|
632
|
-
//
|
633
|
-
typedef struct
|
653
|
+
// ConstantPathOperatorWriteNode
|
654
|
+
typedef struct yp_constant_path_operator_write_node {
|
634
655
|
yp_node_t base;
|
635
656
|
struct yp_constant_path_node *target;
|
636
657
|
yp_location_t operator_loc;
|
637
658
|
struct yp_node *value;
|
638
|
-
|
659
|
+
yp_constant_id_t operator;
|
660
|
+
} yp_constant_path_operator_write_node_t;
|
639
661
|
|
640
|
-
//
|
641
|
-
typedef struct
|
662
|
+
// ConstantPathOrWriteNode
|
663
|
+
typedef struct yp_constant_path_or_write_node {
|
642
664
|
yp_node_t base;
|
643
665
|
struct yp_constant_path_node *target;
|
644
666
|
yp_location_t operator_loc;
|
645
667
|
struct yp_node *value;
|
646
|
-
}
|
668
|
+
} yp_constant_path_or_write_node_t;
|
647
669
|
|
648
|
-
//
|
649
|
-
typedef struct
|
670
|
+
// ConstantPathTargetNode
|
671
|
+
typedef struct yp_constant_path_target_node {
|
650
672
|
yp_node_t base;
|
651
|
-
struct
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
} yp_constant_path_operator_write_node_t;
|
673
|
+
struct yp_node *parent;
|
674
|
+
struct yp_node *child;
|
675
|
+
yp_location_t delimiter_loc;
|
676
|
+
} yp_constant_path_target_node_t;
|
656
677
|
|
657
678
|
// ConstantPathWriteNode
|
658
679
|
typedef struct yp_constant_path_write_node {
|
@@ -667,6 +688,11 @@ typedef struct yp_constant_read_node {
|
|
667
688
|
yp_node_t base;
|
668
689
|
} yp_constant_read_node_t;
|
669
690
|
|
691
|
+
// ConstantTargetNode
|
692
|
+
typedef struct yp_constant_target_node {
|
693
|
+
yp_node_t base;
|
694
|
+
} yp_constant_target_node_t;
|
695
|
+
|
670
696
|
// ConstantWriteNode
|
671
697
|
typedef struct yp_constant_write_node {
|
672
698
|
yp_node_t base;
|
@@ -681,7 +707,7 @@ typedef struct yp_def_node {
|
|
681
707
|
yp_location_t name_loc;
|
682
708
|
struct yp_node *receiver;
|
683
709
|
struct yp_parameters_node *parameters;
|
684
|
-
struct yp_node *
|
710
|
+
struct yp_node *body;
|
685
711
|
yp_constant_id_list_t locals;
|
686
712
|
yp_location_t def_keyword_loc;
|
687
713
|
yp_location_t operator_loc;
|
@@ -788,36 +814,41 @@ typedef struct yp_forwarding_super_node {
|
|
788
814
|
struct yp_block_node *block;
|
789
815
|
} yp_forwarding_super_node_t;
|
790
816
|
|
791
|
-
//
|
792
|
-
typedef struct
|
817
|
+
// GlobalVariableAndWriteNode
|
818
|
+
typedef struct yp_global_variable_and_write_node {
|
793
819
|
yp_node_t base;
|
794
820
|
yp_location_t name_loc;
|
795
821
|
yp_location_t operator_loc;
|
796
822
|
struct yp_node *value;
|
797
|
-
}
|
823
|
+
} yp_global_variable_and_write_node_t;
|
798
824
|
|
799
|
-
//
|
800
|
-
typedef struct
|
825
|
+
// GlobalVariableOperatorWriteNode
|
826
|
+
typedef struct yp_global_variable_operator_write_node {
|
801
827
|
yp_node_t base;
|
802
828
|
yp_location_t name_loc;
|
803
829
|
yp_location_t operator_loc;
|
804
830
|
struct yp_node *value;
|
805
|
-
|
831
|
+
yp_constant_id_t operator;
|
832
|
+
} yp_global_variable_operator_write_node_t;
|
806
833
|
|
807
|
-
//
|
808
|
-
typedef struct
|
834
|
+
// GlobalVariableOrWriteNode
|
835
|
+
typedef struct yp_global_variable_or_write_node {
|
809
836
|
yp_node_t base;
|
810
837
|
yp_location_t name_loc;
|
811
838
|
yp_location_t operator_loc;
|
812
839
|
struct yp_node *value;
|
813
|
-
|
814
|
-
} yp_global_variable_operator_write_node_t;
|
840
|
+
} yp_global_variable_or_write_node_t;
|
815
841
|
|
816
842
|
// GlobalVariableReadNode
|
817
843
|
typedef struct yp_global_variable_read_node {
|
818
844
|
yp_node_t base;
|
819
845
|
} yp_global_variable_read_node_t;
|
820
846
|
|
847
|
+
// GlobalVariableTargetNode
|
848
|
+
typedef struct yp_global_variable_target_node {
|
849
|
+
yp_node_t base;
|
850
|
+
} yp_global_variable_target_node_t;
|
851
|
+
|
821
852
|
// GlobalVariableWriteNode
|
822
853
|
typedef struct yp_global_variable_write_node {
|
823
854
|
yp_node_t base;
|
@@ -869,36 +900,41 @@ typedef struct yp_in_node {
|
|
869
900
|
yp_location_t then_loc;
|
870
901
|
} yp_in_node_t;
|
871
902
|
|
872
|
-
//
|
873
|
-
typedef struct
|
903
|
+
// InstanceVariableAndWriteNode
|
904
|
+
typedef struct yp_instance_variable_and_write_node {
|
874
905
|
yp_node_t base;
|
875
906
|
yp_location_t name_loc;
|
876
907
|
yp_location_t operator_loc;
|
877
908
|
struct yp_node *value;
|
878
|
-
}
|
909
|
+
} yp_instance_variable_and_write_node_t;
|
879
910
|
|
880
|
-
//
|
881
|
-
typedef struct
|
911
|
+
// InstanceVariableOperatorWriteNode
|
912
|
+
typedef struct yp_instance_variable_operator_write_node {
|
882
913
|
yp_node_t base;
|
883
914
|
yp_location_t name_loc;
|
884
915
|
yp_location_t operator_loc;
|
885
916
|
struct yp_node *value;
|
886
|
-
|
917
|
+
yp_constant_id_t operator;
|
918
|
+
} yp_instance_variable_operator_write_node_t;
|
887
919
|
|
888
|
-
//
|
889
|
-
typedef struct
|
920
|
+
// InstanceVariableOrWriteNode
|
921
|
+
typedef struct yp_instance_variable_or_write_node {
|
890
922
|
yp_node_t base;
|
891
923
|
yp_location_t name_loc;
|
892
924
|
yp_location_t operator_loc;
|
893
925
|
struct yp_node *value;
|
894
|
-
|
895
|
-
} yp_instance_variable_operator_write_node_t;
|
926
|
+
} yp_instance_variable_or_write_node_t;
|
896
927
|
|
897
928
|
// InstanceVariableReadNode
|
898
929
|
typedef struct yp_instance_variable_read_node {
|
899
930
|
yp_node_t base;
|
900
931
|
} yp_instance_variable_read_node_t;
|
901
932
|
|
933
|
+
// InstanceVariableTargetNode
|
934
|
+
typedef struct yp_instance_variable_target_node {
|
935
|
+
yp_node_t base;
|
936
|
+
} yp_instance_variable_target_node_t;
|
937
|
+
|
902
938
|
// InstanceVariableWriteNode
|
903
939
|
typedef struct yp_instance_variable_write_node {
|
904
940
|
yp_node_t base;
|
@@ -968,38 +1004,43 @@ typedef struct yp_keyword_rest_parameter_node {
|
|
968
1004
|
typedef struct yp_lambda_node {
|
969
1005
|
yp_node_t base;
|
970
1006
|
yp_constant_id_list_t locals;
|
1007
|
+
yp_location_t operator_loc;
|
971
1008
|
yp_location_t opening_loc;
|
1009
|
+
yp_location_t closing_loc;
|
972
1010
|
struct yp_block_parameters_node *parameters;
|
973
|
-
struct yp_node *
|
1011
|
+
struct yp_node *body;
|
974
1012
|
} yp_lambda_node_t;
|
975
1013
|
|
976
|
-
//
|
977
|
-
typedef struct
|
1014
|
+
// LocalVariableAndWriteNode
|
1015
|
+
typedef struct yp_local_variable_and_write_node {
|
978
1016
|
yp_node_t base;
|
979
1017
|
yp_location_t name_loc;
|
980
1018
|
yp_location_t operator_loc;
|
981
1019
|
struct yp_node *value;
|
982
1020
|
yp_constant_id_t constant_id;
|
983
|
-
|
1021
|
+
uint32_t depth;
|
1022
|
+
} yp_local_variable_and_write_node_t;
|
984
1023
|
|
985
|
-
//
|
986
|
-
typedef struct
|
1024
|
+
// LocalVariableOperatorWriteNode
|
1025
|
+
typedef struct yp_local_variable_operator_write_node {
|
987
1026
|
yp_node_t base;
|
988
1027
|
yp_location_t name_loc;
|
989
1028
|
yp_location_t operator_loc;
|
990
1029
|
struct yp_node *value;
|
991
1030
|
yp_constant_id_t constant_id;
|
992
|
-
|
1031
|
+
yp_constant_id_t operator_id;
|
1032
|
+
uint32_t depth;
|
1033
|
+
} yp_local_variable_operator_write_node_t;
|
993
1034
|
|
994
|
-
//
|
995
|
-
typedef struct
|
1035
|
+
// LocalVariableOrWriteNode
|
1036
|
+
typedef struct yp_local_variable_or_write_node {
|
996
1037
|
yp_node_t base;
|
997
1038
|
yp_location_t name_loc;
|
998
1039
|
yp_location_t operator_loc;
|
999
1040
|
struct yp_node *value;
|
1000
1041
|
yp_constant_id_t constant_id;
|
1001
|
-
|
1002
|
-
}
|
1042
|
+
uint32_t depth;
|
1043
|
+
} yp_local_variable_or_write_node_t;
|
1003
1044
|
|
1004
1045
|
// LocalVariableReadNode
|
1005
1046
|
typedef struct yp_local_variable_read_node {
|
@@ -1008,6 +1049,13 @@ typedef struct yp_local_variable_read_node {
|
|
1008
1049
|
uint32_t depth;
|
1009
1050
|
} yp_local_variable_read_node_t;
|
1010
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
|
+
|
1011
1059
|
// LocalVariableWriteNode
|
1012
1060
|
typedef struct yp_local_variable_write_node {
|
1013
1061
|
yp_node_t base;
|
@@ -1045,8 +1093,9 @@ typedef struct yp_module_node {
|
|
1045
1093
|
yp_constant_id_list_t locals;
|
1046
1094
|
yp_location_t module_keyword_loc;
|
1047
1095
|
struct yp_node *constant_path;
|
1048
|
-
struct yp_node *
|
1096
|
+
struct yp_node *body;
|
1049
1097
|
yp_location_t end_keyword_loc;
|
1098
|
+
yp_string_t name;
|
1050
1099
|
} yp_module_node_t;
|
1051
1100
|
|
1052
1101
|
// MultiWriteNode
|
@@ -1115,7 +1164,7 @@ typedef struct yp_parameters_node {
|
|
1115
1164
|
// ParenthesesNode
|
1116
1165
|
typedef struct yp_parentheses_node {
|
1117
1166
|
yp_node_t base;
|
1118
|
-
struct yp_node *
|
1167
|
+
struct yp_node *body;
|
1119
1168
|
yp_location_t opening_loc;
|
1120
1169
|
yp_location_t closing_loc;
|
1121
1170
|
} yp_parentheses_node_t;
|
@@ -1253,7 +1302,7 @@ typedef struct yp_singleton_class_node {
|
|
1253
1302
|
yp_location_t class_keyword_loc;
|
1254
1303
|
yp_location_t operator_loc;
|
1255
1304
|
struct yp_node *expression;
|
1256
|
-
struct yp_node *
|
1305
|
+
struct yp_node *body;
|
1257
1306
|
yp_location_t end_keyword_loc;
|
1258
1307
|
} yp_singleton_class_node_t;
|
1259
1308
|
|
@@ -1347,6 +1396,7 @@ typedef struct yp_unless_node {
|
|
1347
1396
|
typedef struct yp_until_node {
|
1348
1397
|
yp_node_t base;
|
1349
1398
|
yp_location_t keyword_loc;
|
1399
|
+
yp_location_t closing_loc;
|
1350
1400
|
struct yp_node *predicate;
|
1351
1401
|
struct yp_statements_node *statements;
|
1352
1402
|
} yp_until_node_t;
|
@@ -1363,6 +1413,7 @@ typedef struct yp_when_node {
|
|
1363
1413
|
typedef struct yp_while_node {
|
1364
1414
|
yp_node_t base;
|
1365
1415
|
yp_location_t keyword_loc;
|
1416
|
+
yp_location_t closing_loc;
|
1366
1417
|
struct yp_node *predicate;
|
1367
1418
|
struct yp_statements_node *statements;
|
1368
1419
|
} yp_while_node_t;
|
data/include/yarp/defines.h
CHANGED
@@ -34,6 +34,11 @@
|
|
34
34
|
# define inline __inline
|
35
35
|
#endif
|
36
36
|
|
37
|
+
// Windows versions before 2015 use _snprintf
|
38
|
+
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
39
|
+
# define snprintf _snprintf
|
40
|
+
#endif
|
41
|
+
|
37
42
|
int yp_strncasecmp(const char *string1, const char *string2, size_t length);
|
38
43
|
|
39
44
|
#endif
|
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,
|
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
|