Class: CodeRay::Scanners::Debug

### Home Classes Methods

### In Files

- lib/coderay/scanners/debug.rb

### Parent

CodeRay::Scanners::Scanner

### Methods

- #scan_tokens
- #setup

### Class/Module Index

Quicksearch

- CodeRay
- CodeRay::Duo
- CodeRay::Encoders
- CodeRay::Encoders::CommentFilter
- CodeRay::Encoders::Count
- CodeRay::Encoders::Debug
- CodeRay::Encoders::DebugLint
- CodeRay::Encoders::Div
- CodeRay::Encoders::Encoder
- CodeRay::Encoders::Filter
- CodeRay::Encoders::HTML
- CodeRay::Encoders::HTML::Output
- CodeRay::Encoders::JSON
- CodeRay::Encoders::LinesOfCode
- CodeRay::Encoders::Lint
- CodeRay::Encoders::Null
- CodeRay::Encoders::Page
- CodeRay::Encoders::Span
- CodeRay::Encoders::Statistic
- CodeRay::Encoders::Terminal
- CodeRay::Encoders::Text
- CodeRay::Encoders::TokenKindFilter
- CodeRay::Encoders::XML
- CodeRay::Encoders::YAML
- CodeRay::FileType
- CodeRay::ForRedCloth
- CodeRay::Plugin
- CodeRay::PluginHost
- CodeRay::Scanners
- CodeRay::Scanners::C
- CodeRay::Scanners::CPlusPlus
- CodeRay::Scanners::CSS
- CodeRay::Scanners::Clojure
- CodeRay::Scanners::Debug
- CodeRay::Scanners::Delphi
- CodeRay::Scanners::Diff
- CodeRay::Scanners::ERB
- CodeRay::Scanners::Go
- CodeRay::Scanners::Groovy
- CodeRay::Scanners::HAML
- CodeRay::Scanners::HTML
- CodeRay::Scanners::JSON
- CodeRay::Scanners::Java
- CodeRay::Scanners::JavaScript
- CodeRay::Scanners::Python
- CodeRay::Scanners::Raydebug
- CodeRay::Scanners::Ruby
- CodeRay::Scanners::SQL
- CodeRay::Scanners::Sass
- CodeRay::Scanners::Scanner
- CodeRay::Scanners::Taskpaper
- CodeRay::Scanners::Text
- CodeRay::Scanners::XML
- CodeRay::Scanners::YAML
- CodeRay::Styles
- CodeRay::Styles::Alpha
- CodeRay::Styles::Style
- CodeRay::Tokens
- CodeRay::TokensProxy
- CodeRay::WordList
- CodeRay::WordList::CaseIgnoring

No matching classes.

# CodeRay::Scanners::Debug

# Debug Scanner

Interprets the output of the Encoders::Debug encoder (basically the inverse function).

### Protected Instance Methods

scan_tokens(encoder, options) click to toggle source

    # File lib/coderay/scanners/debug.rb, line 21
    def scan_tokens encoder, options

      opened_tokens = []

      until eos?

        if match = scan(/\s+/)
          encoder.text_token match, :space

        elsif match = scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \)? /)
          if @known_token_kinds.include? self[1]
            encoder.text_token self[2].gsub(/\\(.)/, '\1'), self[1].to_sym
          else
            encoder.text_token matched, :unknown
          end

        elsif match = scan(/ (\w+) ([<\[]) /)
          if @known_token_kinds.include? self[1]
            kind = self[1].to_sym
          else
            kind = :unknown
          end

          opened_tokens << kind
          case self[2]
          when '<'
            encoder.begin_group kind
          when '['
            encoder.begin_line kind
          else
            raise 'CodeRay bug: This case should not be reached.'
          end

        elsif !opened_tokens.empty? && match = scan(/ > /)
          encoder.end_group opened_tokens.pop

        elsif !opened_tokens.empty? && match = scan(/ \] /)
          encoder.end_line opened_tokens.pop

        else
          encoder.text_token getch, :space

        end

      end

      encoder.end_group opened_tokens.pop until opened_tokens.empty?

      encoder
    end

setup() click to toggle source

    # File lib/coderay/scanners/debug.rb, line 16
    def setup
      super
      @known_token_kinds = TokenKinds.keys.map(&:to_s).to_set
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.