+ All Categories
Home > Documents > Symbol Table Ppt.

Symbol Table Ppt.

Date post: 27-Oct-2014
Category:
Upload: rock2b
View: 148 times
Download: 23 times
Share this document with a friend
Popular Tags:
14
IMPLEMENTATION
Transcript
Page 1: Symbol Table Ppt.

IMPLEMENTATION

Page 2: Symbol Table Ppt.
Page 3: Symbol Table Ppt.

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.

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.
Page 6: Symbol Table Ppt.

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.

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.

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.

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.

Symbol TableA name can represent

VariableTypeConstantParameterRecordRecord FieldProcedureArrayLabelfile

Page 11: Symbol Table Ppt.

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.

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.

Symbol Table Data structures Symbol table as list

Symbol table as hash table

Symbol table as search tree

Page 14: Symbol Table Ppt.

Thank you


Recommended