diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-15 20:20:18 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-15 20:20:18 +0000 |
commit | 889d50089d4d98db83ba5617b526da50107be661 (patch) | |
tree | d9bed99952fddce716e6d7acf189603358bb2021 /vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb | |
parent | a5849ee044837be589e9aae554cf99a394b9b9af (diff) | |
download | redmine-889d50089d4d98db83ba5617b526da50107be661.tar.gz redmine-889d50089d4d98db83ba5617b526da50107be661.zip |
Added syntax highlightment for repository files (using CodeRay).
Supported languages: c, ruby, rhtml, yaml, html, xml.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@644 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb')
-rw-r--r-- | vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb b/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb new file mode 100644 index 000000000..0dee38fa9 --- /dev/null +++ b/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb @@ -0,0 +1,60 @@ +module CodeRay +module Scanners + + # = Debug Scanner + class Debug < Scanner + + include Streamable + register_for :debug + + 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 scan(/ > /x) + kind = opened_tokens.pop + match = :close + + else + kind = :error + getch + + end + + match ||= matched + if $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 |