summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2009-04-22 02:46:32 +0000
committermurphy <murphy@rubychan.de>2009-04-22 02:46:32 +0000
commit2a9211596eafed6abd977842241f9bc369e86ef2 (patch)
tree93d330c37d5318d4aac917f90402a481427449cd
parent59b31ae8596f9606217b09d4e3f00dcf5aab8475 (diff)
downloadcoderay-2a9211596eafed6abd977842241f9bc369e86ef2.tar.gz
SQL scanner cleanup (issue #33).
* Increased size of the test suite random samples.
-rw-r--r--lib/coderay/scanners/sql.rb19
-rw-r--r--test/scanners/coderay_suite.rb8
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