prism 1.4.0 → 1.5.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 +23 -1
- data/Makefile +2 -1
- data/README.md +1 -0
- data/config.yml +264 -37
- data/docs/parser_translation.md +8 -23
- data/docs/ripper_translation.md +1 -1
- data/ext/prism/api_node.c +2 -0
- data/ext/prism/extension.c +14 -1
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +275 -49
- data/include/prism/diagnostic.h +4 -0
- data/include/prism/options.h +43 -3
- data/include/prism/regexp.h +2 -2
- data/include/prism/util/pm_buffer.h +8 -0
- data/include/prism/util/pm_integer.h +4 -0
- data/include/prism/util/pm_list.h +6 -0
- data/include/prism/util/pm_string.h +12 -2
- data/include/prism/version.h +2 -2
- data/include/prism.h +39 -14
- data/lib/prism/compiler.rb +456 -151
- data/lib/prism/desugar_compiler.rb +1 -0
- data/lib/prism/dispatcher.rb +16 -0
- data/lib/prism/dot_visitor.rb +5 -1
- data/lib/prism/dsl.rb +3 -0
- data/lib/prism/ffi.rb +17 -7
- data/lib/prism/inspect_visitor.rb +3 -0
- data/lib/prism/lex_compat.rb +1 -0
- data/lib/prism/mutation_compiler.rb +3 -0
- data/lib/prism/node.rb +506 -335
- data/lib/prism/node_ext.rb +4 -1
- data/lib/prism/pack.rb +2 -0
- data/lib/prism/parse_result/comments.rb +1 -0
- data/lib/prism/parse_result/errors.rb +1 -0
- data/lib/prism/parse_result/newlines.rb +1 -0
- data/lib/prism/parse_result.rb +1 -0
- data/lib/prism/pattern.rb +1 -0
- data/lib/prism/polyfill/scan_byte.rb +14 -0
- data/lib/prism/polyfill/warn.rb +42 -0
- data/lib/prism/reflection.rb +3 -0
- data/lib/prism/relocation.rb +1 -0
- data/lib/prism/serialize.rb +24 -19
- data/lib/prism/string_query.rb +1 -0
- data/lib/prism/translation/parser/builder.rb +1 -0
- data/lib/prism/translation/parser/compiler.rb +47 -25
- data/lib/prism/translation/parser/lexer.rb +29 -21
- data/lib/prism/translation/parser.rb +13 -1
- data/lib/prism/translation/parser33.rb +1 -0
- data/lib/prism/translation/parser34.rb +1 -0
- data/lib/prism/translation/parser35.rb +1 -0
- data/lib/prism/translation/parser_current.rb +24 -0
- data/lib/prism/translation/ripper/sexp.rb +1 -0
- data/lib/prism/translation/ripper.rb +17 -1
- data/lib/prism/translation/ruby_parser.rb +286 -3
- data/lib/prism/translation.rb +2 -0
- data/lib/prism/visitor.rb +457 -152
- data/lib/prism.rb +2 -0
- data/prism.gemspec +5 -1
- data/rbi/prism/dsl.rbi +3 -3
- data/rbi/prism/node.rbi +21 -9
- data/sig/prism/dispatcher.rbs +3 -0
- data/sig/prism/dsl.rbs +3 -3
- data/sig/prism/node.rbs +444 -30
- data/sig/prism/node_ext.rbs +84 -17
- data/sig/prism/parse_result/comments.rbs +38 -0
- data/sig/prism/parse_result.rbs +4 -0
- data/sig/prism/reflection.rbs +1 -1
- data/src/diagnostic.c +7 -1
- data/src/node.c +2 -0
- data/src/options.c +2 -2
- data/src/prettyprint.c +2 -0
- data/src/prism.c +252 -130
- data/src/serialize.c +2 -0
- data/src/token_type.c +36 -34
- metadata +6 -2
data/ext/prism/extension.h
CHANGED
data/include/prism/ast.h
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
/* :markup: markdown */
|
2
|
+
|
1
3
|
/*----------------------------------------------------------------------------*/
|
2
4
|
/* This file is generated by the templates/template.rb script and should not */
|
3
5
|
/* be modified manually. See */
|
@@ -10,6 +12,8 @@
|
|
10
12
|
* @file ast.h
|
11
13
|
*
|
12
14
|
* The abstract syntax tree.
|
15
|
+
*
|
16
|
+
* --
|
13
17
|
*/
|
14
18
|
#ifndef PRISM_AST_H
|
15
19
|
#define PRISM_AST_H
|
@@ -30,11 +34,50 @@ typedef enum pm_token_type {
|
|
30
34
|
/** final token in the file */
|
31
35
|
PM_TOKEN_EOF = 1,
|
32
36
|
|
33
|
-
/**
|
34
|
-
|
37
|
+
/** } */
|
38
|
+
PM_TOKEN_BRACE_RIGHT,
|
35
39
|
|
36
|
-
/**
|
37
|
-
|
40
|
+
/** , */
|
41
|
+
PM_TOKEN_COMMA,
|
42
|
+
|
43
|
+
/** } */
|
44
|
+
PM_TOKEN_EMBEXPR_END,
|
45
|
+
|
46
|
+
/** do */
|
47
|
+
PM_TOKEN_KEYWORD_DO,
|
48
|
+
|
49
|
+
/** else */
|
50
|
+
PM_TOKEN_KEYWORD_ELSE,
|
51
|
+
|
52
|
+
/** elsif */
|
53
|
+
PM_TOKEN_KEYWORD_ELSIF,
|
54
|
+
|
55
|
+
/** end */
|
56
|
+
PM_TOKEN_KEYWORD_END,
|
57
|
+
|
58
|
+
/** ensure */
|
59
|
+
PM_TOKEN_KEYWORD_ENSURE,
|
60
|
+
|
61
|
+
/** in */
|
62
|
+
PM_TOKEN_KEYWORD_IN,
|
63
|
+
|
64
|
+
/** rescue */
|
65
|
+
PM_TOKEN_KEYWORD_RESCUE,
|
66
|
+
|
67
|
+
/** then */
|
68
|
+
PM_TOKEN_KEYWORD_THEN,
|
69
|
+
|
70
|
+
/** when */
|
71
|
+
PM_TOKEN_KEYWORD_WHEN,
|
72
|
+
|
73
|
+
/** a newline character outside of other tokens */
|
74
|
+
PM_TOKEN_NEWLINE,
|
75
|
+
|
76
|
+
/** ) */
|
77
|
+
PM_TOKEN_PARENTHESIS_RIGHT,
|
78
|
+
|
79
|
+
/** ; */
|
80
|
+
PM_TOKEN_SEMICOLON,
|
38
81
|
|
39
82
|
/** & */
|
40
83
|
PM_TOKEN_AMPERSAND,
|
@@ -69,9 +112,6 @@ typedef enum pm_token_type {
|
|
69
112
|
/** { */
|
70
113
|
PM_TOKEN_BRACE_LEFT,
|
71
114
|
|
72
|
-
/** } */
|
73
|
-
PM_TOKEN_BRACE_RIGHT,
|
74
|
-
|
75
115
|
/** [ */
|
76
116
|
PM_TOKEN_BRACKET_LEFT,
|
77
117
|
|
@@ -105,9 +145,6 @@ typedef enum pm_token_type {
|
|
105
145
|
/** :: */
|
106
146
|
PM_TOKEN_COLON_COLON,
|
107
147
|
|
108
|
-
/** , */
|
109
|
-
PM_TOKEN_COMMA,
|
110
|
-
|
111
148
|
/** a comment */
|
112
149
|
PM_TOKEN_COMMENT,
|
113
150
|
|
@@ -135,9 +172,6 @@ typedef enum pm_token_type {
|
|
135
172
|
/** #{ */
|
136
173
|
PM_TOKEN_EMBEXPR_BEGIN,
|
137
174
|
|
138
|
-
/** } */
|
139
|
-
PM_TOKEN_EMBEXPR_END,
|
140
|
-
|
141
175
|
/** # */
|
142
176
|
PM_TOKEN_EMBVAR,
|
143
177
|
|
@@ -237,27 +271,12 @@ typedef enum pm_token_type {
|
|
237
271
|
/** defined? */
|
238
272
|
PM_TOKEN_KEYWORD_DEFINED,
|
239
273
|
|
240
|
-
/** do */
|
241
|
-
PM_TOKEN_KEYWORD_DO,
|
242
|
-
|
243
274
|
/** do keyword for a predicate in a while, until, or for loop */
|
244
275
|
PM_TOKEN_KEYWORD_DO_LOOP,
|
245
276
|
|
246
|
-
/** else */
|
247
|
-
PM_TOKEN_KEYWORD_ELSE,
|
248
|
-
|
249
|
-
/** elsif */
|
250
|
-
PM_TOKEN_KEYWORD_ELSIF,
|
251
|
-
|
252
|
-
/** end */
|
253
|
-
PM_TOKEN_KEYWORD_END,
|
254
|
-
|
255
277
|
/** END */
|
256
278
|
PM_TOKEN_KEYWORD_END_UPCASE,
|
257
279
|
|
258
|
-
/** ensure */
|
259
|
-
PM_TOKEN_KEYWORD_ENSURE,
|
260
|
-
|
261
280
|
/** false */
|
262
281
|
PM_TOKEN_KEYWORD_FALSE,
|
263
282
|
|
@@ -270,9 +289,6 @@ typedef enum pm_token_type {
|
|
270
289
|
/** if in the modifier form */
|
271
290
|
PM_TOKEN_KEYWORD_IF_MODIFIER,
|
272
291
|
|
273
|
-
/** in */
|
274
|
-
PM_TOKEN_KEYWORD_IN,
|
275
|
-
|
276
292
|
/** module */
|
277
293
|
PM_TOKEN_KEYWORD_MODULE,
|
278
294
|
|
@@ -291,9 +307,6 @@ typedef enum pm_token_type {
|
|
291
307
|
/** redo */
|
292
308
|
PM_TOKEN_KEYWORD_REDO,
|
293
309
|
|
294
|
-
/** rescue */
|
295
|
-
PM_TOKEN_KEYWORD_RESCUE,
|
296
|
-
|
297
310
|
/** rescue in the modifier form */
|
298
311
|
PM_TOKEN_KEYWORD_RESCUE_MODIFIER,
|
299
312
|
|
@@ -309,9 +322,6 @@ typedef enum pm_token_type {
|
|
309
322
|
/** super */
|
310
323
|
PM_TOKEN_KEYWORD_SUPER,
|
311
324
|
|
312
|
-
/** then */
|
313
|
-
PM_TOKEN_KEYWORD_THEN,
|
314
|
-
|
315
325
|
/** true */
|
316
326
|
PM_TOKEN_KEYWORD_TRUE,
|
317
327
|
|
@@ -330,9 +340,6 @@ typedef enum pm_token_type {
|
|
330
340
|
/** until in the modifier form */
|
331
341
|
PM_TOKEN_KEYWORD_UNTIL_MODIFIER,
|
332
342
|
|
333
|
-
/** when */
|
334
|
-
PM_TOKEN_KEYWORD_WHEN,
|
335
|
-
|
336
343
|
/** while */
|
337
344
|
PM_TOKEN_KEYWORD_WHILE,
|
338
345
|
|
@@ -387,9 +394,6 @@ typedef enum pm_token_type {
|
|
387
394
|
/** -> */
|
388
395
|
PM_TOKEN_MINUS_GREATER,
|
389
396
|
|
390
|
-
/** a newline character outside of other tokens */
|
391
|
-
PM_TOKEN_NEWLINE,
|
392
|
-
|
393
397
|
/** a numbered reference to a capture group in the previous regular expression match */
|
394
398
|
PM_TOKEN_NUMBERED_REFERENCE,
|
395
399
|
|
@@ -399,9 +403,6 @@ typedef enum pm_token_type {
|
|
399
403
|
/** ( for a parentheses node */
|
400
404
|
PM_TOKEN_PARENTHESIS_LEFT_PARENTHESES,
|
401
405
|
|
402
|
-
/** ) */
|
403
|
-
PM_TOKEN_PARENTHESIS_RIGHT,
|
404
|
-
|
405
406
|
/** % */
|
406
407
|
PM_TOKEN_PERCENT,
|
407
408
|
|
@@ -450,9 +451,6 @@ typedef enum pm_token_type {
|
|
450
451
|
/** the end of a regular expression */
|
451
452
|
PM_TOKEN_REGEXP_END,
|
452
453
|
|
453
|
-
/** ; */
|
454
|
-
PM_TOKEN_SEMICOLON,
|
455
|
-
|
456
454
|
/** / */
|
457
455
|
PM_TOKEN_SLASH,
|
458
456
|
|
@@ -519,6 +517,12 @@ typedef enum pm_token_type {
|
|
519
517
|
/** marker for the point in the file at which the parser should stop */
|
520
518
|
PM_TOKEN___END__,
|
521
519
|
|
520
|
+
/** a token that was expected but not found */
|
521
|
+
PM_TOKEN_MISSING,
|
522
|
+
|
523
|
+
/** a token that was not present but it is okay */
|
524
|
+
PM_TOKEN_NOT_PROVIDED,
|
525
|
+
|
522
526
|
/** The maximum token value. */
|
523
527
|
PM_TOKEN_MAXIMUM,
|
524
528
|
} pm_token_type_t;
|
@@ -1420,6 +1424,17 @@ typedef struct pm_array_pattern_node {
|
|
1420
1424
|
|
1421
1425
|
/**
|
1422
1426
|
* ArrayPatternNode#constant
|
1427
|
+
*
|
1428
|
+
* Represents the optional constant preceding the Array
|
1429
|
+
*
|
1430
|
+
* foo in Bar[]
|
1431
|
+
* ^^^
|
1432
|
+
*
|
1433
|
+
* foo in Bar[1, 2, 3]
|
1434
|
+
* ^^^
|
1435
|
+
*
|
1436
|
+
* foo in Bar::Baz[1, 2, 3]
|
1437
|
+
* ^^^^^^^^
|
1423
1438
|
*/
|
1424
1439
|
struct pm_node *constant;
|
1425
1440
|
|
@@ -2692,6 +2707,11 @@ typedef struct pm_class_node {
|
|
2692
2707
|
|
2693
2708
|
/**
|
2694
2709
|
* ClassNode#class_keyword_loc
|
2710
|
+
*
|
2711
|
+
* Represents the location of the `class` keyword.
|
2712
|
+
*
|
2713
|
+
* class Foo end
|
2714
|
+
* ^^^^^
|
2695
2715
|
*/
|
2696
2716
|
pm_location_t class_keyword_loc;
|
2697
2717
|
|
@@ -2702,26 +2722,51 @@ typedef struct pm_class_node {
|
|
2702
2722
|
|
2703
2723
|
/**
|
2704
2724
|
* ClassNode#inheritance_operator_loc
|
2725
|
+
*
|
2726
|
+
* Represents the location of the `<` operator.
|
2727
|
+
*
|
2728
|
+
* class Foo < Bar
|
2729
|
+
* ^
|
2705
2730
|
*/
|
2706
2731
|
pm_location_t inheritance_operator_loc;
|
2707
2732
|
|
2708
2733
|
/**
|
2709
2734
|
* ClassNode#superclass
|
2735
|
+
*
|
2736
|
+
* Represents the superclass of the class.
|
2737
|
+
*
|
2738
|
+
* class Foo < Bar
|
2739
|
+
* ^^^
|
2710
2740
|
*/
|
2711
2741
|
struct pm_node *superclass;
|
2712
2742
|
|
2713
2743
|
/**
|
2714
2744
|
* ClassNode#body
|
2745
|
+
*
|
2746
|
+
* Represents the body of the class.
|
2747
|
+
*
|
2748
|
+
* class Foo
|
2749
|
+
* foo
|
2750
|
+
* ^^^
|
2715
2751
|
*/
|
2716
2752
|
struct pm_node *body;
|
2717
2753
|
|
2718
2754
|
/**
|
2719
2755
|
* ClassNode#end_keyword_loc
|
2756
|
+
*
|
2757
|
+
* Represents the location of the `end` keyword.
|
2758
|
+
*
|
2759
|
+
* class Foo end
|
2760
|
+
* ^^^
|
2720
2761
|
*/
|
2721
2762
|
pm_location_t end_keyword_loc;
|
2722
2763
|
|
2723
2764
|
/**
|
2724
2765
|
* ClassNode#name
|
2766
|
+
*
|
2767
|
+
* The name of the class.
|
2768
|
+
*
|
2769
|
+
* class Foo end # name `:Foo`
|
2725
2770
|
*/
|
2726
2771
|
pm_constant_id_t name;
|
2727
2772
|
} pm_class_node_t;
|
@@ -3758,6 +3803,9 @@ typedef struct pm_false_node {
|
|
3758
3803
|
* foo in Foo(*bar, baz, *qux)
|
3759
3804
|
* ^^^^^^^^^^^^^^^^^^^^
|
3760
3805
|
*
|
3806
|
+
* foo => *bar, baz, *qux
|
3807
|
+
* ^^^^^^^^^^^^^^^
|
3808
|
+
*
|
3761
3809
|
* Type: ::PM_FIND_PATTERN_NODE
|
3762
3810
|
*
|
3763
3811
|
* @extends pm_node_t
|
@@ -3769,31 +3817,76 @@ typedef struct pm_find_pattern_node {
|
|
3769
3817
|
|
3770
3818
|
/**
|
3771
3819
|
* FindPatternNode#constant
|
3820
|
+
*
|
3821
|
+
* Represents the optional constant preceding the pattern
|
3822
|
+
*
|
3823
|
+
* foo in Foo(*bar, baz, *qux)
|
3824
|
+
* ^^^
|
3772
3825
|
*/
|
3773
3826
|
struct pm_node *constant;
|
3774
3827
|
|
3775
3828
|
/**
|
3776
3829
|
* FindPatternNode#left
|
3830
|
+
*
|
3831
|
+
* Represents the first wildcard node in the pattern.
|
3832
|
+
*
|
3833
|
+
* foo in *bar, baz, *qux
|
3834
|
+
* ^^^^
|
3835
|
+
*
|
3836
|
+
* foo in Foo(*bar, baz, *qux)
|
3837
|
+
* ^^^^
|
3777
3838
|
*/
|
3778
3839
|
struct pm_splat_node *left;
|
3779
3840
|
|
3780
3841
|
/**
|
3781
3842
|
* FindPatternNode#requireds
|
3843
|
+
*
|
3844
|
+
* Represents the nodes in between the wildcards.
|
3845
|
+
*
|
3846
|
+
* foo in *bar, baz, *qux
|
3847
|
+
* ^^^
|
3848
|
+
*
|
3849
|
+
* foo in Foo(*bar, baz, 1, *qux)
|
3850
|
+
* ^^^^^^
|
3782
3851
|
*/
|
3783
3852
|
struct pm_node_list requireds;
|
3784
3853
|
|
3785
3854
|
/**
|
3786
3855
|
* FindPatternNode#right
|
3856
|
+
*
|
3857
|
+
* Represents the second wildcard node in the pattern.
|
3858
|
+
*
|
3859
|
+
* foo in *bar, baz, *qux
|
3860
|
+
* ^^^^
|
3861
|
+
*
|
3862
|
+
* foo in Foo(*bar, baz, *qux)
|
3863
|
+
* ^^^^
|
3787
3864
|
*/
|
3788
3865
|
struct pm_node *right;
|
3789
3866
|
|
3790
3867
|
/**
|
3791
3868
|
* FindPatternNode#opening_loc
|
3869
|
+
*
|
3870
|
+
* The location of the opening brace.
|
3871
|
+
*
|
3872
|
+
* foo in [*bar, baz, *qux]
|
3873
|
+
* ^
|
3874
|
+
*
|
3875
|
+
* foo in Foo(*bar, baz, *qux)
|
3876
|
+
* ^
|
3792
3877
|
*/
|
3793
3878
|
pm_location_t opening_loc;
|
3794
3879
|
|
3795
3880
|
/**
|
3796
3881
|
* FindPatternNode#closing_loc
|
3882
|
+
*
|
3883
|
+
* The location of the closing brace.
|
3884
|
+
*
|
3885
|
+
* foo in [*bar, baz, *qux]
|
3886
|
+
* ^
|
3887
|
+
*
|
3888
|
+
* foo in Foo(*bar, baz, *qux)
|
3889
|
+
* ^
|
3797
3890
|
*/
|
3798
3891
|
pm_location_t closing_loc;
|
3799
3892
|
} pm_find_pattern_node_t;
|
@@ -4306,6 +4399,12 @@ typedef struct pm_hash_node {
|
|
4306
4399
|
* foo => { a: 1, b: 2, **c }
|
4307
4400
|
* ^^^^^^^^^^^^^^^^^^^
|
4308
4401
|
*
|
4402
|
+
* foo => Bar[a: 1, b: 2]
|
4403
|
+
* ^^^^^^^^^^^^^^^
|
4404
|
+
*
|
4405
|
+
* foo in { a: 1, b: 2 }
|
4406
|
+
* ^^^^^^^^^^^^^^
|
4407
|
+
*
|
4309
4408
|
* Type: ::PM_HASH_PATTERN_NODE
|
4310
4409
|
*
|
4311
4410
|
* @extends pm_node_t
|
@@ -4317,26 +4416,66 @@ typedef struct pm_hash_pattern_node {
|
|
4317
4416
|
|
4318
4417
|
/**
|
4319
4418
|
* HashPatternNode#constant
|
4419
|
+
*
|
4420
|
+
* Represents the optional constant preceding the Hash.
|
4421
|
+
*
|
4422
|
+
* foo => Bar[a: 1, b: 2]
|
4423
|
+
* ^^^
|
4424
|
+
*
|
4425
|
+
* foo => Bar::Baz[a: 1, b: 2]
|
4426
|
+
* ^^^^^^^^
|
4320
4427
|
*/
|
4321
4428
|
struct pm_node *constant;
|
4322
4429
|
|
4323
4430
|
/**
|
4324
4431
|
* HashPatternNode#elements
|
4432
|
+
*
|
4433
|
+
* Represents the explicit named hash keys and values.
|
4434
|
+
*
|
4435
|
+
* foo => { a: 1, b:, ** }
|
4436
|
+
* ^^^^^^^^
|
4325
4437
|
*/
|
4326
4438
|
struct pm_node_list elements;
|
4327
4439
|
|
4328
4440
|
/**
|
4329
4441
|
* HashPatternNode#rest
|
4442
|
+
*
|
4443
|
+
* Represents the rest of the Hash keys and values. This can be named, unnamed, or explicitly forbidden via `**nil`, this last one results in a `NoKeywordsParameterNode`.
|
4444
|
+
*
|
4445
|
+
* foo => { a: 1, b:, **c }
|
4446
|
+
* ^^^
|
4447
|
+
*
|
4448
|
+
* foo => { a: 1, b:, ** }
|
4449
|
+
* ^^
|
4450
|
+
*
|
4451
|
+
* foo => { a: 1, b:, **nil }
|
4452
|
+
* ^^^^^
|
4330
4453
|
*/
|
4331
4454
|
struct pm_node *rest;
|
4332
4455
|
|
4333
4456
|
/**
|
4334
4457
|
* HashPatternNode#opening_loc
|
4458
|
+
*
|
4459
|
+
* The location of the opening brace.
|
4460
|
+
*
|
4461
|
+
* foo => { a: 1 }
|
4462
|
+
* ^
|
4463
|
+
*
|
4464
|
+
* foo => Bar[a: 1]
|
4465
|
+
* ^
|
4335
4466
|
*/
|
4336
4467
|
pm_location_t opening_loc;
|
4337
4468
|
|
4338
4469
|
/**
|
4339
4470
|
* HashPatternNode#closing_loc
|
4471
|
+
*
|
4472
|
+
* The location of the closing brace.
|
4473
|
+
*
|
4474
|
+
* foo => { a: 1 }
|
4475
|
+
* ^
|
4476
|
+
*
|
4477
|
+
* foo => Bar[a: 1]
|
4478
|
+
* ^
|
4340
4479
|
*/
|
4341
4480
|
pm_location_t closing_loc;
|
4342
4481
|
} pm_hash_pattern_node_t;
|
@@ -5618,6 +5757,9 @@ typedef struct pm_local_variable_read_node {
|
|
5618
5757
|
* foo, bar = baz
|
5619
5758
|
* ^^^ ^^^
|
5620
5759
|
*
|
5760
|
+
* foo => baz
|
5761
|
+
* ^^^
|
5762
|
+
*
|
5621
5763
|
* Type: ::PM_LOCAL_VARIABLE_TARGET_NODE
|
5622
5764
|
*
|
5623
5765
|
* @extends pm_node_t
|
@@ -5820,16 +5962,70 @@ typedef struct pm_match_required_node {
|
|
5820
5962
|
|
5821
5963
|
/**
|
5822
5964
|
* MatchRequiredNode#value
|
5965
|
+
*
|
5966
|
+
* Represents the left-hand side of the operator.
|
5967
|
+
*
|
5968
|
+
* foo => bar
|
5969
|
+
* ^^^
|
5823
5970
|
*/
|
5824
5971
|
struct pm_node *value;
|
5825
5972
|
|
5826
5973
|
/**
|
5827
5974
|
* MatchRequiredNode#pattern
|
5975
|
+
*
|
5976
|
+
* Represents the right-hand side of the operator. The type of the node depends on the expression.
|
5977
|
+
*
|
5978
|
+
* Anything that looks like a local variable name (including `_`) will result in a `LocalVariableTargetNode`.
|
5979
|
+
*
|
5980
|
+
* foo => a # This is equivalent to writing `a = foo`
|
5981
|
+
* ^
|
5982
|
+
*
|
5983
|
+
* Using an explicit `Array` or combining expressions with `,` will result in a `ArrayPatternNode`. This can be preceded by a constant.
|
5984
|
+
*
|
5985
|
+
* foo => [a]
|
5986
|
+
* ^^^
|
5987
|
+
*
|
5988
|
+
* foo => a, b
|
5989
|
+
* ^^^^
|
5990
|
+
*
|
5991
|
+
* foo => Bar[a, b]
|
5992
|
+
* ^^^^^^^^^
|
5993
|
+
*
|
5994
|
+
* If the array pattern contains at least two wildcard matches, a `FindPatternNode` is created instead.
|
5995
|
+
*
|
5996
|
+
* foo => *, 1, *a
|
5997
|
+
* ^^^^^
|
5998
|
+
*
|
5999
|
+
* Using an explicit `Hash` or a constant with square brackets and hash keys in the square brackets will result in a `HashPatternNode`.
|
6000
|
+
*
|
6001
|
+
* foo => { a: 1, b: }
|
6002
|
+
*
|
6003
|
+
* foo => Bar[a: 1, b:]
|
6004
|
+
*
|
6005
|
+
* foo => Bar[**]
|
6006
|
+
*
|
6007
|
+
* To use any variable that needs run time evaluation, pinning is required. This results in a `PinnedVariableNode`
|
6008
|
+
*
|
6009
|
+
* foo => ^a
|
6010
|
+
* ^^
|
6011
|
+
*
|
6012
|
+
* Similar, any expression can be used with pinning. This results in a `PinnedExpressionNode`.
|
6013
|
+
*
|
6014
|
+
* foo => ^(a + 1)
|
6015
|
+
*
|
6016
|
+
* Anything else will result in the regular node for that expression, for example a `ConstantReadNode`.
|
6017
|
+
*
|
6018
|
+
* foo => CONST
|
5828
6019
|
*/
|
5829
6020
|
struct pm_node *pattern;
|
5830
6021
|
|
5831
6022
|
/**
|
5832
6023
|
* MatchRequiredNode#operator_loc
|
6024
|
+
*
|
6025
|
+
* The location of the operator.
|
6026
|
+
*
|
6027
|
+
* foo => bar
|
6028
|
+
* ^^
|
5833
6029
|
*/
|
5834
6030
|
pm_location_t operator_loc;
|
5835
6031
|
} pm_match_required_node_t;
|
@@ -6487,21 +6683,41 @@ typedef struct pm_pinned_expression_node {
|
|
6487
6683
|
|
6488
6684
|
/**
|
6489
6685
|
* PinnedExpressionNode#expression
|
6686
|
+
*
|
6687
|
+
* The expression used in the pinned expression
|
6688
|
+
*
|
6689
|
+
* foo in ^(bar)
|
6690
|
+
* ^^^
|
6490
6691
|
*/
|
6491
6692
|
struct pm_node *expression;
|
6492
6693
|
|
6493
6694
|
/**
|
6494
6695
|
* PinnedExpressionNode#operator_loc
|
6696
|
+
*
|
6697
|
+
* The location of the `^` operator
|
6698
|
+
*
|
6699
|
+
* foo in ^(bar)
|
6700
|
+
* ^
|
6495
6701
|
*/
|
6496
6702
|
pm_location_t operator_loc;
|
6497
6703
|
|
6498
6704
|
/**
|
6499
6705
|
* PinnedExpressionNode#lparen_loc
|
6706
|
+
*
|
6707
|
+
* The location of the opening parenthesis.
|
6708
|
+
*
|
6709
|
+
* foo in ^(bar)
|
6710
|
+
* ^
|
6500
6711
|
*/
|
6501
6712
|
pm_location_t lparen_loc;
|
6502
6713
|
|
6503
6714
|
/**
|
6504
6715
|
* PinnedExpressionNode#rparen_loc
|
6716
|
+
*
|
6717
|
+
* The location of the closing parenthesis.
|
6718
|
+
*
|
6719
|
+
* foo in ^(bar)
|
6720
|
+
* ^
|
6505
6721
|
*/
|
6506
6722
|
pm_location_t rparen_loc;
|
6507
6723
|
} pm_pinned_expression_node_t;
|
@@ -6525,11 +6741,21 @@ typedef struct pm_pinned_variable_node {
|
|
6525
6741
|
|
6526
6742
|
/**
|
6527
6743
|
* PinnedVariableNode#variable
|
6744
|
+
*
|
6745
|
+
* The variable used in the pinned expression
|
6746
|
+
*
|
6747
|
+
* foo in ^bar
|
6748
|
+
* ^^^
|
6528
6749
|
*/
|
6529
6750
|
struct pm_node *variable;
|
6530
6751
|
|
6531
6752
|
/**
|
6532
6753
|
* PinnedVariableNode#operator_loc
|
6754
|
+
*
|
6755
|
+
* The location of the `^` operator
|
6756
|
+
*
|
6757
|
+
* foo in ^bar
|
6758
|
+
* ^
|
6533
6759
|
*/
|
6534
6760
|
pm_location_t operator_loc;
|
6535
6761
|
} pm_pinned_variable_node_t;
|
data/include/prism/diagnostic.h
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
/* :markup: markdown */
|
2
|
+
|
1
3
|
/*----------------------------------------------------------------------------*/
|
2
4
|
/* This file is generated by the templates/template.rb script and should not */
|
3
5
|
/* be modified manually. See */
|
@@ -130,6 +132,8 @@ typedef enum {
|
|
130
132
|
PM_ERR_EXPECT_FOR_DELIMITER,
|
131
133
|
PM_ERR_EXPECT_IDENT_REQ_PARAMETER,
|
132
134
|
PM_ERR_EXPECT_IN_DELIMITER,
|
135
|
+
PM_ERR_EXPECT_LPAREN_AFTER_NOT_LPAREN,
|
136
|
+
PM_ERR_EXPECT_LPAREN_AFTER_NOT_OTHER,
|
133
137
|
PM_ERR_EXPECT_LPAREN_REQ_PARAMETER,
|
134
138
|
PM_ERR_EXPECT_MESSAGE,
|
135
139
|
PM_ERR_EXPECT_RBRACKET,
|