symbol table ppt
TRANSCRIPT
IMPLEMENTATION
There are three main operations to be carried out on the symbol table:
determining whether a string has already been stored
inserting an entry for a string
deleting a string when it goes out of scope
Tablename attributes
: :
• Collect attributes when a name is declared.
Two issues:
1. interface: how to use symbol tables
2. implementation: how to implement it.
• Provide information when a name is used.
used during all phases of compilation
maintains information about many source language constructs
Incrementally constructed and expanded during the analysis phases
used directly in the code generation phases
01 PROGRAM Main02 GLOBAL a,b03 PROCEDURE P (PARAMETER x)04 LOCAL a05 BEGIN {P}06 …a…07 …b…08 …x…09 END {P}10 BEGIN{Main}11 Call P(a)12 END {Main}
Info provided by Symbol TableGiven an Identifier which name is it?What information is to be associated with a
name?How do we access this information?How do we associate this information with a
name?
Symbol TableEach piece of info associated with a name is
called an attribute.Attributes are language dependent.
Actual Characters of the nameTypeStorage allocation info (number of bytes).Line number where declaredLines where referenced.Scope.
Symbol TableA name can represent
VariableTypeConstantParameterRecordRecord FieldProcedureArrayLabelfile
Symbol TableDifferent Classes of Symbols have different
AttributesVariable, Type, Constant, parameter, record field.
Type is one of attributes.
Procedure or function.Number of parameters, parameters themselves, result
type.
Array# of Dimensions, Array bounds.
Filerecord size, record type
Other attributesA scope of a variable can be represented by
A number (Scope is just one of attributes)A different symbol table is constructed for different
scope.
Object Oriented Languages Have classes likeMethod names, class names, object names.Scoping is VERY important. (Inheritance).
Functional Languages LispBinding Issues
Symbol Table Data structures Symbol table as list
Symbol table as hash table
Symbol table as search tree
Thank you