CS152
Chris Pollett
Mar. 2, 2009
const int n=5;Makes n into an integer constant with value 5. So the meaning of n is a name for a datatype attribute "integer constant" and a value attribute 5.
double f(int n) {...}associates the attribute function to the name f together with (a) the number, names, and data types of its parameters, (b) the datatype of the return value, and (c) the body of code to be executed.
int x; //The binding of the datatype attribute to the name x occurs in the compiler
SymbolTable: Names → Attributes.
Which of the following is the correct way to define the type of a nonterminal called expr in Yacc assuming the %union had been set up correctly so that ival mapped to being an int?
void p() {double r,z; ... {int x, y; /* nested block */ ...}}
int x; void main() {/* some code*/}
declare x: integer; y: boolean; begin x:= 2; y:= true; end;
struct A { int x; double y; struct {int* x; char y;} z; };
void p() {int x; ...} void q() {char x;}