Symbol Table Ppt.
Transcript of Symbol Table Ppt.
![Page 1: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/1.jpg)
IMPLEMENTATION
![Page 2: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/2.jpg)
![Page 3: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/3.jpg)
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
![Page 4: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/4.jpg)
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.
![Page 5: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/5.jpg)
![Page 6: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/6.jpg)
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
![Page 7: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/7.jpg)
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}
![Page 8: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/8.jpg)
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?
![Page 9: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/9.jpg)
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.
![Page 10: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/10.jpg)
Symbol TableA name can represent
VariableTypeConstantParameterRecordRecord FieldProcedureArrayLabelfile
![Page 11: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/11.jpg)
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
![Page 12: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/12.jpg)
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
![Page 13: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/13.jpg)
Symbol Table Data structures Symbol table as list
Symbol table as hash table
Symbol table as search tree
![Page 14: Symbol Table Ppt.](https://reader034.fdocuments.in/reader034/viewer/2022042423/544e8cc2af7959d91e8b4a10/html5/thumbnails/14.jpg)
Thank you