module XfOOrth::ReadPoint
This module is used to facilitate the reading of source code text from a buffer.
Attributes
read_buffer[R]
Get the current line of text being read.
Public Instance Methods
eoln?()
click to toggle source
Is the read point at the end of line?
# File lib/fOOrth/compiler/source/read_point.rb, line 41 def eoln? @eoln end
read(&block)
click to toggle source
Read the next character of data from the source. If there is nothing to read, call the block to get some more data to work with.
Parameters
-
block - A block of code that retrieves the next line of source code to be processed.
# File lib/fOOrth/compiler/source/read_point.rb, line 25 def read(&block) unless @read_point return nil unless (@read_buffer = block.call) @read_point = @read_buffer.each_char end begin result, @eoln = @read_point.next, false rescue StopIteration result, @read_point, @eoln = ' ', nil, true end result end
reset_read_point()
click to toggle source
Reset the read point to the initial conditions. Namely, no text in the buffer and not at end of line,
# File lib/fOOrth/compiler/source/read_point.rb, line 14 def reset_read_point @read_point = nil @eoln = false end