6. Symbol table
Once completed the syntax analysis, we can start to develop the semantic analysis phase. First of all we have to design the symbol table organization, in order to hold information about input symbols and expression declarations. Entries in a table are key-value pairs, where the key is the lexeme of an input symbol or an identifier and the value is an instance of the class Symb, declared in Symb.java, that will contain information about that key (in this first implementation Symb is empty). Symbol tables can be structured as Java TreeMaps, as done in the class SymTable, declared in SymTable.java , and their construction for RLA is specified in rla.cup. You can generate the parser and run it on the input program Sample.rla by means of rla.bat (SymTable.java and Symb.java should be stored in a subdirectory named symtab). The output reported in SymbolTableResult.txt will be printed on the Java console.
|