summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEarlopain <[email protected]>2025-01-15 23:24:05 +0100
committerKevin Newton <[email protected]>2025-03-18 13:36:53 -0400
commitfd7a10cf4a73f27a0113a6bc2a65c4c274ee11ec (patch)
tree788c85bfbff8be7d04934cd3ed54500038da252b
parent5d138f2b436dc84b1efed86ac3328e67638887cb (diff)
[ruby/prism] Further refine string handling in the parser translator
Mostly around newlines and line continuation. * percent arrays need special backslash handling in the ast * Fix offset issue for heredocs with many line continuations (used wrong variable as index access) * More refined rules on when to simplify string tokens * Handle line continuations in squiggly heredocs * Correctly dedent squiggly heredocs with interpolation * Consider `':foo:` and `%s[foo]` to not be interpolation https://github.com/ruby/prism/commit/4edfe9d981
-rw-r--r--lib/prism/translation/parser/compiler.rb13
-rw-r--r--lib/prism/translation/parser/lexer.rb62
-rw-r--r--test/prism/fixtures/strings.txt6
-rw-r--r--test/prism/ruby/parser_test.rb3
-rw-r--r--test/prism/snapshots/heredocs_with_fake_newlines.txt223
-rw-r--r--test/prism/snapshots/strings.txt425
6 files changed, 576 insertions, 156 deletions
diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb
index 83cbe6e0c9..8f6a602c42 100644
--- a/lib/prism/translation/parser/compiler.rb
+++ b/lib/prism/translation/parser/compiler.rb
@@ -1119,6 +1119,7 @@ module Prism
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
=======
parts = if node.parts.one? { |part| part.type == :string_node }
node.parts.flat_map do |node|
@@ -1150,6 +1151,8 @@ module Prism
end
>>>>>>> a651126458 (Fix an incompatibility with the parser translator)
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
builder.string_compose(
token(node.opening_loc),
string_nodes_from_interpolation(node, node.opening),
@@ -2214,9 +2217,13 @@ module Prism
unescaped = unescaped.lines
escaped = escaped.lines
<<<<<<< HEAD
+<<<<<<< HEAD
percent_array = opening&.start_with?("%w", "%W", "%i", "%I")
=======
>>>>>>> 2637007929 (Better handle all kinds of multiline strings in the parser translator)
+=======
+ percent_array = opening&.start_with?("%w", "%W", "%i", "%I")
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
# Non-interpolating strings
if opening&.end_with?("'") || opening&.start_with?("%q", "%s", "%w", "%i")
@@ -2224,6 +2231,9 @@ module Prism
current_line = +""
<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
escaped.filter_map.with_index do |escaped_line, index|
unescaped_line = unescaped.fetch(index, "")
current_length += escaped_line.bytesize
@@ -2238,6 +2248,7 @@ module Prism
current_line = +""
current_length = 0
s
+<<<<<<< HEAD
=======
if opening&.end_with?("'")
escaped.each do |line|
@@ -2245,6 +2256,8 @@ module Prism
normalized_lengths << chomped_bytesize(line)
do_next_tokens << true
>>>>>>> 2637007929 (Better handle all kinds of multiline strings in the parser translator)
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
end
else
escaped_lengths = []
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb
index 687b4f6043..4b7ced7afa 100644
--- a/lib/prism/translation/parser/lexer.rb
+++ b/lib/prism/translation/parser/lexer.rb
@@ -407,6 +407,7 @@ module Prism
=======
if (lines = token.value.lines).one?
+<<<<<<< HEAD
# Heredoc interpolation can have multiple STRING_CONTENT nodes on the same line.
is_first_token_on_line = lexed[index - 1] && token.location.start_line != lexed[index - 2][0].location&.start_line
# The parser gem only removes indentation when the heredoc is not nested
@@ -437,6 +438,25 @@ module Prism
end
<<<<<<< HEAD
+=======
+ # Prism usually emits a single token for strings with line continuations.
+ # For squiggly heredocs they are not joined so we do that manually here.
+ current_string = +""
+ current_length = 0
+ start_offset = token.location.start_offset
+ while token.type == :STRING_CONTENT
+ current_length += token.value.bytesize
+ # Heredoc interpolation can have multiple STRING_CONTENT nodes on the same line.
+ is_first_token_on_line = lexed[index - 1] && token.location.start_line != lexed[index - 2][0].location&.start_line
+ # The parser gem only removes indentation when the heredoc is not nested
+ not_nested = heredoc_stack.size == 1
+ if is_percent_array
+ value = percent_array_unescape(token.value)
+ elsif is_first_token_on_line && not_nested && (current_heredoc = heredoc_stack.last).common_whitespace > 0
+ value = trim_heredoc_whitespace(token.value, current_heredoc)
+ end
+
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
current_string << unescape_string(value, quote_stack.last)
if (backslash_count = token.value[/(\\{1,})\n/, 1]&.length).nil? || backslash_count.even? || !interpolation?(quote_stack.last)
tokens << [:tSTRING_CONTENT, [current_string, range(start_offset, start_offset + current_length)]]
@@ -714,7 +734,40 @@ module Prism
while (skipped = scanner.skip_until(/\\/))
# Append what was just skipped over, excluding the found backslash.
result.append_as_bytes(string.byteslice(scanner.pos - skipped, skipped - 1))
+<<<<<<< HEAD
escape_read(result, scanner, false, false)
+=======
+
+ if scanner.peek(1) == "\n"
+ # Line continuation
+ scanner.pos += 1
+ elsif (replacement = ESCAPES[scanner.peek(1)])
+ # Simple single-character escape sequences like \n
+ result.append_as_bytes(replacement)
+ scanner.pos += 1
+ elsif (octal = scanner.check(/[0-7]{1,3}/))
+ # \nnn
+ result.append_as_bytes(octal.to_i(8).chr)
+ scanner.pos += octal.bytesize
+ elsif (hex = scanner.check(/x([0-9a-fA-F]{1,2})/))
+ # \xnn
+ result.append_as_bytes(hex[1..].to_i(16).chr)
+ scanner.pos += hex.bytesize
+ elsif (unicode = scanner.check(/u([0-9a-fA-F]{4})/))
+ # \unnnn
+ result.append_as_bytes(unicode[1..].hex.chr(Encoding::UTF_8))
+ scanner.pos += unicode.bytesize
+ elsif scanner.peek(3) == "u{}"
+ # https://github.com/whitequark/parser/issues/856
+ scanner.pos += 3
+ elsif (unicode_parts = scanner.check(/u{.*}/))
+ # \u{nnnn ...}
+ unicode_parts[2..-2].split.each do |unicode|
+ result.append_as_bytes(unicode.hex.chr(Encoding::UTF_8))
+ end
+ scanner.pos += unicode_parts.bytesize
+ end
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
end
# Add remaining chars
@@ -727,6 +780,9 @@ module Prism
end
<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
# Certain strings are merged into a single string token.
def simplify_string?(value, quote)
case quote
@@ -744,6 +800,7 @@ module Prism
end
end
+<<<<<<< HEAD
# Escape a byte value, given the control and meta flags.
def escape_build(value, control, meta)
value &= 0x9f if control
@@ -794,6 +851,8 @@ module Prism
=======
>>>>>>> bd3dd2b62a (Fix parser translator tokens for %-arrays with whitespace escapes)
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
# In a percent array, certain whitespace can be preceeded with a backslash,
# causing the following characters to be part of the previous element.
def percent_array_unescape(string)
@@ -818,11 +877,14 @@ module Prism
# Determine if characters preceeded by a backslash should be escaped or not
def interpolation?(quote)
!quote.end_with?("'") && !quote.start_with?("%q", "%w", "%i", "%s")
+<<<<<<< HEAD
end
# Regexp allow interpolation but are handled differently during unescaping
def regexp?(quote)
quote == "/" || quote.start_with?("%r")
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
end
# Regexp allow interpolation but are handled differently during unescaping
diff --git a/test/prism/fixtures/strings.txt b/test/prism/fixtures/strings.txt
index 5df0ded1e9..a7986808ba 100644
--- a/test/prism/fixtures/strings.txt
+++ b/test/prism/fixtures/strings.txt
@@ -86,6 +86,9 @@ a\nb\n\nc\n"
bat]
<<<<<<< HEAD
+<<<<<<< HEAD
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
%W[#{foo}\
bar
baz #{bat}
@@ -101,8 +104,11 @@ baz #{bat}
%W(foo\
bar)
+<<<<<<< HEAD
=======
>>>>>>> bd3dd2b62a (Fix parser translator tokens for %-arrays with whitespace escapes)
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
%w[foo bar]
%w[
diff --git a/test/prism/ruby/parser_test.rb b/test/prism/ruby/parser_test.rb
index b5cc45b824..370087d84a 100644
--- a/test/prism/ruby/parser_test.rb
+++ b/test/prism/ruby/parser_test.rb
@@ -92,12 +92,15 @@ module Prism
skip_all = skip_incorrect | [
"unescaping.txt",
<<<<<<< HEAD
+<<<<<<< HEAD
=======
"seattlerb/heredoc_with_extra_carriage_returns_windows.txt",
"seattlerb/heredoc_with_only_carriage_returns_windows.txt",
"seattlerb/heredoc_with_only_carriage_returns.txt",
"seattlerb/pctW_lineno.txt",
>>>>>>> e1c75f304b (Better handle regexp in the parser translator)
+=======
+>>>>>>> 4edfe9d981 (Further refine string handling in the parser translator)
"seattlerb/regexp_esc_C_slash.txt",
]
diff --git a/test/prism/snapshots/heredocs_with_fake_newlines.txt b/test/prism/snapshots/heredocs_with_fake_newlines.txt
new file mode 100644
index 0000000000..df59b29b94
--- /dev/null
+++ b/test/prism/snapshots/heredocs_with_fake_newlines.txt
@@ -0,0 +1,223 @@
+@ ProgramNode (location: (1,0)-(43,8))
+├── flags: ∅
+├── locals: []
+└── statements:
+ @ StatementsNode (location: (1,0)-(43,8))
+ ├── flags: ∅
+ └── body: (length: 4)
+ ├── @ StringNode (location: (1,0)-(1,7))
+ │ ├── flags: newline
+ │ ├── opening_loc: (1,0)-(1,7) = "<<-RUBY"
+ │ ├── content_loc: (2,0)-(13,0) = " \\n\n \\n\n exit\n \\\\n\n \\n\\n\\n\\n\n argh\n \\\\\n \\\\\\\n foo\\nbar\n \\f\n ok\n"
+ │ ├── closing_loc: (13,0)-(14,0) = "RUBY\n"
+ │ └── unescaped: " \n\n \n\n exit\n \\n\n \n\n\n\n\n argh\n \\\n \\ foo\nbar\n \f\n ok\n"
+ ├── @ InterpolatedStringNode (location: (15,0)-(15,7))
+ │ ├── flags: newline, static_literal
+ │ ├── opening_loc: (15,0)-(15,7) = "<<~RUBY"
+ │ ├── parts: (length: 11)
+ │ │ ├── @ StringNode (location: (16,0)-(17,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (16,0)-(17,0) = " \\n\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\n\n"
+ │ │ ├── @ StringNode (location: (17,0)-(18,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (17,0)-(18,0) = " \\n\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\n\n"
+ │ │ ├── @ StringNode (location: (18,0)-(19,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (18,0)-(19,0) = " exit\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "exit\n"
+ │ │ ├── @ StringNode (location: (19,0)-(20,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (19,0)-(20,0) = " \\\\n\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\\n\n"
+ │ │ ├── @ StringNode (location: (20,0)-(21,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (20,0)-(21,0) = " \\n\\n\\n\\n\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\n\n\n\n\n"
+ │ │ ├── @ StringNode (location: (21,0)-(22,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (21,0)-(22,0) = " argh\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "argh\n"
+ │ │ ├── @ StringNode (location: (22,0)-(23,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (22,0)-(23,0) = " \\\\\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\\\n"
+ │ │ ├── @ StringNode (location: (23,0)-(24,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (23,0)-(24,0) = " \\\\\\\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\\"
+ │ │ ├── @ StringNode (location: (24,0)-(25,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (24,0)-(25,0) = " foo\\nbar\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "foo\nbar\n"
+ │ │ ├── @ StringNode (location: (25,0)-(26,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (25,0)-(26,0) = " \\f\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\f\n"
+ │ │ └── @ StringNode (location: (26,0)-(27,0))
+ │ │ ├── flags: static_literal, frozen
+ │ │ ├── opening_loc: ∅
+ │ │ ├── content_loc: (26,0)-(27,0) = " ok\n"
+ │ │ ├── closing_loc: ∅
+ │ │ └── unescaped: "ok\n"
+ │ └── closing_loc: (27,0)-(28,0) = "RUBY\n"
+ ├── @ InterpolatedStringNode (location: (29,0)-(29,7))
+ │ ├── flags: newline
+ │ ├── opening_loc: (29,0)-(29,7) = "<<~RUBY"
+ │ ├── parts: (length: 18)
+ │ │ ├── @ EmbeddedStatementsNode (location: (30,2)-(30,8))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── opening_loc: (30,2)-(30,4) = "\#{"
+ │ │ │ ├── statements:
+ │ │ │ │ @ StatementsNode (location: (30,4)-(30,7))
+ │ │ │ │ ├── flags: ∅
+ │ │ │ │ └── body: (length: 1)
+ │ │ │ │ └── @ IntegerNode (location: (30,4)-(30,7))
+ │ │ │ │ ├── flags: static_literal, decimal
+ │ │ │ │ └── value: 123
+ │ │ │ └── closing_loc: (30,7)-(30,8) = "}"
+ │ │ ├── @ StringNode (location: (30,8)-(31,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (30,8)-(31,0) = "\\n\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\n\n"
+ │ │ ├── @ StringNode (location: (31,0)-(32,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (31,0)-(32,0) = " \\n\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\n\n"
+ │ │ ├── @ StringNode (location: (32,0)-(33,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (32,0)-(33,0) = " exit\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "exit\n"
+ │ │ ├── @ StringNode (location: (33,0)-(33,4))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (33,0)-(33,4) = " \\\\"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\\"
+ │ │ ├── @ EmbeddedStatementsNode (location: (33,4)-(33,10))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── opening_loc: (33,4)-(33,6) = "\#{"
+ │ │ │ ├── statements:
+ │ │ │ │ @ StatementsNode (location: (33,6)-(33,9))
+ │ │ │ │ ├── flags: ∅
+ │ │ │ │ └── body: (length: 1)
+ │ │ │ │ └── @ IntegerNode (location: (33,6)-(33,9))
+ │ │ │ │ ├── flags: static_literal, decimal
+ │ │ │ │ └── value: 123
+ │ │ │ └── closing_loc: (33,9)-(33,10) = "}"
+ │ │ ├── @ StringNode (location: (33,10)-(34,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (33,10)-(34,0) = "n\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "n\n"
+ │ │ ├── @ StringNode (location: (34,0)-(34,4))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (34,0)-(34,4) = " \\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\n"
+ │ │ ├── @ EmbeddedStatementsNode (location: (34,4)-(34,10))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── opening_loc: (34,4)-(34,6) = "\#{"
+ │ │ │ ├── statements:
+ │ │ │ │ @ StatementsNode (location: (34,6)-(34,9))
+ │ │ │ │ ├── flags: ∅
+ │ │ │ │ └── body: (length: 1)
+ │ │ │ │ └── @ IntegerNode (location: (34,6)-(34,9))
+ │ │ │ │ ├── flags: static_literal, decimal
+ │ │ │ │ └── value: 123
+ │ │ │ └── closing_loc: (34,9)-(34,10) = "}"
+ │ │ ├── @ StringNode (location: (34,10)-(35,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (34,10)-(35,0) = "\\n\\n\\n\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\n\n\n\n"
+ │ │ ├── @ StringNode (location: (35,0)-(36,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (35,0)-(36,0) = " argh\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "argh\n"
+ │ │ ├── @ StringNode (location: (36,0)-(36,4))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (36,0)-(36,4) = " \\\\"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\\"
+ │ │ ├── @ EmbeddedStatementsNode (location: (36,4)-(36,10))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── opening_loc: (36,4)-(36,6) = "\#{"
+ │ │ │ ├── statements:
+ │ │ │ │ @ StatementsNode (location: (36,6)-(36,9))
+ │ │ │ │ ├── flags: ∅
+ │ │ │ │ └── body: (length: 1)
+ │ │ │ │ └── @ IntegerNode (location: (36,6)-(36,9))
+ │ │ │ │ ├── flags: static_literal, decimal
+ │ │ │ │ └── value: 123
+ │ │ │ └── closing_loc: (36,9)-(36,10) = "}"
+ │ │ ├── @ StringNode (location: (36,10)-(37,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (36,10)-(37,0) = "baz\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "baz\n"
+ │ │ ├── @ StringNode (location: (37,0)-(38,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (37,0)-(38,0) = " \\\\\\\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\\"
+ │ │ ├── @ StringNode (location: (38,0)-(39,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (38,0)-(39,0) = " foo\\nbar\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "foo\nbar\n"
+ │ │ ├── @ StringNode (location: (39,0)-(40,0))
+ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (39,0)-(40,0) = " \\f\n"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "\f\n"
+ │ │ └── @ StringNode (location: (40,0)-(41,0))
+ │ │ ├── flags: static_literal, frozen
+ │ │ ├── opening_loc: ∅
+ │ │ ├── content_loc: (40,0)-(41,0) = " ok\n"
+ │ │ ├── closing_loc: ∅
+ │ │ └── unescaped: "ok\n"
+ │ └── closing_loc: (41,0)-(42,0) = "RUBY\n"
+ └── @ StringNode (location: (43,0)-(43,8))
+ ├── flags: newline
+ ├── opening_loc: (43,0)-(43,8) = "<<'RUBY'"
+ ├── content_loc: (44,0)-(55,0) = " \\n\n \\n\n exit\n \\n\n \\n\\n\\n\\n\n argh\n \\\n \\\n foo\\nbar\n \\f\n ok\n"
+ ├── closing_loc: (55,0)-(56,0) = "RUBY\n"
+ └── unescaped: " \\n\n \\n\n exit\n \\n\n \\n\\n\\n\\n\n argh\n \\\n \\\n foo\\nbar\n \\f\n ok\n"
diff --git a/test/prism/snapshots/strings.txt b/test/prism/snapshots/strings.txt
index daef5d3a2d..c5e7883b4a 100644
--- a/test/prism/snapshots/strings.txt
+++ b/test/prism/snapshots/strings.txt
@@ -1,10 +1,10 @@
-@ ProgramNode (location: (1,0)-(132,15))
+@ ProgramNode (location: (1,0)-(147,15))
├── flags: ∅
├── locals: []
└── statements:
- @ StatementsNode (location: (1,0)-(132,15))
+ @ StatementsNode (location: (1,0)-(147,15))
├── flags: ∅
- └── body: (length: 58)
+ └── body: (length: 63)
├── @ StringNode (location: (1,0)-(1,6))
│ ├── flags: newline
│ ├── opening_loc: (1,0)-(1,2) = "%%"
@@ -364,324 +364,437 @@
│ │ └── unescaped: "bat"
│ ├── opening_loc: (72,0)-(72,3) = "%w["
│ └── closing_loc: (73,4)-(73,5) = "]"
- ├── @ ArrayNode (location: (75,0)-(75,15))
+ ├── @ ArrayNode (location: (75,0)-(78,1))
+ │ ├── flags: newline
+ │ ├── elements: (length: 3)
+ │ │ ├── @ InterpolatedStringNode (location: (75,3)-(76,3))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── parts: (length: 2)
+ │ │ │ │ ├── @ EmbeddedStatementsNode (location: (75,3)-(75,9))
+ │ │ │ │ │ ├── flags: ∅
+ │ │ │ │ │ ├── opening_loc: (75,3)-(75,5) = "\#{"
+ │ │ │ │ │ ├── statements:
+ │ │ │ │ │ │ @ StatementsNode (location: (75,5)-(75,8))
+ │ │ │ │ │ │ ├── flags: ∅
+ │ │ │ │ │ │ └── body: (length: 1)
+ │ │ │ │ │ │ └── @ CallNode (location: (75,5)-(75,8))
+ │ │ │ │ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ │ │ │ │ ├── receiver: ∅
+ │ │ │ │ │ │ ├── call_operator_loc: ∅
+ │ │ │ │ │ │ ├── name: :foo
+ │ │ │ │ │ │ ├── message_loc: (75,5)-(75,8) = "foo"
+ │ │ │ │ │ │ ├── opening_loc: ∅
+ │ │ │ │ │ │ ├── arguments: ∅
+ │ │ │ │ │ │ ├── closing_loc: ∅
+ │ │ │ │ │ │ └── block: ∅
+ │ │ │ │ │ └── closing_loc: (75,8)-(75,9) = "}"
+ │ │ │ │ └── @ StringNode (location: (75,9)-(76,3))
+ │ │ │ │ ├── flags: static_literal, frozen
+ │ │ │ │ ├── opening_loc: ∅
+ │ │ │ │ ├── content_loc: (75,9)-(76,3) = "\\\nbar"
+ │ │ │ │ ├── closing_loc: ∅
+ │ │ │ │ └── unescaped: "\nbar"
+ │ │ │ └── closing_loc: ∅
+ │ │ ├── @ StringNode (location: (77,0)-(77,3))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (77,0)-(77,3) = "baz"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "baz"
+ │ │ └── @ InterpolatedStringNode (location: (77,4)-(77,10))
+ │ │ ├── flags: ∅
+ │ │ ├── opening_loc: ∅
+ │ │ ├── parts: (length: 1)
+ │ │ │ └── @ EmbeddedStatementsNode (location: (77,4)-(77,10))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── opening_loc: (77,4)-(77,6) = "\#{"
+ │ │ │ ├── statements:
+ │ │ │ │ @ StatementsNode (location: (77,6)-(77,9))
+ │ │ │ │ ├── flags: ∅
+ │ │ │ │ └── body: (length: 1)
+ │ │ │ │ └── @ CallNode (location: (77,6)-(77,9))
+ │ │ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ │ │ ├── receiver: ∅
+ │ │ │ │ ├── call_operator_loc: ∅
+ │ │ │ │ ├── name: :bat
+ │ │ │ │ ├── message_loc: (77,6)-(77,9) = "bat"
+ │ │ │ │ ├── opening_loc: ∅
+ │ │ │ │ ├── arguments: ∅
+ │ │ │ │ ├── closing_loc: ∅
+ │ │ │ │ └── block: ∅
+ │ │ │ └── closing_loc: (77,9)-(77,10) = "}"
+ │ │ └── closing_loc: ∅
+ │ ├── opening_loc: (75,0)-(75,3) = "%W["
+ │ └── closing_loc: (78,0)-(78,1) = "]"
+ ├── @ ArrayNode (location: (80,0)-(80,9))
+ │ ├── flags: newline
+ │ ├── elements: (length: 1)
+ │ │ └── @ StringNode (location: (80,3)-(80,8))
+ │ │ ├── flags: ∅
+ │ │ ├── opening_loc: ∅
+ │ │ ├── content_loc: (80,3)-(80,8) = "foo\\n"
+ │ │ ├── closing_loc: ∅
+ │ │ └── unescaped: "foo\\n"
+ │ ├── opening_loc: (80,0)-(80,3) = "%w("
+ │ └── closing_loc: (80,8)-(80,9) = ")"
+ ├── @ ArrayNode (location: (82,0)-(83,1))
+ │ ├── flags: newline
+ │ ├── elements: (length: 1)
+ │ │ └── @ StringNode (location: (82,3)-(83,0))
+ │ │ ├── flags: ∅
+ │ │ ├── opening_loc: ∅
+ │ │ ├── content_loc: (82,3)-(83,0) = "foo\\\n"
+ │ │ ├── closing_loc: ∅
+ │ │ └── unescaped: "foo\n"
+ │ ├── opening_loc: (82,0)-(82,3) = "%w("
+ │ └── closing_loc: (83,0)-(83,1) = ")"
+ ├── @ ArrayNode (location: (85,0)-(85,10))
+ │ ├── flags: newline
+ │ ├── elements: (length: 2)
+ │ │ ├── @ StringNode (location: (85,3)-(85,6))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── content_loc: (85,3)-(85,6) = "foo"
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── unescaped: "foo"
+ │ │ └── @ StringNode (location: (85,7)-(85,9))
+ │ │ ├── flags: ∅
+ │ │ ├── opening_loc: ∅
+ │ │ ├── content_loc: (85,7)-(85,9) = "\\n"
+ │ │ ├── closing_loc: ∅
+ │ │ └── unescaped: "\\n"
+ │ ├── opening_loc: (85,0)-(85,3) = "%w("
+ │ └── closing_loc: (85,9)-(85,10) = ")"
+ ├── @ ArrayNode (location: (87,0)-(88,4))
+ │ ├── flags: newline
+ │ ├── elements: (length: 1)
+ │ │ └── @ StringNode (location: (87,3)-(88,3))
+ │ │ ├── flags: ∅
+ │ │ ├── opening_loc: ∅
+ │ │ ├── content_loc: (87,3)-(88,3) = "foo\\\nbar"
+ │ │ ├── closing_loc: ∅
+ │ │ └── unescaped: "foo\nbar"
+ │ ├── opening_loc: (87,0)-(87,3) = "%W("
+ │ └── closing_loc: (88,3)-(88,4) = ")"
+ ├── @ ArrayNode (location: (90,0)-(90,15))
│ ├── flags: newline
│ ├── elements: (length: 2)
- │ │ ├── @ StringNode (location: (75,3)-(75,6))
+ │ │ ├── @ StringNode (location: (90,3)-(90,6))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (75,3)-(75,6) = "foo"
+ │ │ │ ├── content_loc: (90,3)-(90,6) = "foo"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "foo"
- │ │ └── @ StringNode (location: (75,11)-(75,14))
+ │ │ └── @ StringNode (location: (90,11)-(90,14))
│ │ ├── flags: ∅
│ │ ├── opening_loc: ∅
- │ │ ├── content_loc: (75,11)-(75,14) = "bar"
+ │ │ ├── content_loc: (90,11)-(90,14) = "bar"
│ │ ├── closing_loc: ∅
│ │ └── unescaped: "bar"
- │ ├── opening_loc: (75,0)-(75,3) = "%w["
- │ └── closing_loc: (75,14)-(75,15) = "]"
- ├── @ ArrayNode (location: (77,0)-(81,1))
+ │ ├── opening_loc: (90,0)-(90,3) = "%w["
+ │ └── closing_loc: (90,14)-(90,15) = "]"
+ ├── @ ArrayNode (location: (92,0)-(96,1))
│ ├── flags: newline
│ ├── elements: (length: 4)
- │ │ ├── @ StringNode (location: (78,2)-(78,3))
+ │ │ ├── @ StringNode (location: (93,2)-(93,3))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (78,2)-(78,3) = "a"
+ │ │ │ ├── content_loc: (93,2)-(93,3) = "a"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "a"
- │ │ ├── @ StringNode (location: (79,2)-(79,3))
+ │ │ ├── @ StringNode (location: (94,2)-(94,3))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (79,2)-(79,3) = "b"
+ │ │ │ ├── content_loc: (94,2)-(94,3) = "b"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "b"
- │ │ ├── @ StringNode (location: (79,6)-(79,7))
+ │ │ ├── @ StringNode (location: (94,6)-(94,7))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (79,6)-(79,7) = "c"
+ │ │ │ ├── content_loc: (94,6)-(94,7) = "c"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "c"
- │ │ └── @ StringNode (location: (80,1)-(80,2))
+ │ │ └── @ StringNode (location: (95,1)-(95,2))
│ │ ├── flags: ∅
│ │ ├── opening_loc: ∅
- │ │ ├── content_loc: (80,1)-(80,2) = "d"
+ │ │ ├── content_loc: (95,1)-(95,2) = "d"
│ │ ├── closing_loc: ∅
│ │ └── unescaped: "d"
- │ ├── opening_loc: (77,0)-(77,3) = "%w["
- │ └── closing_loc: (81,0)-(81,1) = "]"
- ├── @ ArrayNode (location: (83,0)-(83,18))
+ │ ├── opening_loc: (92,0)-(92,3) = "%w["
+ │ └── closing_loc: (96,0)-(96,1) = "]"
+ ├── @ ArrayNode (location: (98,0)-(98,18))
│ ├── flags: newline
│ ├── elements: (length: 1)
- │ │ └── @ StringNode (location: (83,3)-(83,17))
+ │ │ └── @ StringNode (location: (98,3)-(98,17))
│ │ ├── flags: ∅
│ │ ├── opening_loc: ∅
- │ │ ├── content_loc: (83,3)-(83,17) = "f\\u{006f 006f}"
+ │ │ ├── content_loc: (98,3)-(98,17) = "f\\u{006f 006f}"
│ │ ├── closing_loc: ∅
│ │ └── unescaped: "foo"
- │ ├── opening_loc: (83,0)-(83,3) = "%W["
- │ └── closing_loc: (83,17)-(83,18) = "]"
- ├── @ ArrayNode (location: (85,0)-(85,14))
+ │ ├── opening_loc: (98,0)-(98,3) = "%W["
+ │ └── closing_loc: (98,17)-(98,18) = "]"
+ ├── @ ArrayNode (location: (100,0)-(100,14))
│ ├── flags: newline
│ ├── elements: (length: 3)
- │ │ ├── @ StringNode (location: (85,3)-(85,4))
+ │ │ ├── @ StringNode (location: (100,3)-(100,4))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (85,3)-(85,4) = "a"
+ │ │ │ ├── content_loc: (100,3)-(100,4) = "a"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "a"
- │ │ ├── @ InterpolatedStringNode (location: (85,5)-(85,11))
+ │ │ ├── @ InterpolatedStringNode (location: (100,5)-(100,11))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
│ │ │ ├── parts: (length: 3)
- │ │ │ │ ├── @ StringNode (location: (85,5)-(85,6))
+ │ │ │ │ ├── @ StringNode (location: (100,5)-(100,6))
│ │ │ │ │ ├── flags: static_literal, frozen
│ │ │ │ │ ├── opening_loc: ∅
- │ │ │ │ │ ├── content_loc: (85,5)-(85,6) = "b"
+ │ │ │ │ │ ├── content_loc: (100,5)-(100,6) = "b"
│ │ │ │ │ ├── closing_loc: ∅
│ │ │ │ │ └── unescaped: "b"
- │ │ │ │ ├── @ EmbeddedStatementsNode (location: (85,6)-(85,10))
+ │ │ │ │ ├── @ EmbeddedStatementsNode (location: (100,6)-(100,10))
│ │ │ │ │ ├── flags: ∅
- │ │ │ │ │ ├── opening_loc: (85,6)-(85,8) = "\#{"
+ │ │ │ │ │ ├── opening_loc: (100,6)-(100,8) = "\#{"
│ │ │ │ │ ├── statements:
- │ │ │ │ │ │ @ StatementsNode (location: (85,8)-(85,9))
+ │ │ │ │ │ │ @ StatementsNode (location: (100,8)-(100,9))
│ │ │ │ │ │ ├── flags: ∅
│ │ │ │ │ │ └── body: (length: 1)
- │ │ │ │ │ │ └── @ CallNode (location: (85,8)-(85,9))
+ │ │ │ │ │ │ └── @ CallNode (location: (100,8)-(100,9))
│ │ │ │ │ │ ├── flags: variable_call, ignore_visibility
│ │ │ │ │ │ ├── receiver: ∅
│ │ │ │ │ │ ├── call_operator_loc: ∅
│ │ │ │ │ │ ├── name: :c
- │ │ │ │ │ │ ├── message_loc: (85,8)-(85,9) = "c"
+ │ │ │ │ │ │ ├── message_loc: (100,8)-(100,9) = "c"
│ │ │ │ │ │ ├── opening_loc: ∅
│ │ │ │ │ │ ├── arguments: ∅
│ │ │ │ │ │ ├── closing_loc: ∅
│ │ │ │ │ │ └── block: ∅
- │ │ │ │ │ └── closing_loc: (85,9)-(85,10) = "}"
- │ │ │ │ └── @ StringNode (location: (85,10)-(85,11))
+ │ │ │ │ │ └── closing_loc: (100,9)-(100,10) = "}"
+ │ │ │ │ └── @ StringNode (location: (100,10)-(100,11))
│ │ │ │ ├── flags: static_literal, frozen
│ │ │ │ ├── opening_loc: ∅
- │ │ │ │ ├── content_loc: (85,10)-(85,11) = "d"
+ │ │ │ │ ├── content_loc: (100,10)-(100,11) = "d"
│ │ │ │ ├── closing_loc: ∅
│ │ │ │ └── unescaped: "d"
│ │ │ └── closing_loc: ∅
- │ │ └── @ StringNode (location: (85,12)-(85,13))
+ │ │ └── @ StringNode (location: (100,12)-(100,13))
│ │ ├── flags: ∅
│ │ ├── opening_loc: ∅
- │ │ ├── content_loc: (85,12)-(85,13) = "e"
+ │ │ ├── content_loc: (100,12)-(100,13) = "e"
│ │ ├── closing_loc: ∅
│ │ └── unescaped: "e"
- │ ├── opening_loc: (85,0)-(85,3) = "%W["
- │ └── closing_loc: (85,13)-(85,14) = "]"
- ├── @ ArrayNode (location: (87,0)-(87,9))
+ │ ├── opening_loc: (100,0)-(100,3) = "%W["
+ │ └── closing_loc: (100,13)-(100,14) = "]"
+ ├── @ ArrayNode (location: (102,0)-(102,9))
│ ├── flags: newline
│ ├── elements: (length: 3)
- │ │ ├── @ StringNode (location: (87,3)-(87,4))
+ │ │ ├── @ StringNode (location: (102,3)-(102,4))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (87,3)-(87,4) = "a"
+ │ │ │ ├── content_loc: (102,3)-(102,4) = "a"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "a"
- │ │ ├── @ StringNode (location: (87,5)-(87,6))
+ │ │ ├── @ StringNode (location: (102,5)-(102,6))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (87,5)-(87,6) = "b"
+ │ │ │ ├── content_loc: (102,5)-(102,6) = "b"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "b"
- │ │ └── @ StringNode (location: (87,7)-(87,8))
+ │ │ └── @ StringNode (location: (102,7)-(102,8))
│ │ ├── flags: ∅
│ │ ├── opening_loc: ∅
- │ │ ├── content_loc: (87,7)-(87,8) = "c"
+ │ │ ├── content_loc: (102,7)-(102,8) = "c"
│ │ ├── closing_loc: ∅
│ │ └── unescaped: "c"
- │ ├── opening_loc: (87,0)-(87,3) = "%W["
- │ └── closing_loc: (87,8)-(87,9) = "]"
- ├── @ ArrayNode (location: (89,0)-(93,1))
+ │ ├── opening_loc: (102,0)-(102,3) = "%W["
+ │ └── closing_loc: (102,8)-(102,9) = "]"
+ ├── @ ArrayNode (location: (104,0)-(108,1))
│ ├── flags: newline
│ ├── elements: (length: 3)
- │ │ ├── @ StringNode (location: (90,2)-(90,3))
+ │ │ ├── @ StringNode (location: (105,2)-(105,3))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (90,2)-(90,3) = "a"
+ │ │ │ ├── content_loc: (105,2)-(105,3) = "a"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "a"
- │ │ ├── @ StringNode (location: (91,2)-(91,3))
+ │ │ ├── @ StringNode (location: (106,2)-(106,3))
│ │ │ ├── flags: ∅
│ │ │ ├── opening_loc: ∅
- │ │ │ ├── content_loc: (91,2)-(91,3) = "b"
+ │ │ │ ├── content_loc: (106,2)-(106,3) = "b"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "b"
- │ │ └── @ StringNode (location: (92,2)-(92,3))
+ │ │ └── @ StringNode (location: (107,2)-(107,3))
│ │ ├── flags: ∅
│ │ ├── opening_loc: ∅
- │ │ ├── content_loc: (92,2)-(92,3) = "c"
+ │ │ ├── content_loc: (107,2)-(107,3) = "c"
│ │ ├── closing_loc: ∅
│ │ └── unescaped: "c"
- │ ├── opening_loc: (89,0)-(89,3) = "%w["
- │ └── closing_loc: (93,0)-(93,1) = "]"
- ├── @ StringNode (location: (95,0)-(95,15))
+ │ ├── opening_loc: (104,0)-(104,3) = "%w["
+ │ └── closing_loc: (108,0)-(108,1) = "]"
+ ├── @ StringNode (location: (110,0)-(110,15))
│ ├── flags: newline
- │ ├── opening_loc: (95,0)-(95,1) = "'"
- │ ├── content_loc: (95,1)-(95,14) = "\\' foo \\' bar"
- │ ├── closing_loc: (95,14)-(95,15) = "'"
+ │ ├── opening_loc: (110,0)-(110,1) = "'"
+ │ ├── content_loc: (110,1)-(110,14) = "\\' foo \\' bar"
+ │ ├── closing_loc: (110,14)-(110,15) = "'"
│ └── unescaped: "' foo ' bar"
- ├── @ StringNode (location: (97,0)-(97,15))
+ ├── @ StringNode (location: (112,0)-(112,15))
│ ├── flags: newline
- │ ├── opening_loc: (97,0)-(97,1) = "'"
- │ ├── content_loc: (97,1)-(97,14) = "\\\\ foo \\\\ bar"
- │ ├── closing_loc: (97,14)-(97,15) = "'"
+ │ ├── opening_loc: (112,0)-(112,1) = "'"
+ │ ├── content_loc: (112,1)-(112,14) = "\\\\ foo \\\\ bar"
+ │ ├── closing_loc: (112,14)-(112,15) = "'"
│ └── unescaped: "\\ foo \\ bar"
- ├── @ StringNode (location: (99,0)-(102,1))
+ ├── @ StringNode (location: (114,0)-(117,1))
│ ├── flags: newline
- │ ├── opening_loc: (99,0)-(99,1) = "'"
- │ ├── content_loc: (99,1)-(102,0) = "foo\\\nbar\\\\\nbaz\n"
- │ ├── closing_loc: (102,0)-(102,1) = "'"
+ │ ├── opening_loc: (114,0)-(114,1) = "'"
+ │ ├── content_loc: (114,1)-(117,0) = "foo\\\nbar\\\\\nbaz\n"
+ │ ├── closing_loc: (117,0)-(117,1) = "'"
│ └── unescaped: "foo\\\nbar\\\nbaz\n"
- ├── @ InterpolatedStringNode (location: (104,0)-(104,7))
+ ├── @ InterpolatedStringNode (location: (119,0)-(119,7))
│ ├── flags: newline
- │ ├── opening_loc: (104,0)-(104,1) = "\""
+ │ ├── opening_loc: (119,0)-(119,1) = "\""
│ ├── parts: (length: 1)
- │ │ └── @ EmbeddedVariableNode (location: (104,1)-(104,6))
+ │ │ └── @ EmbeddedVariableNode (location: (119,1)-(119,6))
│ │ ├── flags: ∅
- │ │ ├── operator_loc: (104,1)-(104,2) = "#"
+ │ │ ├── operator_loc: (119,1)-(119,2) = "#"
│ │ └── variable:
- │ │ @ GlobalVariableReadNode (location: (104,2)-(104,6))
+ │ │ @ GlobalVariableReadNode (location: (119,2)-(119,6))
│ │ ├── flags: ∅
│ │ └── name: :$foo
- │ └── closing_loc: (104,6)-(104,7) = "\""
- ├── @ InterpolatedStringNode (location: (106,0)-(106,7))
+ │ └── closing_loc: (119,6)-(119,7) = "\""
+ ├── @ InterpolatedStringNode (location: (121,0)-(121,7))
│ ├── flags: newline
- │ ├── opening_loc: (106,0)-(106,1) = "\""
+ │ ├── opening_loc: (121,0)-(121,1) = "\""
│ ├── parts: (length: 1)
- │ │ └── @ EmbeddedVariableNode (location: (106,1)-(106,6))
+ │ │ └── @ EmbeddedVariableNode (location: (121,1)-(121,6))
│ │ ├── flags: ∅
- │ │ ├── operator_loc: (106,1)-(106,2) = "#"
+ │ │ ├── operator_loc: (121,1)-(121,2) = "#"
│ │ └── variable:
- │ │ @ InstanceVariableReadNode (location: (106,2)-(106,6))
+ │ │ @ InstanceVariableReadNode (location: (121,2)-(121,6))
│ │ ├── flags: ∅
│ │ └── name: :@foo
- │ └── closing_loc: (106,6)-(106,7) = "\""
- ├── @ StringNode (location: (108,0)-(108,15))
+ │ └── closing_loc: (121,6)-(121,7) = "\""
+ ├── @ StringNode (location: (123,0)-(123,15))
│ ├── flags: newline
- │ ├── opening_loc: (108,0)-(108,1) = "\""
- │ ├── content_loc: (108,1)-(108,14) = "\\x7 \\x23 \\x61"
- │ ├── closing_loc: (108,14)-(108,15) = "\""
+ │ ├── opening_loc: (123,0)-(123,1) = "\""
+ │ ├── content_loc: (123,1)-(123,14) = "\\x7 \\x23 \\x61"
+ │ ├── closing_loc: (123,14)-(123,15) = "\""
│ └── unescaped: "\a # a"
- ├── @ StringNode (location: (110,0)-(110,13))
+ ├── @ StringNode (location: (125,0)-(125,13))
│ ├── flags: newline
- │ ├── opening_loc: (110,0)-(110,1) = "\""
- │ ├── content_loc: (110,1)-(110,12) = "\\7 \\43 \\141"
- │ ├── closing_loc: (110,12)-(110,13) = "\""
+ │ ├── opening_loc: (125,0)-(125,1) = "\""
+ │ ├── content_loc: (125,1)-(125,12) = "\\7 \\43 \\141"
+ │ ├── closing_loc: (125,12)-(125,13) = "\""
│ └── unescaped: "\a # a"
- ├── @ StringNode (location: (112,0)-(112,17))
+ ├── @ StringNode (location: (127,0)-(127,17))
│ ├── flags: newline, forced_utf8_encoding
- │ ├── opening_loc: (112,0)-(112,1) = "\""
- │ ├── content_loc: (112,1)-(112,16) = "ち\\xE3\\x81\\xFF"
- │ ├── closing_loc: (112,16)-(112,17) = "\""
+ │ ├── opening_loc: (127,0)-(127,1) = "\""
+ │ ├── content_loc: (127,1)-(127,16) = "ち\\xE3\\x81\\xFF"
+ │ ├── closing_loc: (127,16)-(127,17) = "\""
│ └── unescaped: "ち\xE3\x81\xFF"
- ├── @ StringNode (location: (114,0)-(114,6))
+ ├── @ StringNode (location: (129,0)-(129,6))
│ ├── flags: newline
- │ ├── opening_loc: (114,0)-(114,2) = "%["
- │ ├── content_loc: (114,2)-(114,5) = "abc"
- │ ├── closing_loc: (114,5)-(114,6) = "]"
+ │ ├── opening_loc: (129,0)-(129,2) = "%["
+ │ ├── content_loc: (129,2)-(129,5) = "abc"
+ │ ├── closing_loc: (129,5)-(129,6) = "]"
│ └── unescaped: "abc"
- ├── @ StringNode (location: (116,0)-(116,6))
+ ├── @ StringNode (location: (131,0)-(131,6))
│ ├── flags: newline
- │ ├── opening_loc: (116,0)-(116,2) = "%("
- │ ├── content_loc: (116,2)-(116,5) = "abc"
- │ ├── closing_loc: (116,5)-(116,6) = ")"
+ │ ├── opening_loc: (131,0)-(131,2) = "%("
+ │ ├── content_loc: (131,2)-(131,5) = "abc"
+ │ ├── closing_loc: (131,5)-(131,6) = ")"
│ └── unescaped: "abc"
- ├── @ StringNode (location: (118,0)-(118,6))
+ ├── @ StringNode (location: (133,0)-(133,6))
│ ├── flags: newline
- │ ├── opening_loc: (118,0)-(118,2) = "%@"
- │ ├── content_loc: (118,2)-(118,5) = "abc"
- │ ├── closing_loc: (118,5)-(118,6) = "@"
+ │ ├── opening_loc: (133,0)-(133,2) = "%@"
+ │ ├── content_loc: (133,2)-(133,5) = "abc"
+ │ ├── closing_loc: (133,5)-(133,6) = "@"
│ └── unescaped: "abc"
- ├── @ StringNode (location: (120,0)-(120,6))
+ ├── @ StringNode (location: (135,0)-(135,6))
│ ├── flags: newline
- │ ├── opening_loc: (120,0)-(120,2) = "%$"
- │ ├── content_loc: (120,2)-(120,5) = "abc"
- │ ├── closing_loc: (120,5)-(120,6) = "$"
+ │ ├── opening_loc: (135,0)-(135,2) = "%$"
+ │ ├── content_loc: (135,2)-(135,5) = "abc"
+ │ ├── closing_loc: (135,5)-(135,6) = "$"
│ └── unescaped: "abc"
- ├── @ StringNode (location: (122,0)-(122,2))
+ ├── @ StringNode (location: (137,0)-(137,2))
│ ├── flags: newline
- │ ├── opening_loc: (122,0)-(122,1) = "?"
- │ ├── content_loc: (122,1)-(122,2) = "a"
+ │ ├── opening_loc: (137,0)-(137,1) = "?"
+ │ ├── content_loc: (137,1)-(137,2) = "a"
│ ├── closing_loc: ∅
│ └── unescaped: "a"
- ├── @ InterpolatedStringNode (location: (124,0)-(124,6))
+ ├── @ InterpolatedStringNode (location: (139,0)-(139,6))
│ ├── flags: newline, static_literal
│ ├── opening_loc: ∅
│ ├── parts: (length: 2)
- │ │ ├── @ StringNode (location: (124,0)-(124,2))
+ │ │ ├── @ StringNode (location: (139,0)-(139,2))
│ │ │ ├── flags: static_literal, frozen
- │ │ │ ├── opening_loc: (124,0)-(124,1) = "?"
- │ │ │ ├── content_loc: (124,1)-(124,2) = "a"
+ │ │ │ ├── opening_loc: (139,0)-(139,1) = "?"
+ │ │ │ ├── content_loc: (139,1)-(139,2) = "a"
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "a"
- │ │ └── @ StringNode (location: (124,3)-(124,6))
+ │ │ └── @ StringNode (location: (139,3)-(139,6))
│ │ ├── flags: static_literal, frozen
- │ │ ├── opening_loc: (124,3)-(124,4) = "\""
- │ │ ├── content_loc: (124,4)-(124,5) = "a"
- │ │ ├── closing_loc: (124,5)-(124,6) = "\""
+ │ │ ├── opening_loc: (139,3)-(139,4) = "\""
+ │ │ ├── content_loc: (139,4)-(139,5) = "a"
+ │ │ ├── closing_loc: (139,5)-(139,6) = "\""
│ │ └── unescaped: "a"
│ └── closing_loc: ∅
- ├── @ StringNode (location: (126,0)-(126,7))
+ ├── @ StringNode (location: (141,0)-(141,7))
│ ├── flags: newline
- │ ├── opening_loc: (126,0)-(126,3) = "%Q{"
- │ ├── content_loc: (126,3)-(126,6) = "abc"
- │ ├── closing_loc: (126,6)-(126,7) = "}"
+ │ ├── opening_loc: (141,0)-(141,3) = "%Q{"
+ │ ├── content_loc: (141,3)-(141,6) = "abc"
+ │ ├── closing_loc: (141,6)-(141,7) = "}"
│ └── unescaped: "abc"
- ├── @ StringNode (location: (128,0)-(128,5))
+ ├── @ StringNode (location: (143,0)-(143,5))
│ ├── flags: newline
- │ ├── opening_loc: (128,0)-(128,2) = "%^"
- │ ├── content_loc: (128,2)-(128,4) = "\#$"
- │ ├── closing_loc: (128,4)-(128,5) = "^"
+ │ ├── opening_loc: (143,0)-(143,2) = "%^"
+ │ ├── content_loc: (143,2)-(143,4) = "\#$"
+ │ ├── closing_loc: (143,4)-(143,5) = "^"
│ └── unescaped: "\#$"
- ├── @ StringNode (location: (130,0)-(130,4))
+ ├── @ StringNode (location: (145,0)-(145,4))
│ ├── flags: newline
- │ ├── opening_loc: (130,0)-(130,2) = "%@"
- │ ├── content_loc: (130,2)-(130,3) = "#"
- │ ├── closing_loc: (130,3)-(130,4) = "@"
+ │ ├── opening_loc: (145,0)-(145,2) = "%@"
+ │ ├── content_loc: (145,2)-(145,3) = "#"
+ │ ├── closing_loc: (145,3)-(145,4) = "@"
│ └── unescaped: "#"
- └── @ InterpolatedStringNode (location: (132,0)-(132,15))
+ └── @ InterpolatedStringNode (location: (147,0)-(147,15))
├── flags: newline
- ├── opening_loc: (132,0)-(132,1) = "\""
+ ├── opening_loc: (147,0)-(147,1) = "\""
├── parts: (length: 2)
- │ ├── @ EmbeddedStatementsNode (location: (132,1)-(132,12))
+ │ ├── @ EmbeddedStatementsNode (location: (147,1)-(147,12))
│ │ ├── flags: ∅
- │ │ ├── opening_loc: (132,1)-(132,3) = "\#{"
+ │ │ ├── opening_loc: (147,1)-(147,3) = "\#{"
│ │ ├── statements:
- │ │ │ @ StatementsNode (location: (132,3)-(132,11))
+ │ │ │ @ StatementsNode (location: (147,3)-(147,11))
│ │ │ ├── flags: ∅
│ │ │ └── body: (length: 1)
- │ │ │ └── @ InterpolatedStringNode (location: (132,3)-(132,11))
+ │ │ │ └── @ InterpolatedStringNode (location: (147,3)-(147,11))
│ │ │ ├── flags: ∅
- │ │ │ ├── opening_loc: (132,3)-(132,4) = "\""
+ │ │ │ ├── opening_loc: (147,3)-(147,4) = "\""
│ │ │ ├── parts: (length: 2)
- │ │ │ │ ├── @ EmbeddedStatementsNode (location: (132,4)-(132,8))
+ │ │ │ │ ├── @ EmbeddedStatementsNode (location: (147,4)-(147,8))
│ │ │ │ │ ├── flags: ∅
- │ │ │ │ │ ├── opening_loc: (132,4)-(132,6) = "\#{"
+ │ │ │ │ │ ├── opening_loc: (147,4)-(147,6) = "\#{"
│ │ │ │ │ ├── statements:
- │ │ │ │ │ │ @ StatementsNode (location: (132,6)-(132,7))
+ │ │ │ │ │ │ @ StatementsNode (location: (147,6)-(147,7))
│ │ │ │ │ │ ├── flags: ∅
│ │ │ │ │ │ └── body: (length: 1)
- │ │ │ │ │ │ └── @ ConstantReadNode (location: (132,6)-(132,7))
+ │ │ │ │ │ │ └── @ ConstantReadNode (location: (147,6)-(147,7))
│ │ │ │ │ │ ├── flags: ∅
│ │ │ │ │ │ └── name: :B
- │ │ │ │ │ └── closing_loc: (132,7)-(132,8) = "}"
- │ │ │ │ └── @ StringNode (location: (132,8)-(132,10))
+ │ │ │ │ │ └── closing_loc: (147,7)-(147,8) = "}"
+ │ │ │ │ └── @ StringNode (location: (147,8)-(147,10))
│ │ │ │ ├── flags: static_literal, frozen
│ │ │ │ ├── opening_loc: ∅
- │ │ │ │ ├── content_loc: (132,8)-(132,10) = " C"
+ │ │ │ │ ├── content_loc: (147,8)-(147,10) = " C"
│ │ │ │ ├── closing_loc: ∅
│ │ │ │ └── unescaped: " C"
- │ │ │ └── closing_loc: (132,10)-(132,11) = "\""
- │ │ └── closing_loc: (132,11)-(132,12) = "}"
- │ └── @ StringNode (location: (132,12)-(132,14))
+ │ │ │ └── closing_loc: (147,10)-(147,11) = "\""
+ │ │ └── closing_loc: (147,11)-(147,12) = "}"
+ │ └── @ StringNode (location: (147,12)-(147,14))
│ ├── flags: static_literal, frozen
│ ├── opening_loc: ∅
- │ ├── content_loc: (132,12)-(132,14) = " D"
+ │ ├── content_loc: (147,12)-(147,14) = " D"
│ ├── closing_loc: ∅
│ └── unescaped: " D"
- └── closing_loc: (132,14)-(132,15) = "\""
+ └── closing_loc: (147,14)-(147,15) = "\""