[ruby/yarp] Consistently place block arguments on block slot for call
https://github.com/ruby/yarp/commit/fe208302e5
This commit is contained in:
parent
c7875340be
commit
2531ba4ba0
@ -364,12 +364,9 @@ module YARP
|
||||
nil,
|
||||
Location(),
|
||||
Location(),
|
||||
ArgumentsNode([
|
||||
BlockArgumentNode(expression("block"), Location()),
|
||||
expression("foo")
|
||||
]),
|
||||
ArgumentsNode([expression("foo")]),
|
||||
Location(),
|
||||
nil,
|
||||
BlockArgumentNode(expression("block"), Location()),
|
||||
0,
|
||||
"a"
|
||||
)
|
||||
|
@ -68,7 +68,7 @@ module YARP
|
||||
end
|
||||
|
||||
def test_BlockArgumentNode
|
||||
assert_location(BlockArgumentNode, "foo(&bar)", 4...8) { |node| node.arguments.arguments.last }
|
||||
assert_location(BlockArgumentNode, "foo(&bar)", 4...8, &:block)
|
||||
end
|
||||
|
||||
def test_BlockLocalVariableNode
|
||||
|
@ -135,10 +135,10 @@
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (71...74) = "Foo"
|
||||
│ ├── opening_loc: ∅
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (75...79))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (75...79))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (75...79))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (76...79))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -151,8 +151,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "bar"
|
||||
│ │ └── operator_loc: (75...76) = "&"
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "Foo"
|
||||
├── @ CallNode (location: (81...94))
|
||||
@ -218,10 +216,10 @@
|
||||
│ ├── call_operator_loc: (115...117) = "::"
|
||||
│ ├── message_loc: (117...120) = "Bar"
|
||||
│ ├── opening_loc: ∅
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (121...125))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (121...125))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (121...125))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (122...125))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -234,8 +232,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "baz"
|
||||
│ │ └── operator_loc: (121...122) = "&"
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "Bar"
|
||||
├── @ CallNode (location: (127...135))
|
||||
|
@ -267,15 +267,15 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "a?"
|
||||
├── @ CallNode (location: (108...117))
|
||||
├── @ CallNode (location: (108...116))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (108...109) = "a"
|
||||
│ ├── opening_loc: (109...110) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (110...116))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (110...116))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: (116...117) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (110...116))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (111...116))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -288,8 +288,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "block"
|
||||
│ │ └── operator_loc: (110...111) = "&"
|
||||
│ ├── closing_loc: (116...117) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "a"
|
||||
├── @ CallNode (location: (119...130))
|
||||
@ -751,59 +749,61 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (300...340))
|
||||
├── @ CallNode (location: (300...339))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (300...303) = "foo"
|
||||
│ ├── opening_loc: (303...304) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (304...339))
|
||||
│ │ └── arguments: (length: 3)
|
||||
│ │ @ ArgumentsNode (location: (304...332))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ SymbolNode (location: (304...306))
|
||||
│ │ │ ├── opening_loc: (304...305) = ":"
|
||||
│ │ │ ├── value_loc: (305...306) = "a"
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "a"
|
||||
│ │ ├── @ KeywordHashNode (location: (308...332))
|
||||
│ │ │ └── elements: (length: 2)
|
||||
│ │ │ ├── @ AssocNode (location: (308...322))
|
||||
│ │ │ │ ├── key:
|
||||
│ │ │ │ │ @ SymbolNode (location: (308...310))
|
||||
│ │ │ │ │ ├── opening_loc: (308...309) = ":"
|
||||
│ │ │ │ │ ├── value_loc: (309...310) = "h"
|
||||
│ │ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ │ └── unescaped: "h"
|
||||
│ │ │ │ ├── value:
|
||||
│ │ │ │ │ @ ArrayNode (location: (314...322))
|
||||
│ │ │ │ │ ├── elements: (length: 2)
|
||||
│ │ │ │ │ │ ├── @ SymbolNode (location: (315...317))
|
||||
│ │ │ │ │ │ │ ├── opening_loc: (315...316) = ":"
|
||||
│ │ │ │ │ │ │ ├── value_loc: (316...317) = "x"
|
||||
│ │ │ │ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ │ │ │ └── unescaped: "x"
|
||||
│ │ │ │ │ │ └── @ SymbolNode (location: (319...321))
|
||||
│ │ │ │ │ │ ├── opening_loc: (319...320) = ":"
|
||||
│ │ │ │ │ │ ├── value_loc: (320...321) = "y"
|
||||
│ │ │ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ │ │ └── unescaped: "y"
|
||||
│ │ │ │ │ ├── opening_loc: (314...315) = "["
|
||||
│ │ │ │ │ └── closing_loc: (321...322) = "]"
|
||||
│ │ │ │ └── operator_loc: (311...313) = "=>"
|
||||
│ │ │ └── @ AssocNode (location: (324...332))
|
||||
│ │ └── @ KeywordHashNode (location: (308...332))
|
||||
│ │ └── elements: (length: 2)
|
||||
│ │ ├── @ AssocNode (location: (308...322))
|
||||
│ │ │ ├── key:
|
||||
│ │ │ │ @ SymbolNode (location: (324...326))
|
||||
│ │ │ │ ├── opening_loc: (324...325) = ":"
|
||||
│ │ │ │ ├── value_loc: (325...326) = "a"
|
||||
│ │ │ │ @ SymbolNode (location: (308...310))
|
||||
│ │ │ │ ├── opening_loc: (308...309) = ":"
|
||||
│ │ │ │ ├── value_loc: (309...310) = "h"
|
||||
│ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ └── unescaped: "a"
|
||||
│ │ │ │ └── unescaped: "h"
|
||||
│ │ │ ├── value:
|
||||
│ │ │ │ @ SymbolNode (location: (330...332))
|
||||
│ │ │ │ ├── opening_loc: (330...331) = ":"
|
||||
│ │ │ │ ├── value_loc: (331...332) = "b"
|
||||
│ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ └── unescaped: "b"
|
||||
│ │ │ └── operator_loc: (327...329) = "=>"
|
||||
│ │ └── @ BlockArgumentNode (location: (334...339))
|
||||
│ │ │ │ @ ArrayNode (location: (314...322))
|
||||
│ │ │ │ ├── elements: (length: 2)
|
||||
│ │ │ │ │ ├── @ SymbolNode (location: (315...317))
|
||||
│ │ │ │ │ │ ├── opening_loc: (315...316) = ":"
|
||||
│ │ │ │ │ │ ├── value_loc: (316...317) = "x"
|
||||
│ │ │ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ │ │ └── unescaped: "x"
|
||||
│ │ │ │ │ └── @ SymbolNode (location: (319...321))
|
||||
│ │ │ │ │ ├── opening_loc: (319...320) = ":"
|
||||
│ │ │ │ │ ├── value_loc: (320...321) = "y"
|
||||
│ │ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ │ └── unescaped: "y"
|
||||
│ │ │ │ ├── opening_loc: (314...315) = "["
|
||||
│ │ │ │ └── closing_loc: (321...322) = "]"
|
||||
│ │ │ └── operator_loc: (311...313) = "=>"
|
||||
│ │ └── @ AssocNode (location: (324...332))
|
||||
│ │ ├── key:
|
||||
│ │ │ @ SymbolNode (location: (324...326))
|
||||
│ │ │ ├── opening_loc: (324...325) = ":"
|
||||
│ │ │ ├── value_loc: (325...326) = "a"
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "a"
|
||||
│ │ ├── value:
|
||||
│ │ │ @ SymbolNode (location: (330...332))
|
||||
│ │ │ ├── opening_loc: (330...331) = ":"
|
||||
│ │ │ ├── value_loc: (331...332) = "b"
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "b"
|
||||
│ │ └── operator_loc: (327...329) = "=>"
|
||||
│ ├── closing_loc: (339...340) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (334...339))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ SymbolNode (location: (335...339))
|
||||
│ │ │ ├── opening_loc: (335...336) = ":"
|
||||
@ -811,8 +811,6 @@
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "bar"
|
||||
│ │ └── operator_loc: (334...335) = "&"
|
||||
│ ├── closing_loc: (339...340) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (342...391))
|
||||
@ -1063,39 +1061,41 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "hi"
|
||||
├── @ CallNode (location: (535...571))
|
||||
├── @ CallNode (location: (535...570))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (535...538) = "foo"
|
||||
│ ├── opening_loc: (538...539) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (539...570))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ HashNode (location: (539...561))
|
||||
│ │ │ ├── opening_loc: (539...540) = "{"
|
||||
│ │ │ ├── elements: (length: 2)
|
||||
│ │ │ │ ├── @ AssocNode (location: (541...548))
|
||||
│ │ │ │ │ ├── key:
|
||||
│ │ │ │ │ │ @ SymbolNode (location: (541...543))
|
||||
│ │ │ │ │ │ ├── opening_loc: ∅
|
||||
│ │ │ │ │ │ ├── value_loc: (541...542) = "a"
|
||||
│ │ │ │ │ │ ├── closing_loc: (542...543) = ":"
|
||||
│ │ │ │ │ │ └── unescaped: "a"
|
||||
│ │ │ │ │ ├── value:
|
||||
│ │ │ │ │ │ @ TrueNode (location: (544...548))
|
||||
│ │ │ │ │ └── operator_loc: ∅
|
||||
│ │ │ │ └── @ AssocNode (location: (550...558))
|
||||
│ │ @ ArgumentsNode (location: (539...561))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ HashNode (location: (539...561))
|
||||
│ │ ├── opening_loc: (539...540) = "{"
|
||||
│ │ ├── elements: (length: 2)
|
||||
│ │ │ ├── @ AssocNode (location: (541...548))
|
||||
│ │ │ │ ├── key:
|
||||
│ │ │ │ │ @ SymbolNode (location: (550...552))
|
||||
│ │ │ │ │ @ SymbolNode (location: (541...543))
|
||||
│ │ │ │ │ ├── opening_loc: ∅
|
||||
│ │ │ │ │ ├── value_loc: (550...551) = "b"
|
||||
│ │ │ │ │ ├── closing_loc: (551...552) = ":"
|
||||
│ │ │ │ │ └── unescaped: "b"
|
||||
│ │ │ │ │ ├── value_loc: (541...542) = "a"
|
||||
│ │ │ │ │ ├── closing_loc: (542...543) = ":"
|
||||
│ │ │ │ │ └── unescaped: "a"
|
||||
│ │ │ │ ├── value:
|
||||
│ │ │ │ │ @ FalseNode (location: (553...558))
|
||||
│ │ │ │ │ @ TrueNode (location: (544...548))
|
||||
│ │ │ │ └── operator_loc: ∅
|
||||
│ │ │ └── closing_loc: (560...561) = "}"
|
||||
│ │ └── @ BlockArgumentNode (location: (563...570))
|
||||
│ │ │ └── @ AssocNode (location: (550...558))
|
||||
│ │ │ ├── key:
|
||||
│ │ │ │ @ SymbolNode (location: (550...552))
|
||||
│ │ │ │ ├── opening_loc: ∅
|
||||
│ │ │ │ ├── value_loc: (550...551) = "b"
|
||||
│ │ │ │ ├── closing_loc: (551...552) = ":"
|
||||
│ │ │ │ └── unescaped: "b"
|
||||
│ │ │ ├── value:
|
||||
│ │ │ │ @ FalseNode (location: (553...558))
|
||||
│ │ │ └── operator_loc: ∅
|
||||
│ │ └── closing_loc: (560...561) = "}"
|
||||
│ ├── closing_loc: (570...571) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (563...570))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ SymbolNode (location: (564...570))
|
||||
│ │ │ ├── opening_loc: (564...565) = ":"
|
||||
@ -1103,8 +1103,6 @@
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "block"
|
||||
│ │ └── operator_loc: (563...564) = "&"
|
||||
│ ├── closing_loc: (570...571) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (573...593))
|
||||
@ -1195,10 +1193,10 @@
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (629...632) = "foo"
|
||||
│ ├── opening_loc: ∅
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (633...640))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (633...640))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (633...640))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ SymbolNode (location: (634...640))
|
||||
│ │ │ ├── opening_loc: (634...635) = ":"
|
||||
@ -1206,8 +1204,6 @@
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "block"
|
||||
│ │ └── operator_loc: (633...634) = "&"
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (642...672))
|
||||
@ -1216,31 +1212,33 @@
|
||||
│ ├── message_loc: (642...645) = "foo"
|
||||
│ ├── opening_loc: ∅
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (646...672))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ KeywordHashNode (location: (646...663))
|
||||
│ │ │ └── elements: (length: 2)
|
||||
│ │ │ ├── @ AssocNode (location: (646...653))
|
||||
│ │ │ │ ├── key:
|
||||
│ │ │ │ │ @ SymbolNode (location: (646...648))
|
||||
│ │ │ │ │ ├── opening_loc: ∅
|
||||
│ │ │ │ │ ├── value_loc: (646...647) = "a"
|
||||
│ │ │ │ │ ├── closing_loc: (647...648) = ":"
|
||||
│ │ │ │ │ └── unescaped: "a"
|
||||
│ │ │ │ ├── value:
|
||||
│ │ │ │ │ @ TrueNode (location: (649...653))
|
||||
│ │ │ │ └── operator_loc: ∅
|
||||
│ │ │ └── @ AssocNode (location: (655...663))
|
||||
│ │ @ ArgumentsNode (location: (646...663))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ KeywordHashNode (location: (646...663))
|
||||
│ │ └── elements: (length: 2)
|
||||
│ │ ├── @ AssocNode (location: (646...653))
|
||||
│ │ │ ├── key:
|
||||
│ │ │ │ @ SymbolNode (location: (655...657))
|
||||
│ │ │ │ @ SymbolNode (location: (646...648))
|
||||
│ │ │ │ ├── opening_loc: ∅
|
||||
│ │ │ │ ├── value_loc: (655...656) = "b"
|
||||
│ │ │ │ ├── closing_loc: (656...657) = ":"
|
||||
│ │ │ │ └── unescaped: "b"
|
||||
│ │ │ │ ├── value_loc: (646...647) = "a"
|
||||
│ │ │ │ ├── closing_loc: (647...648) = ":"
|
||||
│ │ │ │ └── unescaped: "a"
|
||||
│ │ │ ├── value:
|
||||
│ │ │ │ @ FalseNode (location: (658...663))
|
||||
│ │ │ │ @ TrueNode (location: (649...653))
|
||||
│ │ │ └── operator_loc: ∅
|
||||
│ │ └── @ BlockArgumentNode (location: (665...672))
|
||||
│ │ └── @ AssocNode (location: (655...663))
|
||||
│ │ ├── key:
|
||||
│ │ │ @ SymbolNode (location: (655...657))
|
||||
│ │ │ ├── opening_loc: ∅
|
||||
│ │ │ ├── value_loc: (655...656) = "b"
|
||||
│ │ │ ├── closing_loc: (656...657) = ":"
|
||||
│ │ │ └── unescaped: "b"
|
||||
│ │ ├── value:
|
||||
│ │ │ @ FalseNode (location: (658...663))
|
||||
│ │ └── operator_loc: ∅
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (665...672))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ SymbolNode (location: (666...672))
|
||||
│ │ │ ├── opening_loc: (666...667) = ":"
|
||||
@ -1248,8 +1246,6 @@
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "block"
|
||||
│ │ └── operator_loc: (665...666) = "&"
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (674...695))
|
||||
|
@ -1,17 +1,17 @@
|
||||
@ ProgramNode (location: (0...7))
|
||||
@ ProgramNode (location: (0...6))
|
||||
├── locals: []
|
||||
└── statements:
|
||||
@ StatementsNode (location: (0...7))
|
||||
@ StatementsNode (location: (0...6))
|
||||
└── body: (length: 1)
|
||||
└── @ CallNode (location: (0...7))
|
||||
└── @ CallNode (location: (0...6))
|
||||
├── receiver: ∅
|
||||
├── call_operator_loc: ∅
|
||||
├── message_loc: (0...1) = "x"
|
||||
├── opening_loc: (1...2) = "("
|
||||
├── arguments:
|
||||
│ @ ArgumentsNode (location: (2...6))
|
||||
│ └── arguments: (length: 1)
|
||||
│ └── @ BlockArgumentNode (location: (2...6))
|
||||
├── arguments: ∅
|
||||
├── closing_loc: (6...7) = ")"
|
||||
├── block:
|
||||
│ @ BlockArgumentNode (location: (2...6))
|
||||
│ ├── expression:
|
||||
│ │ @ CallNode (location: (3...6))
|
||||
│ │ ├── receiver: ∅
|
||||
@ -24,7 +24,5 @@
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "blk"
|
||||
│ └── operator_loc: (2...3) = "&"
|
||||
├── closing_loc: (6...7) = ")"
|
||||
├── block: ∅
|
||||
├── flags: ∅
|
||||
└── name: "x"
|
||||
|
@ -745,15 +745,15 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "=~"
|
||||
├── @ CallNode (location: (464...482))
|
||||
├── @ CallNode (location: (464...481))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (464...467) = "foo"
|
||||
│ ├── opening_loc: (467...468) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (468...481))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (468...481))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: (481...482) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (468...481))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ ParenthesesNode (location: (469...481))
|
||||
│ │ │ ├── body:
|
||||
@ -786,19 +786,17 @@
|
||||
│ │ │ ├── opening_loc: (469...470) = "("
|
||||
│ │ │ └── closing_loc: (480...481) = ")"
|
||||
│ │ └── operator_loc: (468...469) = "&"
|
||||
│ ├── closing_loc: (481...482) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (483...494))
|
||||
├── @ CallNode (location: (483...493))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (483...486) = "foo"
|
||||
│ ├── opening_loc: (486...487) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (487...493))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (487...493))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: (493...494) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (487...493))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (488...493))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -811,32 +809,32 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "block"
|
||||
│ │ └── operator_loc: (487...488) = "&"
|
||||
│ ├── closing_loc: (493...494) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (495...513))
|
||||
├── @ CallNode (location: (495...512))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (495...498) = "foo"
|
||||
│ ├── opening_loc: (498...499) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (499...512))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ SplatNode (location: (499...504))
|
||||
│ │ │ ├── operator_loc: (499...500) = "*"
|
||||
│ │ │ └── expression:
|
||||
│ │ │ @ CallNode (location: (500...504))
|
||||
│ │ │ ├── receiver: ∅
|
||||
│ │ │ ├── call_operator_loc: ∅
|
||||
│ │ │ ├── message_loc: (500...504) = "args"
|
||||
│ │ │ ├── opening_loc: ∅
|
||||
│ │ │ ├── arguments: ∅
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ ├── block: ∅
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "args"
|
||||
│ │ └── @ BlockArgumentNode (location: (506...512))
|
||||
│ │ @ ArgumentsNode (location: (499...504))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ SplatNode (location: (499...504))
|
||||
│ │ ├── operator_loc: (499...500) = "*"
|
||||
│ │ └── expression:
|
||||
│ │ @ CallNode (location: (500...504))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
│ │ ├── message_loc: (500...504) = "args"
|
||||
│ │ ├── opening_loc: ∅
|
||||
│ │ ├── arguments: ∅
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "args"
|
||||
│ ├── closing_loc: (512...513) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (506...512))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (507...512))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -849,8 +847,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "block"
|
||||
│ │ └── operator_loc: (506...507) = "&"
|
||||
│ ├── closing_loc: (512...513) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (514...529))
|
||||
@ -991,7 +987,7 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "foo"
|
||||
├── @ CallNode (location: (583...596))
|
||||
├── @ CallNode (location: (583...595))
|
||||
│ ├── receiver:
|
||||
│ │ @ CallNode (location: (583...586))
|
||||
│ │ ├── receiver: ∅
|
||||
@ -1006,10 +1002,10 @@
|
||||
│ ├── call_operator_loc: (586...587) = "."
|
||||
│ ├── message_loc: (587...590) = "bar"
|
||||
│ ├── opening_loc: (590...591) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (591...595))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (591...595))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: (595...596) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (591...595))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (592...595))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -1022,8 +1018,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "baz"
|
||||
│ │ └── operator_loc: (591...592) = "&"
|
||||
│ ├── closing_loc: (595...596) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "bar"
|
||||
├── @ CallNode (location: (597...623))
|
||||
@ -1164,7 +1158,7 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "bar"
|
||||
├── @ CallNode (location: (659...678))
|
||||
├── @ CallNode (location: (659...677))
|
||||
│ ├── receiver:
|
||||
│ │ @ CallNode (location: (659...662))
|
||||
│ │ ├── receiver: ∅
|
||||
@ -1180,14 +1174,16 @@
|
||||
│ ├── message_loc: (663...666) = "bar"
|
||||
│ ├── opening_loc: (666...667) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (667...677))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ SymbolNode (location: (667...671))
|
||||
│ │ │ ├── opening_loc: (667...668) = ":"
|
||||
│ │ │ ├── value_loc: (668...671) = "baz"
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "baz"
|
||||
│ │ └── @ BlockArgumentNode (location: (673...677))
|
||||
│ │ @ ArgumentsNode (location: (667...671))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ SymbolNode (location: (667...671))
|
||||
│ │ ├── opening_loc: (667...668) = ":"
|
||||
│ │ ├── value_loc: (668...671) = "baz"
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ └── unescaped: "baz"
|
||||
│ ├── closing_loc: (677...678) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (673...677))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (674...677))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -1200,8 +1196,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "baz"
|
||||
│ │ └── operator_loc: (673...674) = "&"
|
||||
│ ├── closing_loc: (677...678) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "bar"
|
||||
├── @ CallNode (location: (679...696))
|
||||
@ -1346,7 +1340,7 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "bar"
|
||||
├── @ CallNode (location: (744...771))
|
||||
├── @ CallNode (location: (744...770))
|
||||
│ ├── receiver:
|
||||
│ │ @ CallNode (location: (744...747))
|
||||
│ │ ├── receiver: ∅
|
||||
@ -1362,8 +1356,8 @@
|
||||
│ ├── message_loc: (748...751) = "bar"
|
||||
│ ├── opening_loc: (751...752) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (752...770))
|
||||
│ │ └── arguments: (length: 3)
|
||||
│ │ @ ArgumentsNode (location: (752...762))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ CallNode (location: (752...755))
|
||||
│ │ │ ├── receiver: ∅
|
||||
│ │ │ ├── call_operator_loc: ∅
|
||||
@ -1374,20 +1368,22 @@
|
||||
│ │ │ ├── block: ∅
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "foo"
|
||||
│ │ ├── @ SplatNode (location: (757...762))
|
||||
│ │ │ ├── operator_loc: (757...758) = "*"
|
||||
│ │ │ └── expression:
|
||||
│ │ │ @ CallNode (location: (758...762))
|
||||
│ │ │ ├── receiver: ∅
|
||||
│ │ │ ├── call_operator_loc: ∅
|
||||
│ │ │ ├── message_loc: (758...762) = "args"
|
||||
│ │ │ ├── opening_loc: ∅
|
||||
│ │ │ ├── arguments: ∅
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ ├── block: ∅
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "args"
|
||||
│ │ └── @ BlockArgumentNode (location: (764...770))
|
||||
│ │ └── @ SplatNode (location: (757...762))
|
||||
│ │ ├── operator_loc: (757...758) = "*"
|
||||
│ │ └── expression:
|
||||
│ │ @ CallNode (location: (758...762))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
│ │ ├── message_loc: (758...762) = "args"
|
||||
│ │ ├── opening_loc: ∅
|
||||
│ │ ├── arguments: ∅
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "args"
|
||||
│ ├── closing_loc: (770...771) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (764...770))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (765...770))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -1400,8 +1396,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "block"
|
||||
│ │ └── operator_loc: (764...765) = "&"
|
||||
│ ├── closing_loc: (770...771) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "bar"
|
||||
├── @ CallNode (location: (772...788))
|
||||
|
@ -21,21 +21,19 @@
|
||||
│ │ ├── name_loc: ∅
|
||||
│ │ └── operator_loc: (8...9) = "&"
|
||||
│ ├── body:
|
||||
│ │ @ StatementsNode (location: (13...19))
|
||||
│ │ @ StatementsNode (location: (13...18))
|
||||
│ │ └── body: (length: 1)
|
||||
│ │ └── @ CallNode (location: (13...19))
|
||||
│ │ └── @ CallNode (location: (13...18))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
│ │ ├── message_loc: (13...16) = "bar"
|
||||
│ │ ├── opening_loc: (16...17) = "("
|
||||
│ │ ├── arguments:
|
||||
│ │ │ @ ArgumentsNode (location: (17...18))
|
||||
│ │ │ └── arguments: (length: 1)
|
||||
│ │ │ └── @ BlockArgumentNode (location: (17...18))
|
||||
│ │ ├── arguments: ∅
|
||||
│ │ ├── closing_loc: (18...19) = ")"
|
||||
│ │ ├── block:
|
||||
│ │ │ @ BlockArgumentNode (location: (17...18))
|
||||
│ │ │ ├── expression: ∅
|
||||
│ │ │ └── operator_loc: (17...18) = "&"
|
||||
│ │ ├── closing_loc: (18...19) = ")"
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: ∅
|
||||
│ │ └── name: "bar"
|
||||
│ ├── locals: [:&]
|
||||
@ -65,21 +63,19 @@
|
||||
│ ├── name_loc: ∅
|
||||
│ └── operator_loc: (36...37) = "&"
|
||||
├── body:
|
||||
│ @ StatementsNode (location: (41...47))
|
||||
│ @ StatementsNode (location: (41...46))
|
||||
│ └── body: (length: 1)
|
||||
│ └── @ CallNode (location: (41...47))
|
||||
│ └── @ CallNode (location: (41...46))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (41...44) = "bar"
|
||||
│ ├── opening_loc: (44...45) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (45...46))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (45...46))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: (46...47) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (45...46))
|
||||
│ │ ├── expression: ∅
|
||||
│ │ └── operator_loc: (45...46) = "&"
|
||||
│ ├── closing_loc: (46...47) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "bar"
|
||||
├── locals: [:a, :&]
|
||||
|
@ -57,58 +57,56 @@
|
||||
│ │ └── name: "b"
|
||||
│ ├── rparen_loc: (33...34) = ")"
|
||||
│ └── block: ∅
|
||||
├── @ SuperNode (location: (35...48))
|
||||
├── @ SuperNode (location: (35...47))
|
||||
│ ├── keyword_loc: (35...40) = "super"
|
||||
│ ├── lparen_loc: (40...41) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (41...47))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (41...47))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (42...47))
|
||||
│ │ │ ├── receiver: ∅
|
||||
│ │ │ ├── call_operator_loc: ∅
|
||||
│ │ │ ├── message_loc: (42...47) = "block"
|
||||
│ │ │ ├── opening_loc: ∅
|
||||
│ │ │ ├── arguments: ∅
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ ├── block: ∅
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "block"
|
||||
│ │ └── operator_loc: (41...42) = "&"
|
||||
│ ├── arguments: ∅
|
||||
│ ├── rparen_loc: (47...48) = ")"
|
||||
│ └── block: ∅
|
||||
├── @ SuperNode (location: (49...65))
|
||||
│ └── block:
|
||||
│ @ BlockArgumentNode (location: (41...47))
|
||||
│ ├── expression:
|
||||
│ │ @ CallNode (location: (42...47))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
│ │ ├── message_loc: (42...47) = "block"
|
||||
│ │ ├── opening_loc: ∅
|
||||
│ │ ├── arguments: ∅
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "block"
|
||||
│ └── operator_loc: (41...42) = "&"
|
||||
├── @ SuperNode (location: (49...64))
|
||||
│ ├── keyword_loc: (49...54) = "super"
|
||||
│ ├── lparen_loc: (54...55) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (55...64))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ CallNode (location: (55...56))
|
||||
│ │ │ ├── receiver: ∅
|
||||
│ │ │ ├── call_operator_loc: ∅
|
||||
│ │ │ ├── message_loc: (55...56) = "a"
|
||||
│ │ │ ├── opening_loc: ∅
|
||||
│ │ │ ├── arguments: ∅
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ ├── block: ∅
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "a"
|
||||
│ │ └── @ BlockArgumentNode (location: (58...64))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (59...64))
|
||||
│ │ │ ├── receiver: ∅
|
||||
│ │ │ ├── call_operator_loc: ∅
|
||||
│ │ │ ├── message_loc: (59...64) = "block"
|
||||
│ │ │ ├── opening_loc: ∅
|
||||
│ │ │ ├── arguments: ∅
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ ├── block: ∅
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "block"
|
||||
│ │ └── operator_loc: (58...59) = "&"
|
||||
│ │ @ ArgumentsNode (location: (55...56))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ CallNode (location: (55...56))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
│ │ ├── message_loc: (55...56) = "a"
|
||||
│ │ ├── opening_loc: ∅
|
||||
│ │ ├── arguments: ∅
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "a"
|
||||
│ ├── rparen_loc: (64...65) = ")"
|
||||
│ └── block: ∅
|
||||
│ └── block:
|
||||
│ @ BlockArgumentNode (location: (58...64))
|
||||
│ ├── expression:
|
||||
│ │ @ CallNode (location: (59...64))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
│ │ ├── message_loc: (59...64) = "block"
|
||||
│ │ ├── opening_loc: ∅
|
||||
│ │ ├── arguments: ∅
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "block"
|
||||
│ └── operator_loc: (58...59) = "&"
|
||||
├── @ SuperNode (location: (66...84))
|
||||
│ ├── keyword_loc: (66...71) = "super"
|
||||
│ ├── lparen_loc: (71...72) = "("
|
||||
|
@ -21,21 +21,19 @@
|
||||
│ ├── name_loc: ∅
|
||||
│ └── operator_loc: (8...9) = "&"
|
||||
├── body:
|
||||
│ @ StatementsNode (location: (12...18))
|
||||
│ @ StatementsNode (location: (12...17))
|
||||
│ └── body: (length: 1)
|
||||
│ └── @ CallNode (location: (12...18))
|
||||
│ └── @ CallNode (location: (12...17))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (12...15) = "bar"
|
||||
│ ├── opening_loc: (15...16) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (16...17))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ BlockArgumentNode (location: (16...17))
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: (17...18) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (16...17))
|
||||
│ │ ├── expression: ∅
|
||||
│ │ └── operator_loc: (16...17) = "&"
|
||||
│ ├── closing_loc: (17...18) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "bar"
|
||||
├── locals: [:&]
|
||||
|
@ -1,7 +1,7 @@
|
||||
@ ProgramNode (location: (0...46))
|
||||
@ ProgramNode (location: (0...45))
|
||||
├── locals: []
|
||||
└── statements:
|
||||
@ StatementsNode (location: (0...46))
|
||||
@ StatementsNode (location: (0...45))
|
||||
└── body: (length: 2)
|
||||
├── @ CallNode (location: (0...19))
|
||||
│ ├── receiver: ∅
|
||||
@ -38,14 +38,14 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "fun"
|
||||
└── @ CallNode (location: (21...46))
|
||||
└── @ CallNode (location: (21...45))
|
||||
├── receiver: ∅
|
||||
├── call_operator_loc: ∅
|
||||
├── message_loc: (21...24) = "fun"
|
||||
├── opening_loc: (24...25) = "("
|
||||
├── arguments:
|
||||
│ @ ArgumentsNode (location: (25...45))
|
||||
│ └── arguments: (length: 3)
|
||||
│ @ ArgumentsNode (location: (25...39))
|
||||
│ └── arguments: (length: 2)
|
||||
│ ├── @ CallNode (location: (25...28))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
@ -56,20 +56,22 @@
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "foo"
|
||||
│ ├── @ KeywordHashNode (location: (30...39))
|
||||
│ │ └── elements: (length: 1)
|
||||
│ │ └── @ AssocNode (location: (30...39))
|
||||
│ │ ├── key:
|
||||
│ │ │ @ SymbolNode (location: (30...34))
|
||||
│ │ │ ├── opening_loc: (30...31) = ":"
|
||||
│ │ │ ├── value_loc: (31...34) = "foo"
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "foo"
|
||||
│ │ ├── value:
|
||||
│ │ │ @ IntegerNode (location: (38...39))
|
||||
│ │ │ └── flags: decimal
|
||||
│ │ └── operator_loc: (35...37) = "=>"
|
||||
│ └── @ BlockArgumentNode (location: (41...45))
|
||||
│ └── @ KeywordHashNode (location: (30...39))
|
||||
│ └── elements: (length: 1)
|
||||
│ └── @ AssocNode (location: (30...39))
|
||||
│ ├── key:
|
||||
│ │ @ SymbolNode (location: (30...34))
|
||||
│ │ ├── opening_loc: (30...31) = ":"
|
||||
│ │ ├── value_loc: (31...34) = "foo"
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ └── unescaped: "foo"
|
||||
│ ├── value:
|
||||
│ │ @ IntegerNode (location: (38...39))
|
||||
│ │ └── flags: decimal
|
||||
│ └── operator_loc: (35...37) = "=>"
|
||||
├── closing_loc: (45...46) = ")"
|
||||
├── block:
|
||||
│ @ BlockArgumentNode (location: (41...45))
|
||||
│ ├── expression:
|
||||
│ │ @ CallNode (location: (42...45))
|
||||
│ │ ├── receiver: ∅
|
||||
@ -82,7 +84,5 @@
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "baz"
|
||||
│ └── operator_loc: (41...42) = "&"
|
||||
├── closing_loc: (45...46) = ")"
|
||||
├── block: ∅
|
||||
├── flags: ∅
|
||||
└── name: "fun"
|
||||
|
@ -1,7 +1,7 @@
|
||||
@ ProgramNode (location: (0...36))
|
||||
@ ProgramNode (location: (0...35))
|
||||
├── locals: []
|
||||
└── statements:
|
||||
@ StatementsNode (location: (0...36))
|
||||
@ StatementsNode (location: (0...35))
|
||||
└── body: (length: 2)
|
||||
├── @ CallNode (location: (0...14))
|
||||
│ ├── receiver: ∅
|
||||
@ -38,14 +38,14 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "fun"
|
||||
└── @ CallNode (location: (16...36))
|
||||
└── @ CallNode (location: (16...35))
|
||||
├── receiver: ∅
|
||||
├── call_operator_loc: ∅
|
||||
├── message_loc: (16...19) = "fun"
|
||||
├── opening_loc: (19...20) = "("
|
||||
├── arguments:
|
||||
│ @ ArgumentsNode (location: (20...35))
|
||||
│ └── arguments: (length: 3)
|
||||
│ @ ArgumentsNode (location: (20...29))
|
||||
│ └── arguments: (length: 2)
|
||||
│ ├── @ CallNode (location: (20...23))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
@ -56,20 +56,22 @@
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "foo"
|
||||
│ ├── @ SplatNode (location: (25...29))
|
||||
│ │ ├── operator_loc: (25...26) = "*"
|
||||
│ │ └── expression:
|
||||
│ │ @ CallNode (location: (26...29))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
│ │ ├── message_loc: (26...29) = "bar"
|
||||
│ │ ├── opening_loc: ∅
|
||||
│ │ ├── arguments: ∅
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "bar"
|
||||
│ └── @ BlockArgumentNode (location: (31...35))
|
||||
│ └── @ SplatNode (location: (25...29))
|
||||
│ ├── operator_loc: (25...26) = "*"
|
||||
│ └── expression:
|
||||
│ @ CallNode (location: (26...29))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (26...29) = "bar"
|
||||
│ ├── opening_loc: ∅
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: variable_call
|
||||
│ └── name: "bar"
|
||||
├── closing_loc: (35...36) = ")"
|
||||
├── block:
|
||||
│ @ BlockArgumentNode (location: (31...35))
|
||||
│ ├── expression:
|
||||
│ │ @ CallNode (location: (32...35))
|
||||
│ │ ├── receiver: ∅
|
||||
@ -82,7 +84,5 @@
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "baz"
|
||||
│ └── operator_loc: (31...32) = "&"
|
||||
├── closing_loc: (35...36) = ")"
|
||||
├── block: ∅
|
||||
├── flags: ∅
|
||||
└── name: "fun"
|
||||
|
@ -28,28 +28,30 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "fun"
|
||||
├── @ CallNode (location: (16...36))
|
||||
├── @ CallNode (location: (16...35))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (16...19) = "fun"
|
||||
│ ├── opening_loc: (19...20) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (20...35))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ KeywordHashNode (location: (20...29))
|
||||
│ │ │ └── elements: (length: 1)
|
||||
│ │ │ └── @ AssocNode (location: (20...29))
|
||||
│ │ │ ├── key:
|
||||
│ │ │ │ @ SymbolNode (location: (20...24))
|
||||
│ │ │ │ ├── opening_loc: (20...21) = ":"
|
||||
│ │ │ │ ├── value_loc: (21...24) = "foo"
|
||||
│ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ └── unescaped: "foo"
|
||||
│ │ │ ├── value:
|
||||
│ │ │ │ @ IntegerNode (location: (28...29))
|
||||
│ │ │ │ └── flags: decimal
|
||||
│ │ │ └── operator_loc: (25...27) = "=>"
|
||||
│ │ └── @ BlockArgumentNode (location: (31...35))
|
||||
│ │ @ ArgumentsNode (location: (20...29))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ KeywordHashNode (location: (20...29))
|
||||
│ │ └── elements: (length: 1)
|
||||
│ │ └── @ AssocNode (location: (20...29))
|
||||
│ │ ├── key:
|
||||
│ │ │ @ SymbolNode (location: (20...24))
|
||||
│ │ │ ├── opening_loc: (20...21) = ":"
|
||||
│ │ │ ├── value_loc: (21...24) = "foo"
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "foo"
|
||||
│ │ ├── value:
|
||||
│ │ │ @ IntegerNode (location: (28...29))
|
||||
│ │ │ └── flags: decimal
|
||||
│ │ └── operator_loc: (25...27) = "=>"
|
||||
│ ├── closing_loc: (35...36) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (31...35))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (32...35))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -62,8 +64,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "baz"
|
||||
│ │ └── operator_loc: (31...32) = "&"
|
||||
│ ├── closing_loc: (35...36) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "fun"
|
||||
├── @ CallNode (location: (38...59))
|
||||
|
@ -28,28 +28,30 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "fun"
|
||||
├── @ CallNode (location: (16...36))
|
||||
├── @ CallNode (location: (16...35))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (16...19) = "fun"
|
||||
│ ├── opening_loc: (19...20) = "("
|
||||
│ ├── arguments:
|
||||
│ │ @ ArgumentsNode (location: (20...35))
|
||||
│ │ └── arguments: (length: 2)
|
||||
│ │ ├── @ KeywordHashNode (location: (20...29))
|
||||
│ │ │ └── elements: (length: 1)
|
||||
│ │ │ └── @ AssocNode (location: (20...29))
|
||||
│ │ │ ├── key:
|
||||
│ │ │ │ @ SymbolNode (location: (20...24))
|
||||
│ │ │ │ ├── opening_loc: (20...21) = ":"
|
||||
│ │ │ │ ├── value_loc: (21...24) = "foo"
|
||||
│ │ │ │ ├── closing_loc: ∅
|
||||
│ │ │ │ └── unescaped: "foo"
|
||||
│ │ │ ├── value:
|
||||
│ │ │ │ @ IntegerNode (location: (28...29))
|
||||
│ │ │ │ └── flags: decimal
|
||||
│ │ │ └── operator_loc: (25...27) = "=>"
|
||||
│ │ └── @ BlockArgumentNode (location: (31...35))
|
||||
│ │ @ ArgumentsNode (location: (20...29))
|
||||
│ │ └── arguments: (length: 1)
|
||||
│ │ └── @ KeywordHashNode (location: (20...29))
|
||||
│ │ └── elements: (length: 1)
|
||||
│ │ └── @ AssocNode (location: (20...29))
|
||||
│ │ ├── key:
|
||||
│ │ │ @ SymbolNode (location: (20...24))
|
||||
│ │ │ ├── opening_loc: (20...21) = ":"
|
||||
│ │ │ ├── value_loc: (21...24) = "foo"
|
||||
│ │ │ ├── closing_loc: ∅
|
||||
│ │ │ └── unescaped: "foo"
|
||||
│ │ ├── value:
|
||||
│ │ │ @ IntegerNode (location: (28...29))
|
||||
│ │ │ └── flags: decimal
|
||||
│ │ └── operator_loc: (25...27) = "=>"
|
||||
│ ├── closing_loc: (35...36) = ")"
|
||||
│ ├── block:
|
||||
│ │ @ BlockArgumentNode (location: (31...35))
|
||||
│ │ ├── expression:
|
||||
│ │ │ @ CallNode (location: (32...35))
|
||||
│ │ │ ├── receiver: ∅
|
||||
@ -62,8 +64,6 @@
|
||||
│ │ │ ├── flags: variable_call
|
||||
│ │ │ └── name: "baz"
|
||||
│ │ └── operator_loc: (31...32) = "&"
|
||||
│ ├── closing_loc: (35...36) = ")"
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "fun"
|
||||
├── @ CallNode (location: (38...59))
|
||||
|
@ -1,17 +1,17 @@
|
||||
@ ProgramNode (location: (0...9))
|
||||
@ ProgramNode (location: (0...8))
|
||||
├── locals: []
|
||||
└── statements:
|
||||
@ StatementsNode (location: (0...9))
|
||||
@ StatementsNode (location: (0...8))
|
||||
└── body: (length: 1)
|
||||
└── @ CallNode (location: (0...9))
|
||||
└── @ CallNode (location: (0...8))
|
||||
├── receiver: ∅
|
||||
├── call_operator_loc: ∅
|
||||
├── message_loc: (0...3) = "fun"
|
||||
├── opening_loc: (3...4) = "("
|
||||
├── arguments:
|
||||
│ @ ArgumentsNode (location: (4...8))
|
||||
│ └── arguments: (length: 1)
|
||||
│ └── @ BlockArgumentNode (location: (4...8))
|
||||
├── arguments: ∅
|
||||
├── closing_loc: (8...9) = ")"
|
||||
├── block:
|
||||
│ @ BlockArgumentNode (location: (4...8))
|
||||
│ ├── expression:
|
||||
│ │ @ CallNode (location: (5...8))
|
||||
│ │ ├── receiver: ∅
|
||||
@ -24,7 +24,5 @@
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "bar"
|
||||
│ └── operator_loc: (4...5) = "&"
|
||||
├── closing_loc: (8...9) = ")"
|
||||
├── block: ∅
|
||||
├── flags: ∅
|
||||
└── name: "fun"
|
||||
|
@ -1,7 +1,7 @@
|
||||
@ ProgramNode (location: (0...26))
|
||||
@ ProgramNode (location: (0...25))
|
||||
├── locals: []
|
||||
└── statements:
|
||||
@ StatementsNode (location: (0...26))
|
||||
@ StatementsNode (location: (0...25))
|
||||
└── body: (length: 2)
|
||||
├── @ CallNode (location: (0...9))
|
||||
│ ├── receiver: ∅
|
||||
@ -28,28 +28,30 @@
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: ∅
|
||||
│ └── name: "fun"
|
||||
└── @ CallNode (location: (11...26))
|
||||
└── @ CallNode (location: (11...25))
|
||||
├── receiver: ∅
|
||||
├── call_operator_loc: ∅
|
||||
├── message_loc: (11...14) = "fun"
|
||||
├── opening_loc: (14...15) = "("
|
||||
├── arguments:
|
||||
│ @ ArgumentsNode (location: (15...25))
|
||||
│ └── arguments: (length: 2)
|
||||
│ ├── @ SplatNode (location: (15...19))
|
||||
│ │ ├── operator_loc: (15...16) = "*"
|
||||
│ │ └── expression:
|
||||
│ │ @ CallNode (location: (16...19))
|
||||
│ │ ├── receiver: ∅
|
||||
│ │ ├── call_operator_loc: ∅
|
||||
│ │ ├── message_loc: (16...19) = "bar"
|
||||
│ │ ├── opening_loc: ∅
|
||||
│ │ ├── arguments: ∅
|
||||
│ │ ├── closing_loc: ∅
|
||||
│ │ ├── block: ∅
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "bar"
|
||||
│ └── @ BlockArgumentNode (location: (21...25))
|
||||
│ @ ArgumentsNode (location: (15...19))
|
||||
│ └── arguments: (length: 1)
|
||||
│ └── @ SplatNode (location: (15...19))
|
||||
│ ├── operator_loc: (15...16) = "*"
|
||||
│ └── expression:
|
||||
│ @ CallNode (location: (16...19))
|
||||
│ ├── receiver: ∅
|
||||
│ ├── call_operator_loc: ∅
|
||||
│ ├── message_loc: (16...19) = "bar"
|
||||
│ ├── opening_loc: ∅
|
||||
│ ├── arguments: ∅
|
||||
│ ├── closing_loc: ∅
|
||||
│ ├── block: ∅
|
||||
│ ├── flags: variable_call
|
||||
│ └── name: "bar"
|
||||
├── closing_loc: (25...26) = ")"
|
||||
├── block:
|
||||
│ @ BlockArgumentNode (location: (21...25))
|
||||
│ ├── expression:
|
||||
│ │ @ CallNode (location: (22...25))
|
||||
│ │ ├── receiver: ∅
|
||||
@ -62,7 +64,5 @@
|
||||
│ │ ├── flags: variable_call
|
||||
│ │ └── name: "baz"
|
||||
│ └── operator_loc: (21...22) = "&"
|
||||
├── closing_loc: (25...26) = ")"
|
||||
├── block: ∅
|
||||
├── flags: ∅
|
||||
└── name: "fun"
|
||||
|
@ -668,7 +668,6 @@ nodes:
|
||||
type: location?
|
||||
- name: block
|
||||
type: node?
|
||||
kind: BlockNode
|
||||
- name: flags
|
||||
type: flags
|
||||
kind: CallNodeFlags
|
||||
@ -2315,7 +2314,6 @@ nodes:
|
||||
type: location?
|
||||
- name: block
|
||||
type: node?
|
||||
kind: BlockNode
|
||||
comment: |
|
||||
Represents the use of the `super` keyword with parentheses or arguments.
|
||||
|
||||
|
143
yarp/yarp.c
143
yarp/yarp.c
@ -549,11 +549,7 @@ typedef struct {
|
||||
yp_location_t opening_loc;
|
||||
yp_arguments_node_t *arguments;
|
||||
yp_location_t closing_loc;
|
||||
yp_block_node_t *block;
|
||||
|
||||
// This boolean is used to tell if there is an implicit block (i.e., an
|
||||
// argument passed with an & operator).
|
||||
bool implicit_block;
|
||||
yp_node_t *block;
|
||||
} yp_arguments_t;
|
||||
|
||||
#define YP_EMPTY_ARGUMENTS ((yp_arguments_t) { \
|
||||
@ -561,36 +557,37 @@ typedef struct {
|
||||
.arguments = NULL, \
|
||||
.closing_loc = YP_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE, \
|
||||
.block = NULL, \
|
||||
.implicit_block = false \
|
||||
})
|
||||
|
||||
// Check that the set of arguments parsed for a given node is valid. This means
|
||||
// checking that we don't have both an implicit and explicit block.
|
||||
// Check that we're not about to attempt to attach a brace block to a call that
|
||||
// has arguments without parentheses.
|
||||
static void
|
||||
yp_arguments_validate(yp_parser_t *parser, yp_arguments_t *arguments) {
|
||||
if (arguments->block != NULL && arguments->implicit_block) {
|
||||
yp_diagnostic_list_append(
|
||||
&parser->error_list,
|
||||
arguments->block->base.location.start,
|
||||
arguments->block->base.location.end,
|
||||
YP_ERR_ARGUMENT_BLOCK_MULTI
|
||||
);
|
||||
yp_arguments_validate_block(yp_parser_t *parser, yp_arguments_t *arguments, yp_block_node_t *block) {
|
||||
// First, check that we have arguments and that we don't have a closing
|
||||
// location for them.
|
||||
if (arguments->arguments == NULL || arguments->closing_loc.start != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Brace blocks can't be attached to arguments, only to the call
|
||||
if (arguments->block != NULL &&
|
||||
*arguments->block->opening_loc.start == '{' &&
|
||||
arguments->arguments != NULL &&
|
||||
!(arguments->arguments->arguments.size == 1 &&
|
||||
YP_NODE_TYPE_P(arguments->arguments->arguments.nodes[0], YP_PARENTHESES_NODE)) &&
|
||||
!arguments->closing_loc.end) {
|
||||
// Next, check that we don't have a single parentheses argument. This would
|
||||
// look like:
|
||||
//
|
||||
// foo (1) {}
|
||||
//
|
||||
// In this case, it's actually okay for the block to be attached to the
|
||||
// call, even though it looks like it's attached to the argument.
|
||||
if (arguments->arguments->arguments.size == 1 && YP_NODE_TYPE_P(arguments->arguments->arguments.nodes[0], YP_PARENTHESES_NODE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we didn't hit a case before this check, then at this point we need to
|
||||
// add a syntax error.
|
||||
yp_diagnostic_list_append(
|
||||
&parser->error_list,
|
||||
arguments->block->base.location.start,
|
||||
arguments->block->base.location.end,
|
||||
YP_ERR_ARGUMENT_BLOCK_MULTI
|
||||
block->base.location.start,
|
||||
block->base.location.end,
|
||||
YP_ERR_ARGUMENT_UNEXPECTED_BLOCK
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@ -1340,7 +1337,7 @@ yp_call_node_aref_create(yp_parser_t *parser, yp_node_t *receiver, yp_arguments_
|
||||
|
||||
node->base.location.start = receiver->location.start;
|
||||
if (arguments->block != NULL) {
|
||||
node->base.location.end = arguments->block->base.location.end;
|
||||
node->base.location.end = arguments->block->location.end;
|
||||
} else {
|
||||
node->base.location.end = arguments->closing_loc.end;
|
||||
}
|
||||
@ -1384,7 +1381,7 @@ yp_call_node_call_create(yp_parser_t *parser, yp_node_t *receiver, yp_token_t *o
|
||||
|
||||
node->base.location.start = receiver->location.start;
|
||||
if (arguments->block != NULL) {
|
||||
node->base.location.end = arguments->block->base.location.end;
|
||||
node->base.location.end = arguments->block->location.end;
|
||||
} else if (arguments->closing_loc.start != NULL) {
|
||||
node->base.location.end = arguments->closing_loc.end;
|
||||
} else if (arguments->arguments != NULL) {
|
||||
@ -1417,7 +1414,7 @@ yp_call_node_fcall_create(yp_parser_t *parser, yp_token_t *message, yp_arguments
|
||||
|
||||
node->base.location.start = message->start;
|
||||
if (arguments->block != NULL) {
|
||||
node->base.location.end = arguments->block->base.location.end;
|
||||
node->base.location.end = arguments->block->location.end;
|
||||
} else if (arguments->closing_loc.start != NULL) {
|
||||
node->base.location.end = arguments->closing_loc.end;
|
||||
} else if (arguments->arguments != NULL) {
|
||||
@ -1465,7 +1462,7 @@ yp_call_node_shorthand_create(yp_parser_t *parser, yp_node_t *receiver, yp_token
|
||||
|
||||
node->base.location.start = receiver->location.start;
|
||||
if (arguments->block != NULL) {
|
||||
node->base.location.end = arguments->block->base.location.end;
|
||||
node->base.location.end = arguments->block->location.end;
|
||||
} else {
|
||||
node->base.location.end = arguments->closing_loc.end;
|
||||
}
|
||||
@ -2414,18 +2411,24 @@ yp_forwarding_parameter_node_create(yp_parser_t *parser, const yp_token_t *token
|
||||
// Allocate and initialize a new ForwardingSuper node.
|
||||
static yp_forwarding_super_node_t *
|
||||
yp_forwarding_super_node_create(yp_parser_t *parser, const yp_token_t *token, yp_arguments_t *arguments) {
|
||||
assert(arguments->block == NULL || YP_NODE_TYPE_P(arguments->block, YP_BLOCK_NODE));
|
||||
assert(token->type == YP_TOKEN_KEYWORD_SUPER);
|
||||
yp_forwarding_super_node_t *node = YP_ALLOC_NODE(parser, yp_forwarding_super_node_t);
|
||||
|
||||
yp_block_node_t *block = NULL;
|
||||
if (arguments->block != NULL) {
|
||||
block = (yp_block_node_t *) arguments->block;
|
||||
}
|
||||
|
||||
*node = (yp_forwarding_super_node_t) {
|
||||
{
|
||||
.type = YP_FORWARDING_SUPER_NODE,
|
||||
.location = {
|
||||
.start = token->start,
|
||||
.end = arguments->block != NULL ? arguments->block->base.location.end : token->end
|
||||
.end = block != NULL ? block->base.location.end : token->end
|
||||
},
|
||||
},
|
||||
.block = arguments->block
|
||||
.block = block
|
||||
};
|
||||
|
||||
return node;
|
||||
@ -4282,7 +4285,7 @@ yp_super_node_create(yp_parser_t *parser, const yp_token_t *keyword, yp_argument
|
||||
|
||||
const uint8_t *end;
|
||||
if (arguments->block != NULL) {
|
||||
end = arguments->block->base.location.end;
|
||||
end = arguments->block->location.end;
|
||||
} else if (arguments->closing_loc.start != NULL) {
|
||||
end = arguments->closing_loc.end;
|
||||
} else if (arguments->arguments != NULL) {
|
||||
@ -8894,6 +8897,16 @@ parse_assocs(yp_parser_t *parser, yp_node_t *node) {
|
||||
}
|
||||
}
|
||||
|
||||
// Append an argument to a list of arguments.
|
||||
static inline void
|
||||
parse_arguments_append(yp_parser_t *parser, yp_arguments_t *arguments, yp_node_t *argument) {
|
||||
if (arguments->arguments == NULL) {
|
||||
arguments->arguments = yp_arguments_node_create(parser);
|
||||
}
|
||||
|
||||
yp_arguments_node_arguments_append(arguments->arguments, argument);
|
||||
}
|
||||
|
||||
// Parse a list of arguments.
|
||||
static void
|
||||
parse_arguments(yp_parser_t *parser, yp_arguments_t *arguments, bool accepts_forwarding, yp_token_type_t terminator) {
|
||||
@ -8927,13 +8940,14 @@ parse_arguments(yp_parser_t *parser, yp_arguments_t *arguments, bool accepts_for
|
||||
}
|
||||
|
||||
yp_keyword_hash_node_t *hash = yp_keyword_hash_node_create(parser);
|
||||
argument = (yp_node_t *)hash;
|
||||
argument = (yp_node_t *) hash;
|
||||
|
||||
if (!match7(parser, terminator, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON, YP_TOKEN_EOF, YP_TOKEN_BRACE_RIGHT, YP_TOKEN_KEYWORD_DO, YP_TOKEN_PARENTHESIS_RIGHT)) {
|
||||
parse_assocs(parser, (yp_node_t *) hash);
|
||||
}
|
||||
|
||||
parsed_bare_hash = true;
|
||||
parse_arguments_append(parser, arguments, argument);
|
||||
break;
|
||||
}
|
||||
case YP_TOKEN_UAMPERSAND: {
|
||||
@ -8947,9 +8961,14 @@ parse_arguments(yp_parser_t *parser, yp_arguments_t *arguments, bool accepts_for
|
||||
yp_diagnostic_list_append(&parser->error_list, operator.start, operator.end, YP_ERR_ARGUMENT_NO_FORWARDING_AMP);
|
||||
}
|
||||
|
||||
argument = (yp_node_t *)yp_block_argument_node_create(parser, &operator, expression);
|
||||
argument = (yp_node_t *) yp_block_argument_node_create(parser, &operator, expression);
|
||||
if (parsed_block_argument) {
|
||||
parse_arguments_append(parser, arguments, argument);
|
||||
} else {
|
||||
arguments->block = argument;
|
||||
}
|
||||
|
||||
parsed_block_argument = true;
|
||||
arguments->implicit_block = true;
|
||||
break;
|
||||
}
|
||||
case YP_TOKEN_USTAR: {
|
||||
@ -8972,6 +8991,7 @@ parse_arguments(yp_parser_t *parser, yp_arguments_t *arguments, bool accepts_for
|
||||
argument = (yp_node_t *) yp_splat_node_create(parser, &operator, expression);
|
||||
}
|
||||
|
||||
parse_arguments_append(parser, arguments, argument);
|
||||
break;
|
||||
}
|
||||
case YP_TOKEN_UDOT_DOT_DOT: {
|
||||
@ -8989,7 +9009,8 @@ parse_arguments(yp_parser_t *parser, yp_arguments_t *arguments, bool accepts_for
|
||||
yp_diagnostic_list_append(&parser->error_list, parser->previous.start, parser->previous.end, YP_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES);
|
||||
}
|
||||
|
||||
argument = (yp_node_t *)yp_forwarding_arguments_node_create(parser, &parser->previous);
|
||||
argument = (yp_node_t *) yp_forwarding_arguments_node_create(parser, &parser->previous);
|
||||
parse_arguments_append(parser, arguments, argument);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -9032,12 +9053,11 @@ parse_arguments(yp_parser_t *parser, yp_arguments_t *arguments, bool accepts_for
|
||||
parsed_bare_hash = true;
|
||||
}
|
||||
|
||||
parse_arguments_append(parser, arguments, argument);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
yp_arguments_node_arguments_append(arguments->arguments, argument);
|
||||
|
||||
// If parsing the argument failed, we need to stop parsing arguments.
|
||||
if (YP_NODE_TYPE_P(argument, YP_MISSING_NODE) || parser->recovering) break;
|
||||
|
||||
@ -9737,8 +9757,6 @@ parse_arguments_list(yp_parser_t *parser, yp_arguments_t *arguments, bool accept
|
||||
if (accept1(parser, YP_TOKEN_PARENTHESIS_RIGHT)) {
|
||||
arguments->closing_loc = YP_LOCATION_TOKEN_VALUE(&parser->previous);
|
||||
} else {
|
||||
arguments->arguments = yp_arguments_node_create(parser);
|
||||
|
||||
yp_accepts_block_stack_push(parser, true);
|
||||
parse_arguments(parser, arguments, true, YP_TOKEN_PARENTHESIS_RIGHT);
|
||||
expect1(parser, YP_TOKEN_PARENTHESIS_RIGHT, YP_ERR_ARGUMENT_TERM_PAREN);
|
||||
@ -9753,7 +9771,6 @@ parse_arguments_list(yp_parser_t *parser, yp_arguments_t *arguments, bool accept
|
||||
// If we get here, then the subsequent token cannot be used as an infix
|
||||
// operator. In this case we assume the subsequent token is part of an
|
||||
// argument to this method call.
|
||||
arguments->arguments = yp_arguments_node_create(parser);
|
||||
parse_arguments(parser, arguments, true, YP_TOKEN_EOF);
|
||||
|
||||
yp_accepts_block_stack_pop(parser);
|
||||
@ -9763,16 +9780,28 @@ parse_arguments_list(yp_parser_t *parser, yp_arguments_t *arguments, bool accept
|
||||
// node that starts with a {. If there is, then we can parse it and add it to
|
||||
// the arguments.
|
||||
if (accepts_block) {
|
||||
yp_block_node_t *block = NULL;
|
||||
|
||||
if (accept1(parser, YP_TOKEN_BRACE_LEFT)) {
|
||||
found |= true;
|
||||
arguments->block = parse_block(parser);
|
||||
block = parse_block(parser);
|
||||
yp_arguments_validate_block(parser, arguments, block);
|
||||
} else if (yp_accepts_block_stack_p(parser) && accept1(parser, YP_TOKEN_KEYWORD_DO)) {
|
||||
found |= true;
|
||||
arguments->block = parse_block(parser);
|
||||
block = parse_block(parser);
|
||||
}
|
||||
|
||||
if (block != NULL) {
|
||||
if (arguments->block == NULL) {
|
||||
arguments->block = (yp_node_t *) block;
|
||||
} else {
|
||||
yp_diagnostic_list_append(&parser->error_list, block->base.location.start, block->base.location.end, YP_ERR_ARGUMENT_BLOCK_MULTI);
|
||||
yp_arguments_node_arguments_append(arguments->arguments, arguments->block);
|
||||
arguments->block = (yp_node_t *) block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yp_arguments_validate(parser, arguments);
|
||||
return found;
|
||||
}
|
||||
|
||||
@ -11706,7 +11735,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
|
||||
call->block = arguments.block;
|
||||
|
||||
if (arguments.block != NULL) {
|
||||
call->base.location.end = arguments.block->base.location.end;
|
||||
call->base.location.end = arguments.block->location.end;
|
||||
} else if (arguments.closing_loc.start == NULL) {
|
||||
if (arguments.arguments != NULL) {
|
||||
call->base.location.end = arguments.arguments->base.location.end;
|
||||
@ -12125,7 +12154,6 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
|
||||
yp_binding_power_t binding_power = yp_binding_powers[parser->current.type].left;
|
||||
|
||||
if (binding_power == YP_BINDING_POWER_UNSET || binding_power >= YP_BINDING_POWER_RANGE) {
|
||||
arguments.arguments = yp_arguments_node_create(parser);
|
||||
parse_arguments(parser, &arguments, false, YP_TOKEN_EOF);
|
||||
}
|
||||
}
|
||||
@ -14083,11 +14111,8 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
|
||||
|
||||
if (!accept1(parser, YP_TOKEN_BRACKET_RIGHT)) {
|
||||
yp_accepts_block_stack_push(parser, true);
|
||||
arguments.arguments = yp_arguments_node_create(parser);
|
||||
|
||||
parse_arguments(parser, &arguments, false, YP_TOKEN_BRACKET_RIGHT);
|
||||
yp_accepts_block_stack_pop(parser);
|
||||
|
||||
expect1(parser, YP_TOKEN_BRACKET_RIGHT, YP_ERR_EXPECT_RBRACKET);
|
||||
}
|
||||
|
||||
@ -14103,13 +14128,23 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
|
||||
// If we're at the end of the arguments, we can now check if there is a
|
||||
// block node that starts with a {. If there is, then we can parse it and
|
||||
// add it to the arguments.
|
||||
yp_block_node_t *block = NULL;
|
||||
if (accept1(parser, YP_TOKEN_BRACE_LEFT)) {
|
||||
arguments.block = parse_block(parser);
|
||||
block = parse_block(parser);
|
||||
yp_arguments_validate_block(parser, &arguments, block);
|
||||
} else if (yp_accepts_block_stack_p(parser) && accept1(parser, YP_TOKEN_KEYWORD_DO)) {
|
||||
arguments.block = parse_block(parser);
|
||||
block = parse_block(parser);
|
||||
}
|
||||
|
||||
if (block != NULL) {
|
||||
if (arguments.block != NULL) {
|
||||
yp_diagnostic_list_append(&parser->error_list, block->base.location.start, block->base.location.end, YP_ERR_ARGUMENT_AFTER_BLOCK);
|
||||
yp_arguments_node_arguments_append(arguments.arguments, arguments.block);
|
||||
}
|
||||
|
||||
arguments.block = (yp_node_t *) block;
|
||||
}
|
||||
|
||||
yp_arguments_validate(parser, &arguments);
|
||||
return (yp_node_t *) yp_call_node_aref_create(parser, node, &arguments);
|
||||
}
|
||||
case YP_TOKEN_KEYWORD_IN: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user