Skip to content

Commit

Permalink
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/opal/parser/lexer.rb
Original file line number Diff line number Diff line change
@@ -10,10 +10,11 @@ class Lexer
STR_FUNC_QWORDS = 0x08
STR_FUNC_SYMBOL = 0x10
STR_FUNC_INDENT = 0x20
STR_FUNC_XQUOTE = 0x40

STR_SQUOTE = 0x00
STR_DQUOTE = STR_FUNC_EXPAND
STR_XQUOTE = STR_FUNC_EXPAND
STR_XQUOTE = STR_FUNC_EXPAND | STR_FUNC_XQUOTE
STR_REGEXP = STR_FUNC_REGEXP | STR_FUNC_ESCAPE | STR_FUNC_EXPAND
STR_SWORD = STR_FUNC_QWORDS
STR_DWORD = STR_FUNC_QWORDS | STR_FUNC_EXPAND
@@ -398,8 +399,6 @@ def add_string_content(str_buffer, str_parse)
elsif qwords and scan(/\s/)
pushback(1)
break
elsif scan(/\\\n/)
c = "\n"
elsif scan(/\\/)
if xquote # opal - treat xstrings as dquotes? forces us to double escape
c = self.read_escape
4 changes: 4 additions & 0 deletions spec/cli/lexer_spec.rb
Original file line number Diff line number Diff line change
@@ -38,6 +38,10 @@
expect_parsed_string("\"foo\\tbar\"").to eq("foo\tbar")
expect_parsed_string("\"\\\"foo\"").to eq("\"foo")
end

it "removes new line in string directly after backslash" do
expect_parsed_string("\"foo\\\nbar\"").to eq("foobar")
end
end

describe "single-quoted strings" do

0 comments on commit 8e163c5

Please sign in to comment.