Contents    Page-10    Prev    Next    Page+10    Index   

Translation Section[slide by John Werth.]

The {ws} rule causes the lexical analyzer to skip all delimiters until the next non-delimiter.

The if rule recognizes the string 'if'. When it is found the lexical analyzer returns the token IF, a manifest constant.

The {id} rule must do three jobs:

  1. record the id in the symbol table
  2. return a pointer to the specific id
  3. return the token ID to signify that an id was seen

The first two are accomplished by

     yylval = install(id);
yylval is a global used for this purpose in Yacc. The third is accomplished by return(ID);

The action for {number} is similar.

The rules for the relational operators set yylval to specific manifest constants to show which value was found and return the token RELOP to signify that a relational operator was seen.