Sha256: 87f978ecde549b41c6a268117464396049d5ee284744becf1fee3cd45ac4bd0c

Contents?: true

Size: 1.18 KB

Versions: 14

Compression:

Stored size: 1.18 KB

Contents

module CodeRay
module Scanners

  # = Debug Scanner
  class Debug < Scanner

    include Streamable
    register_for :debug
    file_extension 'raydebug'

  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
            
          elsif scan(/ > /x)
            kind = opened_tokens.pop
            match = :close
            
          else
            kind = :error
            getch

          end
                  
        match ||= matched
        if $DEBUG and not kind
          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

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
raldred-coderay-0.9.339 ./lib/coderay/scanners/debug.rb
raldred-coderay-0.9.3391 ./lib/coderay/scanners/debug.rb
raldred-coderay-0.9.3431 ./lib/coderay/scanners/debug.rb
coderay-0.8.357 ./lib/coderay/scanners/debug.rb
coderay-0.8.260 ./lib/coderay/scanners/debug.rb
coderay-0.8.273 ./lib/coderay/scanners/debug.rb
coderay-0.8.263 ./lib/coderay/scanners/debug.rb
coderay-0.8.303 ./lib/coderay/scanners/debug.rb
coderay-0.8.270 ./lib/coderay/scanners/debug.rb
coderay-0.8.312 ./lib/coderay/scanners/debug.rb
typo-5.1.98 vendor/gems/coderay-0.8.260/lib/coderay/scanners/debug.rb
typo-5.2 vendor/gems/coderay-0.8.260/lib/coderay/scanners/debug.rb
typo-5.2.98 vendor/gems/coderay-0.8.260/lib/coderay/scanners/debug.rb
typo-5.3 vendor/gems/coderay-0.8.260/lib/coderay/scanners/debug.rb