Last modified Friday, 22-Jul-2005 21:47:39 PDT
Paragraph 2, line 6: "Unix system studied in Chapter 5." should appear as "Unix system. Yacc is studied in Chapter 5."
Figure in the middle of page: The syntax tree root node has the wrong label. It should be "assign-expression", not "assign-statement".
Figure at the top of page: The syntax tree root node has the wrong label. It should be "assign-expression", not "assign-statement".
Paragraph 1, lines 1-2: "--where the compiler of language B runs on a different machine, which results in a cross compiler for A" should appear as "where the compiler of language B generates code for (and runs on) a different machine, resulting in a cross compiler for A"
12th line from the bottom: "bookkeeping tokens EOF" should appear as "bookkeeping tokens ENDFILE"
Example 3.7: In the second line (the grammar rule for stmt-sequence), the semicolon should be Courier bold:
stmt-sequence ® stmt ; stmt-sequence | stmt
Middle of page, 2nd line of code: This code should appear as
typedef enum {OpK,ConstK} ExpKind;
Figures of Example 3.9: In the first figure (the parse tree), the third node labeled stmt should be in the same font as the other two stmt nodes (Roman italic). In the second figure, the second node labeled with a semicolon should be in the same font as the other node (Courier bold).
Figure 3.4: In the syntax diagram for mulop, an arrow is missing, and in the syntax diagram for factor, three of the arrows on the right point in the wrong direction. A corrected version of Figure 3.4 is as follows:
Exercise 3.14(a): "Write C-type declarations..." should appear as "Write C type declarations...."
Exercise 3.18: Delete part (a) of this exercise (it requires more knowledge of context-sensitive grammars than is covered in the text). Replace part (b) with the following wording: "Is it possible to write a context-free grammar for the strings of the form xcx, where x is a string of a's and b's? Explain."
Exercise 3.22(a): "Show that a cyclic grammar is ambiguous." should appear as "Explain why a cyclic grammar is likely to be ambiguous."
Line 7: The right-hand dollar sign should line up with the right-hand dollar sign on line 4.
Table 4.3: Delete the 10th line of the table, which reads
$ L L S )E( i i(1)o e o $ I ® i( E )S L
and after the 13th line, which reads
$ L L S )E 1)o e o $ E ® 1
insert the following line:
$ L L S )1 1)o e o $ match
Figure 4.3: Change n to m in the first line of the algorithm.
Top of page: The parse tree figure is missing three branches involving e-productions for term' (the labels for the interior nodes are also in the wrong font). The correct parse tree is as follows:
Table 4.4: The grammar rule in the table entry for term' and + is missing its arrow. It should appear as term' ® e .
Figure 4.5: Change the word language to grammar in the first line of the algorithm.
10th line from the bottom: "Rule 6 adds * to First(mulop)" should appear as "Rule 7 adds * to First(mulop)".
First line: Change if-stmt to else-part at the beginning of the line.
Top of page: Rule 2 is incorrectly stated and should be replaced by the correct rule, given on page 154.
Line 3: The comma on the right-hand side of the grammar rule for var-list should be Courier bold:
var-list ® identifier , var-list | identifier
Figure 5.3: The caption should appear as "The DFA of sets of LR(0) items...."
Definition, item 2: Change a to g in lines 1, 2, 5, 6, 8, and 9 of this item.
Figure 5.5: The caption should appear as "The DFA of sets of LR(0) items...."
Definition, item 2, line 5: "Remove the string a and all of its corresponding states" should appear as "Remove the string g and all of its corresponding states."
Definition, item 2, line 7: "which the construction of a began." should appear as "which the construction of g began."
Definition, item 2, line 8: "item of the form B ® g .A b ." should appear as "item of the form B ® a .A b ."
Table 5.8, line 3: The input is missing a right parenthesis and should appear as ")()$".
Line 15 (middle of page): The end of this line ("because of the rule V ® V :=") should appear as " because of the rule S ® V :=".
Figure 5.7: The transition from state 5 to itself on left parenthesis is missing its arrowhead.
Middle of page: In condition 1 of the two conditions for a grammar to be LR(1), the item [B ® b ., X] in the second line of the condition should appear as [B ® g ., X].
Lines 4 and 5: These lines should appear as follows:
State 2: [S ®
id .,
$]
[V
® id
., :=]
Figure 5.8: The right square bracket in the last item listed in State 0 should be in regular font, not code font.
Figure 5.10: The last three lines of code should be replaced by the following:
int yyerror(char * s) { fprintf(stderr,"%s\n",s); return 0; } /* allows for printing of an error message */
Last paragraph, lines 4-5: Replace the beginning of this sentence by the following text:
This is done by compiling y.tab.c with the symbol YYDEBUG defined to be 1 (for example, by placing the line
#define YYDEBUG 1
at the beginning of the Yacc specification file, just after the #includes) and by setting ...
Yacc code at the top of the page: The last lines of this code (the rules for op) have actions that are missing the assignment symbols; thus, the last three lines of this code should be replaced by the following:
op : '+' { $$ = '+'; } : '-' { $$ = '-'; } ;
Section 5.7.3, line 2: "...contains the pseudotoken error as the only symbol on its right-hand side." should appear as "...contains the pseudotoken error on its right-hand side."
Exercise 5.3, line 2: The grammar rule "A® A ( A ) | e" should appear as "S ® S ( S ) | e" .
Exercise 5.22(a): "...as described in Section 5.7.1,..." should appear as "...as described in Section 5.7.2,..."
Exercise 5.24(a): The replacement rule should appear as:
command : exp {printf("%d\n",$1);} | exp error {printf("%d\n",$1);} ;
Exercise 5.24(b): The replacement rule should appear as:
command : exp {printf("%d\n",$1);} | error exp {printf("%d\n",$2);} ;
Exercise 5.36: Parts (a) and (b) of this exercise cannot be done simultaneously in Yacc, and should be considered as separate exercises. The comment about the use of the %union declaration applies to part (b) only.
Example 6.3: In the fourth line (the grammar rule for var-list), the comma should be Courier bold:
var-list ® id , var-list | id
Example 6.7: In the fourth line the attribute equation is missing a period on the left hand side, and should appear as:
id.dtype = var-list1.dtype
Figure 6.8: The third line of code should appear as
if (t->kind == OpKind)
and the thirteenth line of code should appear as
case Times:
Table 6.7: In the first semantic rule, the word "int" should be in italics:
exp.etype = if exp.isFloat then float else int
Example 6.18: In the attribute grammar table, the second and third semantic rules (for the grammar rule var-list1 ® var-list2 id ,) should appear as
var-list1 .dtype = var-list2
.dtype
id .dtype
= var-list1 .dtype
Table 6.9: The last semantic rule in the right-hand column has a missing left parenthesis before the call to lookup. The correct rule should appear as:
decl.outtab = if (decl.intab = errtab) or exp.err then errtab else if (lookup(decl.intab,id.name) = decl.nestlevel) then errtab else insert(decl.intab,id.name, decl.nestlevel)
Exercise 6.14, last line: "when reductions to a var-list occur." should appear as "when reductions by the rule var-list ® id occur."
Figure 7.4: The three appearances of god should be gcd instead.
Figure 7.5: The first line of code of the function g should appear as follows:
{ int y = m-1;
Figure 7.10: The activation record of the call to r has two arrows from the access link field to the activation record of p. The left arrow should come from the control link field instead of the access link field. The correct figure is as follows:
Figure 7.13, second activation record of p (fifth box down): "<access link>" should appear as "<no access link>".
Line 7: "it is possible that memory is still so " should appear as "it is possible that memory is so ".
Line 9: "Hence, a garbage collection" should appear as "Hence, garbage collection".
Last line: This line of code should appear as follows:
a[t4] = t3
Second paragraph, line 5: Change "simi-lar" to "similar" at the end of the line.
Footnote 16, last line: "Sparc.architecture." should appear as "Sparc architecture."
Figure in the middle of the page: An arrow is missing that should point into the nonbasic block box from the right, just before the text "jump from elsewhere". The correct figure is as follows:
Figure 8.18: Line 6 of basic block B3 should appear as "t4 = x == 0".
Figure 8.19: The topmost node (with label t4) should contain == rather than =.
Section 8.10.2, line 7: "Variables that are references during loops" should appear as "Variables that are referenced during loops".
Line 13: "a function declaration with the name main." should appear as "a function declaration of the form void main(void)."
Code Line 51: This line of code should appear as follows:
char pgm[120]; /* source code file name */
Code Line 100: Insert the following line of code before this line:
fclose(source);
Code Line 510: This line of code should appear as follows:
fprintf(listing,"Const: %d\n",tree->attr.val);
Code Line 626: Insert the following line of code at this point:
static int EOF_Flag = FALSE;
Code Line 630: Replace this line of code by the following code:
static int getNextChar(void)
Code Line 639: Replace this line of code by the following code:
else { EOF_flag = TRUE; return EOF; }
Code Line 647: Replace this line of code by the following code:
{ if (!EOF_flag) linepos-- ;}
Code Line 684: Replace this line of code by the following code:
{ int c = getNextChar();
Code Line 742: Replace this line of code by the following code:
if (c == EOF) { state = DONE; currentToken = ENDFILE; } else if (c == '}') state = START;
Code Line 781: Replace this line of code by the following code:
tokenString[tokenStringIndex++] = (char) c;
Code lines 1453 and 1454 should be interchanged, and code lines 1468 and 1469 should be interchanged.
Code Line 3049: Insert the following line of code before this line:
if (c == EOF) break;
6th line from the bottom: The code line gets(in_Line); should have an additional line of code before it, and an additional line of code after it, as follows:
fflush(stdout); gets(in_Line); lineLen = strlen(in_Line);
2nd line from the bottom: The code line gets(in_Line); should have an additional line of code before it, and an additional line of code after it, as follows:
fflush(stdout); gets(in_Line); lineLen = strlen(in_Line);