Closed flofreud closed 11 years ago
Can identifiers shadow identifiers with the same name of outer blocks? Example given:
int a;
{
boolean a;
}
where { and } denote a block.
There are two possibilities:
Probably I misread the grammar but if the goal for MS1 is to support:
The grammar only allow to return a loc:
stmt -> return loc
loc -> loc [assign] | id | loc.id
This means, it is invalid to write
return 9+3;
The minimum version would be:
long i;
i = 9 + 3;
return i;
We could either request a change of the grammar or support assignment and declaration by MS1. I think there should be no problems for implementation to modify the grammar:
stmt -> return assign | print assign
return we need to support also declarations and assignments, right?
plus type casting. The TAC is complete for MS1. You can have a look over there.
The grammar only allow to return a loc:
Yes and this is how the abstract syntax tree is designed
public interface ReturnNode {
public IdentifierNode getRightValue();
}
where IdentifierNode is the loc
from the grammar. If we want to change the grammar we have to edit the AST
.
But actually i see no problem in using variable names for print only.
I ask because the latest proposal for the Lexer does not covers the declarations and statements.
Am i right to assume, that the terminal definition is to be seen as the pattern specification for the lexemes?
If so, i think there is a problems with the integralDigits. I think the + or - in front of a digit should not be treated as part of the lexeme in the lexer, but as its own token.
I removed it from the num and real beginning and made the real have always at least one pre-seperator digit, a dot and at least one post-seperator digit. This should make the parsing easier. The - for E is still there.
Comments and Discussion for Grammar See Wiki page: Grammar