diff options
Diffstat (limited to 'lib/coderay/scanner.rb')
-rw-r--r-- | lib/coderay/scanner.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/coderay/scanner.rb b/lib/coderay/scanner.rb index 8f8ca77..00dce7d 100644 --- a/lib/coderay/scanner.rb +++ b/lib/coderay/scanner.rb @@ -52,7 +52,7 @@ module CodeRay plugin_host Scanners # Raised if a Scanner fails while scanning - ScanError = Class.new Exception + ScanError = Class.new StandardError # The default options for all scanner classes. # @@ -282,8 +282,8 @@ surrounding code: EOE File.basename(caller[0]), msg, - tokens.size, - tokens.last(10).map { |t| t.inspect }.join("\n"), + tokens.respond_to?(:size) ? tokens.size : 0, + tokens.respond_to?(:last) ? tokens.last(10).map { |t| t.inspect }.join("\n") : '', line, column, pos, matched, state, bol?, eos?, string[pos - ambit, ambit], @@ -291,6 +291,14 @@ surrounding code: ] end + # Shorthand for scan_until(/\z/). + # This method also avoids a JRuby 1.9 mode bug. + def scan_rest + rest = self.rest + terminate + rest + end + end end |