Skip to content

Commit 8401851

Browse files
committed
Match % strings in parser
1 parent beed439 commit 8401851

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/prism/translation/parser/compiler.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,8 @@ def visit_string_node(node)
16891689
builder.string_compose(token(node.opening_loc), children, closing)
16901690
elsif node.opening == "?"
16911691
builder.character([node.unescaped, srange(node.location)])
1692+
elsif node.opening&.start_with?("%") && node.unescaped.empty?
1693+
builder.string_compose(token(node.opening_loc), [], token(node.closing_loc))
16921694
else
16931695
content_lines = node.content.lines
16941696
unescaped_lines = node.unescaped.lines

test/prism/ruby/parser_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,11 @@ class ParserTest < TestCase
6868
"seattlerb/heredoc_with_only_carriage_returns.txt",
6969
"seattlerb/masgn_double_paren.txt",
7070
"seattlerb/parse_line_heredoc_hardnewline.txt",
71-
"seattlerb/pct_nl.txt",
7271
"seattlerb/pctW_lineno.txt",
7372
"seattlerb/regexp_esc_C_slash.txt",
7473
"seattlerb/TestRubyParserShared.txt",
7574
"unparser/corpus/literal/assignment.txt",
7675
"unparser/corpus/literal/block.txt",
77-
"unparser/corpus/literal/def.txt",
7876
"unparser/corpus/literal/dstr.txt",
7977
"unparser/corpus/literal/literal.txt",
8078
"unparser/corpus/literal/pattern.txt",

0 commit comments

Comments
 (0)