Module: wine Branch: master Commit: b2de64eeedbc5ed2cf76b4aa079745dad60b8dbb URL: https://source.winehq.org/git/wine.git/?a=commit;h=b2de64eeedbc5ed2cf76b4aa0...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Jan 22 23:27:35 2020 +0100
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
---
dlls/vbscript/lex.c | 2 +- dlls/vbscript/parse.h | 1 - dlls/vbscript/parser.y | 25 ++++++++++--------------- 3 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 986693e3e1..db104fd892 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -351,7 +351,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx) skip_spaces(ctx); *loc = ctx->ptr - ctx->code; if(ctx->ptr == ctx->end) - return ctx->last_token == tNL ? tEOF : tNL; + return ctx->last_token == tNL ? 0 : tNL;
c = *ctx->ptr;
diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 37ddd7a11c..8d68e781fb 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -284,7 +284,6 @@ typedef struct { const WCHAR *end;
BOOL option_explicit; - BOOL parse_complete; BOOL is_html; HRESULT hres;
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 7a09d0c074..b54d4af32f 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -110,7 +110,7 @@ static statement_t *link_statements(statement_t*,statement_t*); double dbl; }
-%token tEXPRESSION tEOF tNL tEMPTYBRACKETS tEXPRLBRACKET +%token tEXPRESSION tNL tEMPTYBRACKETS tEXPRLBRACKET %token tLTEQ tGTEQ tNEQ %token tSTOP tME tREM tDOT %token <string> tTRUE tFALSE @@ -153,8 +153,8 @@ static statement_t *link_statements(statement_t*,statement_t*); %%
Program - : OptionExplicit_opt SourceElements tEOF { parse_complete(ctx, $1); } - | tEXPRESSION ExpressionNl_opt tEOF { handle_isexpression_script(ctx, $2); } + : OptionExplicit_opt SourceElements { parse_complete(ctx, $1); } + | tEXPRESSION ExpressionNl_opt { handle_isexpression_script(ctx, $2); }
OptionExplicit_opt : /* empty */ { $$ = FALSE; } @@ -506,6 +506,12 @@ StSep
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; }
@@ -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) { - ctx->parse_complete = TRUE; 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;
- ctx->parse_complete = TRUE; if(!expr) return;
@@ -1143,9 +1147,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite
heap_pool_init(&ctx->heap);
- ctx->parse_complete = FALSE; ctx->hres = S_OK; - ctx->last_token = tNL; ctx->last_nl = 0; 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);
- if(FAILED(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; + return ctx->hres; }
void parser_release(parser_ctx_t *ctx)