Class: AjLisp::InputSource
- Inherits:
-
Object
- Object
- AjLisp::InputSource
- Defined in:
- lib/ajlisp/input_source.rb
Instance Method Summary collapse
-
#initialize ⇒ InputSource
constructor
A new instance of InputSource.
- #nextChar ⇒ Object
- #pushChar(ch) ⇒ Object
Constructor Details
#initialize ⇒ InputSource
Returns a new instance of InputSource.
5 6 7 8 9 |
# File 'lib/ajlisp/input_source.rb', line 5 def initialize @line = "" @position = 0 @chars = [] end |
Instance Method Details
#nextChar ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ajlisp/input_source.rb', line 11 def nextChar char = @chars.pop if char return char end while @line.length <= @position @line = gets @position = 0 if @line == nil return nil end end char = @line[@position] @position += 1 return char end |
#pushChar(ch) ⇒ Object
32 33 34 |
# File 'lib/ajlisp/input_source.rb', line 32 def pushChar(ch) @chars.push ch end |