Kinds of Symbols
A compiler must typically deal with several different kinds of
- Symbolic constants: const pi = 3.1415926
Store constant value and type; convert an identifier with this name
to a numeric constant as soon as it is looked up. The language may have
some built-in symbolic constants, such as maxint.
- Enumerated types:
type color = (red, white, blue);
Simply assign constant values 0, 1, ... to the items.
The name color becomes a subrange 0..2.
- Subrange types: type digit = 0..9;
Store the associated scalar type and the lower and upper bounds
- Scalar types:
boolean integer real char pointer
These are predefined as types in the symbol table.
- Variables: these may have scalar types or complex types.