1: program fproc(output);
   2:     var
   3:     i :integer;
   4: 
   5:     procedure print(function frtn :integer);
   6:     begin
   7:         write(frtn:3,'   formal routine =');
   8:     end;
   9: 
  10:     procedure lvl1(function form: integer);
  11:     label   1;
  12:     var
  13:     loc :integer;
  14: 
  15:     function eval :integer;
  16:         begin
  17:         if loc = 8 then begin
  18:             writeln(' non-local jump');
  19:             goto 1;
  20:         end;
  21:         eval := loc;
  22:         end;
  23: 
  24:     begin
  25:     loc := i;
  26:     i := i - 1;
  27:     if (loc = 4) or (loc = 8) then
  28:         lvl1(eval)
  29:     else if loc > 0 then
  30:         lvl1(form);
  31: 1:  write('Stack frame:',loc:3,'   formal print =');
  32:     print(form);
  33:     writeln(form:3);
  34:     end;
  35: 
  36:     function geval :integer;
  37:     begin
  38:         geval := i;
  39:     end;
  40: 
  41:     begin
  42:     writeln('This should print levels 0-3, with formal values of 4.');
  43:     writeln('Level 4 should jump to level 8.');
  44:     writeln('Finally levels 8-10 should print with formal values of -1.');
  45:     i := 10;
  46:     lvl1(geval);
  47:     end.
Last modified: 1984-04-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 555
Valid CSS Valid XHTML 1.0 Strict