vbscript: Use parser_error to set unhandled parser error.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5436fc90f4
commit
b2de64eeed
@ -351,7 +351,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx)
|
|||||||
skip_spaces(ctx);
|
skip_spaces(ctx);
|
||||||
*loc = ctx->ptr - ctx->code;
|
*loc = ctx->ptr - ctx->code;
|
||||||
if(ctx->ptr == ctx->end)
|
if(ctx->ptr == ctx->end)
|
||||||
return ctx->last_token == tNL ? tEOF : tNL;
|
return ctx->last_token == tNL ? 0 : tNL;
|
||||||
|
|
||||||
c = *ctx->ptr;
|
c = *ctx->ptr;
|
||||||
|
|
||||||
|
@ -284,7 +284,6 @@ typedef struct {
|
|||||||
const WCHAR *end;
|
const WCHAR *end;
|
||||||
|
|
||||||
BOOL option_explicit;
|
BOOL option_explicit;
|
||||||
BOOL parse_complete;
|
|
||||||
BOOL is_html;
|
BOOL is_html;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ static statement_t *link_statements(statement_t*,statement_t*);
|
|||||||
double dbl;
|
double dbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
%token tEXPRESSION tEOF tNL tEMPTYBRACKETS tEXPRLBRACKET
|
%token tEXPRESSION tNL tEMPTYBRACKETS tEXPRLBRACKET
|
||||||
%token tLTEQ tGTEQ tNEQ
|
%token tLTEQ tGTEQ tNEQ
|
||||||
%token tSTOP tME tREM tDOT
|
%token tSTOP tME tREM tDOT
|
||||||
%token <string> tTRUE tFALSE
|
%token <string> tTRUE tFALSE
|
||||||
@ -153,8 +153,8 @@ static statement_t *link_statements(statement_t*,statement_t*);
|
|||||||
%%
|
%%
|
||||||
|
|
||||||
Program
|
Program
|
||||||
: OptionExplicit_opt SourceElements tEOF { parse_complete(ctx, $1); }
|
: OptionExplicit_opt SourceElements { parse_complete(ctx, $1); }
|
||||||
| tEXPRESSION ExpressionNl_opt tEOF { handle_isexpression_script(ctx, $2); }
|
| tEXPRESSION ExpressionNl_opt { handle_isexpression_script(ctx, $2); }
|
||||||
|
|
||||||
OptionExplicit_opt
|
OptionExplicit_opt
|
||||||
: /* empty */ { $$ = FALSE; }
|
: /* empty */ { $$ = FALSE; }
|
||||||
@ -506,6 +506,12 @@ StSep
|
|||||||
|
|
||||||
static int parser_error(unsigned *loc, parser_ctx_t *ctx, const char *str)
|
static int parser_error(unsigned *loc, parser_ctx_t *ctx, const char *str)
|
||||||
{
|
{
|
||||||
|
if(ctx->hres == S_OK) {
|
||||||
|
FIXME("%s: %s\n", debugstr_w(ctx->code + *loc), debugstr_a(str));
|
||||||
|
ctx->hres = E_FAIL;
|
||||||
|
}else {
|
||||||
|
WARN("%s: %08x\n", debugstr_w(ctx->code + *loc), ctx->hres);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +536,6 @@ static void source_add_class(parser_ctx_t *ctx, class_decl_t *class_decl)
|
|||||||
|
|
||||||
static void parse_complete(parser_ctx_t *ctx, BOOL option_explicit)
|
static void parse_complete(parser_ctx_t *ctx, BOOL option_explicit)
|
||||||
{
|
{
|
||||||
ctx->parse_complete = TRUE;
|
|
||||||
ctx->option_explicit = option_explicit;
|
ctx->option_explicit = option_explicit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,7 +543,6 @@ static void handle_isexpression_script(parser_ctx_t *ctx, expression_t *expr)
|
|||||||
{
|
{
|
||||||
retval_statement_t *stat;
|
retval_statement_t *stat;
|
||||||
|
|
||||||
ctx->parse_complete = TRUE;
|
|
||||||
if(!expr)
|
if(!expr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1143,9 +1147,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite
|
|||||||
|
|
||||||
heap_pool_init(&ctx->heap);
|
heap_pool_init(&ctx->heap);
|
||||||
|
|
||||||
ctx->parse_complete = FALSE;
|
|
||||||
ctx->hres = S_OK;
|
ctx->hres = S_OK;
|
||||||
|
|
||||||
ctx->last_token = tNL;
|
ctx->last_token = tNL;
|
||||||
ctx->last_nl = 0;
|
ctx->last_nl = 0;
|
||||||
ctx->stats = ctx->stats_tail = NULL;
|
ctx->stats = ctx->stats_tail = NULL;
|
||||||
@ -1158,14 +1160,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite
|
|||||||
|
|
||||||
parser_parse(ctx);
|
parser_parse(ctx);
|
||||||
|
|
||||||
if(FAILED(ctx->hres))
|
|
||||||
return ctx->hres;
|
return ctx->hres;
|
||||||
if(!ctx->parse_complete) {
|
|
||||||
FIXME("parser failed around %s\n", debugstr_w(ctx->code+20 > ctx->ptr ? ctx->code : ctx->ptr-20));
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void parser_release(parser_ctx_t *ctx)
|
void parser_release(parser_ctx_t *ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user