Methods

Files

Class Index [+]

Quicksearch

CodeRay::Scanners::Scheme

Scheme scanner for CodeRay (by closure). Thanks to murphy for putting CodeRay into public.

Constants

CORE_FORMS
IDENT_KIND
IDENTIFIER

IDENTIFIER_INITIAL = /[a-z!@$%&*/\:<=>?~_^]/i IDENTIFIER_SUBSEQUENT = /#{IDENTIFIER_INITIAL}|d|.|+|-/ IDENTIFIER = /#{IDENTIFIER_INITIAL}#{IDENTIFIER_SUBSEQUENT}*|+|-|.{3}/

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

Private Instance Methods

scan_tokens(tokens,options) click to toggle source
     # File lib/coderay/scanners/scheme.rb, line 73
 73:       def scan_tokens tokens,options
 74:         
 75:         state = :initial
 76:         ident_kind = IDENT_KIND
 77:         
 78:         until eos?
 79:           kind = match = nil
 80:           
 81:           case state
 82:           when :initial
 83:             if scan(/ \s+ | \\\n /)
 84:               kind = :space
 85:             elsif scan(/['\(\[\)\]]|#\(/)
 86:               kind = :operator_fat
 87:             elsif scan(/;.*/)
 88:               kind = :comment
 89:             elsif scan(/#\\(?:newline|space|.?)/)
 90:               kind = :char
 91:             elsif scan(/#[ft]/)
 92:               kind = :pre_constant
 93:             elsif scan(/#{IDENTIFIER}/)
 94:               kind = ident_kind[matched]
 95:             elsif scan(/\./)
 96:               kind = :operator
 97:             elsif scan(/"/)
 98:               tokens << [:open, :string]
 99:               state = :string
100:               tokens << ['"', :delimiter]
101:               next
102:             elsif scan(/#{NUM}/) and not matched.empty?
103:               kind = :integer
104:             elsif getch
105:               kind = :error
106:             end
107:             
108:           when :string
109:             if scan(/[^"\\]+/) or scan(/\\.?/)
110:               kind = :content
111:             elsif scan(/"/)
112:               tokens << ['"', :delimiter]
113:               tokens << [:close, :string]
114:               state = :initial
115:               next
116:             else
117:               raise_inspect "else case \" reached; %p not handled." % peek(1),
118:                 tokens, state
119:             end
120:             
121:           else
122:             raise "else case reached"
123:           end
124:           
125:           match ||= matched
126:           if $CODERAY_DEBUG and not kind
127:             raise_inspect 'Error token %p in line %d' %
128:             [[match, kind], line], tokens
129:           end
130:           raise_inspect 'Empty token', tokens, state unless match
131:           
132:           tokens << [match, kind]
133:           
134:         end  # until eos
135:         
136:         if state == :string
137:           tokens << [:close, :string]
138:         end
139:         
140:         tokens
141:         
142:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.