Class CodeRay::Scanners::Raydebug
In: lib/coderay/scanners/raydebug.rb
Parent: Scanner

Debug Scanner

Parses the output of the Encoders::Debug encoder.

Methods

Protected Instance methods

[Source]

    # File lib/coderay/scanners/raydebug.rb, line 15
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

[Validate]