Package com.scriptbasic.readers
Class GenericSourceReader
java.lang.Object
com.scriptbasic.readers.GenericSourceReader
- All Implemented Interfaces:
SourceLocationBound,SourceReader
-
Constructor Summary
ConstructorsConstructorDescriptionGenericSourceReader(Reader reader, SourceProvider sourceProvider, String sourceFileName) -
Method Summary
Modifier and TypeMethodDescriptionget()Get the next character from the input stream.Get the name of the file to which the object is bound to.intGet the line number to which the object is bound to.intGet the position on the line to which the object is bound to.Get the source provider that provided this reader.voidReaders 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.
-
Constructor Details
-
GenericSourceReader
-
-
Method Details
-
getFileName
Description copied from interface:SourceLocationBoundGet the name of the file to which the object is bound to.- Specified by:
getFileNamein interfaceSourceLocationBound- Returns:
- the name of the file
-
getLineNumber
public int getLineNumber()Description copied from interface:SourceLocationBoundGet the line number to which the object is bound to.- Specified by:
getLineNumberin interfaceSourceLocationBound- Returns:
- the line number in the file
-
getPosition
public int getPosition()Description copied from interface:SourceLocationBoundGet the position on the line to which the object is bound to.- Specified by:
getPositionin interfaceSourceLocationBound- Returns:
- the position within the line
-
unget
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
nullparameter.This implementation will not track the position properly when a new line character is pushed back. Such a push back does not happen when using Basic lexical analysis.
- Specified by:
ungetin interfaceSourceReader- Parameters:
ch- the character to push back
-
get
Get the next character from the input stream.- Specified by:
getin interfaceSourceReader- Returns:
- return value
-
getSourceProvider
Description copied from interface:SourceReaderGet the source provider that provided this reader.- Specified by:
getSourceProviderin interfaceSourceReader- Returns:
- the source provider object.
-