Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

ObjectFile Class Reference

A text file containing objects. More...

#include <ObjectFile.h>

Collaboration diagram for ObjectFile:

Collaboration graph
[legend]
List of all members.

Public Methods

 ObjectFile ()
 Default constructor.

 ObjectFile (const string &name)
 Constructs and opens an ObjectFile.

void open (const string &name)
 Opens a new file. More...

bool eof ()
 True iff end of file has been reached.

void error (const string errorString)
 Reports an error. More...

void warning (const string errorString)
 Reports a warning. More...

void unexpected (const Token &t)
 Reports that Token t was unexpected. More...

void next (Token &token)
 Reads the next Token. More...

void check (TokenId type, const Token &token)
 Checks that token if of type 'type' xor report an error. More...

Tokenpeek ()
 Peek one token ahead. More...

Token accept (TokenId type)
 Accept and return a token of type 'type'. More...


Static Public Methods

TokenId findKeyword (const string &keyword)
 Find and return the Token id of 'keyword'. More...

TokenId declareKeyword (const string &keyword)
 Declares a new keyword. More...


Protected Methods

void readToken (Token &token)
 Reads a single token from file. More...

void push (const string &name)
 Push the file include stack. More...

void pop ()
 Pops the file include stack. More...

void getChar ()
 Read the next character. More...

void skipSpaces ()
 Skips all spaces, tabs and newlines. More...


Protected Attributes

stack< TextFilefile
 Stack of included files. More...

Token peekToken
 The token that was peeked.

bool peeked
 True iff a token was peeked.

int ch
 Next character.


Static Protected Attributes

TokenId lastToken = lastsym
 TokenId of the first un-declared token.

map< string, TokenIdkeywordTable
 Keyword to TokenId table.


Related Functions

(Note that these are not member functions.)

ObjectFile & operator>> (ObjectFile &f, Token &token)
 Reads a token from ObjectFile. More...

ObjectFile & operator>> (ObjectFile &f, const TokenId token)
 Checks a token read ObjectFile. More...


Detailed Description

A text file containing objects.

The ObjectFile implements a lexical scanner on TextFile. Textfiles may contain include directives.


Member Function Documentation

Token ObjectFile::accept TokenId    type
 

Accept and return a token of type 'type'.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::check TokenId    type,
const Token   token
 

Checks that token if of type 'type' xor report an error.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

TokenId ObjectFile::declareKeyword const string &    keyword [static]
 

Declares a new keyword.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::error const string    errorString
 

Reports an error.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

TokenId ObjectFile::findKeyword const string &    keyword [static]
 

Find and return the Token id of 'keyword'.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::getChar   [protected]
 

Read the next character.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::next Token   token
 

Reads the next Token.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::open const string &    name
 

Opens a new file.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

Token & ObjectFile::peek  
 

Peek one token ahead.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::pop   [protected]
 

Pops the file include stack.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::push const string &    name [protected]
 

Push the file include stack.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::readToken Token   token [protected]
 

Reads a single token from file.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::skipSpaces   [protected]
 

Skips all spaces, tabs and newlines.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::unexpected const Token   t
 

Reports that Token t was unexpected.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.

void ObjectFile::warning const string    errorString
 

Reports a warning.

Parameters:
. 
Precondition:
.
Postcondition:
.
Returns:
.


Friends And Related Function Documentation

ObjectFile & operator>> ObjectFile &    f,
const TokenId    token
[related]
 

Checks a token read ObjectFile.

Parameters:
f  Object file to read from.
token  [in] Token id to expect.

ObjectFile & operator>> ObjectFile &    f,
Token   token
[related]
 

Reads a token from ObjectFile.

Parameters:
f  Object file to read from.
token  [out] Token read.


Member Data Documentation

stack<TextFile> ObjectFile::file [protected]
 

Stack of included files.

Current file is on top.


The documentation for this class was generated from the following files:
This documentation was generated using doxygen. If you have any comments or additions please mail me.