summaryrefslogtreecommitdiff
path: root/lib/coderay/scanners/debug.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-03-31 21:19:14 +0000
committermurphy <murphy@rubychan.de>2010-03-31 21:19:14 +0000
commitf6645377402a0e7687944d88a4366c9a20523553 (patch)
tree9e9cddc6729a8867e109f025274b36c4e9789447 /lib/coderay/scanners/debug.rb
parent9b5bfe0be01bd888c2ba3fccf68585a72f608ef6 (diff)
downloadcoderay-f6645377402a0e7687944d88a4366c9a20523553.tar.gz
Improved Debug scanner (see Changes.textile).
Diffstat (limited to 'lib/coderay/scanners/debug.rb')
-rw-r--r--lib/coderay/scanners/debug.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/coderay/scanners/debug.rb b/lib/coderay/scanners/debug.rb
index f206f4e..e33bff2 100644
--- a/lib/coderay/scanners/debug.rb
+++ b/lib/coderay/scanners/debug.rb
@@ -27,9 +27,13 @@ module Scanners
tokens << [matched, :space]
next
- elsif scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \) /x)
+ elsif scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \)? /x)
kind = self[1].to_sym
match = self[2].gsub(/\\(.)/, '\1')
+ unless Tokens::AbbreviationForKind.has_key? kind
+ kind = :error
+ match = matched
+ end
elsif scan(/ (\w+) ([<\[]) /x)
kind = self[1].to_sym
@@ -54,20 +58,22 @@ module Scanners
else
kind = :space
getch
-
+
end
-
+
match ||= matched
if $CODERAY_DEBUG and not kind
raise_inspect 'Error token %p in line %d' %
[[match, kind], line], tokens
end
raise_inspect 'Empty token', tokens unless match
-
+
tokens << [match, kind]
end
+ tokens << [:close, opened_tokens.pop] until opened_tokens.empty?
+
tokens
end