Skip to content

Commit

Permalink
Add read_escape method to lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Dec 1, 2013
1 parent 86fcf97 commit fa7dde7
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lib/opal/parser/lexer.rb
Expand Up @@ -175,6 +175,22 @@ def process_numeric
end
end

def read_escape
if scan(/n/)
"\n"
elsif scan(/r/)
"\r"
elsif scan(/\n/)
"\n"
elsif scan(/t/)
"\t"
else
# escaped char doesnt need escaping, so just return it
scan(/./)
scanner.matched
end
end

def next_string_token
str_parse = self.strterm
scanner = @scanner
Expand Down Expand Up @@ -399,19 +415,7 @@ def add_string_content(str_buffer, str_parse)
c = "\\" + scanner.matched
end
else
c = if scan(/n/)
"\n"
elsif scan(/r/)
"\r"
elsif scan(/\n/)
"\n"
elsif scan(/t/)
"\t"
else
# escaped char doesnt need escaping, so just return it
scan(/./)
scanner.matched
end
c = self.read_escape
end
else
handled = false
Expand Down

0 comments on commit fa7dde7

Please sign in to comment.