lib/rouge/lexers/python.rb in rouge-3.18.0 vs lib/rouge/lexers/python.rb in rouge-3.19.0

- old
+ new

@@ -65,12 +65,12 @@ UnicodeWarning UserWarning ValueError VMSError Warning WindowsError ZeroDivisionError ) end - identifier = /[a-z_][a-z0-9_]*/i - dotted_identifier = /[a-z_.][a-z0-9_.]*/i + identifier = /[[:alpha:]_][[:alnum:]_]*/ + dotted_identifier = /[[:alpha:]_.][[:alnum:]_.]*/ def current_string @string_register ||= StringRegister.new end @@ -184,18 +184,11 @@ current_string.remove pop! end end - rule %r/\\/ do |m| - if current_string.type? "r" - token Str - else - token Str::Interpol - end - push :generic_escape - end + rule %r/(?=\\)/, Str, :generic_escape rule %r/{/ do |m| if current_string.type? "f" token Str::Interpol push :generic_interpol @@ -204,26 +197,25 @@ end end end state :generic_escape do - rule %r( + rule %r(\\ ( [\\abfnrtv"'] | \n + | newline | N{[a-zA-Z][a-zA-Z ]+[a-zA-Z]} | u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} | x[a-fA-F0-9]{2} | [0-7]{1,3} ) )x do - if current_string.type? "r" - token Str - else - token Str::Escape - end + current_string.type?("r") ? token(Str) : token(Str::Escape) pop! end + + rule %r/\\./, Str, :pop! end state :generic_interpol do rule %r/[^{}]+/ do |m| recurse m[0]