Skip to content

Commit 03fda15

Browse files
committed
Add some more string escapes to lexer
1 parent fa7dde7 commit 03fda15

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lib/opal/parser/lexer.rb

+19-7
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,27 @@ def process_numeric
176176
end
177177

178178
def read_escape
179-
if scan(/n/)
179+
case scan(/./)
180+
when "\\"
181+
"\\"
182+
when "n"
180183
"\n"
181-
elsif scan(/r/)
182-
"\r"
183-
elsif scan(/\n/)
184-
"\n"
185-
elsif scan(/t/)
184+
when "t"
186185
"\t"
186+
when "r"
187+
"\r"
188+
when "f"
189+
"\f"
190+
when "v"
191+
"\v"
192+
when "a"
193+
"\a"
194+
when "e"
195+
"\e"
196+
when "s"
197+
" "
187198
else
188199
# escaped char doesnt need escaping, so just return it
189-
scan(/./)
190200
scanner.matched
191201
end
192202
end
@@ -408,6 +418,8 @@ def add_string_content(str_buffer, str_parse)
408418

409419
#elsif scan(/\\\\/)
410420
#c = scanner.matched
421+
elsif scan(/\\\n/)
422+
c = "\n"
411423

412424
elsif scan(/\\/)
413425
if str_parse[:type] == :regexp

0 commit comments

Comments
 (0)