Clojure scanner by Licenser.
# 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(%r \s+ | \\\n | , /) encoder.text_token match, :space elsif match = scan(%r['`\(\[\)\]\{\}]|\#[({]|~@?|[@\^]/) encoder.text_token match, :operator elsif match = scan(%r;.*/) encoder.text_token match, :comment # TODO: recognize (comment ...) too elsif match = scan(%r\#?\\(?:newline|space|.?)/) encoder.text_token match, :char elsif match = scan(%r\#[ft]/) encoder.text_token match, :predefined_constant elsif match = scan(%r#{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(%r\s+/) encoder.text_token match, kind if match = scan(%r#{IDENTIFIER}/) end end elsif match = scan(%r#{SYMBOL}/) encoder.text_token match, :symbol elsif match = scan(%r\./) encoder.text_token match, :operator elsif match = scan(%r \# \^ #{IDENTIFIER} /x) encoder.text_token match, :type elsif match = scan(%r (\#)? " /) state = self[1] ? :regexp : :string encoder.begin_group state encoder.text_token match, :delimiter elsif match = scan(%r#{NUM}/) and not matched.empty? encoder.text_token match, match[%r[.e\/]/] ? :float : :integer else encoder.text_token getch, :error end when :string, :regexp if match = scan(%r[^"\\]+|\\.?/) encoder.text_token match, :content elsif match = scan(%r"/) 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