Decaf Parsing and Type Checking Clarifications

Some frequently asked questions about project 3.

Shadowing

Let every block define a new scope. Each new scope will allow a variable name that has been used in an outer scope, but not declared for any other purpose in the same scope. Thus, the following will be legal:

int a;

void f() {
	int a;

	{
		int a;

		a;
	}
}
  

But the following would not be legal:

class A {
	int a;

	void a();
}

Nor would overloading be legal by this definition:

class A {
	int f();

	double f();
}

Error Production Conflicts

Our Statement/VarDecl conflict will arise again with the error productions. Use something to distinguigh between them on the stack so that there is no longer a shift/reduce conflict.

statement ::= error SEMICOLON

var_decl ::= type error SEMICOLON

Arrays

Let's just use the orignal language definition and deal with the ugly syntax

int [][] a = NewArray(10, int []);
a[0] = NewArray(100, int);
a[1] = NewArray(100, int);
...

The grammar supports this already