Class: Klam::Reader

Inherits:
Object
  • Object
show all
Includes:
Converters::List
Defined in:
lib/klam/reader.rb

Constant Summary

Constants included from Primitives::Lists

Primitives::Lists::EMPTY_LIST

Instance Method Summary collapse

Methods included from Converters::List

#arrayToList, #listToArray

Methods included from Primitives::Lists

#cons, #cons?, #hd, #tl

Constructor Details

#initialize(stream) ⇒ Reader

Returns a new instance of Reader.



5
6
7
# File 'lib/klam/reader.rb', line 5

def initialize(stream)
  @lexer = Klam::Lexer.new(stream)
end

Instance Method Details

#nextObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/klam/reader.rb', line 9

def next
  token = @lexer.next
  unless token.nil?
    if token.kind_of? Klam::Lexer::OpenParen
      read_list
    else
      token
    end
  end
end