vbscript: Added negation expression parser/compiler implementation.

oldstable
Jacek Caban 2011-09-12 12:31:37 +02:00 committed by Alexandre Julliard
parent a5fe24c61d
commit fb5509ec06
5 changed files with 18 additions and 3 deletions

View File

@ -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:

View File

@ -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

View File

@ -23,6 +23,7 @@ typedef enum {
EXPR_EMPTY,
EXPR_EQUAL,
EXPR_MEMBER,
EXPR_NEG,
EXPR_NOT,
EXPR_NULL,
EXPR_STRING,

View File

@ -84,7 +84,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
%type <statement> Statement StatementNl
%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
%type <expression> ConcatExpression AdditiveExpression
%type <expression> NotExpression
%type <expression> NotExpression UnaryExpression
%type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt ArgumentList
%type <bool> 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; }

View File

@ -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) \