Language - Symbol table

> Code - (Programming|Computer) Language > Computer Language - (Compiler|Interpreter) - Language translator

1 - About

A symbol table is a used by a compiler or interpreter, where each identifier (a.k.a. symbol with a name) in a program's source code is associated with information relating to its declaration or appearance in the source.

A symbol table:


3 - Example

// Declare an external function
extern double bar(double x);
// Define a public function
double foo(int count)
    double  sum = 0.0;
    // Sum all the values bar(1) to bar(count)
    for (int i = 1;  i <= count;  i++)
        sum += bar((double) i);
    return sum;

A C compiler that parses this code will contain at least the following symbol table entries:

Symbol name Type Scope
bar function, double extern
x double function parameter
foo function, double global
count int function parameter
sum double block local
i int for-loop statement

4 - Documentation / Reference

code/compiler/symbol_table.txt ยท Last modified: 2018/12/19 20:31 by gerardnico