PhotoGENius V1.0.0
A basic library for generating photorealistic images, developed for the course Numerical techniques for photorealistic image generation.
Public Member Functions | Public Attributes | Private Member Functions | List of all members
PGENLib.InputStream Class Reference

This class implements a wrapper around a stream, with the following additional capabilities:

  1. It tracks the line number and column number;
  2. It permits to "un-read" characters and tokens.
More...

Public Member Functions

 InputStream (Stream stream, string fileName="", int tabulations=4)
 Basic constructor for the class.
 
char ReadChar ()
 Read a new character from the stream.
 
void UnreadChar (char ch)
 Push a character back to the stream.
 
void SkipWhitespacesAndComments ()
 Keep reading characters until a non-whitespace/non-comment character is found.
 
StringToken ParseStringToken (SourceLocation tokenLocation)
 Read a StringToken in a given location. More...
 
LiteralNumberToken ParseFloatToken (string firstChar, SourceLocation tokenLocation)
 Read a LiteralNumberToken in a given location. More...
 
Token ReadToken ()
 Reads a token from the stream More...
 
void UnreadToken (Token token)
 Make as if token were never read from inputFile More...
 

Public Attributes

Stream Stream
 
SourceLocation Location
 
char SavedChar
 
SourceLocation SavedLocation
 
int Tabulations
 
TokenSavedToken
 

Private Member Functions

void UpdatePosition (char ch)
 Shift the cursor one position ahead. More...
 
Token ParseKeywordOrIdentifierToken (char firstChar, SourceLocation tokenLocation)
 Read either a KeywordTokeN or a IdentifierToken in a given location. More...
 

Detailed Description

This class implements a wrapper around a stream, with the following additional capabilities:

  1. It tracks the line number and column number;
  2. It permits to "un-read" characters and tokens.

Parameters:

Stream a Stream object, used to read a file;
Location a SourceLocation object;
SavedChar a char? object, holding the un-read character or being null, if no char has been un-read;
SavedLocation a SourceLocation object with the location of the un-read character or token;
Tabulation a Ray object that hit the surface;
SavedToken a Token object, holding the un-read token or being null, if no token has been un-read.

Member Function Documentation

◆ ParseFloatToken()

LiteralNumberToken PGENLib.InputStream.ParseFloatToken ( string  firstChar,
SourceLocation  tokenLocation 
)

Read a LiteralNumberToken in a given location.

Parameters
firstChar
tokenLocation
Returns
Exceptions
GrammarErrorException

◆ ParseKeywordOrIdentifierToken()

Token PGENLib.InputStream.ParseKeywordOrIdentifierToken ( char  firstChar,
SourceLocation  tokenLocation 
)
private

Read either a KeywordTokeN or a IdentifierToken in a given location.

Parameters
firstChar
tokenLocation
Returns

◆ ParseStringToken()

StringToken PGENLib.InputStream.ParseStringToken ( SourceLocation  tokenLocation)

Read a StringToken in a given location.

Parameters
tokenLocationThe location in the file
Returns
The StringToken we just read.

◆ ReadToken()

Token PGENLib.InputStream.ReadToken ( )

Reads a token from the stream

Returns
Exceptions
GrammarErrorExceptiona lexical error is found

◆ UnreadToken()

void PGENLib.InputStream.UnreadToken ( Token  token)

Make as if token were never read from inputFile

Parameters
token

◆ UpdatePosition()

void PGENLib.InputStream.UpdatePosition ( char  ch)
private

Shift the cursor one position ahead.

Parameters
ch

The documentation for this class was generated from the following file: