jscript: Throw more SyntaxErrors in parser.

This commit is contained in:
Piotr Caban 2009-07-24 09:36:23 +02:00 committed by Alexandre Julliard
parent 67c8a3e919
commit f3d24fdda9
2 changed files with 13 additions and 7 deletions

View File

@ -202,7 +202,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%type <statement> Finally %type <statement> Finally
%type <statement_list> StatementList StatementList_opt %type <statement_list> StatementList StatementList_opt
%type <parameter_list> FormalParameterList FormalParameterList_opt %type <parameter_list> FormalParameterList FormalParameterList_opt
%type <expr> Expression Expression_opt %type <expr> Expression Expression_opt Expression_err
%type <expr> ExpressionNoIn ExpressionNoIn_opt %type <expr> ExpressionNoIn ExpressionNoIn_opt
%type <expr> FunctionExpression %type <expr> FunctionExpression
%type <expr> AssignmentExpression AssignmentExpressionNoIn %type <expr> AssignmentExpression AssignmentExpressionNoIn
@ -381,16 +381,16 @@ ExpressionStatement
/* ECMA-262 3rd Edition 12.5 */ /* ECMA-262 3rd Edition 12.5 */
IfStatement IfStatement
: kIF left_bracket Expression right_bracket Statement kELSE Statement : kIF left_bracket Expression_err right_bracket Statement kELSE Statement
{ $$ = new_if_statement(ctx, $3, $5, $7); } { $$ = new_if_statement(ctx, $3, $5, $7); }
| kIF left_bracket Expression right_bracket Statement %prec LOWER_THAN_ELSE | kIF left_bracket Expression_err right_bracket Statement %prec LOWER_THAN_ELSE
{ $$ = new_if_statement(ctx, $3, $5, NULL); } { $$ = new_if_statement(ctx, $3, $5, NULL); }
/* ECMA-262 3rd Edition 12.6 */ /* ECMA-262 3rd Edition 12.6 */
IterationStatement IterationStatement
: kDO Statement kWHILE left_bracket Expression right_bracket semicolon_opt : kDO Statement kWHILE left_bracket Expression_err right_bracket semicolon_opt
{ $$ = new_while_statement(ctx, TRUE, $5, $2); } { $$ = new_while_statement(ctx, TRUE, $5, $2); }
| kWHILE left_bracket Expression right_bracket Statement | kWHILE left_bracket Expression_err right_bracket Statement
{ $$ = new_while_statement(ctx, FALSE, $3, $5); } { $$ = new_while_statement(ctx, FALSE, $3, $5); }
| kFOR left_bracket ExpressionNoIn_opt | kFOR left_bracket ExpressionNoIn_opt
{ if(!explicit_error(ctx, $3, ';')) YYABORT; } { if(!explicit_error(ctx, $3, ';')) YYABORT; }
@ -404,9 +404,9 @@ IterationStatement
{ if(!explicit_error(ctx, $7, ';')) YYABORT; } { if(!explicit_error(ctx, $7, ';')) YYABORT; }
semicolon Expression_opt right_bracket Statement semicolon Expression_opt right_bracket Statement
{ $$ = new_for_statement(ctx, $4, NULL, $7, $10, $12); } { $$ = new_for_statement(ctx, $4, NULL, $7, $10, $12); }
| kFOR left_bracket LeftHandSideExpression kIN Expression right_bracket Statement | kFOR left_bracket LeftHandSideExpression kIN Expression_err right_bracket Statement
{ $$ = new_forin_statement(ctx, NULL, $3, $5, $7); } { $$ = new_forin_statement(ctx, NULL, $3, $5, $7); }
| kFOR left_bracket kVAR VariableDeclarationNoIn kIN Expression right_bracket Statement | kFOR left_bracket kVAR VariableDeclarationNoIn kIN Expression_err right_bracket Statement
{ $$ = new_forin_statement(ctx, $4, NULL, $6, $8); } { $$ = new_forin_statement(ctx, $4, NULL, $6, $8); }
/* ECMA-262 3rd Edition 12.7 */ /* ECMA-262 3rd Edition 12.7 */
@ -493,6 +493,10 @@ Expression_opt
: /* empty */ { $$ = NULL; } : /* empty */ { $$ = NULL; }
| Expression { $$ = $1; } | Expression { $$ = $1; }
Expression_err
: Expression { $$ = $1; }
| error { set_error(ctx, IDS_SYNTAX_ERROR); YYABORT; }
/* ECMA-262 3rd Edition 11.14 */ /* ECMA-262 3rd Edition 11.14 */
Expression Expression
: AssignmentExpression { $$ = $1; } : AssignmentExpression { $$ = $1; }

View File

@ -1331,5 +1331,7 @@ exception_test(function() {eval("while(true");}, "SyntaxError", -2146827282);
exception_test(function() {test = function() {}}, "ReferenceError", -2146823280); exception_test(function() {test = function() {}}, "ReferenceError", -2146823280);
exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284); exception_test(function() {eval("for(i=0")}, "SyntaxError", -2146827284);
exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284); exception_test(function() {eval("for(i=0;i<10")}, "SyntaxError", -2146827284);
exception_test(function() {eval("while(")}, "SyntaxError", -2146827286);
exception_test(function() {eval("if(")}, "SyntaxError", -2146827286);
reportSuccess(); reportSuccess();