Language - Symbol table

Compiler

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:

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

Documentation / Reference





Discover More
Compiler
Compiler - Semantics Analysis

Semantic analysis is the phase in which the compiler: adds semantic information to the parse tree builds the symbol table. This phase performs semantic checks such as: type checking (checking...
Compiler
Lexical Analysis - (Token|Lexical unit|Lexeme|Symbol|Word)

A token is symbols of the vocabulary of the language. Each token is a single atomic unit of the language. The token syntax is typically a regular language, so a finite state automaton constructed from...
Word Recognition Automaton
What is a Lexer ? known also as Tokenizer or Scanner - Lexical Analysis

Lexer are also known as: * Lexical analyzer * Lexical Tokenizer * Lexical Scanner Consider the following expression: A lexer will tokenized it in the following symbol table: Token Lexeme ...



Share this page:
Follow us:
Task Runner