#include <util.H>
Public Member Functions | |
SymbolTable (const string &fileName=string()) | |
Ctor; loads from file fileName if argument present. | |
void | read (const string &fileName) |
Reads symbols from file fileName . | |
void | clear () |
Clears object. | |
unsigned | size () const |
Returns number of symbols in table. | |
bool | empty () const |
Returns whether symbol table is empty. | |
int | get_index (const string &theStr) const |
Maps from a string to its index. | |
string | get_str (unsigned theIdx) const |
Maps from an index to its string. |
In graphs/FSM's, word labels are stored internally as integers. This object holds the mapping from word spellings to their integer representations, and vice versa. Word indices are constrained to be nonnegative, though they need not be consecutive. By convention, the word index corresponding to epsilon (i.e., the representation of the empty string) is 0.
SymbolTable::SymbolTable | ( | const string & | fileName = string() |
) | [inline] |
Ctor; loads from file fileName
if argument present.
void SymbolTable::read | ( | const string & | fileName | ) |
Reads symbols from file fileName
.
void SymbolTable::clear | ( | ) |
Clears object.
unsigned SymbolTable::size | ( | ) | const [inline] |
Returns number of symbols in table.
bool SymbolTable::empty | ( | ) | const [inline] |
Returns whether symbol table is empty.
int SymbolTable::get_index | ( | const string & | theStr | ) | const [inline] |
Maps from a string to its index.
If not in table, returns -1.
string SymbolTable::get_str | ( | unsigned | theIdx | ) | const [inline] |
Maps from an index to its string.
If not in table, returns empty string.