Java Reference
In-Depth Information
16. As mentioned in Section 8.4.2, C allows the same identifier to appear as a
struct name, a label, and an ordinary variable name. Thus, the following
is a valid C program:
main() {
struct xxx {
int a,b;
}c;
int xxx;
xxx:
c.a = 1;
}
In C, the structure name never appears without the terminal struct pre-
ceding it. The label can only be used as the target of a goto statement.
Explain how to use the symbol table interface given in Section 8.1.2 to
allow all three varieties of xxx to coexist in the same scope.
17. Describe how you would use the symbol table interface given in Sec-
tion 8.1.2 to localize the declaration and e
ects of a loop iteration variable.
As an example, consider the variable in the Java-like statement
ff
for (int i=1; i<10; ++i)
{ ...}
In this exercise, we seek the following:
The declaration of i cannot possibly conflict with any other decla-
ration of i .
The e
ects on this i are confined to the body of the loop. That is, the
scope of i includes the expressions of the for statement as well as
its body, represented above as
ff
. The value of the loop's iteration
variable is undefined when the loop exits.
...
18. Write a
method for handling the array type definitions represented
by the AST in Figure 8.19(b), with upper and lower bounds included
in array specification. Note that some type checking on the bounds
expressions will be required in this method.
visit
 
Search WWH ::




Custom Search