From 0d33bc0cde5b9eca805cec1133e2c48ebdea5c84 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 11 Sep 2023 15:26:42 -0400 Subject: [ruby/yarp] Simplify multi-target parsing This simplifies how we handle multi-targets, and also fixes a bug we had where for loops were always getting multi-targets, even when there was only a single target. https://github.com/ruby/yarp/commit/31eb8b7ad5 --- test/yarp/snapshots/for.txt | 40 +++++++--------------- .../yarp/snapshots/unparser/corpus/literal/for.txt | 20 ++++------- test/yarp/snapshots/whitequark/for.txt | 20 ++++------- 3 files changed, 24 insertions(+), 56 deletions(-) (limited to 'test/yarp/snapshots') diff --git a/test/yarp/snapshots/for.txt b/test/yarp/snapshots/for.txt index 3475d585e2..e8b3868b7b 100644 --- a/test/yarp/snapshots/for.txt +++ b/test/yarp/snapshots/for.txt @@ -5,13 +5,9 @@ └── body: (length: 6) ├── @ ForNode (location: (0...20)) │ ├── index: - │ │ @ MultiTargetNode (location: (4...5)) - │ │ ├── targets: (length: 1) - │ │ │ └── @ LocalVariableTargetNode (location: (4...5)) - │ │ │ ├── name: :i - │ │ │ └── depth: 0 - │ │ ├── lparen_loc: ∅ - │ │ └── rparen_loc: ∅ + │ │ @ LocalVariableTargetNode (location: (4...5)) + │ │ ├── name: :i + │ │ └── depth: 0 │ ├── collection: │ │ @ RangeNode (location: (9...14)) │ │ ├── left: @@ -34,13 +30,9 @@ │ └── end_keyword_loc: (17...20) = "end" ├── @ ForNode (location: (22...44)) │ ├── index: - │ │ @ MultiTargetNode (location: (26...27)) - │ │ ├── targets: (length: 1) - │ │ │ └── @ LocalVariableTargetNode (location: (26...27)) - │ │ │ ├── name: :i - │ │ │ └── depth: 0 - │ │ ├── lparen_loc: ∅ - │ │ └── rparen_loc: ∅ + │ │ @ LocalVariableTargetNode (location: (26...27)) + │ │ ├── name: :i + │ │ └── depth: 0 │ ├── collection: │ │ @ RangeNode (location: (31...36)) │ │ ├── left: @@ -130,13 +122,9 @@ │ └── end_keyword_loc: (91...94) = "end" ├── @ ForNode (location: (96...119)) │ ├── index: - │ │ @ MultiTargetNode (location: (100...101)) - │ │ ├── targets: (length: 1) - │ │ │ └── @ LocalVariableTargetNode (location: (100...101)) - │ │ │ ├── name: :i - │ │ │ └── depth: 0 - │ │ ├── lparen_loc: ∅ - │ │ └── rparen_loc: ∅ + │ │ @ LocalVariableTargetNode (location: (100...101)) + │ │ ├── name: :i + │ │ └── depth: 0 │ ├── collection: │ │ @ RangeNode (location: (105...110)) │ │ ├── left: @@ -159,13 +147,9 @@ │ └── end_keyword_loc: (116...119) = "end" └── @ ForNode (location: (121...143)) ├── index: - │ @ MultiTargetNode (location: (125...126)) - │ ├── targets: (length: 1) - │ │ └── @ LocalVariableTargetNode (location: (125...126)) - │ │ ├── name: :i - │ │ └── depth: 0 - │ ├── lparen_loc: ∅ - │ └── rparen_loc: ∅ + │ @ LocalVariableTargetNode (location: (125...126)) + │ ├── name: :i + │ └── depth: 0 ├── collection: │ @ RangeNode (location: (130...135)) │ ├── left: diff --git a/test/yarp/snapshots/unparser/corpus/literal/for.txt b/test/yarp/snapshots/unparser/corpus/literal/for.txt index 682c2bcb14..62fde3418d 100644 --- a/test/yarp/snapshots/unparser/corpus/literal/for.txt +++ b/test/yarp/snapshots/unparser/corpus/literal/for.txt @@ -13,13 +13,9 @@ │ │ └── arguments: (length: 1) │ │ └── @ ForNode (location: (4...29)) │ │ ├── index: - │ │ │ @ MultiTargetNode (location: (8...9)) - │ │ │ ├── targets: (length: 1) - │ │ │ │ └── @ LocalVariableTargetNode (location: (8...9)) - │ │ │ │ ├── name: :a - │ │ │ │ └── depth: 0 - │ │ │ ├── lparen_loc: ∅ - │ │ │ └── rparen_loc: ∅ + │ │ │ @ LocalVariableTargetNode (location: (8...9)) + │ │ │ ├── name: :a + │ │ │ └── depth: 0 │ │ ├── collection: │ │ │ @ CallNode (location: (13...16)) │ │ │ ├── receiver: ∅ @@ -54,13 +50,9 @@ │ └── name: "bar" ├── @ ForNode (location: (31...56)) │ ├── index: - │ │ @ MultiTargetNode (location: (35...36)) - │ │ ├── targets: (length: 1) - │ │ │ └── @ LocalVariableTargetNode (location: (35...36)) - │ │ │ ├── name: :a - │ │ │ └── depth: 0 - │ │ ├── lparen_loc: ∅ - │ │ └── rparen_loc: ∅ + │ │ @ LocalVariableTargetNode (location: (35...36)) + │ │ ├── name: :a + │ │ └── depth: 0 │ ├── collection: │ │ @ CallNode (location: (40...43)) │ │ ├── receiver: ∅ diff --git a/test/yarp/snapshots/whitequark/for.txt b/test/yarp/snapshots/whitequark/for.txt index daf73081e6..285dadd26d 100644 --- a/test/yarp/snapshots/whitequark/for.txt +++ b/test/yarp/snapshots/whitequark/for.txt @@ -5,13 +5,9 @@ └── body: (length: 2) ├── @ ForNode (location: (0...24)) │ ├── index: - │ │ @ MultiTargetNode (location: (4...5)) - │ │ ├── targets: (length: 1) - │ │ │ └── @ LocalVariableTargetNode (location: (4...5)) - │ │ │ ├── name: :a - │ │ │ └── depth: 0 - │ │ ├── lparen_loc: ∅ - │ │ └── rparen_loc: ∅ + │ │ @ LocalVariableTargetNode (location: (4...5)) + │ │ ├── name: :a + │ │ └── depth: 0 │ ├── collection: │ │ @ CallNode (location: (9...12)) │ │ ├── receiver: ∅ @@ -47,13 +43,9 @@ │ └── end_keyword_loc: (21...24) = "end" └── @ ForNode (location: (26...48)) ├── index: - │ @ MultiTargetNode (location: (30...31)) - │ ├── targets: (length: 1) - │ │ └── @ LocalVariableTargetNode (location: (30...31)) - │ │ ├── name: :a - │ │ └── depth: 0 - │ ├── lparen_loc: ∅ - │ └── rparen_loc: ∅ + │ @ LocalVariableTargetNode (location: (30...31)) + │ ├── name: :a + │ └── depth: 0 ├── collection: │ @ CallNode (location: (35...38)) │ ├── receiver: ∅ -- cgit v1.2.3