From fb5509ec06939b26647e8054dd439aba9c0913c2 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 12 Sep 2011 12:31:37 +0200 Subject: [PATCH] vbscript: Added negation expression parser/compiler implementation. --- dlls/vbscript/compile.c | 2 ++ dlls/vbscript/interp.c | 6 ++++++ dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 11 ++++++++--- dlls/vbscript/vbscript.h | 1 + 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 9e59fe1e218..baaa07807e1 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -246,6 +246,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_equal); case EXPR_MEMBER: return compile_member_expression(ctx, (member_expression_t*)expr, TRUE); + case EXPR_NEG: + return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg); case EXPR_NOT: return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not); case EXPR_NULL: diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 90531fb3a8d..a70ca5f667f 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -391,6 +391,12 @@ static HRESULT interp_concat(exec_ctx_t *ctx) return stack_push(ctx, &v); } +static HRESULT interp_neg(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static const instr_func_t op_funcs[] = { #define X(x,n,a,b) interp_ ## x, OP_LIST diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index b47360c2bc9..0c87209a5f9 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -23,6 +23,7 @@ typedef enum { EXPR_EMPTY, EXPR_EQUAL, EXPR_MEMBER, + EXPR_NEG, EXPR_NOT, EXPR_NULL, EXPR_STRING, diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 756cf6a5961..316957c9944 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -84,7 +84,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); %type Statement StatementNl %type Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type ConcatExpression AdditiveExpression -%type NotExpression +%type NotExpression UnaryExpression %type MemberExpression %type Arguments_opt ArgumentList_opt ArgumentList %type OptionExplicit_opt @@ -145,8 +145,13 @@ ConcatExpression | ConcatExpression '&' AdditiveExpression { $$ = new_binary_expression(ctx, EXPR_CONCAT, $1, $3); CHECK_ERROR; } AdditiveExpression - : LiteralExpression /* FIXME */ { $$ = $1; } - | CallExpression /* FIXME */ { $$ = $1; } + : UnaryExpression /* FIXME */ { $$ = $1; } + + +UnaryExpression + : LiteralExpression { $$ = $1; } + | CallExpression { $$ = $1; } + | '-' UnaryExpression { $$ = new_unary_expression(ctx, EXPR_NEG, $2); CHECK_ERROR; } CallExpression : PrimaryExpression { $$ = $1; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 2abbc9d2b61..9db26920eb4 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -96,6 +96,7 @@ typedef enum { X(icall, 1, ARG_BSTR, ARG_UINT) \ X(icallv, 1, ARG_BSTR, ARG_UINT) \ X(long, 1, ARG_INT, 0) \ + X(neg, 1, 0, 0) \ X(not, 1, 0, 0) \ X(null, 1, 0, 0) \ X(ret, 0, 0, 0) \