Chapter 8: Intermediate Code Generation

Creating symbol table .

P {t=mktable(nil);
  push(t,tblptr);
  push(0,offset)}
D
 
  {addwidth(top(tblptr),top(offset));
  pop(tblptr);
  pop(offset)}
D D ; D
   
   

The symbol tables are created using two stacks: tblptr to hold pointers to symbol tables of the enclosing procedures and offset whose top element is the next available relative address for a local of the current procedure. Declarations in nested procedures can be processed by the syntax directed definitions given below. Note that they are basically same as those given above but we have separately dealt with the epsilon productions. Go to the next page for the explanation.