Class: YARD::Parser::Ruby::Legacy::RubyLex::BufferedReader

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/parser/ruby/legacy/ruby_lex.rb

Overview

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    stuff
    for
  A
, <<-B    stuff
    for
  B
)

When the lexer encounters the <