comparison vendor/gems/coderay-1.0.0/lib/coderay/scanners/raydebug.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents
children
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
1 module CodeRay
2 module Scanners
3
4 # = Debug Scanner
5 #
6 # Parses the output of the Encoders::Debug encoder.
7 class Raydebug < Scanner
8
9 register_for :raydebug
10 file_extension 'raydebug'
11 title 'CodeRay Token Dump'
12
13 protected
14
15 def scan_tokens encoder, options
16
17 opened_tokens = []
18
19 until eos?
20
21 if match = scan(/\s+/)
22 encoder.text_token match, :space
23
24 elsif match = scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) /x)
25 kind = self[1]
26 encoder.text_token kind, :class
27 encoder.text_token '(', :operator
28 match = self[2]
29 encoder.text_token match, kind.to_sym
30 encoder.text_token match, :operator if match = scan(/\)/)
31
32 elsif match = scan(/ (\w+) ([<\[]) /x)
33 kind = self[1]
34 case self[2]
35 when '<'
36 encoder.text_token kind, :class
37 when '['
38 encoder.text_token kind, :class
39 else
40 raise 'CodeRay bug: This case should not be reached.'
41 end
42 kind = kind.to_sym
43 opened_tokens << kind
44 encoder.begin_group kind
45 encoder.text_token self[2], :operator
46
47 elsif !opened_tokens.empty? && match = scan(/ [>\]] /x)
48 encoder.text_token match, :operator
49 encoder.end_group opened_tokens.pop
50
51 else
52 encoder.text_token getch, :space
53
54 end
55
56 end
57
58 encoder.end_group opened_tokens.pop until opened_tokens.empty?
59
60 encoder
61 end
62
63 end
64
65 end
66 end