Class: CodeRay::Scanners::Clojure

### Home Classes Methods

### In Files

- lib/coderay/scanners/clojure.rb

### Parent

CodeRay::Scanners::Scanner

### Methods

- #scan_tokens

### 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::Clojure

Clojure scanner by Licenser.

### Constants

BASIC_IDENTIFIER
COMPLEX10
COMPLEX16
COMPLEX2
COMPLEX8
DECIMAL
DIGIT
DIGIT10
DIGIT16
DIGIT2
DIGIT8
EXACTNESS
EXP
EXP_MARK
IDENTIFIER
IDENT_KIND
IMAG10
IMAG16
IMAG2
IMAG8
KEYWORD_NEXT_TOKEN_KIND
NUM
NUM10
NUM16
NUM2
NUM8
PREFIX10
PREFIX16
PREFIX2
PREFIX8
RADIX10
RADIX16
RADIX2
RADIX8
REAL10
REAL16
REAL2
REAL8
SIGN
SUFFIX
SYMBOL
UINT10
UINT16
UINT2
UINT8
UREAL10
UREAL16
UREAL2
UREAL8

### Protected Instance Methods

scan_tokens(encoder, options) click to toggle source

    # File lib/coderay/scanners/clojure.rb, line 144
    def scan_tokens encoder, options

      state = :initial
      kind = nil

      until eos?

        case state
        when :initial
          if match = scan(/ \s+ | \\\n | , /)
            encoder.text_token match, :space
          elsif match = scan(/['`\(\[\)\]\{\}]|\#[({]|~@?|[@\^]/)
            encoder.text_token match, :operator
          elsif match = scan(/;.*/)
            encoder.text_token match, :comment  # TODO: recognize (comment ...) too
          elsif match = scan(/\#?\\(?:newline|space|.?)/)
            encoder.text_token match, :char
          elsif match = scan(/\#[ft]/)
            encoder.text_token match, :predefined_constant
          elsif match = scan(/#{IDENTIFIER}/)
            kind = IDENT_KIND[match]
            encoder.text_token match, kind
            if rest? && kind == :keyword
              if kind = KEYWORD_NEXT_TOKEN_KIND[match]
                encoder.text_token match, :space if match = scan(/\s+/)
                encoder.text_token match, kind if match = scan(/#{IDENTIFIER}/)
              end
            end
          elsif match = scan(/#{SYMBOL}/)
            encoder.text_token match, :symbol
          elsif match = scan(/\./)
            encoder.text_token match, :operator
          elsif match = scan(/ \# \^ #{IDENTIFIER} /x)
            encoder.text_token match, :type
          elsif match = scan(/ (\#)? " /)
            state = self[1] ? :regexp : :string
            encoder.begin_group state
            encoder.text_token match, :delimiter
          elsif match = scan(/#{NUM}/) and not matched.empty?
            encoder.text_token match, match[/[.e\/]/] ? :float : :integer
          else
            encoder.text_token getch, :error
          end

        when :string, :regexp
          if match = scan(/[^"\\]+|\\.?/)
            encoder.text_token match, :content
          elsif match = scan(/"/)
            encoder.text_token match, :delimiter
            encoder.end_group state
            state = :initial
          else
            raise_inspect "else case \" reached; %p not handled." % peek(1),
              encoder, state
          end

        else
          raise 'else case reached'

        end

      end

      if [:string, :regexp].include? state
        encoder.end_group state
      end

      encoder

    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.