Class: CodeRay::Scanners::Delphi

### Home Classes Methods

### In Files

- lib/coderay/scanners/delphi.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::Delphi

Scanner for the Delphi language (Object Pascal).

Alias: `pascal`

### Protected Instance Methods

scan_tokens(encoder, options) click to toggle source

    # File lib/coderay/scanners/delphi.rb, line 45
    def scan_tokens encoder, options

      state = :initial
      last_token = ''

      until eos?

        if state == :initial

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

          elsif match = scan(% \{ \$ [^}]* \}? | \(\* \$ (?: .*? \*\) | .* ) !x)
            encoder.text_token match, :preprocessor
            next

          elsif match = scan(% // [^\n]* | \{ [^}]* \}? | \(\* (?: .*? \*\) | .* ) !x)
            encoder.text_token match, :comment
            next

          elsif match = scan(/ <[>=]? | >=? | :=? | [-+=*\/;,@\^|\(\)\[\]] | \.\. /)
            encoder.text_token match, :operator

          elsif match = scan(/\./)
            encoder.text_token match, :operator
            next if last_token == 'end'

          elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /)
            encoder.text_token match, NAME_FOLLOWS[last_token] ? :ident : IDENT_KIND[match]

          elsif match = skip(/ ' ( [^\n']|'' ) (?:'|$) /)
            encoder.begin_group :char
            encoder.text_token "'", :delimiter
            encoder.text_token self[1], :content
            encoder.text_token "'", :delimiter
            encoder.end_group :char
            next

          elsif match = scan(/ ' /)
            encoder.begin_group :string
            encoder.text_token match, :delimiter
            state = :string

          elsif match = scan(/ \# (?: \d+ | \$[0-9A-Fa-f]+ ) /)
            encoder.text_token match, :char

          elsif match = scan(/ \$ [0-9A-Fa-f]+ /)
            encoder.text_token match, :hex

          elsif match = scan(/ (?: \d+ ) (?![eE]|\.[^.]) /)
            encoder.text_token match, :integer

          elsif match = scan(/ \d+ (?: \.\d+ (?: [eE][+-]? \d+ )? | [eE][+-]? \d+ ) /)
            encoder.text_token match, :float

          else
            encoder.text_token getch, :error
            next

          end

        elsif state == :string
          if match = scan(/[^\n']+/)
            encoder.text_token match, :content
          elsif match = scan(/''/)
            encoder.text_token match, :char
          elsif match = scan(/'/)
            encoder.text_token match, :delimiter
            encoder.end_group :string
            state = :initial
            next
          elsif match = scan(/\n/)
            encoder.end_group :string
            encoder.text_token match, :space
            state = :initial
          else
            raise "else case \' reached; %p not handled." % peek(1), encoder
          end

        else
          raise 'else-case reached', encoder

        end

        last_token = match

      end

      if state == :string
        encoder.end_group state
      end

      encoder
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.