jscript: Added "Expected '('" error.
This commit is contained in:
parent
98223b96e7
commit
29d9f09992
|
@ -27,6 +27,7 @@ STRINGTABLE DISCARDABLE
|
|||
IDS_NO_PROPERTY "Object doesn't support this property or method"
|
||||
IDS_ARG_NOT_OPT "Argument not optional"
|
||||
IDS_SYNTAX_ERROR "Syntax error"
|
||||
IDS_LBRACKET "Expected '('"
|
||||
IDS_NOT_FUNC "Function expected"
|
||||
IDS_NOT_DATE "'[object]' is not a date object"
|
||||
IDS_NOT_NUM "Number expected"
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#define YYPARSE_PARAM ctx
|
||||
|
||||
static int parser_error(const char*);
|
||||
static void set_error(parser_ctx_t*,UINT);
|
||||
static BOOL allow_auto_semicolon(parser_ctx_t*);
|
||||
static void program_parsed(parser_ctx_t*,source_elements_t*);
|
||||
static source_elements_t *function_body_parsed(parser_ctx_t*,source_elements_t*);
|
||||
|
@ -266,7 +267,7 @@ SourceElements
|
|||
|
||||
/* ECMA-262 3rd Edition 13 */
|
||||
FunctionExpression
|
||||
: KFunction Identifier_opt '(' FormalParameterList_opt ')' '{' FunctionBody '}'
|
||||
: KFunction Identifier_opt left_bracket FormalParameterList_opt ')' '{' FunctionBody '}'
|
||||
{ $$ = new_function_expression(ctx, $2, $4, $7, $1, $8-$1+1); }
|
||||
|
||||
KFunction
|
||||
|
@ -379,24 +380,24 @@ ExpressionStatement
|
|||
|
||||
/* ECMA-262 3rd Edition 12.5 */
|
||||
IfStatement
|
||||
: kIF '(' Expression ')' Statement kELSE Statement
|
||||
: kIF left_bracket Expression ')' Statement kELSE Statement
|
||||
{ $$ = new_if_statement(ctx, $3, $5, $7); }
|
||||
| kIF '(' Expression ')' Statement %prec LOWER_THAN_ELSE
|
||||
| kIF left_bracket Expression ')' Statement %prec LOWER_THAN_ELSE
|
||||
{ $$ = new_if_statement(ctx, $3, $5, NULL); }
|
||||
|
||||
/* ECMA-262 3rd Edition 12.6 */
|
||||
IterationStatement
|
||||
: kDO Statement kWHILE '(' Expression ')' semicolon_opt
|
||||
: kDO Statement kWHILE left_bracket Expression ')' semicolon_opt
|
||||
{ $$ = new_while_statement(ctx, TRUE, $5, $2); }
|
||||
| kWHILE '(' Expression ')' Statement
|
||||
| kWHILE left_bracket Expression ')' Statement
|
||||
{ $$ = new_while_statement(ctx, FALSE, $3, $5); }
|
||||
| kFOR '(' ExpressionNoIn_opt ';' Expression_opt ';' Expression_opt ')' Statement
|
||||
| kFOR left_bracket ExpressionNoIn_opt ';' Expression_opt ';' Expression_opt ')' Statement
|
||||
{ $$ = new_for_statement(ctx, NULL, $3, $5, $7, $9); }
|
||||
| kFOR '(' kVAR VariableDeclarationListNoIn ';' Expression_opt ';' Expression_opt ')' Statement
|
||||
| kFOR left_bracket kVAR VariableDeclarationListNoIn ';' Expression_opt ';' Expression_opt ')' Statement
|
||||
{ $$ = new_for_statement(ctx, $4, NULL, $6, $8, $10); }
|
||||
| kFOR '(' LeftHandSideExpression kIN Expression ')' Statement
|
||||
| kFOR left_bracket LeftHandSideExpression kIN Expression ')' Statement
|
||||
{ $$ = new_forin_statement(ctx, NULL, $3, $5, $7); }
|
||||
| kFOR '(' kVAR VariableDeclarationNoIn kIN Expression ')' Statement
|
||||
| kFOR left_bracket kVAR VariableDeclarationNoIn kIN Expression ')' Statement
|
||||
{ $$ = new_forin_statement(ctx, $4, NULL, $6, $8); }
|
||||
|
||||
/* ECMA-262 3rd Edition 12.7 */
|
||||
|
@ -416,7 +417,7 @@ ReturnStatement
|
|||
|
||||
/* ECMA-262 3rd Edition 12.10 */
|
||||
WithStatement
|
||||
: kWITH '(' Expression ')' Statement
|
||||
: kWITH left_bracket Expression ')' Statement
|
||||
{ $$ = new_with_statement(ctx, $3, $5); }
|
||||
|
||||
/* ECMA-262 3rd Edition 12.12 */
|
||||
|
@ -426,8 +427,8 @@ LabelledStatement
|
|||
|
||||
/* ECMA-262 3rd Edition 12.11 */
|
||||
SwitchStatement
|
||||
: kSWITCH '(' Expression ')' CaseBlock
|
||||
{ $$ = new_switch_statement(ctx, $3, $5); }
|
||||
: kSWITCH left_bracket Expression ')' CaseBlock
|
||||
{ $$ = new_switch_statement(ctx, $3, $5); }
|
||||
|
||||
/* ECMA-262 3rd Edition 12.11 */
|
||||
CaseBlock
|
||||
|
@ -471,8 +472,8 @@ TryStatement
|
|||
|
||||
/* ECMA-262 3rd Edition 12.14 */
|
||||
Catch
|
||||
: kCATCH '(' tIdentifier ')' Block
|
||||
{ $$ = new_catch_block(ctx, $3, $5); }
|
||||
: kCATCH left_bracket tIdentifier ')' Block
|
||||
{ $$ = new_catch_block(ctx, $3, $5); }
|
||||
|
||||
/* ECMA-262 3rd Edition 12.14 */
|
||||
Finally
|
||||
|
@ -493,6 +494,7 @@ Expression
|
|||
ExpressionNoIn_opt
|
||||
: /* empty */ { $$ = NULL; }
|
||||
| ExpressionNoIn { $$ = $1; }
|
||||
| error { set_error(ctx, IDS_SYNTAX_ERROR); YYABORT; }
|
||||
|
||||
/* ECMA-262 3rd Edition 11.14 */
|
||||
ExpressionNoIn
|
||||
|
@ -796,6 +798,10 @@ semicolon_opt
|
|||
: ';'
|
||||
| error { if(!allow_auto_semicolon(ctx)) {YYABORT;} }
|
||||
|
||||
left_bracket
|
||||
: '('
|
||||
| error { set_error(ctx, IDS_LBRACKET); YYABORT; }
|
||||
|
||||
%%
|
||||
|
||||
static BOOL allow_auto_semicolon(parser_ctx_t *ctx)
|
||||
|
@ -1434,6 +1440,12 @@ static int parser_error(const char *str)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void set_error(parser_ctx_t *ctx, UINT error)
|
||||
{
|
||||
ctx->hres = JSCRIPT_ERROR|error;
|
||||
}
|
||||
|
||||
|
||||
static expression_t *new_identifier_expression(parser_ctx_t *ctx, const WCHAR *identifier)
|
||||
{
|
||||
identifier_expression_t *ret = parser_alloc(ctx, sizeof(identifier_expression_t));
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#define IDS_NO_PROPERTY 0x01B6
|
||||
#define IDS_ARG_NOT_OPT 0x01c1
|
||||
#define IDS_SYNTAX_ERROR 0x03EA
|
||||
#define IDS_LBRACKET 0x03ED
|
||||
#define IDS_NOT_FUNC 0x138A
|
||||
#define IDS_NOT_DATE 0x138E
|
||||
#define IDS_NOT_NUM 0x1389
|
||||
|
|
|
@ -1318,5 +1318,12 @@ exception_test(function() {arr.toString = Function.prototype.toString; arr.toStr
|
|||
exception_test(function() {date();}, "TypeError", -2146823286);
|
||||
exception_test(function() {arr();}, "TypeError", -2146823286);
|
||||
exception_test(function() {eval("for(i=0;) {}");}, "SyntaxError", -2146827286);
|
||||
exception_test(function() {eval("function {};");}, "SyntaxError", -2146827283);
|
||||
exception_test(function() {eval("if");}, "SyntaxError", -2146827283);
|
||||
exception_test(function() {eval("do i=0; while");}, "SyntaxError", -2146827283);
|
||||
exception_test(function() {eval("while");}, "SyntaxError", -2146827283);
|
||||
exception_test(function() {eval("for");}, "SyntaxError", -2146827283);
|
||||
exception_test(function() {eval("with");}, "SyntaxError", -2146827283);
|
||||
exception_test(function() {eval("switch");}, "SyntaxError", -2146827283);
|
||||
|
||||
reportSuccess();
|
||||
|
|
Loading…
Reference in New Issue