Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Escape before EOL in double quote strings now removes newline
Fix to lexer to remove new line chactarers when prefixed with an escape
  • Loading branch information
adambeynon committed Dec 3, 2013
1 parent ab4a9d7 commit 8e163c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/opal/parser/lexer.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/cli/lexer_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 8e163c5

Please sign in to comment.