Skip to content

Commit

Permalink
Fixed parsing of escaped characters in strings
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Feb 24, 2013
1 parent 26fc790 commit 8eb2ae2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,8 @@ def identify_string(ltype, quoted = ltype, type = nil)
if %w[' /].include? @ltype then
case ch = getc
when "\\", "\n", "'"
when @ltype
str << ch
else
ungetc
end
Expand Down
11 changes: 11 additions & 0 deletions test/test_rdoc_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ def test_class_tokenize_regexp_backref
assert_equal expected, tokens
end

def test_class_tokenize_regexp_escape
tokens = RDoc::RubyLex.tokenize "/\\//", nil

expected = [
@TK::TkREGEXP.new( 0, 1, 0, "/\\//"),
@TK::TkNL .new( 4, 1, 4, "\n"),
]

assert_equal expected, tokens
end

def test_class_tokenize_string
tokens = RDoc::RubyLex.tokenize "'hi'", nil

Expand Down

0 comments on commit 8eb2ae2

Please sign in to comment.