Augustana University College

COMPUTING SCIENCE 370
Programming Languages


Implementation of Block-Structured Languages



An Example Program

Consider the following Pascal program. Figure 6.1 in the texbook illustrates the contour diagram for this program assuming that program a calls procedure b, which in turn calls procedure c, and Figure 6.2 shows the corresponding activation records on the run-time stack.

   program a(. . .);
      var N: integer;
      
      procedure b (sum: real);
         var i: integer;
         avg: real;
         Data: array [1 .. 10] of real;

         procedure c (val: real);
         begin
           .
           .
              writeln( Data[i] );  
           .
           .
         end {c};

      begin
        .
        .
      end {b};
      
   begin
     .
     .
   end {a}.         
Copyright © 2004 Jonathan Mohr