In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier, symbol, constant, procedure and function in a program's source code is associated with information relating to its declaration or appearance in the source.
Most compilers print some or all of this information in symbol table and cross-reference listings at the end of translation.
The symbol table is accessed by most phases of a compiler, beginning with lexical analysis, and continuing through optimization.
[3] As the lexical analyser spends a great proportion of its time looking up the symbol table, this activity has a crucial effect on the overall speed of the compiler.
While reverse engineering an executable, many tools refer to the symbol table to check what addresses have been assigned to global variables and known functions.
If the symbol table has been stripped or cleaned out before being converted into an executable, tools will find it harder to determine addresses or understand anything about the program.
Consider the following program written in C: A C compiler that parses this code will contain at least the following symbol table entries: In addition, the symbol table may also contain entries generated by the compiler for intermediate expression values (e.g., the expression that casts the i loop variable into a double, and the return value of the call to function bar()), statement labels, and so forth.
The Python programming language includes extensive support for creating and manipulating symbol tables.
Similarly, OpenCog provides a dynamic symbol table, called the atomspace, which is used for knowledge representation.