Class RubyLex::BufferedReader

Object
  |
  +--RubyLex::BufferedReader

Read an input stream character by character. We allow for unlimited ungetting of characters just read.

We simplify the implementation greatly by reading the entire input into a buffer initially, and then simply traversing it using pointers.

We also have to allow for the here document diversion. This little gem comes about when the lexer encounters a here document. At this point we effectively need to split the input stream into two parts: one to read the body of the here document, the other to read the rest of the input line where the here document was initially encountered. For example, we might have

  do_something(<<-A, <<-B)
    stuff
    for

    stuff
    for

When the lexer encounters the <<A, it reads until the end of the line, and keeps it around for later. It then reads the body of the here document. Once complete, it needs to read the rest of the original line, but then skip the here document body.


Attributes

line_num [R]

Constructor Summary

initialize(content)

Public Instance Method Summary

Object column
Object divert_read_from(reserve)
Object get_read
Object getc
Object getc_already_read
Object line_num
      Returns the value of attribute line_num .
Object line_num=(value)
      Sets the attribute line_num .
Object peek(at)
Object peek_equal(str)
Object ungetc(ch)

Public Instance Method Details

column

public Object column


divert_read_from

public Object divert_read_from(reserve)


get_read

public Object get_read


getc

public Object getc


getc_already_read

public Object getc_already_read


line_num

public Object line_num

Returns the value of attribute line_num


line_num=

public Object line_num=(value)

Sets the attribute line_num

Parameters:
value - the value to set the attribute line_num to.

peek

public Object peek(at)


peek_equal

public Object peek_equal(str)


ungetc

public Object ungetc(ch)

Raises:
RuntimeError