Contents    Page-10    Prev    Next    Page+10    Index   

Table for Labels

Pascal requires a label statement to pre-declare statement labels:

   label 1492, 1776;

It is necessary to ensure that user labels do not conflict with compiler-generated labels. An easy way to do that is to keep user labels in a linear table, whose index becomes the internal label.

Labels used in statements are converted to the internal labels. The intermediate code has both label and goto as operators, each taking an integer internal label number as argument.

   labels[labelnumber++] = tok->intval;

   1776:   (label 1)       goto 1776;   (goto 1)