From fae7352f93e35eaed32d486e1c91e3c15616f4e5 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 14 Sep 2011 12:59:26 +0200 Subject: [PATCH] vbscript: Added 'or' expression parser/compiler implementation. --- dlls/vbscript/compile.c | 2 ++ dlls/vbscript/interp.c | 6 ++++++ dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 6 +++++- dlls/vbscript/vbscript.h | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 9b74bb77b33..8b759180858 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -388,6 +388,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not); case EXPR_NULL: return push_instr(ctx, OP_null) != -1 ? S_OK : E_OUTOFMEMORY; + case EXPR_OR: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_or); case EXPR_STRING: return push_instr_str(ctx, OP_string, ((string_expression_t*)expr)->value); case EXPR_SUB: diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index d5e0370402e..e55d3285553 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -588,6 +588,12 @@ static HRESULT interp_and(exec_ctx_t *ctx) return stack_push(ctx, &v); } +static HRESULT interp_or(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static HRESULT cmp_oper(exec_ctx_t *ctx) { variant_val_t l, r; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index d61a5f0370d..b4a91c892eb 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -34,6 +34,7 @@ typedef enum { EXPR_NEQUAL, EXPR_NOT, EXPR_NULL, + EXPR_OR, EXPR_STRING, EXPR_SUB, EXPR_ULONG, diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 5c0468106ba..48843e74224 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -98,7 +98,7 @@ static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL); %type Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt %type Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression -%type NotExpression UnaryExpression AndExpression +%type NotExpression UnaryExpression AndExpression OrExpression %type MemberExpression %type Arguments_opt ArgumentList_opt ArgumentList %type OptionExplicit_opt @@ -188,7 +188,11 @@ EmptyBrackets_opt | tEMPTYBRACKETS Expression + : OrExpression { $$ = $1; } + +OrExpression : AndExpression { $$ = $1; } + | OrExpression tOR AndExpression { $$ = new_binary_expression(ctx, EXPR_OR, $1, $3); CHECK_ERROR; } AndExpression : NotExpression { $$ = $1; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 1d2f95d68d1..2a05998857c 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -139,6 +139,7 @@ typedef enum { X(nequal, 1, 0, 0) \ X(not, 1, 0, 0) \ X(null, 1, 0, 0) \ + X(or, 1, 0, 0) \ X(ret, 0, 0, 0) \ X(short, 1, ARG_INT, 0) \ X(string, 1, ARG_STR, 0) \