Mercurial > hg > soundsoftware-site
diff vendor/gems/coderay-0.9.7/lib/coderay/scanners/.svn/text-base/debug.rb.svn-base @ 210:0579821a129a
Update to Redmine trunk rev 4802
author | Chris Cannam |
---|---|
date | Tue, 08 Feb 2011 13:51:46 +0000 |
parents | vendor/plugins/coderay-0.9.2/lib/coderay/scanners/debug.rb@513646585e45 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/gems/coderay-0.9.7/lib/coderay/scanners/.svn/text-base/debug.rb.svn-base Tue Feb 08 13:51:46 2011 +0000 @@ -0,0 +1,62 @@ +module CodeRay +module Scanners + + # = Debug Scanner + class Debug < Scanner + + include Streamable + register_for :debug + file_extension 'raydebug' + title 'CodeRay Token Dump' + + protected + def scan_tokens tokens, options + + opened_tokens = [] + + until eos? + + kind = nil + match = nil + + if scan(/\s+/) + tokens << [matched, :space] + next + + elsif scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \) /x) + kind = self[1].to_sym + match = self[2].gsub(/\\(.)/, '\1') + + elsif scan(/ (\w+) < /x) + kind = self[1].to_sym + opened_tokens << kind + match = :open + + elsif !opened_tokens.empty? && scan(/ > /x) + kind = opened_tokens.pop || :error + match = :close + + else + kind = :error + 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 + end + + end + +end +end