Class GenericHierarchicalSourceReader

java.lang.Object
com.scriptbasic.readers.GenericHierarchicalSourceReader
All Implemented Interfaces:
SourceLocationBound, HierarchicalSourceReader, SourceReader

public class GenericHierarchicalSourceReader extends Object implements HierarchicalSourceReader
  • Constructor Details

    • GenericHierarchicalSourceReader

      public GenericHierarchicalSourceReader(SourceReader reader)
  • Method Details

    • include

      public void include(SourceReader reader)
      Include a new reader into the chain and start to use that child reader so long as long exhausts.
      Specified by:
      include in interface HierarchicalSourceReader
      Parameters:
      reader - parameter
    • getFileName

      public String getFileName()
      Description copied from interface: SourceLocationBound
      Get the name of the file to which the object is bound to.
      Specified by:
      getFileName in interface SourceLocationBound
      Returns:
      the name of the file
    • getLineNumber

      public int getLineNumber()
      Description copied from interface: SourceLocationBound
      Get the line number to which the object is bound to.
      Specified by:
      getLineNumber in interface SourceLocationBound
      Returns:
      the line number in the file
    • getPosition

      public int getPosition()
      Description copied from interface: SourceLocationBound
      Get the position on the line to which the object is bound to.
      Specified by:
      getPosition in interface SourceLocationBound
      Returns:
      the position within the line
    • unget

      public void unget(Integer ch)
      Description copied from interface: SourceReader
      Readers should support lexical analyzers offering the possibility to push some characters back to the input stream, when a lexical analyzer can not decide its selection only consuming extra characters.

      Some of the readers may limit the operation of this push back functionality not supporting tracking line numbers, position and file name when this method is used.

      Lexical analyzers should push back the characters that were read from the reader the backward order as they were read. (Read last pushed back first.)

      Implementation should ignore null parameter.

      Specified by:
      unget in interface SourceReader
      Parameters:
      ch - the character to push back
    • get

      public Integer get()
      Get the next character from the input stream.

      This version implements hierarchical reading. When a source finishes, it returns to the parent reader and continues reading from there.

      Specified by:
      get in interface SourceReader
      Returns:
      return value
    • getSourceProvider

      public SourceProvider getSourceProvider()
      Description copied from interface: SourceReader
      Get the source provider that provided this reader.
      Specified by:
      getSourceProvider in interface SourceReader
      Returns:
      the source provider object.