From 2a9211596eafed6abd977842241f9bc369e86ef2 Mon Sep 17 00:00:00 2001 From: murphy Date: Wed, 22 Apr 2009 02:46:32 +0000 Subject: SQL scanner cleanup (issue #33). * Increased size of the test suite random samples. --- lib/coderay/scanners/sql.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'lib/coderay/scanners/sql.rb') 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 -- cgit v1.2.1