diff --git a/lib/rouge/lexers/lua.rb b/lib/rouge/lexers/lua.rb index add4055b2d..8059912183 100644 --- a/lib/rouge/lexers/lua.rb +++ b/lib/rouge/lexers/lua.rb @@ -72,7 +72,10 @@ def builtins rule %r([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?) do |m| name = m[0] - if self.builtins.include?(name) + if name == "gsub" + token Name::Builtin + push :gsub + elsif self.builtins.include?(name) token Name::Builtin elsif name =~ /\./ a, b = name.split('.', 2) @@ -98,6 +101,41 @@ def builtins rule %r(\(), Punctuation, :pop! end + state :gsub do + rule %r/\)/, Punctuation, :pop! + rule %r/[(,]/, Punctuation + rule %r/\s+/, Text + rule %r/"/, Str::Regex, :regex + end + + state :regex do + rule %r(") do + token Str::Regex + goto :regex_end + end + + rule %r/\[\^?/, Str::Escape, :regex_group + rule %r/\\./, Str::Escape + rule %r{[(][?][:=