Interface SourceReader

All Superinterfaces:
SourceLocationBound
All Known Subinterfaces:
HierarchicalSourceReader
All Known Implementing Classes:
GenericHierarchicalSourceReader, GenericSourceReader

public interface SourceReader extends SourceLocationBound
Source code reader. This class is almost works as the usual Reader and the implementation GenericSourceReader actually wraps the standard Reader class. The extra functionality is keeping track of the file name, the line number and the position to help error reporting of lexical and syntax analyzers and to allow character push back when the lexical analyzer needs to push back some characters.

When it comes to reading the only way to get character from the stream is calling the method get().

Author:
Peter Verhas
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Get the next character from the input stream.
    Get the source provider that provided this reader.
    void
    unget(Integer character)
    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.

    Methods inherited from interface com.scriptbasic.interfaces.SourceLocationBound

    getFileName, getLineNumber, getPosition
  • Method Details

    • unget

      void unget(Integer character)
      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.

      Parameters:
      character - the character to push back
    • get

      Integer get()
      Get the next character from the input stream.
      Returns:
      return value
    • getSourceProvider

      SourceProvider getSourceProvider()
      Get the source provider that provided this reader.
      Returns:
      the source provider object.