statement(TokenNameEOF);
if ((token == TokenNameRBRACE) || (token == TokenNamecase) || (token == TokenNamedefault) || (token == TokenNameelse)
|| (token == TokenNameelseif) || (token == TokenNameendif) || (token == TokenNameendfor)
- || (token == TokenNameendforeach) || (token == TokenNameendwhile) || (token == TokenNameendswitch)
+ || (token == TokenNameendforeach) || (token == TokenNameendwhile) || (token == TokenNameendswitch) || (token == TokenNameenddeclare)
|| (token == TokenNameEOF) || (token == TokenNameERROR)) {
return;
}
getNextToken();
functionDefinition(methodDecl);
return statement;
+ } else if (token == TokenNamedeclare) {
+ //T_DECLARE '(' declare_list ')' declare_statement
+ getNextToken();
+ if (token != TokenNameLPAREN) {
+ throwSyntaxError("'(' expected in 'declare' statement.");
+ }
+ getNextToken();
+ declare_list();
+ if (token != TokenNameRPAREN) {
+ throwSyntaxError("')' expected in 'declare' statement.");
+ }
+ getNextToken();
+ declare_statement();
+ return statement;
} else if (token == TokenNametry) {
getNextToken();
if (token != TokenNameLBRACE) {
return statement;
}
+ private void declare_statement() {
+ // statement
+ //| ':' inner_statement_list T_ENDDECLARE ';'
+ //;
+ if (token == TokenNameCOLON) {
+ getNextToken();
+ // TODO: implement inner_statement_list();
+ statementList();
+ if (token != TokenNameenddeclare) {
+ throwSyntaxError("'enddeclare' expected in 'declare' statement.");
+ }
+ getNextToken();
+ if (token != TokenNameSEMICOLON) {
+ throwSyntaxError("';' expected after 'enddeclare' keyword.");
+ }
+ getNextToken();
+ } else {
+ statement(TokenNameRPAREN);
+ }
+ }
+
+ private void declare_list() {
+ // T_STRING '=' static_scalar
+ //| declare_list ',' T_STRING '=' static_scalar
+ while (true) {
+ if (token != TokenNameIdentifier) {
+ throwSyntaxError("Identifier expected in 'declare' list.");
+ }
+ getNextToken();
+ if (token != TokenNameEQUAL) {
+ throwSyntaxError("'=' expected in 'declare' list.");
+ }
+ getNextToken();
+ static_scalar();
+ if (token != TokenNameCOMMA) {
+ break;
+ }
+ getNextToken();
+ }
+ }
+
private void additional_catches() {
while (token == TokenNamecatch) {
getNextToken();
throwSyntaxError("'{' expected in 'catch' statement.");
}
getNextToken();
- statementList();
if (token != TokenNameRBRACE) {
- throwSyntaxError("'}' expected in 'catch' statement.");
+ statementList();
+ if (token != TokenNameRBRACE) {
+ throwSyntaxError("'}' expected in 'catch' statement.");
+ }
}
getNextToken();
}
if (token != TokenNameEQUAL) {
throwSyntaxError("'=' expected after 'list' keyword.");
}
- getNextToken();
- expr();
+ getNextToken();
+ expr();
} else {
throwSyntaxError("'(' expected after 'list' keyword.");
}
case TokenNameXOR_EQUAL:
case TokenNameRIGHT_SHIFT_EQUAL:
case TokenNameLEFT_SHIFT_EQUAL:
- getNextToken();
- expr();
+ getNextToken();
+ expr();
break;
case TokenNamePLUS_PLUS:
case TokenNameMINUS_MINUS:
case TokenNameLESS_EQUAL:
case TokenNameGREATER:
case TokenNameGREATER_EQUAL:
- getNextToken();
- expr();
+ getNextToken();
+ expr();
break;
// | expr T_INSTANCEOF class_name_reference
// | expr '?' expr ':' expr
class_name_reference();
break;
case TokenNameQUESTION:
- getNextToken();
- expr();
+ getNextToken();
+ expr();
if (token == TokenNameCOLON) {
getNextToken();
expr();