lib-ruby-parser 0.0.1.beta2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4871 @@
1
+ # This file is autogenerated by codegen/nodes_rb.rs
2
+
3
+ # Root module
4
+ module LibRubyParser
5
+ # Module with all known Node sub-types
6
+ module Nodes
7
+ # Represents +alias to from+ statement.
8
+ class Alias < Node
9
+ # Target of the +alias+.
10
+ #
11
+ # +Sym("foo")+ node for +alias :foo :bar+
12
+ #
13
+ # @return [Node]
14
+ attr_reader :to
15
+
16
+ # Source of the +alias+.
17
+ #
18
+ # +Sym("bar")+ node for +alias :foo :bar+
19
+ #
20
+ # @return [Node]
21
+ attr_reader :from
22
+
23
+ # Location of the +alias+ keyword
24
+ #
25
+ # @example
26
+ # alias foo bar
27
+ # ~~~~~
28
+ #
29
+ #
30
+ # @return [Loc]
31
+ attr_reader :keyword_l
32
+
33
+ # Location of the full expression
34
+ #
35
+ # @example
36
+ # alias foo bar
37
+ # ~~~~~~~~~~~~~
38
+ #
39
+ #
40
+ # @return [Loc]
41
+ attr_reader :expression_l
42
+
43
+ end
44
+
45
+ # Represents +foo && bar+ (or +foo and bar+) statement.
46
+ class And < Node
47
+ # Left hand statament of the +&&+ operation.
48
+ #
49
+ # +Lvar("foo")+ node for +foo && bar+
50
+ #
51
+ # @return [Node]
52
+ attr_reader :lhs
53
+
54
+ # Right hand statement of the +&&+ operation.
55
+ #
56
+ # +Lvar("bar")+ node for +foo && bar+
57
+ #
58
+ # @return [Node]
59
+ attr_reader :rhs
60
+
61
+ # Location of the +&&+ (or +and+) operator
62
+ #
63
+ # @example
64
+ # a && b
65
+ # ~~
66
+ #
67
+ #
68
+ # @return [Loc]
69
+ attr_reader :operator_l
70
+
71
+ # Location of the full expression
72
+ #
73
+ # @example
74
+ # a && b
75
+ # ~~~~~~
76
+ #
77
+ #
78
+ # @return [Loc]
79
+ attr_reader :expression_l
80
+
81
+ end
82
+
83
+ # Represents +a &&= 1+ statement.
84
+ class AndAsgn < Node
85
+ # Receiver of the +&&=+ operation.
86
+ #
87
+ # +Lvasgn("a")+ node for +a &&= 1+
88
+ #
89
+ # @return [Node]
90
+ attr_reader :recv
91
+
92
+ # Right hand statement of assignment
93
+ #
94
+ # +Int("1")+ node for +a &&= 1+
95
+ #
96
+ # @return [Node]
97
+ attr_reader :value
98
+
99
+ # Location of the +&&=+ operator
100
+ #
101
+ # @example
102
+ # a &&= 1
103
+ # ~~~
104
+ #
105
+ #
106
+ # @return [Loc]
107
+ attr_reader :operator_l
108
+
109
+ # Location of the full expression
110
+ #
111
+ # @example
112
+ # a &&= 1
113
+ # ~~~~~~~
114
+ #
115
+ #
116
+ # @return [Loc]
117
+ attr_reader :expression_l
118
+
119
+ end
120
+
121
+ # Represents a positional required block/method argument.
122
+ #
123
+ # +a+ in +def m(a); end+ or +proc { |a| }+
124
+ class Arg < Node
125
+ # Name of the argument
126
+ #
127
+ # @return [String]
128
+ attr_reader :name
129
+
130
+ # Location of the full expression
131
+ #
132
+ # @example
133
+ # def m(argument); end
134
+ # ~~~~~~~~
135
+ #
136
+ #
137
+ # @return [Loc]
138
+ attr_reader :expression_l
139
+
140
+ end
141
+
142
+ # Represents an arguments list
143
+ #
144
+ # +Args(vec![Arg("a"), Optarg("b", Int("1"))])+ in +def m(a, b = 1); end+
145
+ class Args < Node
146
+ # List of arguments
147
+ #
148
+ # @return [::Array<Node>]
149
+ attr_reader :args
150
+
151
+ # Location of the full expression
152
+ #
153
+ # @example
154
+ # def m(a, b = 1, c:, &blk); end
155
+ # ~~~~~~~~~~~~~~~~~~~~
156
+ #
157
+ #
158
+ # @return [Loc]
159
+ attr_reader :expression_l
160
+
161
+ # Location of the open parenthesis
162
+ #
163
+ # @example
164
+ # def m(a, b = 1, c:, &blk); end
165
+ # ~
166
+ #
167
+ # +None+ for code like +def m; end+ or +def m arg; end+
168
+ #
169
+ # @return [Loc, nil]
170
+ attr_reader :begin_l
171
+
172
+ # Location of the closing parenthesis
173
+ #
174
+ # @example
175
+ # def m(a, b = 1, c:, &blk); end
176
+ # ~
177
+ #
178
+ # +None+ for code like +def m; end+ or +def m arg; end+
179
+ #
180
+ # @return [Loc, nil]
181
+ attr_reader :end_l
182
+
183
+ end
184
+
185
+ # Represents an array literal
186
+ class Array < Node
187
+ # A list of elements
188
+ #
189
+ # @return [::Array<Node>]
190
+ attr_reader :elements
191
+
192
+ # Location of the open bracket
193
+ #
194
+ # @example
195
+ # [1, 2, 3]
196
+ # ~
197
+ #
198
+ #
199
+ # @return [Loc, nil]
200
+ attr_reader :begin_l
201
+
202
+ # Location of the closing bracket
203
+ #
204
+ # @example
205
+ # [1, 2, 3]
206
+ # ~
207
+ #
208
+ #
209
+ # @return [Loc, nil]
210
+ attr_reader :end_l
211
+
212
+ # Location of the full expression
213
+ #
214
+ # @example
215
+ # [1, 2, 3]
216
+ # ~~~~~~~~~
217
+ #
218
+ #
219
+ # @return [Loc]
220
+ attr_reader :expression_l
221
+
222
+ end
223
+
224
+ # Represents an array pattern used in pattern matching
225
+ class ArrayPattern < Node
226
+ # A list of elements
227
+ #
228
+ # @return [::Array<Node>]
229
+ attr_reader :elements
230
+
231
+ # Location of the open bracket
232
+ #
233
+ # @example
234
+ # [1, ^a, 3 => foo]
235
+ # ~
236
+ #
237
+ # +None+ for pattern like +1, 2+ without brackets
238
+ #
239
+ # @return [Loc, nil]
240
+ attr_reader :begin_l
241
+
242
+ # Location of the closing bracket
243
+ #
244
+ # @example
245
+ # [1, ^a, 3 => foo]
246
+ # ~
247
+ #
248
+ # +None+ for pattern like +1, 2+ without brackets
249
+ #
250
+ # @return [Loc, nil]
251
+ attr_reader :end_l
252
+
253
+ # Location of the full expression
254
+ #
255
+ # @example
256
+ # [1, ^a, 3 => foo]
257
+ # ~~~~~~~~~~~~~~~~~
258
+ #
259
+ #
260
+ # @return [Loc]
261
+ attr_reader :expression_l
262
+
263
+ end
264
+
265
+ # Represents an array pattern *with trailing comma* used in pattern matching
266
+ #
267
+ # It's slightly different from +ArrayPattern+, trailing comma at the end works as +, *+
268
+ class ArrayPatternWithTail < Node
269
+ # A list of elements
270
+ #
271
+ # @return [::Array<Node>]
272
+ attr_reader :elements
273
+
274
+ # Location of the open bracket
275
+ #
276
+ # @example
277
+ # [1, ^a, 3 => foo,]
278
+ # ~
279
+ #
280
+ # +None+ for pattern like +1, 2,+ without brackets
281
+ #
282
+ # @return [Loc, nil]
283
+ attr_reader :begin_l
284
+
285
+ # Location of the closing bracket
286
+ #
287
+ # @example
288
+ # [1, ^a, 3 => foo,]
289
+ # ~
290
+ #
291
+ # +None+ for pattern like +1, 2,+ without brackets
292
+ #
293
+ # @return [Loc, nil]
294
+ attr_reader :end_l
295
+
296
+ # Location of the full expression
297
+ #
298
+ # @example
299
+ # [1, ^a, 3 => foo,]
300
+ # ~~~~~~~~~~~~~~~~~~
301
+ #
302
+ #
303
+ # @return [Loc]
304
+ attr_reader :expression_l
305
+
306
+ end
307
+
308
+ # Represents special global variables:
309
+ # 1. +&` +
310
+ # 2. +$&+
311
+ # 3. +$'+
312
+ # 4. +$++
313
+ class BackRef < Node
314
+ # Name of the variable (+"$+"+ for +$++)
315
+ #
316
+ # @return [String]
317
+ attr_reader :name
318
+
319
+ # Location of the full expression
320
+ #
321
+ # @example
322
+ # $+
323
+ # ~~
324
+ #
325
+ #
326
+ # @return [Loc]
327
+ attr_reader :expression_l
328
+
329
+ end
330
+
331
+ # Represents compound statement (i.e. a multi-statement)
332
+ #
333
+ # Basically all blocks of code are wrapped into +Begin+ node (e.g. method/block body, rescue/ensure handler etc)
334
+ class Begin < Node
335
+ # A list of statements
336
+ #
337
+ # @return [::Array<Node>]
338
+ attr_reader :statements
339
+
340
+ # Begin of the block
341
+ #
342
+ # @example
343
+ # (1; 2)
344
+ # ~
345
+ #
346
+ # +None+ if the block of code is "implicit", like
347
+ #
348
+ # @example
349
+ # if true; 1; 2; end
350
+ #
351
+ #
352
+ # @return [Loc, nil]
353
+ attr_reader :begin_l
354
+
355
+ # End of the block
356
+ #
357
+ # @example
358
+ # (1; 2)
359
+ # ~
360
+ #
361
+ # +None+ if the block of code is "implicit", like
362
+ #
363
+ # @example
364
+ # if true; 1; 2; end
365
+ #
366
+ #
367
+ # @return [Loc, nil]
368
+ attr_reader :end_l
369
+
370
+ # Location of the full expression
371
+ #
372
+ # @example
373
+ # (1; 2)
374
+ # ~~~~~~
375
+ #
376
+ #
377
+ # @return [Loc]
378
+ attr_reader :expression_l
379
+
380
+ end
381
+
382
+ # Represents a Ruby block that is passed to a method (+proc { |foo| bar }+)
383
+ class Block < Node
384
+ # Method call that takes a block
385
+ #
386
+ # +Send("foo")+ in +foo {}+
387
+ #
388
+ # @return [Node]
389
+ attr_reader :call
390
+
391
+ # A list of argument that block takes
392
+ #
393
+ # +vec![ Arg("a"), Optarg("b", Int("1")) ]+ for +proc { |a, b = 1| }+
394
+ #
395
+ # +None+ if the block takes no arguments
396
+ #
397
+ # @return [Node, nil]
398
+ attr_reader :args
399
+
400
+ # Block body, +None+ if block has no body.
401
+ #
402
+ # @return [Node, nil]
403
+ attr_reader :body
404
+
405
+ # Location of the open brace
406
+ #
407
+ # @example
408
+ # proc { }
409
+ # ~
410
+ #
411
+ #
412
+ # @return [Loc]
413
+ attr_reader :begin_l
414
+
415
+ # Location of the closing brace
416
+ #
417
+ # @example
418
+ # proc { }
419
+ # ~
420
+ #
421
+ #
422
+ # @return [Loc]
423
+ attr_reader :end_l
424
+
425
+ # Location of the full expression
426
+ #
427
+ # @example
428
+ # proc { }
429
+ # ~~~~~~~~
430
+ #
431
+ #
432
+ # @return [Loc]
433
+ attr_reader :expression_l
434
+
435
+ end
436
+
437
+ # Represents a +&blk+ argument in the method definition (but not in the method call, see +BlockPass+)
438
+ class Blockarg < Node
439
+ # Name of the argument, +String("foo")+ for +def m(&foo)+
440
+ #
441
+ # @return [String]
442
+ attr_reader :name
443
+
444
+ # Location of the +&+ operator
445
+ #
446
+ # @example
447
+ # def m(&foo); end
448
+ # ~
449
+ #
450
+ #
451
+ # @return [Loc]
452
+ attr_reader :operator_l
453
+
454
+ # Location of the name
455
+ #
456
+ # @example
457
+ # def m(&foo); end
458
+ # ~~~
459
+ #
460
+ #
461
+ # @return [Loc]
462
+ attr_reader :name_l
463
+
464
+ # Location of the full expression
465
+ #
466
+ # @example
467
+ # def m(&foo); end
468
+ # ~~~~
469
+ #
470
+ #
471
+ # @return [Loc]
472
+ attr_reader :expression_l
473
+
474
+ end
475
+
476
+ # Represents a +&blk+ argument of the method call (but not of the method definition, see +BlockArg+)
477
+ class BlockPass < Node
478
+ # Value that is converted to a block
479
+ #
480
+ # +Int("1")+ in +foo(&1)+ (yes, it's possible)
481
+ #
482
+ # @return [Node]
483
+ attr_reader :value
484
+
485
+ # Location of the +&+ operator
486
+ #
487
+ # @example
488
+ # foo(&blk)
489
+ # ~
490
+ #
491
+ #
492
+ # @return [Loc]
493
+ attr_reader :operator_l
494
+
495
+ # Location of the full expression
496
+ #
497
+ # @example
498
+ # foo(&bar)
499
+ # ~~~~
500
+ #
501
+ #
502
+ # @return [Loc]
503
+ attr_reader :expression_l
504
+
505
+ end
506
+
507
+ # Represents a +break+ keyword (with optional argument)
508
+ class Break < Node
509
+ # A list of arguments
510
+ #
511
+ # @return [::Array<Node>]
512
+ attr_reader :args
513
+
514
+ # Location of the +break+ keyword
515
+ #
516
+ # @example
517
+ # break :foo
518
+ # ~~~~~
519
+ #
520
+ #
521
+ # @return [Loc]
522
+ attr_reader :keyword_l
523
+
524
+ # Location of the full expression
525
+ #
526
+ # @example
527
+ # break(:foo)
528
+ # ~~~~~~~~~~~
529
+ #
530
+ #
531
+ # @return [Loc]
532
+ attr_reader :expression_l
533
+
534
+ end
535
+
536
+ # Represents a +case+ statement (for pattern matching see +CaseMatch+ node)
537
+ class Case < Node
538
+ # Expression given to +case+, +Int("1")+ for +case 1; end+
539
+ # +None+ for code like
540
+ #
541
+ # @example
542
+ # case
543
+ # when pattern
544
+ # end
545
+ #
546
+ #
547
+ # @return [Node, nil]
548
+ attr_reader :expr
549
+
550
+ # A list of +When+ nodes (each has +patterns+ and +body+)
551
+ #
552
+ # @return [::Array<Node>]
553
+ attr_reader :when_bodies
554
+
555
+ # Body of the +else+ branch, +None+ if there's no +else+ branch
556
+ #
557
+ # @return [Node, nil]
558
+ attr_reader :else_body
559
+
560
+ # Location of the +case+ keyword
561
+ #
562
+ # @example
563
+ # case 1; end
564
+ # ~~~~
565
+ #
566
+ #
567
+ # @return [Loc]
568
+ attr_reader :keyword_l
569
+
570
+ # Location of the +else+ keyword
571
+ #
572
+ # @example
573
+ # case 1; else; end
574
+ # ~~~~
575
+ #
576
+ # +None+ if there's no +else+ branch
577
+ #
578
+ # @return [Loc, nil]
579
+ attr_reader :else_l
580
+
581
+ # Location of the +end+ keyword
582
+ #
583
+ # @example
584
+ # case 1; end
585
+ # ~~~
586
+ #
587
+ #
588
+ # @return [Loc]
589
+ attr_reader :end_l
590
+
591
+ # Location of the full expression
592
+ #
593
+ # @example
594
+ # case 1; end
595
+ # ~~~~~~~~~~~
596
+ #
597
+ #
598
+ # @return [Loc]
599
+ attr_reader :expression_l
600
+
601
+ end
602
+
603
+ # Represents a +case+ statement used for pattern matching (for regular +case+ see +Case+ node)
604
+ class CaseMatch < Node
605
+ # Expression given to +case+, +Int("1")+ for +case 1; in 1; end+
606
+ # +None+ for code like
607
+ #
608
+ # @example
609
+ # case
610
+ # in pattern
611
+ # end
612
+ #
613
+ #
614
+ # @return [Node]
615
+ attr_reader :expr
616
+
617
+ # A list of +InPattern+ nodes (each has +pattern+, +guard+ and +body+)
618
+ #
619
+ # @return [::Array<Node>]
620
+ attr_reader :in_bodies
621
+
622
+ # Body of the +else+ branch, +None+ if there's no +else+ branch
623
+ #
624
+ # @return [Node, nil]
625
+ attr_reader :else_body
626
+
627
+ # Location of the +case+ keyword
628
+ #
629
+ # @example
630
+ # case 1; in 2; end
631
+ # ~~~~
632
+ #
633
+ #
634
+ # @return [Loc]
635
+ attr_reader :keyword_l
636
+
637
+ # Location of the +else+ keyword
638
+ #
639
+ # @example
640
+ # case 1; in 2; else; end
641
+ # ~~~~
642
+ #
643
+ # +None+ if there's no +else+ branch
644
+ #
645
+ # @return [Loc, nil]
646
+ attr_reader :else_l
647
+
648
+ # Location of the +end+ keyword
649
+ #
650
+ # @example
651
+ # case 1; in 2; end
652
+ # ~~~
653
+ #
654
+ #
655
+ # @return [Loc]
656
+ attr_reader :end_l
657
+
658
+ # Location of the full expression
659
+ #
660
+ # @example
661
+ # case 1; in 2; end
662
+ # ~~~~~~~~~~~~~~~~~
663
+ #
664
+ #
665
+ # @return [Loc]
666
+ attr_reader :expression_l
667
+
668
+ end
669
+
670
+ # Represents a constant assignment (i.e. +A = 1+)
671
+ class Casgn < Node
672
+ # Scope where the constant is defined:
673
+ # 1. +Some(Const("A"))+ for +A::B = 1+
674
+ # 2. +None+ if it's defined in the current scope (i.e. +A = 1+)
675
+ # 3. +Some(Cbase)+ if it's defined in the global scope (i.e. +::A = 1+)
676
+ #
677
+ # @return [Node, nil]
678
+ attr_reader :scope
679
+
680
+ # Name of the constant, +String("A")+ for +A = 1+
681
+ #
682
+ # @return [String]
683
+ attr_reader :name
684
+
685
+ # Value that is assigned to a constant, +Int("1")+ for +A = 1+.
686
+ #
687
+ # **Note**: +None+ if constant assignment is a part of the multi-assignment.
688
+ # In such case +value+ belongs to +Masgn+ node of the multi-assignment.
689
+ #
690
+ # @return [Node, nil]
691
+ attr_reader :value
692
+
693
+ # Location of the +::+ operator
694
+ #
695
+ # @example
696
+ # A::B = 1
697
+ # ~~
698
+ #
699
+ # ::A = 1
700
+ # ~~
701
+ #
702
+ # +None+ if the constant is defined in the current scope
703
+ #
704
+ # @return [Loc, nil]
705
+ attr_reader :double_colon_l
706
+
707
+ # Location of the constant name
708
+ #
709
+ # @example
710
+ # A::CONST = 1
711
+ # ~~~~~
712
+ #
713
+ #
714
+ # @return [Loc]
715
+ attr_reader :name_l
716
+
717
+ # Location of the +=+ operator
718
+ #
719
+ # @example
720
+ # A = 1
721
+ # ~
722
+ #
723
+ # +None+ if constant assignment is a part of the multi-assignment.
724
+ # In such case +=+ belongs to a +Masgn+ node
725
+ #
726
+ # @return [Loc, nil]
727
+ attr_reader :operator_l
728
+
729
+ # Location of the full expression
730
+ #
731
+ # @example
732
+ # A = 1
733
+ # ~~~~~
734
+ #
735
+ #
736
+ # @return [Loc]
737
+ attr_reader :expression_l
738
+
739
+ end
740
+
741
+ # Represents leading +::+ part of the constant access/assignment that is used to get/set on a global namespace.
742
+ class Cbase < Node
743
+ # Location of the full expression
744
+ #
745
+ # @example
746
+ # ::A
747
+ # ~~
748
+ #
749
+ #
750
+ # @return [Loc]
751
+ attr_reader :expression_l
752
+
753
+ end
754
+
755
+ # Represents a class definition (using a +class+ keyword, +Class.new+ is just a method call)
756
+ class Class < Node
757
+ # Name of the class, +String("Foo")+ for +class Foo; end+
758
+ #
759
+ # @return [Node]
760
+ attr_reader :name
761
+
762
+ # Superclass. Can be an expression in cases like +class A < (obj.foo + 1); end+
763
+ #
764
+ # +None+ if no explicit superclass given (i.e. +class Foo; end+)
765
+ #
766
+ # @return [Node, nil]
767
+ attr_reader :superclass
768
+
769
+ # Body of the method, +None+ if there's no body.
770
+ #
771
+ # @return [Node, nil]
772
+ attr_reader :body
773
+
774
+ # Location of the +class+ keyword.
775
+ #
776
+ # @example
777
+ # class Foo; end
778
+ # ~~~~~
779
+ #
780
+ #
781
+ # @return [Loc]
782
+ attr_reader :keyword_l
783
+
784
+ # Location of the +<+ operator
785
+ #
786
+ # @example
787
+ # class A < B; end
788
+ # ~
789
+ #
790
+ # +None+ if there's no explicit superclass given.
791
+ #
792
+ # @return [Loc, nil]
793
+ attr_reader :operator_l
794
+
795
+ # Location of the +end+ keyword.
796
+ #
797
+ # @example
798
+ # class Foo; end
799
+ # ~~~
800
+ #
801
+ #
802
+ # @return [Loc]
803
+ attr_reader :end_l
804
+
805
+ # Location of the full expression
806
+ #
807
+ # @example
808
+ # class Foo; end
809
+ # ~~~~~~~~~~~~~~
810
+ #
811
+ #
812
+ # @return [Loc]
813
+ attr_reader :expression_l
814
+
815
+ end
816
+
817
+ # Represents a +Complex+ literal (that returns an +Complex+ number)
818
+ class Complex < Node
819
+ # Value of the complex literal, returned as a +String+, +String("1i")+ for +1i+
820
+ #
821
+ # @return [String]
822
+ attr_reader :value
823
+
824
+ # Location of the +-+ (but not +++) operator. +++ is a part of the literal:
825
+ # 1. ++1i+ is +String("+1i")+ with +operator = None+
826
+ # 2. +-1i+ is +String("1i")+ with +operator = String("-")+
827
+ #
828
+ # @example
829
+ # -1i
830
+ # ~
831
+ #
832
+ #
833
+ # @return [Loc, nil]
834
+ attr_reader :operator_l
835
+
836
+ # Location of the full expression
837
+ #
838
+ # @example
839
+ # -1i
840
+ # ~~~
841
+ #
842
+ #
843
+ # @return [Loc]
844
+ attr_reader :expression_l
845
+
846
+ end
847
+
848
+ # Represents constant access (i.e. +Foo::Bar+)
849
+ class Const < Node
850
+ # Scope where the constant is taken from:
851
+ # 1. +Some(Const("A"))+ for +A::B+
852
+ # 2. +None+ if it's taken from the current scope (i.e. +A+)
853
+ # 3. +Some(Cbase)+ if it's taken from the global scope (i.e. +::A+)
854
+ #
855
+ # @return [Node, nil]
856
+ attr_reader :scope
857
+
858
+ # Name of the constant, +String("Foo")+ for +Foo+
859
+ #
860
+ # @return [String]
861
+ attr_reader :name
862
+
863
+ # Location of the +::+ operator. +None+ if constant is taken from the current scope.
864
+ #
865
+ # @example
866
+ # A::B
867
+ # ~~
868
+ #
869
+ #
870
+ # @return [Loc, nil]
871
+ attr_reader :double_colon_l
872
+
873
+ # Location of the constant name
874
+ #
875
+ # @example
876
+ # Foo::Bar
877
+ # ~~~
878
+ #
879
+ #
880
+ # @return [Loc]
881
+ attr_reader :name_l
882
+
883
+ # Location of the full expression
884
+ #
885
+ # @example
886
+ # Foo::Bar
887
+ # ~~~~~~~~
888
+ #
889
+ #
890
+ # @return [Loc]
891
+ attr_reader :expression_l
892
+
893
+ end
894
+
895
+ # Const pattern used in pattern matching (e.g. +in A(1, 2)+)
896
+ class ConstPattern < Node
897
+ # Constant that is used, +Const("Foo")+ for +in For(42)+
898
+ #
899
+ # @return [Node]
900
+ attr_reader :const
901
+
902
+ # Inner part of the constant pattern
903
+ #
904
+ # +ArrayPattern(vec![ Int("1") ])+ for +Foo(1)+
905
+ #
906
+ # @return [Node]
907
+ attr_reader :pattern
908
+
909
+ # Location of the open parenthesis
910
+ #
911
+ # @example
912
+ # case 1; in Foo(42); end
913
+ # ~
914
+ #
915
+ #
916
+ # @return [Loc]
917
+ attr_reader :begin_l
918
+
919
+ # Location of the closing parenthesis
920
+ #
921
+ # @example
922
+ # case 1; in Foo(42); end
923
+ # ~
924
+ #
925
+ #
926
+ # @return [Loc]
927
+ attr_reader :end_l
928
+
929
+ # Location of the full expression
930
+ #
931
+ # @example
932
+ # case 1; in Foo(42); end
933
+ # ~~~~~~~
934
+ #
935
+ #
936
+ # @return [Loc]
937
+ attr_reader :expression_l
938
+
939
+ end
940
+
941
+ # Represents conditional method call using +&.+ operator
942
+ class CSend < Node
943
+ # Receiver of the method call, +Int("1")+ for +1&.foo+
944
+ #
945
+ # @return [Node]
946
+ attr_reader :recv
947
+
948
+ # Name of the method, +String("foo")+ for +1&.foo+
949
+ #
950
+ # @return [String]
951
+ attr_reader :method_name
952
+
953
+ # List of arguments
954
+ #
955
+ # @example
956
+ # foo&.bar(42)
957
+ # # and also setters like
958
+ # foo&.bar = 42
959
+ #
960
+ #
961
+ # @return [::Array<Node>]
962
+ attr_reader :args
963
+
964
+ # Location of the +&.+ operator
965
+ #
966
+ # @example
967
+ # foo&.bar
968
+ # ~~
969
+ #
970
+ #
971
+ # @return [Loc]
972
+ attr_reader :dot_l
973
+
974
+ # Location of the method name
975
+ #
976
+ # @example
977
+ # foo&.bar(42)
978
+ # ~~~
979
+ #
980
+ # +None+ in a very special case when method call is implicit (i.e. +foo&.()+)
981
+ #
982
+ # @return [Loc, nil]
983
+ attr_reader :selector_l
984
+
985
+ # Location of the open parenthesis
986
+ #
987
+ # @example
988
+ # foo&.bar(42)
989
+ # ~
990
+ #
991
+ # +None+ if there are no parentheses
992
+ #
993
+ # @return [Loc, nil]
994
+ attr_reader :begin_l
995
+
996
+ # Location of the closing parenthesis
997
+ #
998
+ # @example
999
+ # foo&.bar(42)
1000
+ # ~
1001
+ #
1002
+ # +None+ if there are no parentheses
1003
+ #
1004
+ # @return [Loc, nil]
1005
+ attr_reader :end_l
1006
+
1007
+ # Location of the operator if +CSend+ is a part of assignment like
1008
+ #
1009
+ # @example
1010
+ # foo&.bar = 1
1011
+ # ~
1012
+ #
1013
+ # +None+ for a regular call.
1014
+ #
1015
+ # @return [Loc, nil]
1016
+ attr_reader :operator_l
1017
+
1018
+ # Location of the full expression
1019
+ #
1020
+ # @example
1021
+ # foo&.bar(42)
1022
+ # ~~~~~~~~~~~~
1023
+ #
1024
+ #
1025
+ # @return [Loc]
1026
+ attr_reader :expression_l
1027
+
1028
+ end
1029
+
1030
+ # Represents access to class variable (i.e. +@@var+)
1031
+ class Cvar < Node
1032
+ # Name of the class variable, +String("@@foo")+ for +@@foo+
1033
+ #
1034
+ # @return [String]
1035
+ attr_reader :name
1036
+
1037
+ # Location of the full expression
1038
+ #
1039
+ # @example
1040
+ # @@foo
1041
+ # ~~~~~
1042
+ #
1043
+ #
1044
+ # @return [Loc]
1045
+ attr_reader :expression_l
1046
+
1047
+ end
1048
+
1049
+ # Represents class variable assignment (i.e. +@@var = 42+)
1050
+ class Cvasgn < Node
1051
+ # Name of the class variable, +String("@@foo")+ for +@@foo = 1+
1052
+ #
1053
+ # @return [String]
1054
+ attr_reader :name
1055
+
1056
+ # Value that is assigned to class variable, +Int("1")+ for +@@foo = 1+
1057
+ #
1058
+ # @return [Node, nil]
1059
+ attr_reader :value
1060
+
1061
+ # Location of the class variable name
1062
+ #
1063
+ # @example
1064
+ # @@foo = 1
1065
+ # ~~~~~
1066
+ #
1067
+ #
1068
+ # @return [Loc]
1069
+ attr_reader :name_l
1070
+
1071
+ # Location of the +=+ operator
1072
+ #
1073
+ # @example
1074
+ # @@foo = 1
1075
+ # ~
1076
+ #
1077
+ #
1078
+ # @return [Loc, nil]
1079
+ attr_reader :operator_l
1080
+
1081
+ # Location of the full expression
1082
+ #
1083
+ # @example
1084
+ # @@foo = 1
1085
+ # ~~~~~~~~~
1086
+ #
1087
+ #
1088
+ # @return [Loc]
1089
+ attr_reader :expression_l
1090
+
1091
+ end
1092
+
1093
+ # Represents method definition using +def+ keyword (not on a singleton, see +Defs+ node).
1094
+ class Def < Node
1095
+ # Name of the method, +String("foo")+ for +def foo; end+
1096
+ #
1097
+ # @return [String]
1098
+ attr_reader :name
1099
+
1100
+ # Arguments of a method, +None+ if there's no arguments.
1101
+ #
1102
+ # All information about parentheses around arguments is stored in this node.
1103
+ #
1104
+ # @return [Node, nil]
1105
+ attr_reader :args
1106
+
1107
+ # Body of a method, +None+ if there's no body.
1108
+ #
1109
+ # @return [Node, nil]
1110
+ attr_reader :body
1111
+
1112
+ # Location of the +def+ keyword.
1113
+ #
1114
+ # @example
1115
+ # def foo; end
1116
+ # ~~~
1117
+ #
1118
+ #
1119
+ # @return [Loc]
1120
+ attr_reader :keyword_l
1121
+
1122
+ # Location of the method name.
1123
+ #
1124
+ # @example
1125
+ # def foo; end
1126
+ # ~~~
1127
+ #
1128
+ #
1129
+ # @return [Loc]
1130
+ attr_reader :name_l
1131
+
1132
+ # Location of the +end+ keyword.
1133
+ #
1134
+ # @example
1135
+ # def foo; end
1136
+ # ~~~
1137
+ #
1138
+ # +None+ for endless method definition
1139
+ #
1140
+ # @return [Loc, nil]
1141
+ attr_reader :end_l
1142
+
1143
+ # Location of the +=+ operator for endless method definition
1144
+ #
1145
+ # @example
1146
+ # def m() = 1
1147
+ # ~
1148
+ #
1149
+ # +None+ for regular method definition
1150
+ #
1151
+ # @return [Loc, nil]
1152
+ attr_reader :assignment_l
1153
+
1154
+ # Location of the full expression
1155
+ #
1156
+ # @example
1157
+ # def m(a); foo; end
1158
+ # ~~~~~~~~~~~~~~~~~~
1159
+ #
1160
+ #
1161
+ # @return [Loc]
1162
+ attr_reader :expression_l
1163
+
1164
+ end
1165
+
1166
+ # Represents a +defined?(foo)+ expression
1167
+ class Defined < Node
1168
+ # Value given to +defined?+
1169
+ #
1170
+ # @return [Node]
1171
+ attr_reader :value
1172
+
1173
+ # Location of the +defined?+ keyword
1174
+ #
1175
+ # @example
1176
+ # defined?(foo)
1177
+ # ~~~~~~~~
1178
+ #
1179
+ #
1180
+ # @return [Loc]
1181
+ attr_reader :keyword_l
1182
+
1183
+ # Location of the open parenthesis
1184
+ #
1185
+ # @example
1186
+ # defined?(foo)
1187
+ # ~
1188
+ #
1189
+ # +None+ if there are no parentheses
1190
+ #
1191
+ # @return [Loc, nil]
1192
+ attr_reader :begin_l
1193
+
1194
+ # Location of the closing parenthesis
1195
+ #
1196
+ # @example
1197
+ # defined?(foo)
1198
+ # ~
1199
+ #
1200
+ # +None+ if there are no parentheses
1201
+ #
1202
+ # @return [Loc, nil]
1203
+ attr_reader :end_l
1204
+
1205
+ # Location of the full expression
1206
+ #
1207
+ # @example
1208
+ # defined?(foo)
1209
+ # ~~~~~~~~~~~~~
1210
+ #
1211
+ #
1212
+ # @return [Loc]
1213
+ attr_reader :expression_l
1214
+
1215
+ end
1216
+
1217
+ # Represents a singleton method definition (i.e. +def self.foo; end+)
1218
+ class Defs < Node
1219
+ # Definee of a method definition, +Lvar("x")+ for +def x.foo; end+
1220
+ #
1221
+ # @return [Node]
1222
+ attr_reader :definee
1223
+
1224
+ # Name of the method, +String("foo")+ for +def x.foo; end+
1225
+ #
1226
+ # @return [String]
1227
+ attr_reader :name
1228
+
1229
+ # Arguments of a method, +None+ if there's no arguments.
1230
+ #
1231
+ # All information about parentheses around arguments is stored in this node.
1232
+ #
1233
+ # @return [Node, nil]
1234
+ attr_reader :args
1235
+
1236
+ # Body of the method, +None+ if there's no body.
1237
+ #
1238
+ # @return [Node, nil]
1239
+ attr_reader :body
1240
+
1241
+ # Location of the +def+ keyword
1242
+ #
1243
+ # @example
1244
+ # def self.foo; end
1245
+ # ~~~
1246
+ #
1247
+ #
1248
+ # @return [Loc]
1249
+ attr_reader :keyword_l
1250
+
1251
+ # Location of the +.+
1252
+ #
1253
+ # @example
1254
+ # def self.foo; end
1255
+ # ~
1256
+ #
1257
+ #
1258
+ # @return [Loc]
1259
+ attr_reader :operator_l
1260
+
1261
+ # Location of the method name
1262
+ #
1263
+ # @example
1264
+ # def self.foo; end
1265
+ # ~~~
1266
+ #
1267
+ #
1268
+ # @return [Loc]
1269
+ attr_reader :name_l
1270
+
1271
+ # Location of the +=+ operator for endless method definition
1272
+ #
1273
+ # @example
1274
+ # def self.foo() = 42
1275
+ # ~
1276
+ #
1277
+ # +None+ for regular method definition
1278
+ #
1279
+ # @return [Loc, nil]
1280
+ attr_reader :assignment_l
1281
+
1282
+ # Location of the +end+ keyword
1283
+ #
1284
+ # @example
1285
+ # def self.foo; end
1286
+ # ~~~
1287
+ #
1288
+ # +None+ for endless method definition
1289
+ #
1290
+ # @return [Loc, nil]
1291
+ attr_reader :end_l
1292
+
1293
+ # Location of the full expression
1294
+ #
1295
+ # @example
1296
+ # def self.foo; end
1297
+ # ~~~~~~~~~~~~~~~~~
1298
+ #
1299
+ #
1300
+ # @return [Loc]
1301
+ attr_reader :expression_l
1302
+
1303
+ end
1304
+
1305
+ # Represents a string with interpolation (i.e. +"#{foo}"+)
1306
+ class Dstr < Node
1307
+ # A list of string parts (static literals and interpolated expressions)
1308
+ #
1309
+ # @return [::Array<Node>]
1310
+ attr_reader :parts
1311
+
1312
+ # Location of the string begin
1313
+ #
1314
+ # @example
1315
+ # "#{foo}"
1316
+ # ~
1317
+ #
1318
+ # %Q{#{foo}}
1319
+ # ~~~
1320
+ #
1321
+ #
1322
+ # @return [Loc, nil]
1323
+ attr_reader :begin_l
1324
+
1325
+ # Location of the string end
1326
+ #
1327
+ # @example
1328
+ # "#{foo}"
1329
+ # ~
1330
+ #
1331
+ # %Q{#{foo}}
1332
+ # ~
1333
+ #
1334
+ #
1335
+ # @return [Loc, nil]
1336
+ attr_reader :end_l
1337
+
1338
+ # Location of the full expression
1339
+ #
1340
+ # @example
1341
+ # "#{foo}"
1342
+ # ~~~~~~~~
1343
+ #
1344
+ # %Q{#{foo}}
1345
+ # ~~~~~~~~~~
1346
+ #
1347
+ #
1348
+ # @return [Loc]
1349
+ attr_reader :expression_l
1350
+
1351
+ end
1352
+
1353
+ # Represents a symbol with interpolation (i.e. +:"#{foo}"+)
1354
+ class Dsym < Node
1355
+ # A list of symbol parts (static literals and interpolated expressions)
1356
+ #
1357
+ # @return [::Array<Node>]
1358
+ attr_reader :parts
1359
+
1360
+ # Location of the symbol begin
1361
+ #
1362
+ # @example
1363
+ # :"#{foo}"
1364
+ # ~~
1365
+ #
1366
+ # +None+ if +Dsym+ is a part of the interpolated symbol array:
1367
+ #
1368
+ # @example
1369
+ # %I[#{bar}]
1370
+ #
1371
+ #
1372
+ # @return [Loc, nil]
1373
+ attr_reader :begin_l
1374
+
1375
+ # Location of the symbol begin
1376
+ #
1377
+ # @example
1378
+ # :"#{foo}"
1379
+ # ~
1380
+ #
1381
+ # +None+ if +Dsym+ is a part of the interpolated symbol array:
1382
+ #
1383
+ # @example
1384
+ # %I[#{bar}]
1385
+ #
1386
+ #
1387
+ # @return [Loc, nil]
1388
+ attr_reader :end_l
1389
+
1390
+ # Location of the full expression
1391
+ #
1392
+ # @example
1393
+ # :"#{foo}"
1394
+ # ~~~~~~~~~
1395
+ #
1396
+ #
1397
+ # @return [Loc]
1398
+ attr_reader :expression_l
1399
+
1400
+ end
1401
+
1402
+ # Represents exclusive flip-flop (i.e. in +if foo...bar; end+)
1403
+ class EFlipFlop < Node
1404
+ # Left part of the flip-flop. +None+ if based on a range without begin (+...bar+)
1405
+ #
1406
+ # @return [Node, nil]
1407
+ attr_reader :left
1408
+
1409
+ # Right part of the flip-flop. +None+ if based on a range without end (+foo...+)
1410
+ #
1411
+ # @return [Node, nil]
1412
+ attr_reader :right
1413
+
1414
+ # Location of the +...+ operator
1415
+ #
1416
+ # @example
1417
+ # if foo...bar; end
1418
+ # ~~~
1419
+ #
1420
+ #
1421
+ # @return [Loc]
1422
+ attr_reader :operator_l
1423
+
1424
+ # Location of the full expression
1425
+ #
1426
+ # @example
1427
+ # if foo...bar; end
1428
+ # ~~~~~~~~~
1429
+ #
1430
+ #
1431
+ # @return [Loc]
1432
+ attr_reader :expression_l
1433
+
1434
+ end
1435
+
1436
+ # Represents a special empty else that is a part of the pattern matching.
1437
+ #
1438
+ # Usually empty else (e.g. part of the +if+ statement) doesn't mean anything,
1439
+ # however in pattern matching it prevents raising a +NoPatternError+.
1440
+ #
1441
+ # Throwing away this +else+ may affect your code.
1442
+ class EmptyElse < Node
1443
+ # Location of the +else+ keyword
1444
+ #
1445
+ # @example
1446
+ # case foo; in 1; else; end
1447
+ # ~~~~
1448
+ #
1449
+ #
1450
+ # @return [Loc]
1451
+ attr_reader :expression_l
1452
+
1453
+ end
1454
+
1455
+ # Represents a special +__ENCODING__+ keyword
1456
+ class Encoding < Node
1457
+ # Location of the +__ENCODING__+ keyword
1458
+ #
1459
+ # @example
1460
+ # __ENCODING__
1461
+ # ~~~~~~~~~~~~
1462
+ #
1463
+ #
1464
+ # @return [Loc]
1465
+ attr_reader :expression_l
1466
+
1467
+ end
1468
+
1469
+ # Represents a block of code with +ensure+ (i.e. +begin; ensure; end+)
1470
+ class Ensure < Node
1471
+ # Block of code that is wrapped into +ensure+
1472
+ # **Note**: that's the body of the +ensure+ block
1473
+ #
1474
+ # +Int("1")+ for +begin; 1; ensure; 2; end+
1475
+ #
1476
+ # @return [Node, nil]
1477
+ attr_reader :body
1478
+
1479
+ # Body of the +ensure+ block
1480
+ #
1481
+ # +Int("2")+ for +begin; 1; ensure; 2; end+
1482
+ #
1483
+ # @return [Node, nil]
1484
+ attr_reader :ensure
1485
+
1486
+ # Location of the +ensure+ keyword
1487
+ #
1488
+ # @example
1489
+ # begin; ensure; end
1490
+ # ~~~~~~
1491
+ #
1492
+ #
1493
+ # @return [Loc]
1494
+ attr_reader :keyword_l
1495
+
1496
+ # Location of the full expression
1497
+ #
1498
+ # @example
1499
+ # begin; 1; rescue; 2; else; 3; ensure; 4; end
1500
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1501
+ #
1502
+ # **Note**: begin/end belong to +KwBegin+ node.
1503
+ #
1504
+ # @return [Loc]
1505
+ attr_reader :expression_l
1506
+
1507
+ end
1508
+
1509
+ # Represents range literal with excluded +end+ (i.e. +1...3+)
1510
+ class Erange < Node
1511
+ # Begin of the range, +None+ if range has no begin (i.e +...42+)
1512
+ #
1513
+ # @return [Node, nil]
1514
+ attr_reader :left
1515
+
1516
+ # End of the range, +None+ if range has no end (i.e +42...+)
1517
+ #
1518
+ # @return [Node, nil]
1519
+ attr_reader :right
1520
+
1521
+ # Location of the +...+ operator
1522
+ #
1523
+ # @example
1524
+ # 1...3
1525
+ # ~~~
1526
+ #
1527
+ #
1528
+ # @return [Loc]
1529
+ attr_reader :operator_l
1530
+
1531
+ # Location of the full expression
1532
+ #
1533
+ # @example
1534
+ # 1...3
1535
+ # ~~~~~
1536
+ #
1537
+ #
1538
+ # @return [Loc]
1539
+ attr_reader :expression_l
1540
+
1541
+ end
1542
+
1543
+ # Represents a +false+ literal
1544
+ class False < Node
1545
+ # Location of the +false+ literal
1546
+ #
1547
+ # @example
1548
+ # false
1549
+ # ~~~~~
1550
+ #
1551
+ #
1552
+ # @return [Loc]
1553
+ attr_reader :expression_l
1554
+
1555
+ end
1556
+
1557
+ # Represents a special +__FILE__+ literal
1558
+ class File < Node
1559
+ # Location of the +__FILE__+ literal
1560
+ #
1561
+ # @example
1562
+ # __FILE__
1563
+ # ~~~~~~~~
1564
+ #
1565
+ #
1566
+ # @return [Loc]
1567
+ attr_reader :expression_l
1568
+
1569
+ end
1570
+
1571
+ # Represents a find pattern using in pattern matching (i.e. +in [*x, 1 => a, *y]+)
1572
+ #
1573
+ # It's different from +ArrayPattern+/+ConstPattern+ because it supports multiple wildcard pattern
1574
+ class FindPattern < Node
1575
+ # Inner part of the find pattern
1576
+ #
1577
+ # @return [::Array<Node>]
1578
+ attr_reader :elements
1579
+
1580
+ # Location of the begin
1581
+ #
1582
+ # @example
1583
+ # case foo; in [*x, 1 => a, *y]; end
1584
+ # ~
1585
+ #
1586
+ # +None+ if there are no brackets/parentheses
1587
+ #
1588
+ # @return [Loc, nil]
1589
+ attr_reader :begin_l
1590
+
1591
+ # Location of the end
1592
+ #
1593
+ # @example
1594
+ # case foo; in [*x, 1 => a, *y]; end
1595
+ # ~
1596
+ #
1597
+ # +None+ if there are no brackets/parentheses
1598
+ #
1599
+ # @return [Loc, nil]
1600
+ attr_reader :end_l
1601
+
1602
+ # Location of the full expression
1603
+ #
1604
+ # @example
1605
+ # case foo; in [*x, 1 => a, *y]; end
1606
+ # ~~~~~~~~~~~~~~~~
1607
+ #
1608
+ #
1609
+ # @return [Loc]
1610
+ attr_reader :expression_l
1611
+
1612
+ end
1613
+
1614
+ # Represents a float literal (i.e. +42.5+)
1615
+ class Float < Node
1616
+ # String value of the literal, +String("42.5")+ for +42.5+
1617
+ #
1618
+ # @return [String]
1619
+ attr_reader :value
1620
+
1621
+ # Location of unary +-+ (but not +++)
1622
+ #
1623
+ # @example
1624
+ # -42.5
1625
+ # ~
1626
+ #
1627
+ #
1628
+ # @return [Loc, nil]
1629
+ attr_reader :operator_l
1630
+
1631
+ # Location of the full expression
1632
+ #
1633
+ # @example
1634
+ # -42.5
1635
+ # ~~~~~
1636
+ #
1637
+ #
1638
+ # @return [Loc]
1639
+ attr_reader :expression_l
1640
+
1641
+ end
1642
+
1643
+ # Represents a +for+ loop
1644
+ class For < Node
1645
+ # Variable that is used in loop, +Lvasgn("a")+ in +for a in b; end+
1646
+ #
1647
+ # @return [Node]
1648
+ attr_reader :iterator
1649
+
1650
+ # Collection that is for iteration. +Lvar("b")+ in +for a in b; end+
1651
+ #
1652
+ # @return [Node]
1653
+ attr_reader :iteratee
1654
+
1655
+ # Body of the loop. +None+ if there's no body
1656
+ #
1657
+ # @return [Node, nil]
1658
+ attr_reader :body
1659
+
1660
+ # Location of the +for+ keyword
1661
+ #
1662
+ # @example
1663
+ # for a in b; end
1664
+ # ~~~
1665
+ #
1666
+ #
1667
+ # @return [Loc]
1668
+ attr_reader :keyword_l
1669
+
1670
+ # Location of the +in+ keyword
1671
+ #
1672
+ # @example
1673
+ # for a in b; end
1674
+ # ~~
1675
+ #
1676
+ #
1677
+ # @return [Loc]
1678
+ attr_reader :operator_l
1679
+
1680
+ # Location of the +do+ keyword
1681
+ #
1682
+ # @example
1683
+ # for a in b do; end
1684
+ # ~~
1685
+ #
1686
+ # **Note**: this +do+ is optional, and so +begin_l+ can be +None+.
1687
+ #
1688
+ # @return [Loc]
1689
+ attr_reader :begin_l
1690
+
1691
+ # Location of the +end+ keyword
1692
+ #
1693
+ # @example
1694
+ # for a in b; end
1695
+ # ~~~
1696
+ #
1697
+ #
1698
+ # @return [Loc]
1699
+ attr_reader :end_l
1700
+
1701
+ # Location of the full expression
1702
+ #
1703
+ # @example
1704
+ # for a in b; end
1705
+ # ~~~~~~~~~~~~~~~
1706
+ #
1707
+ #
1708
+ # @return [Loc]
1709
+ attr_reader :expression_l
1710
+
1711
+ end
1712
+
1713
+ # Represents a special +...+ argument that forwards positional/keyword/block arguments.
1714
+ class ForwardArg < Node
1715
+ # Location of the +...+
1716
+ #
1717
+ # @example
1718
+ # def m(...); end
1719
+ # ~~~
1720
+ #
1721
+ #
1722
+ # @return [Loc]
1723
+ attr_reader :expression_l
1724
+
1725
+ end
1726
+
1727
+ # Represents a +...+ operator that contains forwarded argument (see +ForwardArg+)
1728
+ class ForwardedArgs < Node
1729
+ # Location of the +...+
1730
+ #
1731
+ # @example
1732
+ # def m(...); foo(...); end
1733
+ # ~~~
1734
+ #
1735
+ #
1736
+ # @return [Loc]
1737
+ attr_reader :expression_l
1738
+
1739
+ end
1740
+
1741
+ # Represents access to global variable (i.e. +$foo+)
1742
+ class Gvar < Node
1743
+ # Name of the global variable, +String("$foo")+ for +$foo+
1744
+ #
1745
+ # @return [String]
1746
+ attr_reader :name
1747
+
1748
+ # Location of the full expression
1749
+ #
1750
+ # @example
1751
+ # $foo
1752
+ # ~~~~
1753
+ #
1754
+ #
1755
+ # @return [Loc]
1756
+ attr_reader :expression_l
1757
+
1758
+ end
1759
+
1760
+ # Represents global variable assignment (i.e. +$foo = 42+)
1761
+ class Gvasgn < Node
1762
+ # Name of the global variable, +String("$foo")+ for +$foo+
1763
+ #
1764
+ # @return [String]
1765
+ attr_reader :name
1766
+
1767
+ # Value that is assigned to global variable, +Int("42")+ for +$foo = 42+
1768
+ #
1769
+ # +None+ if global variable assignment is a part of the multi-assignment.
1770
+ # In such case +value+ is a part of the +Masgn+ node.
1771
+ #
1772
+ # @return [Node, nil]
1773
+ attr_reader :value
1774
+
1775
+ # Location of the global variable name
1776
+ #
1777
+ # @example
1778
+ # $foo = 42
1779
+ # ~~~~
1780
+ #
1781
+ #
1782
+ # @return [Loc]
1783
+ attr_reader :name_l
1784
+
1785
+ # Location of the +=+ operator
1786
+ #
1787
+ # @example
1788
+ # $foo = 42
1789
+ # ~
1790
+ #
1791
+ # +None+ if global variable assignment is a part of the multi-assignment.
1792
+ # In such case +=+ operator belongs to the +Masgn+ node.
1793
+ #
1794
+ # @return [Loc, nil]
1795
+ attr_reader :operator_l
1796
+
1797
+ # Location of the full expression
1798
+ #
1799
+ # @example
1800
+ # $foo = 42
1801
+ # ~~~~~~~~~
1802
+ #
1803
+ #
1804
+ # @return [Loc]
1805
+ attr_reader :expression_l
1806
+
1807
+ end
1808
+
1809
+ # Represents a hash literal (i.e. +{ foo: 42 }+)
1810
+ class Hash < Node
1811
+ # A list of key-value pairs
1812
+ #
1813
+ # @return [::Array<Node>]
1814
+ attr_reader :pairs
1815
+
1816
+ # Location of the open parenthesis
1817
+ #
1818
+ # @example
1819
+ # { a: 1 }
1820
+ # ~
1821
+ #
1822
+ # +None+ if hash literal is implicit, e.g. +foo(key: "value")+
1823
+ #
1824
+ # @return [Loc, nil]
1825
+ attr_reader :begin_l
1826
+
1827
+ # Location of the closing parenthesis
1828
+ #
1829
+ # @example
1830
+ # { a: 1 }
1831
+ # ~
1832
+ #
1833
+ # +None+ if hash literal is implicit, e.g. +foo(key: "value")+
1834
+ #
1835
+ # @return [Loc, nil]
1836
+ attr_reader :end_l
1837
+
1838
+ # Location of the full expression
1839
+ #
1840
+ # @example
1841
+ # { a: 1 }
1842
+ # ~~~~~~~~
1843
+ #
1844
+ #
1845
+ # @return [Loc]
1846
+ attr_reader :expression_l
1847
+
1848
+ end
1849
+
1850
+ # Represents a hash pattern used in pattern matching (i.e. +in { a: 1 }+)
1851
+ class HashPattern < Node
1852
+ # A list of inner patterns
1853
+ #
1854
+ # @return [::Array<Node>]
1855
+ attr_reader :elements
1856
+
1857
+ # Location of the open parenthesis
1858
+ #
1859
+ # @example
1860
+ # case foo; in { a: 1 }; end
1861
+ # ~
1862
+ #
1863
+ # +None+ if there are no parentheses
1864
+ #
1865
+ # @return [Loc, nil]
1866
+ attr_reader :begin_l
1867
+
1868
+ # Location of the open parenthesis
1869
+ #
1870
+ # @example
1871
+ # case foo; in { a: 1 }; end
1872
+ # ~
1873
+ #
1874
+ # +None+ if there are no parentheses
1875
+ #
1876
+ # @return [Loc, nil]
1877
+ attr_reader :end_l
1878
+
1879
+ # Location of the full expression
1880
+ #
1881
+ # @example
1882
+ # case foo; in { a: 1 }; end
1883
+ # ~~~~~~~~
1884
+ #
1885
+ #
1886
+ # @return [Loc]
1887
+ attr_reader :expression_l
1888
+
1889
+ end
1890
+
1891
+ # Represents a here-document literal (both with and without interpolation)
1892
+ #
1893
+ # It's similar to +Dstr+ in terms of abstract syntax tree, but has different source maps.
1894
+ class Heredoc < Node
1895
+ # A list of string parts (static literals and interpolated expressions)
1896
+ #
1897
+ # @return [::Array<Node>]
1898
+ attr_reader :parts
1899
+
1900
+ # Location of the here-document body
1901
+ #
1902
+ # @example
1903
+ # <<-HERE\n a\n #{42}\nHERE
1904
+ # ~~~~~~~~~~~~~~~
1905
+ #
1906
+ #
1907
+ # @return [Loc]
1908
+ attr_reader :heredoc_body_l
1909
+
1910
+ # Location of the here-document end
1911
+ #
1912
+ # @example
1913
+ # <<-HERE\n a\n #{42}\nHERE
1914
+ # ~~~~
1915
+ #
1916
+ #
1917
+ # @return [Loc]
1918
+ attr_reader :heredoc_end_l
1919
+
1920
+ # Location of the here-document identifier
1921
+ #
1922
+ # @example
1923
+ # <<-HERE\n a\n #{42}\nHERE
1924
+ # ~~~~~~~
1925
+ #
1926
+ # **Note**: This is the only node (with +XHeredoc+) that has +expression_l+ smaller that all other sub-locations merged.
1927
+ # The reason for that is that it's possible to add more code after here-document ID:
1928
+ #
1929
+ # @example
1930
+ # <<-HERE + "rest"
1931
+ # content
1932
+ # HERE
1933
+ #
1934
+ #
1935
+ # @return [Loc]
1936
+ attr_reader :expression_l
1937
+
1938
+ end
1939
+
1940
+ # Represents an +if+ statement (i.e. +if foo; bar; else; baz; end+)
1941
+ class If < Node
1942
+ # Condition given to the +if+ statement, +Lvar("a")+ for +if a; b; else; c; end+
1943
+ #
1944
+ # @return [Node]
1945
+ attr_reader :cond
1946
+
1947
+ # True-branch of the +if+ statement, +Lvar("b")+ for +if a; b; else; c; end+
1948
+ #
1949
+ # @return [Node, nil]
1950
+ attr_reader :if_true
1951
+
1952
+ # False-branch of the +if+ statement, +Lvar("c")+ for +if a; b; else; c; end+
1953
+ #
1954
+ # @return [Node, nil]
1955
+ attr_reader :if_false
1956
+
1957
+ # Location of the +if+ keyword
1958
+ #
1959
+ # @example
1960
+ # if foo; end
1961
+ # ~~
1962
+ #
1963
+ #
1964
+ # @return [Loc]
1965
+ attr_reader :keyword_l
1966
+
1967
+ # Location of the +then+ keyword
1968
+ #
1969
+ # @example
1970
+ # if foo then; end
1971
+ # ~~~~
1972
+ #
1973
+ # +None+ if +then+ keyword is omitted
1974
+ #
1975
+ # @return [Loc]
1976
+ attr_reader :begin_l
1977
+
1978
+ # Location of the +else+ keyword
1979
+ #
1980
+ # @example
1981
+ # if foo; else; end
1982
+ # ~~~~
1983
+ #
1984
+ # +None+ if there's no +else+ branch
1985
+ #
1986
+ # @return [Loc, nil]
1987
+ attr_reader :else_l
1988
+
1989
+ # Location of the +end+ keyword
1990
+ #
1991
+ # @example
1992
+ # if foo; end
1993
+ # ~~~
1994
+ #
1995
+ #
1996
+ # @return [Loc, nil]
1997
+ attr_reader :end_l
1998
+
1999
+ # Location of the full expression
2000
+ #
2001
+ # @example
2002
+ # if a then; b; else; c end
2003
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~
2004
+ #
2005
+ #
2006
+ # @return [Loc]
2007
+ attr_reader :expression_l
2008
+
2009
+ end
2010
+
2011
+ # Represents an +if+ guard used in pattern matching (i.e. +case foo; in pattern if guard; end+)
2012
+ class IfGuard < Node
2013
+ # Condition of the guard, +Lvar("foo")+ in +in pattern if guard+
2014
+ #
2015
+ # @return [Node]
2016
+ attr_reader :cond
2017
+
2018
+ # Location of the +if+ keyword
2019
+ #
2020
+ # @example
2021
+ # case foo; in pattern if cond; end
2022
+ # ~~
2023
+ #
2024
+ #
2025
+ # @return [Loc]
2026
+ attr_reader :keyword_l
2027
+
2028
+ # Location of the full expression
2029
+ #
2030
+ # @example
2031
+ # case foo; in pattern if cond; end
2032
+ # ~~~~~~~
2033
+ #
2034
+ #
2035
+ # @return [Loc]
2036
+ attr_reader :expression_l
2037
+
2038
+ end
2039
+
2040
+ # Represents inclusive flip-flop (i.e. in +if foo..bar; end+)
2041
+ class IFlipFlop < Node
2042
+ # Left part of the flip-flop. +None+ if based on a range without begin (+..bar+)
2043
+ #
2044
+ # @return [Node, nil]
2045
+ attr_reader :left
2046
+
2047
+ # Right part of the flip-flop. +None+ if based on a range without end (+foo..+)
2048
+ #
2049
+ # @return [Node, nil]
2050
+ attr_reader :right
2051
+
2052
+ # Location of the +..+ operator
2053
+ #
2054
+ # @example
2055
+ # if foo..bar; end
2056
+ # ~~
2057
+ #
2058
+ #
2059
+ # @return [Loc]
2060
+ attr_reader :operator_l
2061
+
2062
+ # Location of the full expression
2063
+ #
2064
+ # @example
2065
+ # if foo..bar; end
2066
+ # ~~~~~~~~
2067
+ #
2068
+ #
2069
+ # @return [Loc]
2070
+ attr_reader :expression_l
2071
+
2072
+ end
2073
+
2074
+ # Represents an +if+/+unless+ modifier (i.e. +stmt if cond+)
2075
+ class IfMod < Node
2076
+ # Condition of the modifier
2077
+ #
2078
+ # @return [Node]
2079
+ attr_reader :cond
2080
+
2081
+ # True-branch of the modifier.
2082
+ #
2083
+ # Always set for +if+ modifier.
2084
+ # Always +None+ for +unless+ modifier.
2085
+ #
2086
+ # @return [Node, nil]
2087
+ attr_reader :if_true
2088
+
2089
+ # False-branch of the modifier.
2090
+ #
2091
+ # Always set for +unless+ modifier.
2092
+ # Always +None+ for +if+ modifier.
2093
+ #
2094
+ # @return [Node, nil]
2095
+ attr_reader :if_false
2096
+
2097
+ # Location of the +if+/+unless+ keyword
2098
+ #
2099
+ # @example
2100
+ # stmt if cond
2101
+ # ~~
2102
+ #
2103
+ # stmt unless cond
2104
+ # ~~~~~~
2105
+ #
2106
+ #
2107
+ # @return [Loc]
2108
+ attr_reader :keyword_l
2109
+
2110
+ # Location of the full expression
2111
+ #
2112
+ # @example
2113
+ # stmt if cond
2114
+ # ~~~~~~~~~~~~
2115
+ #
2116
+ # stmt unless cond
2117
+ # ~~~~~~~~~~~~~~~~
2118
+ #
2119
+ #
2120
+ # @return [Loc]
2121
+ attr_reader :expression_l
2122
+
2123
+ end
2124
+
2125
+ # Represents ternary +if+ statement (i.e. +cond ? if_true : if_false+)
2126
+ class IfTernary < Node
2127
+ # Condition of the +if+ statement
2128
+ #
2129
+ # @return [Node]
2130
+ attr_reader :cond
2131
+
2132
+ # True-branch
2133
+ #
2134
+ # @return [Node]
2135
+ attr_reader :if_true
2136
+
2137
+ # True-branch
2138
+ #
2139
+ # @return [Node]
2140
+ attr_reader :if_false
2141
+
2142
+ # Location of the +?+ operator
2143
+ #
2144
+ # @example
2145
+ # cond ? if_true : if_false
2146
+ # ~
2147
+ #
2148
+ #
2149
+ # @return [Loc]
2150
+ attr_reader :question_l
2151
+
2152
+ # Location of the +:+ operator
2153
+ #
2154
+ # @example
2155
+ # cond ? if_true : if_false
2156
+ # ~
2157
+ #
2158
+ #
2159
+ # @return [Loc]
2160
+ attr_reader :colon_l
2161
+
2162
+ # Location of the full expression
2163
+ #
2164
+ # @example
2165
+ # cond ? if_true : if_false
2166
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~
2167
+ #
2168
+ #
2169
+ # @return [Loc]
2170
+ attr_reader :expression_l
2171
+
2172
+ end
2173
+
2174
+ # Represents indexing operation (i.e. +foo[1,2,3]+)
2175
+ class Index < Node
2176
+ # Receiver of indexing
2177
+ #
2178
+ # @return [Node]
2179
+ attr_reader :recv
2180
+
2181
+ # A list of indexes
2182
+ #
2183
+ # @return [::Array<Node>]
2184
+ attr_reader :indexes
2185
+
2186
+ # Location of open bracket
2187
+ #
2188
+ # @example
2189
+ # foo[1, 2, 3]
2190
+ # ~
2191
+ #
2192
+ #
2193
+ # @return [Loc]
2194
+ attr_reader :begin_l
2195
+
2196
+ # Location of closing bracket
2197
+ #
2198
+ # @example
2199
+ # foo[1, 2, 3]
2200
+ # ~
2201
+ #
2202
+ #
2203
+ # @return [Loc]
2204
+ attr_reader :end_l
2205
+
2206
+ # Location of the full expression
2207
+ #
2208
+ # @example
2209
+ # foo[1, 2, 3]
2210
+ # ~~~~~~~~~~~~
2211
+ #
2212
+ #
2213
+ # @return [Loc]
2214
+ attr_reader :expression_l
2215
+
2216
+ end
2217
+
2218
+ # Represents assignment using indexing operation (i.e. +foo[1, 2, 3] = bar+)
2219
+ class IndexAsgn < Node
2220
+ # Receiver of the indexing
2221
+ #
2222
+ # @return [Node]
2223
+ attr_reader :recv
2224
+
2225
+ # A list of indexes
2226
+ #
2227
+ # @return [::Array<Node>]
2228
+ attr_reader :indexes
2229
+
2230
+ # Value that is assigned
2231
+ #
2232
+ # +None+ if assignment is a part of the multi-assignment.
2233
+ # In such case +value+ belongs to +Masgn+ node.
2234
+ #
2235
+ # @return [Node, nil]
2236
+ attr_reader :value
2237
+
2238
+ # Location of open bracket
2239
+ #
2240
+ # @example
2241
+ # foo[1, 2, 3] = bar
2242
+ # ~
2243
+ #
2244
+ #
2245
+ # @return [Loc]
2246
+ attr_reader :begin_l
2247
+
2248
+ # Location of closing bracket
2249
+ #
2250
+ # @example
2251
+ # foo[1, 2, 3] = bar
2252
+ # ~
2253
+ #
2254
+ #
2255
+ # @return [Loc]
2256
+ attr_reader :end_l
2257
+
2258
+ # Location of the +=+ operator
2259
+ #
2260
+ # @example
2261
+ # foo[1, 2, 3] = bar
2262
+ # ~
2263
+ #
2264
+ # +None+ if assignment is a part of the multi-assignment.
2265
+ # In such case operator +=+ belongs to +Masgn+ node.
2266
+ #
2267
+ # @return [Loc, nil]
2268
+ attr_reader :operator_l
2269
+
2270
+ # Location of the full expression
2271
+ #
2272
+ # @example
2273
+ # foo[1, 2, 3] = bar
2274
+ # ~~~~~~~~~~~~~~~~~~
2275
+ #
2276
+ #
2277
+ # @return [Loc]
2278
+ attr_reader :expression_l
2279
+
2280
+ end
2281
+
2282
+ # Represents an +in pattern+ branch of the pattern matching
2283
+ class InPattern < Node
2284
+ # Value that is used for matching
2285
+ #
2286
+ # @return [Node]
2287
+ attr_reader :pattern
2288
+
2289
+ # Guard that is used for matching
2290
+ #
2291
+ # Optional, so can be +None+
2292
+ #
2293
+ # @return [Node, nil]
2294
+ attr_reader :guard
2295
+
2296
+ # Body of the branch that is invoked if value matches pattern
2297
+ #
2298
+ # @return [Node, nil]
2299
+ attr_reader :body
2300
+
2301
+ # Location of the +in+ keyword
2302
+ #
2303
+ # @example
2304
+ # case value; in pattern; end
2305
+ # ~~
2306
+ #
2307
+ #
2308
+ # @return [Loc]
2309
+ attr_reader :keyword_l
2310
+
2311
+ # Location of the +then+ keyword
2312
+ #
2313
+ # @example
2314
+ # case value; in pattern then; end
2315
+ # ~~~~
2316
+ #
2317
+ #
2318
+ # @return [Loc]
2319
+ attr_reader :begin_l
2320
+
2321
+ # Location of the full expression
2322
+ #
2323
+ # @example
2324
+ # case value; in pattern then; 42; end
2325
+ # ~~~~~~~~~~~~~~~~~~~
2326
+ #
2327
+ #
2328
+ # @return [Loc]
2329
+ attr_reader :expression_l
2330
+
2331
+ end
2332
+
2333
+ # Represents an integer literal (i.e. +42+)
2334
+ class Int < Node
2335
+ # String value of the literal, +String("42")+ for +42+
2336
+ #
2337
+ # @return [String]
2338
+ attr_reader :value
2339
+
2340
+ # Location of unary +-+ (but not +++)
2341
+ #
2342
+ # @example
2343
+ # -42
2344
+ # ~
2345
+ #
2346
+ #
2347
+ # @return [Loc, nil]
2348
+ attr_reader :operator_l
2349
+
2350
+ # Location of the full expression
2351
+ #
2352
+ # @example
2353
+ # -42
2354
+ # ~~~
2355
+ #
2356
+ #
2357
+ # @return [Loc]
2358
+ attr_reader :expression_l
2359
+
2360
+ end
2361
+
2362
+ # Represents inclusive range (i.e. +2..4+)
2363
+ class Irange < Node
2364
+ # Begin of the range, +None+ if range has no +begin+ (i.e. +..4+)
2365
+ #
2366
+ # @return [Node, nil]
2367
+ attr_reader :left
2368
+
2369
+ # End of the range, +None+ if range has no +end+ (i.e. +2..+)
2370
+ #
2371
+ # @return [Node, nil]
2372
+ attr_reader :right
2373
+
2374
+ # Location of the +..+ operator
2375
+ #
2376
+ # @example
2377
+ # 2..4
2378
+ # ~~
2379
+ #
2380
+ #
2381
+ # @return [Loc]
2382
+ attr_reader :operator_l
2383
+
2384
+ # Location of the full expression
2385
+ #
2386
+ # @example
2387
+ # 2..4
2388
+ # ~~~~
2389
+ #
2390
+ #
2391
+ # @return [Loc]
2392
+ attr_reader :expression_l
2393
+
2394
+ end
2395
+
2396
+ # Represents access to instance variable (i.e. +@foo+)
2397
+ class Ivar < Node
2398
+ # Name of the instance variable, +String("@foo")+ in +@foo+
2399
+ #
2400
+ # @return [String]
2401
+ attr_reader :name
2402
+
2403
+ # Location of the full expression
2404
+ #
2405
+ # @example
2406
+ # @foo
2407
+ # ~~~~
2408
+ #
2409
+ #
2410
+ # @return [Loc]
2411
+ attr_reader :expression_l
2412
+
2413
+ end
2414
+
2415
+ # Represents instance variable assignment (i.e +@foo = 42+)
2416
+ class Ivasgn < Node
2417
+ # Name of the instance variable, +String("@foo")+ in +@foo = 42+
2418
+ #
2419
+ # @return [String]
2420
+ attr_reader :name
2421
+
2422
+ # Value that is assigned to instance variable.
2423
+ #
2424
+ # +None+ if instance variable assignment is a part of the multi-assignment.
2425
+ # In such case +value+ is a part of the +Masgn+ node.
2426
+ #
2427
+ # @return [Node, nil]
2428
+ attr_reader :value
2429
+
2430
+ # Location of the instance variable name.
2431
+ #
2432
+ # @example
2433
+ # @foo = 1
2434
+ # ~~~~
2435
+ #
2436
+ #
2437
+ # @return [Loc]
2438
+ attr_reader :name_l
2439
+
2440
+ # Location of the +=+ operator.
2441
+ #
2442
+ # @example
2443
+ # @foo = 1
2444
+ # ~
2445
+ #
2446
+ # +None+ if instance variable assignment is a part of the multi-assignment.
2447
+ # In such case +value+ is a part of the +Masgn+ node.
2448
+ #
2449
+ # @return [Loc, nil]
2450
+ attr_reader :operator_l
2451
+
2452
+ # Location of the full expression
2453
+ #
2454
+ # @example
2455
+ # @foo = 42
2456
+ # ~~~~~~~~~
2457
+ #
2458
+ #
2459
+ # @return [Loc]
2460
+ attr_reader :expression_l
2461
+
2462
+ end
2463
+
2464
+ # Represents required keyword argument (i.e. +foo+ in +def m(foo:); end+)
2465
+ class Kwarg < Node
2466
+ # Name of the keyword argument
2467
+ #
2468
+ # @return [String]
2469
+ attr_reader :name
2470
+
2471
+ # Location of the name
2472
+ #
2473
+ # @example
2474
+ # def foo(bar:); end
2475
+ # ~~~
2476
+ #
2477
+ #
2478
+ # @return [Loc]
2479
+ attr_reader :name_l
2480
+
2481
+ # Location of the full expression
2482
+ #
2483
+ # @example
2484
+ # def foo(bar:); end
2485
+ # ~~~~
2486
+ #
2487
+ #
2488
+ # @return [Loc]
2489
+ attr_reader :expression_l
2490
+
2491
+ end
2492
+
2493
+ # Represents kwargs that are given to a method call, super or yield (i.e. +foo(bar: 1)+)
2494
+ class Kwargs < Node
2495
+ # A list of key-value pairs
2496
+ #
2497
+ # @return [::Array<Node>]
2498
+ attr_reader :pairs
2499
+
2500
+ # Location of the full expression
2501
+ #
2502
+ # @example
2503
+ # foo(bar: 1)
2504
+ # ~~~~~~
2505
+ #
2506
+ #
2507
+ # @return [Loc]
2508
+ attr_reader :expression_l
2509
+
2510
+ end
2511
+
2512
+ # Represents an explicit +begin; end+ block.
2513
+ #
2514
+ # The reason why it's different is that
2515
+ #
2516
+ # @example
2517
+ # begin; foo; end while cond
2518
+ #
2519
+ # is a post-while loop (same with post-until loop)
2520
+ class KwBegin < Node
2521
+ # A list of statements
2522
+ #
2523
+ # @return [::Array<Node>]
2524
+ attr_reader :statements
2525
+
2526
+ # Location of the +begin+ keyword
2527
+ #
2528
+ # @example
2529
+ # begin; foo; end
2530
+ # ~~~~~
2531
+ #
2532
+ #
2533
+ # @return [Loc, nil]
2534
+ attr_reader :begin_l
2535
+
2536
+ # Location of the +end+ keyword
2537
+ #
2538
+ # @example
2539
+ # begin; foo; end
2540
+ # ~~~
2541
+ #
2542
+ #
2543
+ # @return [Loc, nil]
2544
+ attr_reader :end_l
2545
+
2546
+ # Location of the full expression
2547
+ #
2548
+ # @example
2549
+ # begin; foo; bar
2550
+ # ~~~~~~~~~~~~~~~
2551
+ #
2552
+ #
2553
+ # @return [Loc]
2554
+ attr_reader :expression_l
2555
+
2556
+ end
2557
+
2558
+ # Represents an special argument that rejects all keyword arguments (i.e. +def m(**nil); end+)
2559
+ class Kwnilarg < Node
2560
+ # Location of the +nil+
2561
+ #
2562
+ # @example
2563
+ # def m(**nil); end
2564
+ # ~~~
2565
+ #
2566
+ #
2567
+ # @return [Loc]
2568
+ attr_reader :name_l
2569
+
2570
+ # Location of the +nil+
2571
+ #
2572
+ # @example
2573
+ # def m(**nil); end
2574
+ # ~~~~~
2575
+ #
2576
+ #
2577
+ # @return [Loc]
2578
+ attr_reader :expression_l
2579
+
2580
+ end
2581
+
2582
+ # Represents an optional keyword argument (i.e. +foo+ in +def m(foo: 42); end+)
2583
+ class Kwoptarg < Node
2584
+ # Name of the optional keyword argument
2585
+ #
2586
+ # @return [String]
2587
+ attr_reader :name
2588
+
2589
+ # Default value of the optional keyword argument
2590
+ #
2591
+ # @return [Node]
2592
+ attr_reader :default
2593
+
2594
+ # Location of the argument name
2595
+ #
2596
+ # @example
2597
+ # def m(foo: 1); end
2598
+ # ~~~
2599
+ #
2600
+ #
2601
+ # @return [Loc]
2602
+ attr_reader :name_l
2603
+
2604
+ # Location of the argument name
2605
+ #
2606
+ # @example
2607
+ # def m(foo: 1); end
2608
+ # ~~~~~~
2609
+ #
2610
+ #
2611
+ # @return [Loc]
2612
+ attr_reader :expression_l
2613
+
2614
+ end
2615
+
2616
+ # Represents a keyword rest argument (i.e. +foo+ in +def m(**foo); end+)
2617
+ class Kwrestarg < Node
2618
+ # Name of the keyword rest argument, +String("foo")+ in +def m(**foo); end+.
2619
+ #
2620
+ # +None+ if argument has no name (+def m(**); end+)
2621
+ #
2622
+ # @return [String, nil]
2623
+ attr_reader :name
2624
+
2625
+ # Location of the +**+ operator
2626
+ #
2627
+ # @example
2628
+ # def m(**foo); end
2629
+ # ~~
2630
+ #
2631
+ #
2632
+ # @return [Loc]
2633
+ attr_reader :operator_l
2634
+
2635
+ # Location of the argument name
2636
+ #
2637
+ # @example
2638
+ # def m(**foo); end
2639
+ # ~~~
2640
+ #
2641
+ # +None+ if argument has no name (+def m(**); end+)
2642
+ #
2643
+ # @return [Loc, nil]
2644
+ attr_reader :name_l
2645
+
2646
+ # Location of the full expression
2647
+ #
2648
+ # @example
2649
+ # def m(**foo); end
2650
+ # ~~~~~
2651
+ #
2652
+ #
2653
+ # @return [Loc]
2654
+ attr_reader :expression_l
2655
+
2656
+ end
2657
+
2658
+ # Represents a keyword arguments splat (i.e. +**bar+ in a call like +foo(**bar)+)
2659
+ class Kwsplat < Node
2660
+ # Value that is converted into a +Hash+ using +**+
2661
+ #
2662
+ # @return [Node]
2663
+ attr_reader :value
2664
+
2665
+ # Location of the +**+ operator
2666
+ #
2667
+ # @example
2668
+ # foo(**bar)
2669
+ # ~~
2670
+ #
2671
+ #
2672
+ # @return [Loc]
2673
+ attr_reader :operator_l
2674
+
2675
+ # Location of the full expression
2676
+ #
2677
+ # @example
2678
+ # foo(**bar)
2679
+ # ~~~~~
2680
+ #
2681
+ #
2682
+ # @return [Loc]
2683
+ attr_reader :expression_l
2684
+
2685
+ end
2686
+
2687
+ # Represents a lambda call using +->+ (i.e. +-> {}+)
2688
+ #
2689
+ # Note that +Lambda+ is a part of the +Block+, not other way around.
2690
+ class Lambda < Node
2691
+ # Location of the +->+
2692
+ #
2693
+ # @example
2694
+ # -> {}
2695
+ # ~~
2696
+ #
2697
+ #
2698
+ # @return [Loc]
2699
+ attr_reader :expression_l
2700
+
2701
+ end
2702
+
2703
+ # Represents a special +__LINE__+ literal
2704
+ class Line < Node
2705
+ # Location of the +__LINE__+ literal
2706
+ #
2707
+ # @example
2708
+ # __LINE__
2709
+ # ~~~~~~~~
2710
+ #
2711
+ #
2712
+ # @return [Loc]
2713
+ attr_reader :expression_l
2714
+
2715
+ end
2716
+
2717
+ # Represents access to a local variable (i.e. +foo+)
2718
+ #
2719
+ # Parser knows that it's a local variable because:
2720
+ # 1. there was an assignment to this variable **before** accessing it
2721
+ # 2. it's an argument of the current method / block
2722
+ # 3. it's been implicitly declared by +MatchWithLvasgn+ node
2723
+ #
2724
+ # Otherwise it's a method call (see +Send+)
2725
+ class Lvar < Node
2726
+ # Name of the local variable
2727
+ #
2728
+ # @return [String]
2729
+ attr_reader :name
2730
+
2731
+ # Location of the local variable
2732
+ #
2733
+ # @example
2734
+ # foo
2735
+ # ~~~
2736
+ #
2737
+ #
2738
+ # @return [Loc]
2739
+ attr_reader :expression_l
2740
+
2741
+ end
2742
+
2743
+ # Represents local variable assignment (i.e. +foo = 42+)
2744
+ class Lvasgn < Node
2745
+ # Name of the local variable
2746
+ #
2747
+ # @return [String]
2748
+ attr_reader :name
2749
+
2750
+ # Value that is assigned to a local variable
2751
+ #
2752
+ # @return [Node, nil]
2753
+ attr_reader :value
2754
+
2755
+ # Location of the local variable name
2756
+ #
2757
+ # @example
2758
+ # foo = 42
2759
+ # ~~~
2760
+ #
2761
+ #
2762
+ # @return [Loc]
2763
+ attr_reader :name_l
2764
+
2765
+ # Location of the +=+ operator
2766
+ #
2767
+ # @example
2768
+ # foo = 42
2769
+ # ~
2770
+ #
2771
+ # +None+ if local variable assignment is a part of the multi-assignment.
2772
+ # In such case +value+ is a part of the +Masgn+ node.
2773
+ #
2774
+ # @return [Loc, nil]
2775
+ attr_reader :operator_l
2776
+
2777
+ # Location of the full expression
2778
+ #
2779
+ # @example
2780
+ # foo = 42
2781
+ # ~~~~~~~~
2782
+ #
2783
+ #
2784
+ # @return [Loc]
2785
+ attr_reader :expression_l
2786
+
2787
+ end
2788
+
2789
+ # Represents mass-assignment (i.e. +foo, bar = 1, 2+)
2790
+ class Masgn < Node
2791
+ # Left hand statement of the assignment
2792
+ #
2793
+ # @return [Node]
2794
+ attr_reader :lhs
2795
+
2796
+ # Left hand statement of the assignment
2797
+ #
2798
+ # @return [Node]
2799
+ attr_reader :rhs
2800
+
2801
+ # Location of the +=+ operator
2802
+ #
2803
+ # @example
2804
+ # foo, bar = 1, 2
2805
+ # ~
2806
+ #
2807
+ #
2808
+ # @return [Loc]
2809
+ attr_reader :operator_l
2810
+
2811
+ # Location of the full expression
2812
+ #
2813
+ # @example
2814
+ # foo, bar = 1, 2
2815
+ # ~~~~~~~~~~~~~~~
2816
+ #
2817
+ #
2818
+ # @return [Loc]
2819
+ attr_reader :expression_l
2820
+
2821
+ end
2822
+
2823
+ # Represents pattern matching using one of the given patterns (i.e. +foo in 1 | 2+)
2824
+ class MatchAlt < Node
2825
+ # Left pattern
2826
+ #
2827
+ # @return [Node]
2828
+ attr_reader :lhs
2829
+
2830
+ # Right pattern
2831
+ #
2832
+ # @return [Node]
2833
+ attr_reader :rhs
2834
+
2835
+ # Location of the +|+ operator
2836
+ #
2837
+ # @example
2838
+ # foo in 1 | 2
2839
+ # ~
2840
+ #
2841
+ #
2842
+ # @return [Loc]
2843
+ attr_reader :operator_l
2844
+
2845
+ # Location of the full expression
2846
+ #
2847
+ # @example
2848
+ # foo in 1 | 2
2849
+ # ~~~~~
2850
+ #
2851
+ #
2852
+ # @return [Loc]
2853
+ attr_reader :expression_l
2854
+
2855
+ end
2856
+
2857
+ # Represents matching with renaming into specified local variable (i.e. +case 1; in Integer => a; end+)
2858
+ class MatchAs < Node
2859
+ # Pattern that is used for matching
2860
+ #
2861
+ # @return [Node]
2862
+ attr_reader :value
2863
+
2864
+ # Variable that is assigned if matched (see +MatchVar+ node)
2865
+ #
2866
+ # @return [Node]
2867
+ attr_reader :as
2868
+
2869
+ # Location of the +=>+ operator
2870
+ #
2871
+ # @example
2872
+ # case 1; in Integer => a; end
2873
+ # ~~
2874
+ #
2875
+ #
2876
+ # @return [Loc]
2877
+ attr_reader :operator_l
2878
+
2879
+ # Location of the full expression
2880
+ #
2881
+ # @example
2882
+ # case 1; in Integer => a; end
2883
+ # ~~~~~~~~~~~~
2884
+ #
2885
+ #
2886
+ # @return [Loc]
2887
+ attr_reader :expression_l
2888
+
2889
+ end
2890
+
2891
+ # Represents implicit matching using +if /regex/+
2892
+ #
2893
+ # @example
2894
+ # if /.*/
2895
+ # puts 'true'
2896
+ # else
2897
+ # puts 'false'
2898
+ # end
2899
+ #
2900
+ # Prints "false".
2901
+ #
2902
+ # Under the hood this construction matches regex against +$_+, so the following works:
2903
+ #
2904
+ # @example
2905
+ # $_ = 'match_me'
2906
+ # if /match_me/
2907
+ # puts 'true'
2908
+ # else
2909
+ # puts 'false'
2910
+ # end
2911
+ #
2912
+ # this code prints "true".
2913
+ class MatchCurrentLine < Node
2914
+ # Given regex
2915
+ #
2916
+ # @return [Node]
2917
+ attr_reader :re
2918
+
2919
+ # Location of the regex
2920
+ #
2921
+ # @example
2922
+ # if /re/; end
2923
+ # ~~~~
2924
+ #
2925
+ # Technically this location is redundant, but keeping it is the only way to
2926
+ # have the same interface for all nodes.
2927
+ #
2928
+ # @return [Loc]
2929
+ attr_reader :expression_l
2930
+
2931
+ end
2932
+
2933
+ # Represents empty hash pattern that is used in pattern matching (i.e. +in **nil+)
2934
+ class MatchNilPattern < Node
2935
+ # Location of the +**+ operator
2936
+ #
2937
+ # @example
2938
+ # in **nil
2939
+ # ~~
2940
+ #
2941
+ #
2942
+ # @return [Loc]
2943
+ attr_reader :operator_l
2944
+
2945
+ # Location of the name
2946
+ #
2947
+ # @example
2948
+ # in **nil
2949
+ # ~~~
2950
+ #
2951
+ #
2952
+ # @return [Loc]
2953
+ attr_reader :name_l
2954
+
2955
+ # Location of the full expression
2956
+ #
2957
+ # @example
2958
+ # in **nil
2959
+ # ~~~~~
2960
+ #
2961
+ #
2962
+ # @return [Loc]
2963
+ attr_reader :expression_l
2964
+
2965
+ end
2966
+
2967
+ # Represents a one-line pattern matching that can throw an error (i.e. +foo => pattern+)
2968
+ class MatchPattern < Node
2969
+ # Value that is used for matching
2970
+ #
2971
+ # @return [Node]
2972
+ attr_reader :value
2973
+
2974
+ # Pattern that is used for matching
2975
+ #
2976
+ # @return [Node]
2977
+ attr_reader :pattern
2978
+
2979
+ # Location of the +=>+ operator
2980
+ #
2981
+ # @example
2982
+ # foo => pattern
2983
+ # ~~
2984
+ #
2985
+ #
2986
+ # @return [Loc]
2987
+ attr_reader :operator_l
2988
+
2989
+ # Location of the full expression
2990
+ #
2991
+ # @example
2992
+ # foo => pattern
2993
+ # ~~~~~~~~~~~~~~
2994
+ #
2995
+ #
2996
+ # @return [Loc]
2997
+ attr_reader :expression_l
2998
+
2999
+ end
3000
+
3001
+ # Represents a one-line pattern matching that never throws but returns true/false (i.e. +foo in pattern+)
3002
+ class MatchPatternP < Node
3003
+ # Value that is used for matching
3004
+ #
3005
+ # @return [Node]
3006
+ attr_reader :value
3007
+
3008
+ # Pattern that is used for matching
3009
+ #
3010
+ # @return [Node]
3011
+ attr_reader :pattern
3012
+
3013
+ # Location of the +in+ operator
3014
+ #
3015
+ # @example
3016
+ # foo in pattern
3017
+ # ~~
3018
+ #
3019
+ #
3020
+ # @return [Loc]
3021
+ attr_reader :operator_l
3022
+
3023
+ # Location of the full expression
3024
+ #
3025
+ # @example
3026
+ # foo in pattern
3027
+ # ~~~~~~~~~~~~~~
3028
+ #
3029
+ #
3030
+ # @return [Loc]
3031
+ attr_reader :expression_l
3032
+
3033
+ end
3034
+
3035
+ # Represents a wildcard pattern used in pattern matching (i.e. +in *foo+)
3036
+ class MatchRest < Node
3037
+ # Name of the variable name
3038
+ #
3039
+ # +None+ if there's no name (i.e. +in *+)
3040
+ #
3041
+ # @return [Node, nil]
3042
+ attr_reader :name
3043
+
3044
+ # Location of the +*+ operator
3045
+ #
3046
+ # @example
3047
+ # case foo; in *bar; end
3048
+ # ~
3049
+ #
3050
+ #
3051
+ # @return [Loc]
3052
+ attr_reader :operator_l
3053
+
3054
+ # Location of the +*+ operator
3055
+ #
3056
+ # @example
3057
+ # case foo; in *bar; end
3058
+ # ~~~~
3059
+ #
3060
+ #
3061
+ # @return [Loc]
3062
+ attr_reader :expression_l
3063
+
3064
+ end
3065
+
3066
+ # Represents matching with assignment into a local variable (i.e. +pattern => var+)
3067
+ class MatchVar < Node
3068
+ # Name of the variable that is assigned if matching succeeds
3069
+ #
3070
+ # @return [String]
3071
+ attr_reader :name
3072
+
3073
+ # Location of the name
3074
+ #
3075
+ # @example
3076
+ # case foo; in pattern => bar; end
3077
+ # ~~~
3078
+ #
3079
+ # **Note** it can also be produced by a hash pattern
3080
+ #
3081
+ # @example
3082
+ # case foo; in { a: }; end
3083
+ # ~
3084
+ #
3085
+ #
3086
+ # @return [Loc]
3087
+ attr_reader :name_l
3088
+
3089
+ # Location of the full expression
3090
+ #
3091
+ # @example
3092
+ # case foo; in pattern => bar; end
3093
+ # ~~~
3094
+ #
3095
+ # **Note** it can also be produced by a hash pattern
3096
+ #
3097
+ # @example
3098
+ # case foo; in { a: }; end
3099
+ # ~~
3100
+ #
3101
+ #
3102
+ # @return [Loc]
3103
+ attr_reader :expression_l
3104
+
3105
+ end
3106
+
3107
+ # Represents matching a regex that produces local variables (i.e. +/(?<match>bar)/ =~ 'bar'+)
3108
+ #
3109
+ # Each named group in regex declares a local variable.
3110
+ class MatchWithLvasgn < Node
3111
+ # Regex that is used for matching
3112
+ #
3113
+ # @return [Node]
3114
+ attr_reader :re
3115
+
3116
+ # Value that is used for matching
3117
+ #
3118
+ # @return [Node]
3119
+ attr_reader :value
3120
+
3121
+ # Location of the +=~+ operatir
3122
+ #
3123
+ # @example
3124
+ # /(?<match>bar)/ =~ 'bar'
3125
+ # ~~
3126
+ #
3127
+ #
3128
+ # @return [Loc]
3129
+ attr_reader :operator_l
3130
+
3131
+ # Location of the full expression
3132
+ #
3133
+ # @example
3134
+ # /(?<match>bar)/ =~ 'bar'
3135
+ # ~~~~~~~~~~~~~~~~~~~~~~~~
3136
+ #
3137
+ #
3138
+ # @return [Loc]
3139
+ attr_reader :expression_l
3140
+
3141
+ end
3142
+
3143
+ # Represents left hand statement of the mass-assignment (i.e. +foo, bar+ in +foo, bar = 1, 2+)
3144
+ class Mlhs < Node
3145
+ # A list of items that are assigned
3146
+ #
3147
+ # @return [::Array<Node>]
3148
+ attr_reader :items
3149
+
3150
+ # Location of the open parenthesis
3151
+ #
3152
+ # @example
3153
+ # (a, b) = 1, 2
3154
+ # ~
3155
+ #
3156
+ # +None+ if there are no parentheses
3157
+ #
3158
+ # @return [Loc, nil]
3159
+ attr_reader :begin_l
3160
+
3161
+ # Location of the closing parenthesis
3162
+ #
3163
+ # @example
3164
+ # (a, b) = 1, 2
3165
+ # ~
3166
+ #
3167
+ # +None+ if there are no parentheses
3168
+ #
3169
+ # @return [Loc, nil]
3170
+ attr_reader :end_l
3171
+
3172
+ # Location of the full expression
3173
+ #
3174
+ # @example
3175
+ # (a, b) = 1, 2
3176
+ # ~~~~~~
3177
+ #
3178
+ #
3179
+ # @return [Loc]
3180
+ attr_reader :expression_l
3181
+
3182
+ end
3183
+
3184
+ # Represents module declaration using +module+ keyword
3185
+ class Module < Node
3186
+ # Name of the module
3187
+ #
3188
+ # @return [Node]
3189
+ attr_reader :name
3190
+
3191
+ # Body of the module
3192
+ #
3193
+ # +None+ if module has no body
3194
+ #
3195
+ # @return [Node, nil]
3196
+ attr_reader :body
3197
+
3198
+ # Location of the +module+ keyword
3199
+ #
3200
+ # @example
3201
+ # module M; end
3202
+ # ~~~~~~
3203
+ #
3204
+ #
3205
+ # @return [Loc]
3206
+ attr_reader :keyword_l
3207
+
3208
+ # Location of the +end+ keyword
3209
+ #
3210
+ # @example
3211
+ # module M; end
3212
+ # ~~~
3213
+ #
3214
+ #
3215
+ # @return [Loc]
3216
+ attr_reader :end_l
3217
+
3218
+ # Location of the full expression
3219
+ #
3220
+ # @example
3221
+ # module M; end
3222
+ # ~~~~~~~~~~~~~
3223
+ #
3224
+ #
3225
+ # @return [Loc]
3226
+ attr_reader :expression_l
3227
+
3228
+ end
3229
+
3230
+ # Represents +next+ keyword
3231
+ class Next < Node
3232
+ # Arguments given to +next+
3233
+ #
3234
+ # @return [::Array<Node>]
3235
+ attr_reader :args
3236
+
3237
+ # Location of the +next+ keyword
3238
+ #
3239
+ # @example
3240
+ # next 42
3241
+ # ~~~~
3242
+ #
3243
+ #
3244
+ # @return [Loc]
3245
+ attr_reader :keyword_l
3246
+
3247
+ # Location of the full expression
3248
+ #
3249
+ # @example
3250
+ # next(42)
3251
+ # ~~~~~~~~
3252
+ #
3253
+ #
3254
+ # @return [Loc]
3255
+ attr_reader :expression_l
3256
+
3257
+ end
3258
+
3259
+ # Represents +nil+ literal
3260
+ class Nil < Node
3261
+ # Location of the +nil+ keyword
3262
+ #
3263
+ # @example
3264
+ # nil
3265
+ # ~~~
3266
+ #
3267
+ #
3268
+ # @return [Loc]
3269
+ attr_reader :expression_l
3270
+
3271
+ end
3272
+
3273
+ # Represents numeric global variable (e.g. +$1+)
3274
+ class NthRef < Node
3275
+ # Name of the variable, +String("1")+ for +$1+
3276
+ #
3277
+ # @return [String]
3278
+ attr_reader :name
3279
+
3280
+ # Location of the full expression
3281
+ #
3282
+ # @example
3283
+ # $1
3284
+ # ~~
3285
+ #
3286
+ #
3287
+ # @return [Loc]
3288
+ attr_reader :expression_l
3289
+
3290
+ end
3291
+
3292
+ # Represents a block that takes numbered parameters (i.e. +proc { _1 }+)
3293
+ class Numblock < Node
3294
+ # Method call that takes a block
3295
+ #
3296
+ # @return [Node]
3297
+ attr_reader :call
3298
+
3299
+ # Number of parameters that block takes
3300
+ #
3301
+ # @return [Integer]
3302
+ attr_reader :numargs
3303
+
3304
+ # Block body
3305
+ #
3306
+ # @return [Node]
3307
+ attr_reader :body
3308
+
3309
+ # Location of the open brace
3310
+ #
3311
+ # @example
3312
+ # proc { _1 }
3313
+ # ~
3314
+ #
3315
+ #
3316
+ # @return [Loc]
3317
+ attr_reader :begin_l
3318
+
3319
+ # Location of the closing brace
3320
+ #
3321
+ # @example
3322
+ # proc { _1 }
3323
+ # ~
3324
+ #
3325
+ #
3326
+ # @return [Loc]
3327
+ attr_reader :end_l
3328
+
3329
+ # Location of the open brace
3330
+ #
3331
+ # @example
3332
+ # proc { _1 }
3333
+ # ~~~~~~~~~~~
3334
+ #
3335
+ #
3336
+ # @return [Loc]
3337
+ attr_reader :expression_l
3338
+
3339
+ end
3340
+
3341
+ # Represents an operation with assignment (e.g. +a += 1+)
3342
+ class OpAsgn < Node
3343
+ # Left hand statement of the assignment
3344
+ #
3345
+ # @return [Node]
3346
+ attr_reader :recv
3347
+
3348
+ # Operator, can be one of:
3349
+ # 1. ++=+
3350
+ # 2. +-=+
3351
+ # 3. +*=+
3352
+ # 4. +/=+
3353
+ # 5. +|=+
3354
+ # 6. +&=+
3355
+ # 7. +>>=+
3356
+ # 8. +<<=+
3357
+ # 9. +%=+
3358
+ # 10. +^=+
3359
+ # 11. +**=+
3360
+ #
3361
+ # @return [String]
3362
+ attr_reader :operator
3363
+
3364
+ # Right hand statement of the assignment
3365
+ #
3366
+ # @return [Node]
3367
+ attr_reader :value
3368
+
3369
+ # Location of the operator
3370
+ #
3371
+ # @example
3372
+ # a.b <<= c
3373
+ # ~~~
3374
+ #
3375
+ #
3376
+ # @return [Loc]
3377
+ attr_reader :operator_l
3378
+
3379
+ # Location of the operator
3380
+ #
3381
+ # @example
3382
+ # a.b <<= c
3383
+ # ~~~~~~~~~
3384
+ #
3385
+ #
3386
+ # @return [Loc]
3387
+ attr_reader :expression_l
3388
+
3389
+ end
3390
+
3391
+ # Represents optional positional argument (i.e. +foo+ in +m(foo = 1)+)
3392
+ class Optarg < Node
3393
+ # Name of the argument
3394
+ #
3395
+ # @return [String]
3396
+ attr_reader :name
3397
+
3398
+ # Default value of the argument
3399
+ #
3400
+ # @return [Node]
3401
+ attr_reader :default
3402
+
3403
+ # Location of the argument name
3404
+ #
3405
+ # @example
3406
+ # def m(foo = 1); end
3407
+ # ~~~
3408
+ #
3409
+ #
3410
+ # @return [Loc]
3411
+ attr_reader :name_l
3412
+
3413
+ # Location of the +=+ operator
3414
+ #
3415
+ # @example
3416
+ # def m(foo = 1); end
3417
+ # ~
3418
+ #
3419
+ #
3420
+ # @return [Loc]
3421
+ attr_reader :operator_l
3422
+
3423
+ # Location of the full expression
3424
+ #
3425
+ # @example
3426
+ # def m(foo = 1); end
3427
+ # ~~~~~~~
3428
+ #
3429
+ #
3430
+ # @return [Loc]
3431
+ attr_reader :expression_l
3432
+
3433
+ end
3434
+
3435
+ # Represents +foo || bar+ (or +foo or bar+) statement.
3436
+ class Or < Node
3437
+ # Left hand statement
3438
+ #
3439
+ # @return [Node]
3440
+ attr_reader :lhs
3441
+
3442
+ # Right hand statement
3443
+ #
3444
+ # @return [Node]
3445
+ attr_reader :rhs
3446
+
3447
+ # Location of the +||+/+or+ operator
3448
+ #
3449
+ # @example
3450
+ # foo || bar
3451
+ # ~~
3452
+ #
3453
+ #
3454
+ # @return [Loc]
3455
+ attr_reader :operator_l
3456
+
3457
+ # Location of the full expression
3458
+ #
3459
+ # @example
3460
+ # foo || bar
3461
+ # ~~~~~~~~~~
3462
+ #
3463
+ #
3464
+ # @return [Loc]
3465
+ attr_reader :expression_l
3466
+
3467
+ end
3468
+
3469
+ # Represents +lhs ||= rhs+ assignment
3470
+ class OrAsgn < Node
3471
+ # Left hand statement
3472
+ #
3473
+ # @return [Node]
3474
+ attr_reader :recv
3475
+
3476
+ # Right hand statement
3477
+ #
3478
+ # @return [Node]
3479
+ attr_reader :value
3480
+
3481
+ # Location of the +||=+ operator
3482
+ #
3483
+ # @example
3484
+ # foo ||= bar
3485
+ # ~~~
3486
+ #
3487
+ #
3488
+ # @return [Loc]
3489
+ attr_reader :operator_l
3490
+
3491
+ # Location of the full expression
3492
+ #
3493
+ # @example
3494
+ # foo ||= bar
3495
+ # ~~~~~~~~~~~
3496
+ #
3497
+ #
3498
+ # @return [Loc]
3499
+ attr_reader :expression_l
3500
+
3501
+ end
3502
+
3503
+ # Represents a key/value pair (e.g. a part of the +Hash+ node)
3504
+ class Pair < Node
3505
+ # Key of the pair
3506
+ #
3507
+ # @return [Node]
3508
+ attr_reader :key
3509
+
3510
+ # Value of the pair
3511
+ #
3512
+ # @return [Node]
3513
+ attr_reader :value
3514
+
3515
+ # Location of the +:+ or +=>+ operator
3516
+ #
3517
+ # @example
3518
+ # { foo: bar }
3519
+ # ~
3520
+ #
3521
+ # { :foo => bar }
3522
+ # ~~
3523
+ #
3524
+ #
3525
+ # @return [Loc]
3526
+ attr_reader :operator_l
3527
+
3528
+ # Location of the full expression
3529
+ #
3530
+ # @example
3531
+ # { foo: bar }
3532
+ # ~~~~~~~~
3533
+ #
3534
+ # { :foo => bar }
3535
+ # ~~~~~~~~~~~
3536
+ #
3537
+ #
3538
+ # @return [Loc]
3539
+ attr_reader :expression_l
3540
+
3541
+ end
3542
+
3543
+ # Represents a pattern based on a "pinned" variable (e.g. +^foo+)
3544
+ class Pin < Node
3545
+ # Variable that is pinned
3546
+ #
3547
+ # @return [Node]
3548
+ attr_reader :var
3549
+
3550
+ # Location of the +^+ operator
3551
+ #
3552
+ # @example
3553
+ # case foo; in ^bar; end
3554
+ # ~
3555
+ #
3556
+ #
3557
+ # @return [Loc]
3558
+ attr_reader :selector_l
3559
+
3560
+ # Location of the full expression
3561
+ #
3562
+ # @example
3563
+ # case foo; in ^bar; end
3564
+ # ~~~~
3565
+ #
3566
+ #
3567
+ # @return [Loc]
3568
+ attr_reader :expression_l
3569
+
3570
+ end
3571
+
3572
+ # Represents +END { .. }+ statement
3573
+ class Postexe < Node
3574
+ # Body of the block
3575
+ #
3576
+ # @return [Node, nil]
3577
+ attr_reader :body
3578
+
3579
+ # Location of the +END+ keyword
3580
+ #
3581
+ # @example
3582
+ # END { 42 }
3583
+ # ~~~
3584
+ #
3585
+ #
3586
+ # @return [Loc]
3587
+ attr_reader :keyword_l
3588
+
3589
+ # Location of the open parenthesis
3590
+ #
3591
+ # @example
3592
+ # END { 42 }
3593
+ # ~
3594
+ #
3595
+ #
3596
+ # @return [Loc]
3597
+ attr_reader :begin_l
3598
+
3599
+ # Location of the closing parenthesis
3600
+ #
3601
+ # @example
3602
+ # END { 42 }
3603
+ # ~
3604
+ #
3605
+ #
3606
+ # @return [Loc]
3607
+ attr_reader :end_l
3608
+
3609
+ # Location of the full expression
3610
+ #
3611
+ # @example
3612
+ # END { 42 }
3613
+ # ~~~~~~~~~~
3614
+ #
3615
+ #
3616
+ # @return [Loc]
3617
+ attr_reader :expression_l
3618
+
3619
+ end
3620
+
3621
+ # Represents +BEGIN { ... }+ statement
3622
+ class Preexe < Node
3623
+ # Body of the block
3624
+ #
3625
+ # @return [Node, nil]
3626
+ attr_reader :body
3627
+
3628
+ # Location of the +BEGIN+ keyword
3629
+ #
3630
+ # @example
3631
+ # BEGIN { 42 }
3632
+ # ~~~~~
3633
+ #
3634
+ #
3635
+ # @return [Loc]
3636
+ attr_reader :keyword_l
3637
+
3638
+ # Location of the open parenthesis
3639
+ #
3640
+ # @example
3641
+ # BEGIN { 42 }
3642
+ # ~
3643
+ #
3644
+ #
3645
+ # @return [Loc]
3646
+ attr_reader :begin_l
3647
+
3648
+ # Location of the closing parenthesis
3649
+ #
3650
+ # @example
3651
+ # BEGIN { 42 }
3652
+ # ~
3653
+ #
3654
+ #
3655
+ # @return [Loc]
3656
+ attr_reader :end_l
3657
+
3658
+ # Location of the full expression
3659
+ #
3660
+ # @example
3661
+ # BEGIN { 42 }
3662
+ # ~~~~~~~~~~~~
3663
+ #
3664
+ #
3665
+ # @return [Loc]
3666
+ attr_reader :expression_l
3667
+
3668
+ end
3669
+
3670
+ # Represents a sole block argument (e.g. +|foo|+)
3671
+ #
3672
+ # Block that takes a single array argument automatically expands it.
3673
+ # Adding trailing comma after block argument disables this behavior (and then the only argument is emitted as +Arg+).
3674
+ class Procarg0 < Node
3675
+ # Parts of the sole block argument.
3676
+ #
3677
+ # +proc { |(a, b)| }+ also counts as a sole argument, so this list may contain:
3678
+ # 1. A single +Arg+ node (for +proc { |a| }+ case)
3679
+ # 2. Multiple +Arg+ nodes (for +proc { |(a, b, c)| }+ case)
3680
+ #
3681
+ # @return [::Array<Node>]
3682
+ attr_reader :args
3683
+
3684
+ # Location of the open parenthesis
3685
+ #
3686
+ # @example
3687
+ # proc { |(foo, bar)| }
3688
+ # ~
3689
+ #
3690
+ # +None+ if there's only one argument
3691
+ #
3692
+ # @return [Loc, nil]
3693
+ attr_reader :begin_l
3694
+
3695
+ # Location of the open parenthesis
3696
+ #
3697
+ # @example
3698
+ # proc { |(foo, bar)| }
3699
+ # ~
3700
+ #
3701
+ # +None+ if there's only one argument
3702
+ #
3703
+ # @return [Loc, nil]
3704
+ attr_reader :end_l
3705
+
3706
+ # Location of the full expression
3707
+ #
3708
+ # @example
3709
+ # proc { |(foo, bar)| }
3710
+ # ~~~~~~~~~~
3711
+ #
3712
+ #
3713
+ # @return [Loc]
3714
+ attr_reader :expression_l
3715
+
3716
+ end
3717
+
3718
+ # Represents rational literal (e.g. +1r+)
3719
+ class Rational < Node
3720
+ # String value of the literal, +String("1r")+ for +1r+
3721
+ #
3722
+ # @return [String]
3723
+ attr_reader :value
3724
+
3725
+ # Location of the unary +-+ (but not +++)
3726
+ #
3727
+ # @example
3728
+ # -1r
3729
+ # ~
3730
+ #
3731
+ #
3732
+ # @return [Loc, nil]
3733
+ attr_reader :operator_l
3734
+
3735
+ # Location of the full expression
3736
+ #
3737
+ # @example
3738
+ # -1r
3739
+ # ~~~
3740
+ #
3741
+ #
3742
+ # @return [Loc]
3743
+ attr_reader :expression_l
3744
+
3745
+ end
3746
+
3747
+ # Represents +redo+ keyword
3748
+ class Redo < Node
3749
+ # Location of the full expression
3750
+ #
3751
+ # @example
3752
+ # redo
3753
+ # ~~~~
3754
+ #
3755
+ #
3756
+ # @return [Loc]
3757
+ attr_reader :expression_l
3758
+
3759
+ end
3760
+
3761
+ # Represents regex literal (e.g. +/foo/+)
3762
+ class Regexp < Node
3763
+ # A list of static and dynamic regex parts
3764
+ #
3765
+ # @return [::Array<Node>]
3766
+ attr_reader :parts
3767
+
3768
+ # Regex options.
3769
+ #
3770
+ # +None+ if regex has no explicit flags
3771
+ #
3772
+ # @return [Node, nil]
3773
+ attr_reader :options
3774
+
3775
+ # Location of the regex begin
3776
+ #
3777
+ # @example
3778
+ # /foo/
3779
+ # ~
3780
+ #
3781
+ # %r{foo}
3782
+ # ~~
3783
+ #
3784
+ #
3785
+ # @return [Loc]
3786
+ attr_reader :begin_l
3787
+
3788
+ # Location of the regex end
3789
+ #
3790
+ # @example
3791
+ # /foo/
3792
+ # ~
3793
+ #
3794
+ # %r{foo}
3795
+ # ~
3796
+ #
3797
+ #
3798
+ # @return [Loc]
3799
+ attr_reader :end_l
3800
+
3801
+ # Location of the full expression
3802
+ #
3803
+ # @example
3804
+ # /foo/mix
3805
+ # ~~~~~~~~
3806
+ #
3807
+ #
3808
+ # @return [Loc]
3809
+ attr_reader :expression_l
3810
+
3811
+ end
3812
+
3813
+ # Represents flags of the regex literal (i.e. +mix+ for +/foo/mix+)
3814
+ class RegOpt < Node
3815
+ # A list of flags
3816
+ #
3817
+ # @return [String, nil]
3818
+ attr_reader :options
3819
+
3820
+ # Location of the full expression
3821
+ #
3822
+ # @example
3823
+ # /foo/mix
3824
+ # ~~~
3825
+ #
3826
+ #
3827
+ # @return [Loc]
3828
+ attr_reader :expression_l
3829
+
3830
+ end
3831
+
3832
+ # Represents a +rescue+ block
3833
+ class Rescue < Node
3834
+ # Body of the block that is wrapped into +rescue+ (i.e. the part that may throw an error)
3835
+ #
3836
+ # @return [Node, nil]
3837
+ attr_reader :body
3838
+
3839
+ # A list of +rescue+ handlers (see +RescueBody+ node)
3840
+ #
3841
+ # @return [::Array<Node>]
3842
+ attr_reader :rescue_bodies
3843
+
3844
+ # Else branch.
3845
+ #
3846
+ # +None+ if there's no +else+ branch
3847
+ #
3848
+ # @return [Node, nil]
3849
+ attr_reader :else
3850
+
3851
+ # Location of the +else+ keyword
3852
+ #
3853
+ # @example
3854
+ # begin; 1; rescue StandardError => e; 2; else; 3; end
3855
+ # ~~~~
3856
+ #
3857
+ # +None+ if there's no +else+ branch
3858
+ #
3859
+ # @return [Loc, nil]
3860
+ attr_reader :else_l
3861
+
3862
+ # Location of the full expression
3863
+ #
3864
+ # @example
3865
+ # begin; 1; rescue StandardError => e; 2; else; 3; end
3866
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3867
+ #
3868
+ # **Note**: +begin/end+ keywords belong to +KwBegin+ node
3869
+ #
3870
+ # @return [Loc]
3871
+ attr_reader :expression_l
3872
+
3873
+ end
3874
+
3875
+ # Represents a single +rescue+ handler (i.e. +rescue E => e ...+)
3876
+ class RescueBody < Node
3877
+ # A list of exception classes
3878
+ #
3879
+ # +None+ if no classes specified (i.e. +rescue => e; ...+ or just +rescue; ...+)
3880
+ #
3881
+ # @return [Node, nil]
3882
+ attr_reader :exc_list
3883
+
3884
+ # Variable that captures exception
3885
+ #
3886
+ # +None+ if no variable specified (i.e. +rescue E; ...+ or just +rescue; ... +)
3887
+ #
3888
+ # @return [Node, nil]
3889
+ attr_reader :exc_var
3890
+
3891
+ # Body of the handler
3892
+ #
3893
+ # @return [Node, nil]
3894
+ attr_reader :body
3895
+
3896
+ # Location of the +rescue+ keyword
3897
+ #
3898
+ # @example
3899
+ # begin; 1; rescue E => e; 2; end
3900
+ # ~~~~~~
3901
+ #
3902
+ #
3903
+ # @return [Loc]
3904
+ attr_reader :keyword_l
3905
+
3906
+ # Location of the +=>+ operator
3907
+ #
3908
+ # @example
3909
+ # begin; 1; rescue E => e; 2; end
3910
+ # ~~
3911
+ #
3912
+ # +None+ if exception is not captured.
3913
+ #
3914
+ # @return [Loc, nil]
3915
+ attr_reader :assoc_l
3916
+
3917
+ # Location of the +then+ keyword
3918
+ #
3919
+ # @example
3920
+ # begin; 1; rescue E => e then; 2; end
3921
+ # ~~~~
3922
+ #
3923
+ # +then+ is optional, so +begin_l+ can be +None+
3924
+ #
3925
+ # @return [Loc, nil]
3926
+ attr_reader :begin_l
3927
+
3928
+ # Location of the full expression
3929
+ #
3930
+ # @example
3931
+ # begin; 1; rescue E => e then; 2; end
3932
+ # ~~~~~~~~~~~~~~~~~~~~~
3933
+ #
3934
+ #
3935
+ # @return [Loc]
3936
+ attr_reader :expression_l
3937
+
3938
+ end
3939
+
3940
+ # Represents positional rest argument (i.e. +*foo+ in +def m(*foo); end+)
3941
+ class Restarg < Node
3942
+ # Name of the argument.
3943
+ #
3944
+ # +None+ if argument has no name (i.e. +def m(*); end+)
3945
+ #
3946
+ # @return [String, nil]
3947
+ attr_reader :name
3948
+
3949
+ # Location of the +*+ operator
3950
+ #
3951
+ # @example
3952
+ # def m(*foo); end
3953
+ # ~
3954
+ #
3955
+ #
3956
+ # @return [Loc]
3957
+ attr_reader :operator_l
3958
+
3959
+ # Location of the argument name
3960
+ #
3961
+ # @example
3962
+ # def m(*foo); end
3963
+ # ~~~
3964
+ #
3965
+ #
3966
+ # @return [Loc, nil]
3967
+ attr_reader :name_l
3968
+
3969
+ # Location of the full expression
3970
+ #
3971
+ # @example
3972
+ # def m(*foo); end
3973
+ # ~~~~
3974
+ #
3975
+ #
3976
+ # @return [Loc]
3977
+ attr_reader :expression_l
3978
+
3979
+ end
3980
+
3981
+ # Represents +retry+ keyword
3982
+ class Retry < Node
3983
+ # Location of the +retry+ keyword
3984
+ #
3985
+ # @example
3986
+ # retry
3987
+ # ~~~~~
3988
+ #
3989
+ #
3990
+ # @return [Loc]
3991
+ attr_reader :expression_l
3992
+
3993
+ end
3994
+
3995
+ # Represents +return+ keyword
3996
+ class Return < Node
3997
+ # A list of values that is returned
3998
+ #
3999
+ # @return [::Array<Node>]
4000
+ attr_reader :args
4001
+
4002
+ # Location of the +return+ keyword
4003
+ #
4004
+ # @example
4005
+ # return 1, 2
4006
+ # ~~~~~~
4007
+ #
4008
+ #
4009
+ # @return [Loc]
4010
+ attr_reader :keyword_l
4011
+
4012
+ # Location of the full expression
4013
+ #
4014
+ # @example
4015
+ # return 1, 2
4016
+ # ~~~~~~~~~~~
4017
+ #
4018
+ #
4019
+ # @return [Loc]
4020
+ attr_reader :expression_l
4021
+
4022
+ end
4023
+
4024
+ # Represents opening a singleton class (i.e. +class << foo; ... end;+)
4025
+ class SClass < Node
4026
+ # Expression that is used to get a singleton class
4027
+ #
4028
+ # +Lvar("foo")+ for +class << foo; end+
4029
+ #
4030
+ # @return [Node]
4031
+ attr_reader :expr
4032
+
4033
+ # Body of the block
4034
+ #
4035
+ # @return [Node, nil]
4036
+ attr_reader :body
4037
+
4038
+ # Location of the +class+ keyword
4039
+ #
4040
+ # @example
4041
+ # class << foo; end
4042
+ # ~~~~~
4043
+ #
4044
+ #
4045
+ # @return [Loc]
4046
+ attr_reader :keyword_l
4047
+
4048
+ # Location of the +<<+ operator
4049
+ #
4050
+ # @example
4051
+ # class << foo; end
4052
+ # ~~
4053
+ #
4054
+ #
4055
+ # @return [Loc]
4056
+ attr_reader :operator_l
4057
+
4058
+ # Location of the +end+ keyword
4059
+ #
4060
+ # @example
4061
+ # class << foo; end
4062
+ # ~~~
4063
+ #
4064
+ #
4065
+ # @return [Loc]
4066
+ attr_reader :end_l
4067
+
4068
+ # Location of the full expression
4069
+ #
4070
+ # @example
4071
+ # class << foo; end
4072
+ # ~~~~~~~~~~~~~~~~~
4073
+ #
4074
+ #
4075
+ # @return [Loc]
4076
+ attr_reader :expression_l
4077
+
4078
+ end
4079
+
4080
+ # Represents +self+ keyword
4081
+ class Self_ < Node
4082
+ # Location of the +self+ keyword
4083
+ #
4084
+ # @example
4085
+ # self
4086
+ # ~~~~
4087
+ #
4088
+ #
4089
+ # @return [Loc]
4090
+ attr_reader :expression_l
4091
+
4092
+ end
4093
+
4094
+ # Represents a method call (e.g. +foo.bar(42)+)
4095
+ class Send < Node
4096
+ # Receiver of the method call
4097
+ #
4098
+ # +None+ for implicit method call (e.g. +foo(42)+)
4099
+ #
4100
+ # @return [Node, nil]
4101
+ attr_reader :recv
4102
+
4103
+ # Name of the method that is called
4104
+ #
4105
+ # @return [String]
4106
+ attr_reader :method_name
4107
+
4108
+ # A list of arguments
4109
+ #
4110
+ # @return [::Array<Node>]
4111
+ attr_reader :args
4112
+
4113
+ # Location of the +.+ operator
4114
+ #
4115
+ # @example
4116
+ # foo.bar(42)
4117
+ # ~
4118
+ #
4119
+ # +None+ for implicit method call (e.g. +foo(42)+)
4120
+ #
4121
+ # @return [Loc, nil]
4122
+ attr_reader :dot_l
4123
+
4124
+ # Location of the method name
4125
+ #
4126
+ # @example
4127
+ # foo.bar(42)
4128
+ # ~~~
4129
+ #
4130
+ # +None+ in a very special case when method call is implicit (i.e. +foo.(42)+)
4131
+ #
4132
+ # @return [Loc, nil]
4133
+ attr_reader :selector_l
4134
+
4135
+ # Location of open parenthesis
4136
+ #
4137
+ # @example
4138
+ # foo(42)
4139
+ # ~
4140
+ #
4141
+ # +None+ if there are no parentheses
4142
+ #
4143
+ # @return [Loc, nil]
4144
+ attr_reader :begin_l
4145
+
4146
+ # Location of closing parenthesis
4147
+ #
4148
+ # @example
4149
+ # foo(42)
4150
+ # ~
4151
+ #
4152
+ # +None+ if there are no parentheses
4153
+ #
4154
+ # @return [Loc, nil]
4155
+ attr_reader :end_l
4156
+
4157
+ # Location of the operator if method is a setter
4158
+ #
4159
+ # @example
4160
+ # foo.bar = 42
4161
+ # ~
4162
+ #
4163
+ # +None+ otherwise
4164
+ #
4165
+ # @return [Loc, nil]
4166
+ attr_reader :operator_l
4167
+
4168
+ # Location of the full expression
4169
+ #
4170
+ # @example
4171
+ # foo.bar(42)
4172
+ # ~~~~~~~~~~~
4173
+ #
4174
+ #
4175
+ # @return [Loc]
4176
+ attr_reader :expression_l
4177
+
4178
+ end
4179
+
4180
+ # Represents a special block argument that "shadows" outer variable (i.e. +|;foo|+)
4181
+ class Shadowarg < Node
4182
+ # Name of the argument
4183
+ #
4184
+ # @return [String]
4185
+ attr_reader :name
4186
+
4187
+ # Location of the argument
4188
+ #
4189
+ # @example
4190
+ # proc { |;foo|}
4191
+ # ~~~
4192
+ #
4193
+ #
4194
+ # @return [Loc]
4195
+ attr_reader :expression_l
4196
+
4197
+ end
4198
+
4199
+ # Represents an arguments splat (i.e. +*bar+ in a call like +foo(*bar)+)
4200
+ class Splat < Node
4201
+ # Value that is converted to array
4202
+ #
4203
+ # @return [Node, nil]
4204
+ attr_reader :value
4205
+
4206
+ # Location of the +*+ operator
4207
+ #
4208
+ # @example
4209
+ # foo(*bar)
4210
+ # ~
4211
+ #
4212
+ #
4213
+ # @return [Loc]
4214
+ attr_reader :operator_l
4215
+
4216
+ # Location of the full expression
4217
+ #
4218
+ # @example
4219
+ # foo(*bar)
4220
+ # ~~~~
4221
+ #
4222
+ #
4223
+ # @return [Loc]
4224
+ attr_reader :expression_l
4225
+
4226
+ end
4227
+
4228
+ # Represents a plain non-interpolated string literal (e.g. +"foo"+)
4229
+ class Str < Node
4230
+ # Value of the string literal
4231
+ #
4232
+ # Note that it's a +StringValue+, not a +String+.
4233
+ # The reason is that you can get UTF-8 incompatible strings
4234
+ # from a valid UTF-8 source using escape sequences like +"\xFF"+
4235
+ #
4236
+ # These "\", "x", "F", "F" chars are valid separately, but together
4237
+ # they construct a char with code = 255 that is invalid for UTF-8.
4238
+ #
4239
+ # You can use +to_string_lossy+ or +to_string+ methods to get a raw string value.
4240
+ #
4241
+ # @return [String]
4242
+ attr_reader :value
4243
+
4244
+ # Location of the string begin
4245
+ #
4246
+ # @example
4247
+ # "foo"
4248
+ # ~
4249
+ #
4250
+ # +None+ if string literal is a part of the words array (like +%w[foo bar baz]+)
4251
+ #
4252
+ # @return [Loc, nil]
4253
+ attr_reader :begin_l
4254
+
4255
+ # Location of the string begin
4256
+ #
4257
+ # @example
4258
+ # "foo"
4259
+ # ~
4260
+ #
4261
+ # +None+ if string literal is a part of the words array (like +%w[foo bar baz]+)
4262
+ #
4263
+ # @return [Loc, nil]
4264
+ attr_reader :end_l
4265
+
4266
+ # Location of the full expression
4267
+ #
4268
+ # @example
4269
+ # "foo"
4270
+ # ~~~~~
4271
+ #
4272
+ #
4273
+ # @return [Loc]
4274
+ attr_reader :expression_l
4275
+
4276
+ end
4277
+
4278
+ # Represents a +super+ keyword
4279
+ class Super < Node
4280
+ # A list of arguments given to +super+
4281
+ #
4282
+ # @return [::Array<Node>]
4283
+ attr_reader :args
4284
+
4285
+ # Location of the +super+ keyword
4286
+ #
4287
+ # @example
4288
+ # super(1, 2)
4289
+ # ~~~~~
4290
+ #
4291
+ #
4292
+ # @return [Loc]
4293
+ attr_reader :keyword_l
4294
+
4295
+ # Location of the open parenthesis
4296
+ #
4297
+ # @example
4298
+ # super(1, 2)
4299
+ # ~
4300
+ #
4301
+ # +None+ if there are no parentheses
4302
+ #
4303
+ # @return [Loc, nil]
4304
+ attr_reader :begin_l
4305
+
4306
+ # Location of the closing parenthesis
4307
+ #
4308
+ # @example
4309
+ # super(1, 2)
4310
+ # ~
4311
+ #
4312
+ # +None+ if there are no parentheses
4313
+ #
4314
+ # @return [Loc, nil]
4315
+ attr_reader :end_l
4316
+
4317
+ # Location of the full expression
4318
+ #
4319
+ # @example
4320
+ # super(1, 2)
4321
+ # ~~~~~~~~~~~
4322
+ #
4323
+ #
4324
+ # @return [Loc]
4325
+ attr_reader :expression_l
4326
+
4327
+ end
4328
+
4329
+ # Represents a plain symbol literal (i.e. +:foo+)
4330
+ #
4331
+ # Note that +:+ in +{ foo: bar }+ belongs to a +pair+ node.
4332
+ class Sym < Node
4333
+ # Value of the symbol literal
4334
+ #
4335
+ # Note that it's a +StringValue+, not a +String+.
4336
+ # The reason is that you can get UTF-8 incompatible strings
4337
+ # from a valid UTF-8 source using escape sequences like +"\xFF"+
4338
+ #
4339
+ # These "\", "x", "F", "F" chars are valid separately, but together
4340
+ # they construct a char with code = 255 that is invalid for UTF-8.
4341
+ #
4342
+ # You can use +to_string_lossy+ or +to_string+ methods to get a raw symbol value.
4343
+ #
4344
+ # @return [String]
4345
+ attr_reader :name
4346
+
4347
+ # Location of the symbol begin
4348
+ #
4349
+ # @example
4350
+ # :foo
4351
+ # ~
4352
+ #
4353
+ # +None+ if symbol is a label (+{ foo: 1 }+) or a part of the symbols array (+%i[foo bar baz]+)
4354
+ #
4355
+ # @return [Loc, nil]
4356
+ attr_reader :begin_l
4357
+
4358
+ # Location of the symbol end
4359
+ #
4360
+ # @example
4361
+ # { 'foo': 1 }
4362
+ # ~
4363
+ #
4364
+ # +None+ if symbol is **not** a string label (+:foo+) or a part of the symbols array (+%i[foo bar baz]+)
4365
+ #
4366
+ # @return [Loc, nil]
4367
+ attr_reader :end_l
4368
+
4369
+ # Location of the full expression
4370
+ #
4371
+ # @example
4372
+ # :foo
4373
+ # ~~~~
4374
+ #
4375
+ # { foo: 1 }
4376
+ # ~~~~
4377
+ #
4378
+ # %i[foo]
4379
+ # ~~~
4380
+ #
4381
+ #
4382
+ # @return [Loc]
4383
+ attr_reader :expression_l
4384
+
4385
+ end
4386
+
4387
+ # Represents a +true+ literal
4388
+ class True < Node
4389
+ # Location of the +true+ keyword
4390
+ #
4391
+ # @example
4392
+ # true
4393
+ # ~~~~
4394
+ #
4395
+ #
4396
+ # @return [Loc]
4397
+ attr_reader :expression_l
4398
+
4399
+ end
4400
+
4401
+ # Represents an +undef+ keyword (e.g. +undef foo, :bar+)
4402
+ class Undef < Node
4403
+ # A list of names to +undef+
4404
+ #
4405
+ # @return [::Array<Node>]
4406
+ attr_reader :names
4407
+
4408
+ # Location the +undef+ keyword
4409
+ #
4410
+ # @example
4411
+ # undef foo, :bar
4412
+ # ~~~~~
4413
+ #
4414
+ #
4415
+ # @return [Loc]
4416
+ attr_reader :keyword_l
4417
+
4418
+ # Location of the full expression
4419
+ #
4420
+ # @example
4421
+ # undef :foo, bar
4422
+ # ~~~~~~~~~~~~~~~
4423
+ #
4424
+ #
4425
+ # @return [Loc]
4426
+ attr_reader :expression_l
4427
+
4428
+ end
4429
+
4430
+ # Represents an +unless+ guard used in pattern matching (i.e. +in pattern unless guard+)
4431
+ class UnlessGuard < Node
4432
+ # Condition of the guard, +Lvar("foo")+ in +in pattern unless guard+
4433
+ #
4434
+ # @return [Node]
4435
+ attr_reader :cond
4436
+
4437
+ # Location of the +unless+ keyword
4438
+ #
4439
+ # @example
4440
+ # case foo; in pattern unless cond; end
4441
+ # ~~~~~~
4442
+ #
4443
+ #
4444
+ # @return [Loc]
4445
+ attr_reader :keyword_l
4446
+
4447
+ # Location of the full expression
4448
+ #
4449
+ # @example
4450
+ # case foo; in pattern unless cond; end
4451
+ # ~~~~~~~~~~~
4452
+ #
4453
+ #
4454
+ # @return [Loc]
4455
+ attr_reader :expression_l
4456
+
4457
+ end
4458
+
4459
+ # Represents +until+ loop
4460
+ class Until < Node
4461
+ # Condition of the loop
4462
+ #
4463
+ # @return [Node]
4464
+ attr_reader :cond
4465
+
4466
+ # Body of the loop.
4467
+ #
4468
+ # +None+ if body is empty
4469
+ #
4470
+ # @return [Node, nil]
4471
+ attr_reader :body
4472
+
4473
+ # Location of the +until+ keyword
4474
+ #
4475
+ # @example
4476
+ # until cond do; foo; end
4477
+ # ~~~~~
4478
+ #
4479
+ #
4480
+ # @return [Loc]
4481
+ attr_reader :keyword_l
4482
+
4483
+ # Location of the +do+ keyword
4484
+ #
4485
+ # @example
4486
+ # until cond do; foo; end
4487
+ # ~~
4488
+ #
4489
+ # +do+ is optional, and so +begin_l+ can be +None+
4490
+ #
4491
+ # @return [Loc, nil]
4492
+ attr_reader :begin_l
4493
+
4494
+ # Location of the +end+ keyword
4495
+ #
4496
+ # @example
4497
+ # until cond do; foo; end
4498
+ # ~~~
4499
+ #
4500
+ # +None+ if loop is a modifier (i.e. +foo until bar+)
4501
+ #
4502
+ # @return [Loc, nil]
4503
+ attr_reader :end_l
4504
+
4505
+ # Location of the full expression
4506
+ #
4507
+ # @example
4508
+ # until cond do; foo; end
4509
+ # ~~~~~~~~~~~~~~~~~~~~~~~
4510
+ #
4511
+ # foo until bar
4512
+ # ~~~~~~~~~~~~~
4513
+ #
4514
+ #
4515
+ # @return [Loc]
4516
+ attr_reader :expression_l
4517
+
4518
+ end
4519
+
4520
+ # Represents a post-until loop
4521
+ #
4522
+ # @example
4523
+ # begin
4524
+ # foo
4525
+ # end until bar
4526
+ #
4527
+ class UntilPost < Node
4528
+ # Condition of the loop
4529
+ #
4530
+ # @return [Node]
4531
+ attr_reader :cond
4532
+
4533
+ # Body of the loop
4534
+ #
4535
+ # @return [Node]
4536
+ attr_reader :body
4537
+
4538
+ # Location of the +until+ keyword
4539
+ #
4540
+ # @example
4541
+ # begin; foo; end until bar
4542
+ # ~~~~~
4543
+ #
4544
+ #
4545
+ # @return [Loc]
4546
+ attr_reader :keyword_l
4547
+
4548
+ # Location of the +until+ keyword
4549
+ #
4550
+ # @example
4551
+ # begin; foo; end until bar
4552
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~
4553
+ #
4554
+ #
4555
+ # @return [Loc]
4556
+ attr_reader :expression_l
4557
+
4558
+ end
4559
+
4560
+ # Represents a branch of the +case+ statement (i.e. +when foo+)
4561
+ class When < Node
4562
+ # A list of values to compare/match against
4563
+ #
4564
+ # @return [::Array<Node>]
4565
+ attr_reader :patterns
4566
+
4567
+ # Body of the +when+ branch
4568
+ #
4569
+ # @return [Node, nil]
4570
+ attr_reader :body
4571
+
4572
+ # Location of the +when+ keyword
4573
+ #
4574
+ # @example
4575
+ # case foo; when bar; end
4576
+ # ~~~~
4577
+ #
4578
+ #
4579
+ # @return [Loc]
4580
+ attr_reader :keyword_l
4581
+
4582
+ # Location of the +then+ keyword
4583
+ #
4584
+ # @example
4585
+ # case foo; when bar then baz; end
4586
+ # ~~~~
4587
+ #
4588
+ # +then+ is optional, and so +begin_l+ can be +None+
4589
+ #
4590
+ # @return [Loc]
4591
+ attr_reader :begin_l
4592
+
4593
+ # Location of the full expression
4594
+ #
4595
+ # @example
4596
+ # case foo; when bar then baz; end
4597
+ # ~~~~~~~~~~~~~~~~~
4598
+ #
4599
+ #
4600
+ # @return [Loc]
4601
+ attr_reader :expression_l
4602
+
4603
+ end
4604
+
4605
+ # Represents +while+ loop
4606
+ class While < Node
4607
+ # Condition of the loop
4608
+ #
4609
+ # @return [Node]
4610
+ attr_reader :cond
4611
+
4612
+ # Body of the loop.
4613
+ #
4614
+ # +None+ if body is empty
4615
+ #
4616
+ # @return [Node, nil]
4617
+ attr_reader :body
4618
+
4619
+ # Location of the +while+ keyword
4620
+ #
4621
+ # @example
4622
+ # while cond do; foo; end
4623
+ # ~~~~~
4624
+ #
4625
+ #
4626
+ # @return [Loc]
4627
+ attr_reader :keyword_l
4628
+
4629
+ # Location of the +do+ keyword
4630
+ #
4631
+ # @example
4632
+ # while cond do; foo; end
4633
+ # ~~
4634
+ #
4635
+ # +do+ is optional, and so +begin_l+ can be +None+
4636
+ #
4637
+ # @return [Loc, nil]
4638
+ attr_reader :begin_l
4639
+
4640
+ # Location of the +end+ keyword
4641
+ #
4642
+ # @example
4643
+ # while cond do; foo; end
4644
+ # ~~~
4645
+ #
4646
+ # +None+ if loop is a modifier (i.e. +foo while bar+)
4647
+ #
4648
+ # @return [Loc, nil]
4649
+ attr_reader :end_l
4650
+
4651
+ # Location of the full expression
4652
+ #
4653
+ # @example
4654
+ # while cond do; foo; end
4655
+ # ~~~~~~~~~~~~~~~~~~~~~~~
4656
+ #
4657
+ # foo while bar
4658
+ # ~~~~~~~~~~~~~
4659
+ #
4660
+ #
4661
+ # @return [Loc]
4662
+ attr_reader :expression_l
4663
+
4664
+ end
4665
+
4666
+ # Represents a post-while loop
4667
+ #
4668
+ # @example
4669
+ # begin
4670
+ # foo
4671
+ # end while bar
4672
+ #
4673
+ class WhilePost < Node
4674
+ # Condition of the loop
4675
+ #
4676
+ # @return [Node]
4677
+ attr_reader :cond
4678
+
4679
+ # Body of the loop
4680
+ #
4681
+ # @return [Node]
4682
+ attr_reader :body
4683
+
4684
+ # Location of the +while+ keyword
4685
+ #
4686
+ # @example
4687
+ # begin; foo; end while bar
4688
+ # ~~~~~
4689
+ #
4690
+ #
4691
+ # @return [Loc]
4692
+ attr_reader :keyword_l
4693
+
4694
+ # Location of the +while+ keyword
4695
+ #
4696
+ # @example
4697
+ # begin; foo; end while bar
4698
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~
4699
+ #
4700
+ #
4701
+ # @return [Loc]
4702
+ attr_reader :expression_l
4703
+
4704
+ end
4705
+
4706
+ # Represents a executable here-document literal (both with and without interpolation)
4707
+ #
4708
+ # It's similar to +Xstr+ in terms of abstract syntax tree, but has different source maps.
4709
+ class XHeredoc < Node
4710
+ # A list of string parts (static literals and interpolated expressions)
4711
+ #
4712
+ # @return [::Array<Node>]
4713
+ attr_reader :parts
4714
+
4715
+ # Location of the executable here-document body
4716
+ #
4717
+ # @example
4718
+ # <<-`HERE`\n a\n #{42}\nHERE
4719
+ # ~~~~~~~~~~~~~~~
4720
+ #
4721
+ #
4722
+ # @return [Loc]
4723
+ attr_reader :heredoc_body_l
4724
+
4725
+ # Location of the executable here-document end
4726
+ #
4727
+ # @example
4728
+ # <<-`HERE`\n a\n #{42}\nHERE
4729
+ # ~~~~
4730
+ #
4731
+ #
4732
+ # @return [Loc]
4733
+ attr_reader :heredoc_end_l
4734
+
4735
+ # Location of the executable here-document identifier
4736
+ #
4737
+ # @example
4738
+ # <<-`HERE`\n a\n #{42}\nHERE
4739
+ # ~~~~~~~
4740
+ #
4741
+ # **Note**: This is the only node (with +Heredoc+) that has +expression_l+ smaller that all other sub-locations merged.
4742
+ # The reason for that is that it's possible to add more code after here-document ID:
4743
+ #
4744
+ # @example
4745
+ # <<-`HERE` + "rest"
4746
+ # content
4747
+ # HERE
4748
+ #
4749
+ #
4750
+ # @return [Loc]
4751
+ attr_reader :expression_l
4752
+
4753
+ end
4754
+
4755
+ # Represents an executable string (i.e. + +sh #{script_name}+ +)
4756
+ class Xstr < Node
4757
+ # A list of string parts (static literals and interpolated expressions)
4758
+ #
4759
+ # @return [::Array<Node>]
4760
+ attr_reader :parts
4761
+
4762
+ # Location of the string begin
4763
+ #
4764
+ # @example
4765
+ # `#{foo}`
4766
+ # ~
4767
+ #
4768
+ # %X{#{foo}}
4769
+ # ~~~
4770
+ #
4771
+ #
4772
+ # @return [Loc]
4773
+ attr_reader :begin_l
4774
+
4775
+ # Location of the string end
4776
+ #
4777
+ # @example
4778
+ # `#{foo}`
4779
+ # ~
4780
+ #
4781
+ # %X{#{foo}}
4782
+ # ~
4783
+ #
4784
+ #
4785
+ # @return [Loc]
4786
+ attr_reader :end_l
4787
+
4788
+ # Location of the full expression
4789
+ #
4790
+ # @example
4791
+ # `#{foo}`
4792
+ # ~~~~~~~~
4793
+ #
4794
+ # %X{#{foo}}
4795
+ # ~~~~~~~~~~
4796
+ #
4797
+ #
4798
+ # @return [Loc]
4799
+ attr_reader :expression_l
4800
+
4801
+ end
4802
+
4803
+ # Represents an +yield+ keyword
4804
+ class Yield < Node
4805
+ # A list of arguments given to +yield+
4806
+ #
4807
+ # @return [::Array<Node>]
4808
+ attr_reader :args
4809
+
4810
+ # Location of the +yield+ keyword
4811
+ #
4812
+ # @example
4813
+ # yield 1, 2
4814
+ # ~~~~~
4815
+ #
4816
+ #
4817
+ # @return [Loc]
4818
+ attr_reader :keyword_l
4819
+
4820
+ # Location of the open parenthesis
4821
+ #
4822
+ # @example
4823
+ # yield(1, 2)
4824
+ # ~
4825
+ #
4826
+ # +None+ if there are no parentheses
4827
+ #
4828
+ # @return [Loc, nil]
4829
+ attr_reader :begin_l
4830
+
4831
+ # Location of the closing parenthesis
4832
+ #
4833
+ # @example
4834
+ # yield(1, 2)
4835
+ # ~
4836
+ #
4837
+ # +None+ if there are no parentheses
4838
+ #
4839
+ # @return [Loc, nil]
4840
+ attr_reader :end_l
4841
+
4842
+ # Location of the full expression
4843
+ #
4844
+ # @example
4845
+ # yield(1, 2)
4846
+ # ~~~~~~~~~~~
4847
+ #
4848
+ #
4849
+ # @return [Loc]
4850
+ attr_reader :expression_l
4851
+
4852
+ end
4853
+
4854
+ # Represents a +super+ call without arguments and parentheses
4855
+ #
4856
+ # It's different from +super()+ as it implicitly forwards current arguments
4857
+ class ZSuper < Node
4858
+ # Location of the +super+ keyword
4859
+ #
4860
+ # @example
4861
+ # super
4862
+ # ~~~~~
4863
+ #
4864
+ #
4865
+ # @return [Loc]
4866
+ attr_reader :expression_l
4867
+
4868
+ end
4869
+
4870
+ end
4871
+ end