πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

Representing Scope Information

Representing Scope Information

In the source program, every name possesses a region of validity, called the scope of that name.

The rules in a block-structured language are as follows:

  1. If a name declared within block B then it will be valid only within B.
  2. If B1 block is nested within B2 then the name that is valid for block B2 is also valid for B1 unless the name's identifier is re-declared in B1.
  • These scope rules need a more complicated organization of symbol table than a list of associations between names and attributes.
  • Tables are organized into stack and each table contains the list of names and their associated attributes.
  • Whenever a new block is entered then a new table is entered onto the stack. The new table holds the name that is declared as local to this block.
  • When the declaration is compiled then the table is searched for a name.
  • If the name is not found in the table then the new name is inserted.
  • When the name's reference is translated then each table is searched, starting from the each table on the stack.

For example:

  1. int x;  
  2. void f(int m) {  
  3.      float x, y;  
  4. {  
  5.             int i, j;  
  6.             int u, v;  
  7. }  
  8. }  
  9. int g (int n)  
  10. {  
  11.       bool t;  
  12. }  

Representing Scope Information

Fig: Symbol table organization that complies with static scope information rules

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>