Class: Kapusta::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/kapusta/reader.rb

Constant Summary collapse

WHITESPACE =
[' ', "\t", "\n", "\r", "\f", "\v", ','].freeze
DELIMS =
['(', ')', '[', ']', '{', '}', '"', ';'].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Reader

Returns a new instance of Reader.



12
13
14
15
# File 'lib/kapusta/reader.rb', line 12

def initialize(source)
  @src = source
  @pos = 0
end

Class Method Details

.read_all(source) ⇒ Object



8
9
10
# File 'lib/kapusta/reader.rb', line 8

def self.read_all(source)
  new(source).read_all
end

Instance Method Details

#read_allObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/kapusta/reader.rb', line 17

def read_all
  forms = []
  loop do
    skip_ws
    break if eof?

    forms << read_form
  end
  forms
end