diff options
author | murphy <murphy@rubychan.de> | 2009-04-22 02:46:32 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2009-04-22 02:46:32 +0000 |
commit | 2a9211596eafed6abd977842241f9bc369e86ef2 (patch) | |
tree | 93d330c37d5318d4aac917f90402a481427449cd /lib/coderay/scanners | |
parent | 59b31ae8596f9606217b09d4e3f00dcf5aab8475 (diff) | |
download | coderay-2a9211596eafed6abd977842241f9bc369e86ef2.tar.gz |
SQL scanner cleanup (issue #33).
* Increased size of the test suite random samples.
Diffstat (limited to 'lib/coderay/scanners')
-rw-r--r-- | lib/coderay/scanners/sql.rb | 19 |
1 files changed, 11 insertions, 8 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 |