yarp 0.6.0 → 0.8.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 +55 -0
- data/CONTRIBUTING.md +4 -0
- data/{Makefile.in → Makefile} +5 -4
- data/README.md +6 -3
- data/config.yml +83 -274
- data/docs/build_system.md +4 -15
- data/docs/building.md +1 -5
- data/docs/encoding.md +1 -0
- data/docs/{extension.md → ruby_api.md} +6 -3
- data/docs/serialization.md +71 -24
- data/ext/yarp/api_node.c +173 -585
- data/ext/yarp/extconf.rb +15 -10
- data/ext/yarp/extension.c +4 -2
- data/ext/yarp/extension.h +1 -1
- data/include/yarp/ast.h +167 -306
- data/include/yarp/defines.h +5 -15
- data/include/yarp/enc/yp_encoding.h +1 -0
- data/include/yarp/unescape.h +1 -1
- data/include/yarp/util/yp_buffer.h +9 -0
- 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 +4 -0
- data/include/yarp/util/yp_state_stack.h +1 -1
- data/include/yarp/util/yp_string.h +5 -1
- data/include/yarp/version.h +2 -3
- data/include/yarp.h +4 -2
- data/lib/yarp/ffi.rb +226 -0
- data/lib/yarp/lex_compat.rb +16 -2
- data/lib/yarp/node.rb +594 -1437
- data/lib/yarp/ripper_compat.rb +3 -3
- data/lib/yarp/serialize.rb +312 -149
- data/lib/yarp.rb +167 -2
- data/src/enc/yp_unicode.c +9 -0
- data/src/node.c +92 -250
- data/src/prettyprint.c +81 -206
- data/src/serialize.c +124 -149
- data/src/unescape.c +29 -35
- data/src/util/yp_buffer.c +18 -0
- data/src/util/yp_list.c +7 -16
- data/src/util/yp_state_stack.c +0 -6
- data/src/util/yp_string.c +8 -17
- data/src/yarp.c +444 -717
- data/yarp.gemspec +5 -5
- metadata +6 -6
- data/config.h.in +0 -25
- data/configure +0 -4487
data/include/yarp/ast.h
CHANGED
@@ -217,137 +217,124 @@ 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
|
-
|
330
|
-
YP_NODE_SPLAT_NODE = 114,
|
331
|
-
YP_NODE_STATEMENTS_NODE = 115,
|
332
|
-
YP_NODE_STRING_CONCAT_NODE = 116,
|
333
|
-
YP_NODE_STRING_NODE = 117,
|
334
|
-
YP_NODE_SUPER_NODE = 118,
|
335
|
-
YP_NODE_SYMBOL_NODE = 119,
|
336
|
-
YP_NODE_TRUE_NODE = 120,
|
337
|
-
YP_NODE_UNDEF_NODE = 121,
|
338
|
-
YP_NODE_UNLESS_NODE = 122,
|
339
|
-
YP_NODE_UNTIL_NODE = 123,
|
340
|
-
YP_NODE_WHEN_NODE = 124,
|
341
|
-
YP_NODE_WHILE_NODE = 125,
|
342
|
-
YP_NODE_X_STRING_NODE = 126,
|
343
|
-
YP_NODE_YIELD_NODE = 127,
|
220
|
+
YP_NODE_AND_WRITE_NODE = 4,
|
221
|
+
YP_NODE_ARGUMENTS_NODE = 5,
|
222
|
+
YP_NODE_ARRAY_NODE = 6,
|
223
|
+
YP_NODE_ARRAY_PATTERN_NODE = 7,
|
224
|
+
YP_NODE_ASSOC_NODE = 8,
|
225
|
+
YP_NODE_ASSOC_SPLAT_NODE = 9,
|
226
|
+
YP_NODE_BACK_REFERENCE_READ_NODE = 10,
|
227
|
+
YP_NODE_BEGIN_NODE = 11,
|
228
|
+
YP_NODE_BLOCK_ARGUMENT_NODE = 12,
|
229
|
+
YP_NODE_BLOCK_NODE = 13,
|
230
|
+
YP_NODE_BLOCK_PARAMETER_NODE = 14,
|
231
|
+
YP_NODE_BLOCK_PARAMETERS_NODE = 15,
|
232
|
+
YP_NODE_BREAK_NODE = 16,
|
233
|
+
YP_NODE_CALL_NODE = 17,
|
234
|
+
YP_NODE_CALL_OPERATOR_AND_WRITE_NODE = 18,
|
235
|
+
YP_NODE_CALL_OPERATOR_OR_WRITE_NODE = 19,
|
236
|
+
YP_NODE_CALL_OPERATOR_WRITE_NODE = 20,
|
237
|
+
YP_NODE_CAPTURE_PATTERN_NODE = 21,
|
238
|
+
YP_NODE_CASE_NODE = 22,
|
239
|
+
YP_NODE_CLASS_NODE = 23,
|
240
|
+
YP_NODE_CLASS_VARIABLE_READ_NODE = 24,
|
241
|
+
YP_NODE_CLASS_VARIABLE_WRITE_NODE = 25,
|
242
|
+
YP_NODE_CONSTANT_PATH_NODE = 26,
|
243
|
+
YP_NODE_CONSTANT_PATH_WRITE_NODE = 27,
|
244
|
+
YP_NODE_CONSTANT_READ_NODE = 28,
|
245
|
+
YP_NODE_CONSTANT_WRITE_NODE = 29,
|
246
|
+
YP_NODE_DEF_NODE = 30,
|
247
|
+
YP_NODE_DEFINED_NODE = 31,
|
248
|
+
YP_NODE_ELSE_NODE = 32,
|
249
|
+
YP_NODE_EMBEDDED_STATEMENTS_NODE = 33,
|
250
|
+
YP_NODE_EMBEDDED_VARIABLE_NODE = 34,
|
251
|
+
YP_NODE_ENSURE_NODE = 35,
|
252
|
+
YP_NODE_FALSE_NODE = 36,
|
253
|
+
YP_NODE_FIND_PATTERN_NODE = 37,
|
254
|
+
YP_NODE_FLIP_FLOP_NODE = 38,
|
255
|
+
YP_NODE_FLOAT_NODE = 39,
|
256
|
+
YP_NODE_FOR_NODE = 40,
|
257
|
+
YP_NODE_FORWARDING_ARGUMENTS_NODE = 41,
|
258
|
+
YP_NODE_FORWARDING_PARAMETER_NODE = 42,
|
259
|
+
YP_NODE_FORWARDING_SUPER_NODE = 43,
|
260
|
+
YP_NODE_GLOBAL_VARIABLE_READ_NODE = 44,
|
261
|
+
YP_NODE_GLOBAL_VARIABLE_WRITE_NODE = 45,
|
262
|
+
YP_NODE_HASH_NODE = 46,
|
263
|
+
YP_NODE_HASH_PATTERN_NODE = 47,
|
264
|
+
YP_NODE_IF_NODE = 48,
|
265
|
+
YP_NODE_IMAGINARY_NODE = 49,
|
266
|
+
YP_NODE_IN_NODE = 50,
|
267
|
+
YP_NODE_INSTANCE_VARIABLE_READ_NODE = 51,
|
268
|
+
YP_NODE_INSTANCE_VARIABLE_WRITE_NODE = 52,
|
269
|
+
YP_NODE_INTEGER_NODE = 53,
|
270
|
+
YP_NODE_INTERPOLATED_REGULAR_EXPRESSION_NODE = 54,
|
271
|
+
YP_NODE_INTERPOLATED_STRING_NODE = 55,
|
272
|
+
YP_NODE_INTERPOLATED_SYMBOL_NODE = 56,
|
273
|
+
YP_NODE_INTERPOLATED_X_STRING_NODE = 57,
|
274
|
+
YP_NODE_KEYWORD_HASH_NODE = 58,
|
275
|
+
YP_NODE_KEYWORD_PARAMETER_NODE = 59,
|
276
|
+
YP_NODE_KEYWORD_REST_PARAMETER_NODE = 60,
|
277
|
+
YP_NODE_LAMBDA_NODE = 61,
|
278
|
+
YP_NODE_LOCAL_VARIABLE_READ_NODE = 62,
|
279
|
+
YP_NODE_LOCAL_VARIABLE_WRITE_NODE = 63,
|
280
|
+
YP_NODE_MATCH_PREDICATE_NODE = 64,
|
281
|
+
YP_NODE_MATCH_REQUIRED_NODE = 65,
|
282
|
+
YP_NODE_MISSING_NODE = 66,
|
283
|
+
YP_NODE_MODULE_NODE = 67,
|
284
|
+
YP_NODE_MULTI_WRITE_NODE = 68,
|
285
|
+
YP_NODE_NEXT_NODE = 69,
|
286
|
+
YP_NODE_NIL_NODE = 70,
|
287
|
+
YP_NODE_NO_KEYWORDS_PARAMETER_NODE = 71,
|
288
|
+
YP_NODE_NUMBERED_REFERENCE_READ_NODE = 72,
|
289
|
+
YP_NODE_OPERATOR_WRITE_NODE = 73,
|
290
|
+
YP_NODE_OPTIONAL_PARAMETER_NODE = 74,
|
291
|
+
YP_NODE_OR_NODE = 75,
|
292
|
+
YP_NODE_OR_WRITE_NODE = 76,
|
293
|
+
YP_NODE_PARAMETERS_NODE = 77,
|
294
|
+
YP_NODE_PARENTHESES_NODE = 78,
|
295
|
+
YP_NODE_PINNED_EXPRESSION_NODE = 79,
|
296
|
+
YP_NODE_PINNED_VARIABLE_NODE = 80,
|
297
|
+
YP_NODE_POST_EXECUTION_NODE = 81,
|
298
|
+
YP_NODE_PRE_EXECUTION_NODE = 82,
|
299
|
+
YP_NODE_PROGRAM_NODE = 83,
|
300
|
+
YP_NODE_RANGE_NODE = 84,
|
301
|
+
YP_NODE_RATIONAL_NODE = 85,
|
302
|
+
YP_NODE_REDO_NODE = 86,
|
303
|
+
YP_NODE_REGULAR_EXPRESSION_NODE = 87,
|
304
|
+
YP_NODE_REQUIRED_DESTRUCTURED_PARAMETER_NODE = 88,
|
305
|
+
YP_NODE_REQUIRED_PARAMETER_NODE = 89,
|
306
|
+
YP_NODE_RESCUE_MODIFIER_NODE = 90,
|
307
|
+
YP_NODE_RESCUE_NODE = 91,
|
308
|
+
YP_NODE_REST_PARAMETER_NODE = 92,
|
309
|
+
YP_NODE_RETRY_NODE = 93,
|
310
|
+
YP_NODE_RETURN_NODE = 94,
|
311
|
+
YP_NODE_SELF_NODE = 95,
|
312
|
+
YP_NODE_SINGLETON_CLASS_NODE = 96,
|
313
|
+
YP_NODE_SOURCE_ENCODING_NODE = 97,
|
314
|
+
YP_NODE_SOURCE_FILE_NODE = 98,
|
315
|
+
YP_NODE_SOURCE_LINE_NODE = 99,
|
316
|
+
YP_NODE_SPLAT_NODE = 100,
|
317
|
+
YP_NODE_STATEMENTS_NODE = 101,
|
318
|
+
YP_NODE_STRING_CONCAT_NODE = 102,
|
319
|
+
YP_NODE_STRING_NODE = 103,
|
320
|
+
YP_NODE_SUPER_NODE = 104,
|
321
|
+
YP_NODE_SYMBOL_NODE = 105,
|
322
|
+
YP_NODE_TRUE_NODE = 106,
|
323
|
+
YP_NODE_UNDEF_NODE = 107,
|
324
|
+
YP_NODE_UNLESS_NODE = 108,
|
325
|
+
YP_NODE_UNTIL_NODE = 109,
|
326
|
+
YP_NODE_WHEN_NODE = 110,
|
327
|
+
YP_NODE_WHILE_NODE = 111,
|
328
|
+
YP_NODE_X_STRING_NODE = 112,
|
329
|
+
YP_NODE_YIELD_NODE = 113,
|
344
330
|
};
|
345
331
|
|
346
332
|
typedef uint16_t yp_node_type_t;
|
347
333
|
typedef uint16_t yp_node_flags_t;
|
348
334
|
|
349
|
-
// We store the flags enum in every node in the tree
|
350
|
-
|
335
|
+
// We store the flags enum in every node in the tree. Some flags are common to
|
336
|
+
// all nodes (the ones listed below). Others are specific to certain node types.
|
337
|
+
static const yp_node_flags_t YP_NODE_FLAG_NEWLINE = 0x1;
|
351
338
|
|
352
339
|
// For easy access, we define some macros to check node type
|
353
340
|
#define YP_NODE_TYPE(node) ((enum yp_node_type)node->type)
|
@@ -392,6 +379,14 @@ typedef struct yp_and_node {
|
|
392
379
|
yp_location_t operator_loc;
|
393
380
|
} yp_and_node_t;
|
394
381
|
|
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
|
+
|
395
390
|
// ArgumentsNode
|
396
391
|
typedef struct yp_arguments_node {
|
397
392
|
yp_node_t base;
|
@@ -460,7 +455,7 @@ typedef struct yp_block_node {
|
|
460
455
|
yp_node_t base;
|
461
456
|
yp_constant_id_list_t locals;
|
462
457
|
struct yp_block_parameters_node *parameters;
|
463
|
-
struct yp_node *
|
458
|
+
struct yp_node *body;
|
464
459
|
yp_location_t opening_loc;
|
465
460
|
yp_location_t closing_loc;
|
466
461
|
} yp_block_node_t;
|
@@ -498,7 +493,6 @@ typedef struct yp_call_node {
|
|
498
493
|
struct yp_arguments_node *arguments;
|
499
494
|
yp_location_t closing_loc;
|
500
495
|
struct yp_block_node *block;
|
501
|
-
uint32_t flags;
|
502
496
|
yp_string_t name;
|
503
497
|
} yp_call_node_t;
|
504
498
|
|
@@ -553,35 +547,10 @@ typedef struct yp_class_node {
|
|
553
547
|
struct yp_node *constant_path;
|
554
548
|
yp_location_t inheritance_operator_loc;
|
555
549
|
struct yp_node *superclass;
|
556
|
-
struct yp_node *
|
550
|
+
struct yp_node *body;
|
557
551
|
yp_location_t end_keyword_loc;
|
558
552
|
} yp_class_node_t;
|
559
553
|
|
560
|
-
// ClassVariableOperatorAndWriteNode
|
561
|
-
typedef struct yp_class_variable_operator_and_write_node {
|
562
|
-
yp_node_t base;
|
563
|
-
yp_location_t name_loc;
|
564
|
-
yp_location_t operator_loc;
|
565
|
-
struct yp_node *value;
|
566
|
-
} yp_class_variable_operator_and_write_node_t;
|
567
|
-
|
568
|
-
// ClassVariableOperatorOrWriteNode
|
569
|
-
typedef struct yp_class_variable_operator_or_write_node {
|
570
|
-
yp_node_t base;
|
571
|
-
yp_location_t name_loc;
|
572
|
-
yp_location_t operator_loc;
|
573
|
-
struct yp_node *value;
|
574
|
-
} yp_class_variable_operator_or_write_node_t;
|
575
|
-
|
576
|
-
// ClassVariableOperatorWriteNode
|
577
|
-
typedef struct yp_class_variable_operator_write_node {
|
578
|
-
yp_node_t base;
|
579
|
-
yp_location_t name_loc;
|
580
|
-
yp_location_t operator_loc;
|
581
|
-
struct yp_node *value;
|
582
|
-
yp_constant_id_t operator;
|
583
|
-
} yp_class_variable_operator_write_node_t;
|
584
|
-
|
585
554
|
// ClassVariableReadNode
|
586
555
|
typedef struct yp_class_variable_read_node {
|
587
556
|
yp_node_t base;
|
@@ -595,31 +564,6 @@ typedef struct yp_class_variable_write_node {
|
|
595
564
|
yp_location_t operator_loc;
|
596
565
|
} yp_class_variable_write_node_t;
|
597
566
|
|
598
|
-
// ConstantOperatorAndWriteNode
|
599
|
-
typedef struct yp_constant_operator_and_write_node {
|
600
|
-
yp_node_t base;
|
601
|
-
yp_location_t name_loc;
|
602
|
-
yp_location_t operator_loc;
|
603
|
-
struct yp_node *value;
|
604
|
-
} yp_constant_operator_and_write_node_t;
|
605
|
-
|
606
|
-
// ConstantOperatorOrWriteNode
|
607
|
-
typedef struct yp_constant_operator_or_write_node {
|
608
|
-
yp_node_t base;
|
609
|
-
yp_location_t name_loc;
|
610
|
-
yp_location_t operator_loc;
|
611
|
-
struct yp_node *value;
|
612
|
-
} yp_constant_operator_or_write_node_t;
|
613
|
-
|
614
|
-
// ConstantOperatorWriteNode
|
615
|
-
typedef struct yp_constant_operator_write_node {
|
616
|
-
yp_node_t base;
|
617
|
-
yp_location_t name_loc;
|
618
|
-
yp_location_t operator_loc;
|
619
|
-
struct yp_node *value;
|
620
|
-
yp_constant_id_t operator;
|
621
|
-
} yp_constant_operator_write_node_t;
|
622
|
-
|
623
567
|
// ConstantPathNode
|
624
568
|
typedef struct yp_constant_path_node {
|
625
569
|
yp_node_t base;
|
@@ -628,31 +572,6 @@ typedef struct yp_constant_path_node {
|
|
628
572
|
yp_location_t delimiter_loc;
|
629
573
|
} yp_constant_path_node_t;
|
630
574
|
|
631
|
-
// ConstantPathOperatorAndWriteNode
|
632
|
-
typedef struct yp_constant_path_operator_and_write_node {
|
633
|
-
yp_node_t base;
|
634
|
-
struct yp_constant_path_node *target;
|
635
|
-
yp_location_t operator_loc;
|
636
|
-
struct yp_node *value;
|
637
|
-
} yp_constant_path_operator_and_write_node_t;
|
638
|
-
|
639
|
-
// ConstantPathOperatorOrWriteNode
|
640
|
-
typedef struct yp_constant_path_operator_or_write_node {
|
641
|
-
yp_node_t base;
|
642
|
-
struct yp_constant_path_node *target;
|
643
|
-
yp_location_t operator_loc;
|
644
|
-
struct yp_node *value;
|
645
|
-
} yp_constant_path_operator_or_write_node_t;
|
646
|
-
|
647
|
-
// ConstantPathOperatorWriteNode
|
648
|
-
typedef struct yp_constant_path_operator_write_node {
|
649
|
-
yp_node_t base;
|
650
|
-
struct yp_constant_path_node *target;
|
651
|
-
yp_location_t operator_loc;
|
652
|
-
struct yp_node *value;
|
653
|
-
yp_constant_id_t operator;
|
654
|
-
} yp_constant_path_operator_write_node_t;
|
655
|
-
|
656
575
|
// ConstantPathWriteNode
|
657
576
|
typedef struct yp_constant_path_write_node {
|
658
577
|
yp_node_t base;
|
@@ -680,7 +599,7 @@ typedef struct yp_def_node {
|
|
680
599
|
yp_location_t name_loc;
|
681
600
|
struct yp_node *receiver;
|
682
601
|
struct yp_parameters_node *parameters;
|
683
|
-
struct yp_node *
|
602
|
+
struct yp_node *body;
|
684
603
|
yp_constant_id_list_t locals;
|
685
604
|
yp_location_t def_keyword_loc;
|
686
605
|
yp_location_t operator_loc;
|
@@ -746,6 +665,14 @@ typedef struct yp_find_pattern_node {
|
|
746
665
|
yp_location_t closing_loc;
|
747
666
|
} yp_find_pattern_node_t;
|
748
667
|
|
668
|
+
// FlipFlopNode
|
669
|
+
typedef struct yp_flip_flop_node {
|
670
|
+
yp_node_t base;
|
671
|
+
struct yp_node *left;
|
672
|
+
struct yp_node *right;
|
673
|
+
yp_location_t operator_loc;
|
674
|
+
} yp_flip_flop_node_t;
|
675
|
+
|
749
676
|
// FloatNode
|
750
677
|
typedef struct yp_float_node {
|
751
678
|
yp_node_t base;
|
@@ -779,31 +706,6 @@ typedef struct yp_forwarding_super_node {
|
|
779
706
|
struct yp_block_node *block;
|
780
707
|
} yp_forwarding_super_node_t;
|
781
708
|
|
782
|
-
// GlobalVariableOperatorAndWriteNode
|
783
|
-
typedef struct yp_global_variable_operator_and_write_node {
|
784
|
-
yp_node_t base;
|
785
|
-
yp_location_t name_loc;
|
786
|
-
yp_location_t operator_loc;
|
787
|
-
struct yp_node *value;
|
788
|
-
} yp_global_variable_operator_and_write_node_t;
|
789
|
-
|
790
|
-
// GlobalVariableOperatorOrWriteNode
|
791
|
-
typedef struct yp_global_variable_operator_or_write_node {
|
792
|
-
yp_node_t base;
|
793
|
-
yp_location_t name_loc;
|
794
|
-
yp_location_t operator_loc;
|
795
|
-
struct yp_node *value;
|
796
|
-
} yp_global_variable_operator_or_write_node_t;
|
797
|
-
|
798
|
-
// GlobalVariableOperatorWriteNode
|
799
|
-
typedef struct yp_global_variable_operator_write_node {
|
800
|
-
yp_node_t base;
|
801
|
-
yp_location_t name_loc;
|
802
|
-
yp_location_t operator_loc;
|
803
|
-
struct yp_node *value;
|
804
|
-
yp_constant_id_t operator;
|
805
|
-
} yp_global_variable_operator_write_node_t;
|
806
|
-
|
807
709
|
// GlobalVariableReadNode
|
808
710
|
typedef struct yp_global_variable_read_node {
|
809
711
|
yp_node_t base;
|
@@ -860,31 +762,6 @@ typedef struct yp_in_node {
|
|
860
762
|
yp_location_t then_loc;
|
861
763
|
} yp_in_node_t;
|
862
764
|
|
863
|
-
// InstanceVariableOperatorAndWriteNode
|
864
|
-
typedef struct yp_instance_variable_operator_and_write_node {
|
865
|
-
yp_node_t base;
|
866
|
-
yp_location_t name_loc;
|
867
|
-
yp_location_t operator_loc;
|
868
|
-
struct yp_node *value;
|
869
|
-
} yp_instance_variable_operator_and_write_node_t;
|
870
|
-
|
871
|
-
// InstanceVariableOperatorOrWriteNode
|
872
|
-
typedef struct yp_instance_variable_operator_or_write_node {
|
873
|
-
yp_node_t base;
|
874
|
-
yp_location_t name_loc;
|
875
|
-
yp_location_t operator_loc;
|
876
|
-
struct yp_node *value;
|
877
|
-
} yp_instance_variable_operator_or_write_node_t;
|
878
|
-
|
879
|
-
// InstanceVariableOperatorWriteNode
|
880
|
-
typedef struct yp_instance_variable_operator_write_node {
|
881
|
-
yp_node_t base;
|
882
|
-
yp_location_t name_loc;
|
883
|
-
yp_location_t operator_loc;
|
884
|
-
struct yp_node *value;
|
885
|
-
yp_constant_id_t operator;
|
886
|
-
} yp_instance_variable_operator_write_node_t;
|
887
|
-
|
888
765
|
// InstanceVariableReadNode
|
889
766
|
typedef struct yp_instance_variable_read_node {
|
890
767
|
yp_node_t base;
|
@@ -909,7 +786,6 @@ typedef struct yp_interpolated_regular_expression_node {
|
|
909
786
|
yp_location_t opening_loc;
|
910
787
|
struct yp_node_list parts;
|
911
788
|
yp_location_t closing_loc;
|
912
|
-
uint32_t flags;
|
913
789
|
} yp_interpolated_regular_expression_node_t;
|
914
790
|
|
915
791
|
// InterpolatedStringNode
|
@@ -962,37 +838,9 @@ typedef struct yp_lambda_node {
|
|
962
838
|
yp_constant_id_list_t locals;
|
963
839
|
yp_location_t opening_loc;
|
964
840
|
struct yp_block_parameters_node *parameters;
|
965
|
-
struct yp_node *
|
841
|
+
struct yp_node *body;
|
966
842
|
} yp_lambda_node_t;
|
967
843
|
|
968
|
-
// LocalVariableOperatorAndWriteNode
|
969
|
-
typedef struct yp_local_variable_operator_and_write_node {
|
970
|
-
yp_node_t base;
|
971
|
-
yp_location_t name_loc;
|
972
|
-
yp_location_t operator_loc;
|
973
|
-
struct yp_node *value;
|
974
|
-
yp_constant_id_t constant_id;
|
975
|
-
} yp_local_variable_operator_and_write_node_t;
|
976
|
-
|
977
|
-
// LocalVariableOperatorOrWriteNode
|
978
|
-
typedef struct yp_local_variable_operator_or_write_node {
|
979
|
-
yp_node_t base;
|
980
|
-
yp_location_t name_loc;
|
981
|
-
yp_location_t operator_loc;
|
982
|
-
struct yp_node *value;
|
983
|
-
yp_constant_id_t constant_id;
|
984
|
-
} yp_local_variable_operator_or_write_node_t;
|
985
|
-
|
986
|
-
// LocalVariableOperatorWriteNode
|
987
|
-
typedef struct yp_local_variable_operator_write_node {
|
988
|
-
yp_node_t base;
|
989
|
-
yp_location_t name_loc;
|
990
|
-
yp_location_t operator_loc;
|
991
|
-
struct yp_node *value;
|
992
|
-
yp_constant_id_t constant_id;
|
993
|
-
yp_constant_id_t operator_id;
|
994
|
-
} yp_local_variable_operator_write_node_t;
|
995
|
-
|
996
844
|
// LocalVariableReadNode
|
997
845
|
typedef struct yp_local_variable_read_node {
|
998
846
|
yp_node_t base;
|
@@ -1037,7 +885,7 @@ typedef struct yp_module_node {
|
|
1037
885
|
yp_constant_id_list_t locals;
|
1038
886
|
yp_location_t module_keyword_loc;
|
1039
887
|
struct yp_node *constant_path;
|
1040
|
-
struct yp_node *
|
888
|
+
struct yp_node *body;
|
1041
889
|
yp_location_t end_keyword_loc;
|
1042
890
|
} yp_module_node_t;
|
1043
891
|
|
@@ -1075,6 +923,15 @@ typedef struct yp_numbered_reference_read_node {
|
|
1075
923
|
yp_node_t base;
|
1076
924
|
} yp_numbered_reference_read_node_t;
|
1077
925
|
|
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
|
+
|
1078
935
|
// OptionalParameterNode
|
1079
936
|
typedef struct yp_optional_parameter_node {
|
1080
937
|
yp_node_t base;
|
@@ -1092,6 +949,14 @@ typedef struct yp_or_node {
|
|
1092
949
|
yp_location_t operator_loc;
|
1093
950
|
} yp_or_node_t;
|
1094
951
|
|
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
|
+
|
1095
960
|
// ParametersNode
|
1096
961
|
typedef struct yp_parameters_node {
|
1097
962
|
yp_node_t base;
|
@@ -1107,7 +972,7 @@ typedef struct yp_parameters_node {
|
|
1107
972
|
// ParenthesesNode
|
1108
973
|
typedef struct yp_parentheses_node {
|
1109
974
|
yp_node_t base;
|
1110
|
-
struct yp_node *
|
975
|
+
struct yp_node *body;
|
1111
976
|
yp_location_t opening_loc;
|
1112
977
|
yp_location_t closing_loc;
|
1113
978
|
} yp_parentheses_node_t;
|
@@ -1159,7 +1024,6 @@ typedef struct yp_range_node {
|
|
1159
1024
|
struct yp_node *left;
|
1160
1025
|
struct yp_node *right;
|
1161
1026
|
yp_location_t operator_loc;
|
1162
|
-
uint32_t flags;
|
1163
1027
|
} yp_range_node_t;
|
1164
1028
|
|
1165
1029
|
// RationalNode
|
@@ -1180,7 +1044,6 @@ typedef struct yp_regular_expression_node {
|
|
1180
1044
|
yp_location_t content_loc;
|
1181
1045
|
yp_location_t closing_loc;
|
1182
1046
|
yp_string_t unescaped;
|
1183
|
-
uint32_t flags;
|
1184
1047
|
} yp_regular_expression_node_t;
|
1185
1048
|
|
1186
1049
|
// RequiredDestructuredParameterNode
|
@@ -1247,7 +1110,7 @@ typedef struct yp_singleton_class_node {
|
|
1247
1110
|
yp_location_t class_keyword_loc;
|
1248
1111
|
yp_location_t operator_loc;
|
1249
1112
|
struct yp_node *expression;
|
1250
|
-
struct yp_node *
|
1113
|
+
struct yp_node *body;
|
1251
1114
|
yp_location_t end_keyword_loc;
|
1252
1115
|
} yp_singleton_class_node_t;
|
1253
1116
|
|
@@ -1343,7 +1206,6 @@ typedef struct yp_until_node {
|
|
1343
1206
|
yp_location_t keyword_loc;
|
1344
1207
|
struct yp_node *predicate;
|
1345
1208
|
struct yp_statements_node *statements;
|
1346
|
-
uint32_t flags;
|
1347
1209
|
} yp_until_node_t;
|
1348
1210
|
|
1349
1211
|
// WhenNode
|
@@ -1360,7 +1222,6 @@ typedef struct yp_while_node {
|
|
1360
1222
|
yp_location_t keyword_loc;
|
1361
1223
|
struct yp_node *predicate;
|
1362
1224
|
struct yp_statements_node *statements;
|
1363
|
-
uint32_t flags;
|
1364
1225
|
} yp_while_node_t;
|
1365
1226
|
|
1366
1227
|
// XStringNode
|
@@ -1383,30 +1244,30 @@ typedef struct yp_yield_node {
|
|
1383
1244
|
|
1384
1245
|
// CallNodeFlags
|
1385
1246
|
typedef enum {
|
1386
|
-
YP_CALL_NODE_FLAGS_SAFE_NAVIGATION = 1 <<
|
1387
|
-
YP_CALL_NODE_FLAGS_VARIABLE_CALL = 1 <<
|
1247
|
+
YP_CALL_NODE_FLAGS_SAFE_NAVIGATION = 1 << 1,
|
1248
|
+
YP_CALL_NODE_FLAGS_VARIABLE_CALL = 1 << 2,
|
1388
1249
|
} yp_call_node_flags_t;
|
1389
1250
|
|
1390
1251
|
// LoopFlags
|
1391
1252
|
typedef enum {
|
1392
|
-
YP_LOOP_FLAGS_BEGIN_MODIFIER = 1 <<
|
1253
|
+
YP_LOOP_FLAGS_BEGIN_MODIFIER = 1 << 1,
|
1393
1254
|
} yp_loop_flags_t;
|
1394
1255
|
|
1395
|
-
//
|
1256
|
+
// RangeFlags
|
1396
1257
|
typedef enum {
|
1397
|
-
|
1398
|
-
}
|
1258
|
+
YP_RANGE_FLAGS_EXCLUDE_END = 1 << 1,
|
1259
|
+
} yp_range_flags_t;
|
1399
1260
|
|
1400
1261
|
// RegularExpressionFlags
|
1401
1262
|
typedef enum {
|
1402
|
-
YP_REGULAR_EXPRESSION_FLAGS_IGNORE_CASE = 1 <<
|
1403
|
-
YP_REGULAR_EXPRESSION_FLAGS_MULTI_LINE = 1 <<
|
1404
|
-
YP_REGULAR_EXPRESSION_FLAGS_EXTENDED = 1 <<
|
1405
|
-
YP_REGULAR_EXPRESSION_FLAGS_EUC_JP = 1 <<
|
1406
|
-
YP_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT = 1 <<
|
1407
|
-
YP_REGULAR_EXPRESSION_FLAGS_WINDOWS_31J = 1 <<
|
1408
|
-
YP_REGULAR_EXPRESSION_FLAGS_UTF_8 = 1 <<
|
1409
|
-
YP_REGULAR_EXPRESSION_FLAGS_ONCE = 1 <<
|
1263
|
+
YP_REGULAR_EXPRESSION_FLAGS_IGNORE_CASE = 1 << 1,
|
1264
|
+
YP_REGULAR_EXPRESSION_FLAGS_MULTI_LINE = 1 << 2,
|
1265
|
+
YP_REGULAR_EXPRESSION_FLAGS_EXTENDED = 1 << 3,
|
1266
|
+
YP_REGULAR_EXPRESSION_FLAGS_EUC_JP = 1 << 4,
|
1267
|
+
YP_REGULAR_EXPRESSION_FLAGS_ASCII_8BIT = 1 << 5,
|
1268
|
+
YP_REGULAR_EXPRESSION_FLAGS_WINDOWS_31J = 1 << 6,
|
1269
|
+
YP_REGULAR_EXPRESSION_FLAGS_UTF_8 = 1 << 7,
|
1270
|
+
YP_REGULAR_EXPRESSION_FLAGS_ONCE = 1 << 8,
|
1410
1271
|
} yp_regular_expression_flags_t;
|
1411
1272
|
|
1412
1273
|
#endif // YARP_AST_H
|
data/include/yarp/defines.h
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
|
4
4
|
// This file should be included first by any *.h or *.c in YARP
|
5
5
|
|
6
|
-
#include "yarp/config.h"
|
7
|
-
|
8
6
|
#include <ctype.h>
|
9
7
|
#include <stdarg.h>
|
10
8
|
#include <stddef.h>
|
@@ -36,19 +34,11 @@
|
|
36
34
|
# define inline __inline
|
37
35
|
#endif
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
#if defined(HAVE_SNPRINTF)
|
44
|
-
// We use snprintf if it's available
|
45
|
-
# define yp_snprintf snprintf
|
46
|
-
|
47
|
-
#else
|
48
|
-
// In case snprintf isn't present on the system, we provide our own that simply
|
49
|
-
// forwards to the less-safe sprintf.
|
50
|
-
# define yp_snprintf(dest, size, ...) sprintf((dest), __VA_ARGS__)
|
51
|
-
|
37
|
+
// Windows versions before 2015 use _snprintf
|
38
|
+
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
39
|
+
# define snprintf _snprintf
|
52
40
|
#endif
|
53
41
|
|
42
|
+
int yp_strncasecmp(const char *string1, const char *string2, size_t length);
|
43
|
+
|
54
44
|
#endif
|
@@ -87,6 +87,7 @@ extern yp_encoding_t yp_encoding_iso_8859_16;
|
|
87
87
|
extern yp_encoding_t yp_encoding_koi8_r;
|
88
88
|
extern yp_encoding_t yp_encoding_shift_jis;
|
89
89
|
extern yp_encoding_t yp_encoding_utf_8;
|
90
|
+
extern yp_encoding_t yp_encoding_utf8_mac;
|
90
91
|
extern yp_encoding_t yp_encoding_windows_31j;
|
91
92
|
extern yp_encoding_t yp_encoding_windows_1251;
|
92
93
|
extern yp_encoding_t yp_encoding_windows_1252;
|