Class: Clojure::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/clj/parser.rb,
ext/clj/parser.c

Constant Summary collapse

NUMBERS =
'0' .. '9'
UNICODE_REGEX =
/[0-9|a-f|A-F]{4}/
OCTAL_REGEX =
/[0-3]?[0-7]?[0-7]/

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ Parser

Returns a new instance of Parser.


460
461
462
463
464
465
466
467
468
# File 'ext/clj/parser.c', line 460

def initialize (source, options = {})
	@source  = source.is_a?(String) ? StringIO.new(source) : source
	@options = options

	@map_class    = options[:map_class]    || Clojure::Map
	@vector_class = options[:vector_class] || Clojure::Vector
	@list_class   = options[:list_class]   || Clojure::List
	@set_class    = options[:set_class]    || Clojure::Set
end

Instance Method Details

#parseObject


514
515
516
517
518
519
520
521
522
523
524
# File 'ext/clj/parser.c', line 514

def parse
	result = read_next

	ignore(false)

	if @source.read(1)
		raise SyntaxError, 'there is some unconsumed input'
	end

	result
end