[symbols.h] Type: Symbol


#include "standard.h"



    This module implements the symbol type for a unique representation of strings
    and the symbol table in which they are stored. One intention is the reduction
    of place- and time-complexity when dealing with many identical strings.

    Spezification
    1) forall String s : strcmp(s,symbolToString(stringToSymbol(s))) == 0.
    2) forall Symbol s : equalSymbols(s,stringToSymbol(symbolToString(s)).
    3) equalSymbols is an equality.



The Type


symbol Abstract symbol type


Init & Quit

void initSymbols(void)
initializes the symbol table
void freeSymbols(void)
releases the symbol table


Conversion

symbol stringToSymbol(c_string str)
converts string 'str' into a symbol
symbol lstringToSymbol(c_string str)
converts ( lower case ) string 'str' into a symbol
symbol ustringToSymbol(c_string str)
converts ( upper case ) string 'str' into a symbol
c_string symbolToString(symbol sym)
string corresponding to symbol 'sym'


Predicates

c_bool equalSymbols(symbol a, symbol b)
whether two symbols 'a' and 'b' are equal


Debugging

void printSymbols(int indent)
prints the symbol table to stdout
int countSymbols(void)
number of symbols in the symbol table