SA
i ask if any one can help me in this grammar problem :
Expression ::= Expression ( "&&" | "<" | "+" | "-" | "*" ) Expression
| Expression "[" Expression "]"
| Expression "." "length"
| Expression "." Identifier "(" ( Expression ( "," Expression )* )? ")"
| <INTEGER_LITERAL>
| "true"
| "false"
| Identifier
| "this"
| "new" "int" "[" Expression "]"
| "new" Identifier "(" ")"
| "!" Expression
| "(" Expression ")" Identifier ::= <IDENTIFIER>
this grammar contain left recursion and left factoring , i resolved left factoring
void Expression():
{
}
{
Expression()
( ( "&&" | "<" | "+" | "-" | "*" ) Expression()
| "[" Expression() "]"
| "." "length"
| "." Identifier() "(" ( Expression() ( "," Expression() )* )? ")" )
| (<NUMBER>)+
| "true"
| "false"
| Identifier()
| "this"
| <NEW> ("int" "[" Expression() "]"| Identifier() "(" ")")
| "!" Expression()
| "(" Expression() ")"
}
but left recursion no : i think it is now look like
A->A(B|C|E|D)
A->(B|C|E|D)expr2
expr2->(B|C|E|D)expr2*
but I'm not sure can any one confirm .
Thanks in advance Guys .
reply asap .