summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes.textile4
-rw-r--r--lib/coderay/scanners/debug.rb14
2 files changed, 13 insertions, 5 deletions
diff --git a/Changes.textile b/Changes.textile
index 2d599b7..ba19409 100644
--- a/Changes.textile
+++ b/Changes.textile
@@ -59,7 +59,9 @@ h3. @Scanners@
h3. @Scanners::Debug@
* *NEW*: Support for line tokens (@begin_line@ and @end_line@ represented by @[@ and @]@.)
-* *FIXED*: Doesn't send @:error@ and @nil@ tokens for buggy input any more.
+* *FIXED*: Don't send @:error@ and @nil@ tokens for buggy input any more.
+* *FIXED*: Closes unclosed tokens at the end of @scan_tokens@.
+* *IMPROVED*: Highlight unknown tokens as @:error@.
h3. @Scanners::Diff@
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