Class | CodeRay::Scanners::Debug |
In: |
lib/coderay/scanners/debug.rb
|
Parent: | Scanner |
Interprets the output of the Encoders::Debug encoder.
# File lib/coderay/scanners/debug.rb, line 14 14: def scan_tokens encoder, options 15: 16: opened_tokens = [] 17: 18: until eos? 19: 20: if match = scan(/\s+/) 21: encoder.text_token match, :space 22: 23: elsif match = scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \)? /x) 24: kind = self[1].to_sym 25: match = self[2].gsub(/\\(.)/m, '\1') 26: unless TokenKinds.has_key? kind 27: kind = :error 28: match = matched 29: end 30: encoder.text_token match, kind 31: 32: elsif match = scan(/ (\w+) ([<\[]) /x) 33: kind = self[1].to_sym 34: opened_tokens << kind 35: case self[2] 36: when '<' 37: encoder.begin_group kind 38: when '[' 39: encoder.begin_line kind 40: else 41: raise 'CodeRay bug: This case should not be reached.' 42: end 43: 44: elsif !opened_tokens.empty? && match = scan(/ > /x) 45: encoder.end_group opened_tokens.pop 46: 47: elsif !opened_tokens.empty? && match = scan(/ \] /x) 48: encoder.end_line opened_tokens.pop 49: 50: else 51: encoder.text_token getch, :space 52: 53: end 54: 55: end 56: 57: encoder.end_group opened_tokens.pop until opened_tokens.empty? 58: 59: encoder 60: end