diff options
-rw-r--r-- | lib/coderay/scanners/sql.rb | 19 | ||||
-rw-r--r-- | test/scanners/coderay_suite.rb | 8 |
2 files changed, 15 insertions, 12 deletions
diff --git a/lib/coderay/scanners/sql.rb b/lib/coderay/scanners/sql.rb index 9ba0b4d..126c95d 100644 --- a/lib/coderay/scanners/sql.rb +++ b/lib/coderay/scanners/sql.rb @@ -50,7 +50,7 @@ module CodeRay module Scanners kind = nil match = nil - + if state == :initial if scan(/ \s+ | \\\n /x) @@ -58,10 +58,10 @@ module CodeRay module Scanners elsif scan(/^(?:--\s?|#).*/) kind = :comment - + elsif scan(%r! /\* (?: .*? \*/ | .* ) !mx) kind = :comment - + elsif scan(/ [-+*\/=<>;,!&^|()\[\]{}~%] | \.(?!\d) /x) kind = :operator @@ -88,7 +88,7 @@ module CodeRay module Scanners elsif scan(/\d[fF]|\d*\.\d+(?:[eE][+-]?\d+)?|\d+[eE][+-]?\d+/) kind = :float - + else getch kind = :error @@ -144,16 +144,19 @@ module CodeRay module Scanners end match ||= matched -# raise [match, kind], tokens if kind == :error + unless kind + raise_inspect 'Error token %p in line %d' % + [[match, kind], line], tokens, state + end + raise_inspect 'Empty token', tokens unless match tokens << [match, kind] end -# RAILS_DEFAULT_LOGGER.info tokens.inspect tokens end - + end - + end end
\ No newline at end of file diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index 5edf6be..dc0c1a0 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -100,15 +100,15 @@ module CodeRay if ENV['deluxe'] MAX_CODE_SIZE_TO_HIGHLIGHT = 500_000_000 MAX_CODE_SIZE_TO_TEST = 500_000_000 - DEFAULT_MAX = 1024 + DEFAULT_MAX = 4096 elsif ENV['fast'] MAX_CODE_SIZE_TO_HIGHLIGHT = 5_000_000 MAX_CODE_SIZE_TO_TEST = 1_000_000 DEFAULT_MAX = 16 else - MAX_CODE_SIZE_TO_HIGHLIGHT = 5_000_000 - MAX_CODE_SIZE_TO_TEST = 5_000_000 - DEFAULT_MAX = 512 + MAX_CODE_SIZE_TO_HIGHLIGHT = 10_000_000 + MAX_CODE_SIZE_TO_TEST = 10_000_000 + DEFAULT_MAX = 1024 end class << self |