kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.3 KiB
63 lines
1.3 KiB
18 years ago
|
module CodeRay
|
||
|
module Scanners
|
||
|
|
||
|
# = Debug Scanner
|
||
|
class Debug < Scanner
|
||
|
|
||
|
include Streamable
|
||
|
register_for :debug
|
||
15 years ago
|
file_extension 'raydebug'
|
||
|
title 'CodeRay Token Dump'
|
||
18 years ago
|
|
||
|
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
|
||
|
|
||
15 years ago
|
elsif !opened_tokens.empty? && scan(/ > /x)
|
||
|
kind = opened_tokens.pop || :error
|
||
18 years ago
|
match = :close
|
||
|
|
||
|
else
|
||
|
kind = :error
|
||
|
getch
|
||
|
|
||
|
end
|
||
|
|
||
|
match ||= matched
|
||
15 years ago
|
if $CODERAY_DEBUG and not kind
|
||
18 years ago
|
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
|