Skip to content

Commit

Permalink
Add some more string escapes to lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Dec 1, 2013
1 parent fa7dde7 commit 03fda15
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/opal/parser/lexer.rb
Expand Up @@ -176,17 +176,27 @@ def process_numeric
end

def read_escape
if scan(/n/)
case scan(/./)
when "\\"
"\\"
when "n"
"\n"
elsif scan(/r/)
"\r"
elsif scan(/\n/)
"\n"
elsif scan(/t/)
when "t"
"\t"
when "r"
"\r"
when "f"
"\f"
when "v"
"\v"
when "a"
"\a"
when "e"
"\e"
when "s"
" "
else
# escaped char doesnt need escaping, so just return it
scan(/./)
scanner.matched
end
end
Expand Down Expand Up @@ -408,6 +418,8 @@ def add_string_content(str_buffer, str_parse)

#elsif scan(/\\\\/)
#c = scanner.matched
elsif scan(/\\\n/)
c = "\n"

elsif scan(/\\/)
if str_parse[:type] == :regexp
Expand Down

0 comments on commit 03fda15

Please sign in to comment.