Methods

CodeRay::Scanners::Clojure

Clojure scanner by Licenser.

Constants

IDENT_KIND
KEYWORD_NEXT_TOKEN_KIND
BASIC_IDENTIFIER
IDENTIFIER
SYMBOL
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

Protected Instance Methods

scan_tokens(encoder, options) click to toggle source
     # File lib/coderay/scanners/clojure.rb, line 145
145:       def scan_tokens encoder, options
146:         
147:         state = :initial
148:         kind = nil
149:         
150:         until eos?
151:           
152:           case state
153:           when :initial
154:             if match = scan(/ \s+ | \\\n | , /)
155:               encoder.text_token match, :space
156:             elsif match = scan(/['`\(\[\)\]\{\}]|\#[({]|~@?|[@\^]/)
157:               encoder.text_token match, :operator
158:             elsif match = scan(/;.*/)
159:               encoder.text_token match, :comment  # TODO: recognize (comment ...) too
160:             elsif match = scan(/\#?\\(?:newline|space|.?)/)
161:               encoder.text_token match, :char
162:             elsif match = scan(/\#[ft]/)
163:               encoder.text_token match, :predefined_constant
164:             elsif match = scan(/#{IDENTIFIER}/)
165:               kind = IDENT_KIND[match]
166:               encoder.text_token match, kind
167:               if rest? && kind == :keyword
168:                 if kind = KEYWORD_NEXT_TOKEN_KIND[match]
169:                   encoder.text_token match, :space if match = scan(/\s+/)
170:                   encoder.text_token match, kind if match = scan(/#{IDENTIFIER}/)
171:                 end
172:               end
173:             elsif match = scan(/#{SYMBOL}/)
174:               encoder.text_token match, :symbol
175:             elsif match = scan(/\./)
176:               encoder.text_token match, :operator
177:             elsif match = scan(/ \# \^ #{IDENTIFIER} /x)
178:               encoder.text_token match, :type
179:             elsif match = scan(/ (\#)? " /)
180:               state = self[1] ? :regexp : :string
181:               encoder.begin_group state
182:               encoder.text_token match, :delimiter
183:             elsif match = scan(/#{NUM}/) and not matched.empty?
184:               encoder.text_token match, match[/[.e\/]/] ? :float : :integer
185:             else
186:               encoder.text_token getch, :error
187:             end
188:             
189:           when :string, :regexp
190:             if match = scan(/[^"\\]+|\\.?/)
191:               encoder.text_token match, :content
192:             elsif match = scan(/"/)
193:               encoder.text_token match, :delimiter
194:               encoder.end_group state
195:               state = :initial
196:             else
197:               raise_inspect "else case \" reached; %p not handled." % peek(1),
198:                 encoder, state
199:             end
200:             
201:           else
202:             raise 'else case reached'
203:             
204:           end
205:           
206:         end
207:         
208:         if [:string, :regexp].include? state
209:           encoder.end_group state
210:         end
211:         
212:         encoder
213:         
214:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.