vbscript: Added multiplicative expression parser/compiler implementation.

This commit is contained in:
Jacek Caban 2011-09-13 11:40:39 +02:00 committed by Alexandre Julliard
parent 80eff04037
commit 2f3c235a44
5 changed files with 28 additions and 1 deletions

View File

@ -353,6 +353,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value);
case EXPR_CONCAT:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_concat);
case EXPR_DIV:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_div);
case EXPR_DOUBLE:
return push_instr_double(ctx, OP_double, ((double_expression_t*)expr)->value);
case EXPR_EMPTY:
@ -365,6 +367,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return compile_member_expression(ctx, (member_expression_t*)expr, TRUE);
case EXPR_MOD:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mod);
case EXPR_MUL:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mul);
case EXPR_NEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
case EXPR_NEQUAL:

View File

@ -690,6 +690,18 @@ static HRESULT interp_idiv(exec_ctx_t *ctx)
return stack_push(ctx, &v);
}
static HRESULT interp_div(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT interp_mul(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT interp_neg(exec_ctx_t *ctx)
{
variant_val_t val;

View File

@ -20,12 +20,14 @@ typedef enum {
EXPR_ADD,
EXPR_BOOL,
EXPR_CONCAT,
EXPR_DIV,
EXPR_DOUBLE,
EXPR_EMPTY,
EXPR_EQUAL,
EXPR_IDIV,
EXPR_MEMBER,
EXPR_MOD,
EXPR_MUL,
EXPR_NEG,
EXPR_NEQUAL,
EXPR_NOT,

View File

@ -91,7 +91,7 @@ static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*);
%type <statement> Statement StatementNl StatementsNl IfStatement Else_opt
%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression
%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
%type <expression> NotExpression UnaryExpression
%type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt ArgumentList
@ -203,6 +203,13 @@ IntdivExpression
{ $$ = new_binary_expression(ctx, EXPR_IDIV, $1, $3); CHECK_ERROR; }
MultiplicativeExpression
: ExpExpression { $$ = $1; }
| MultiplicativeExpression '*' ExpExpression
{ $$ = new_binary_expression(ctx, EXPR_MUL, $1, $3); CHECK_ERROR; }
| MultiplicativeExpression '/' ExpExpression
{ $$ = new_binary_expression(ctx, EXPR_DIV, $1, $3); CHECK_ERROR; }
ExpExpression
: UnaryExpression /* FIXME */ { $$ = $1; }
UnaryExpression

View File

@ -103,6 +103,7 @@ typedef enum {
X(assign_member, 1, ARG_BSTR, 0) \
X(bool, 1, ARG_INT, 0) \
X(concat, 1, 0, 0) \
X(div, 1, 0, 0) \
X(double, 1, ARG_DOUBLE, 0) \
X(empty, 1, 0, 0) \
X(equal, 1, 0, 0) \
@ -113,6 +114,7 @@ typedef enum {
X(jmp_false, 0, ARG_ADDR, 0) \
X(long, 1, ARG_INT, 0) \
X(mod, 1, 0, 0) \
X(mul, 1, 0, 0) \
X(neg, 1, 0, 0) \
X(nequal, 1, 0, 0) \
X(not, 1, 0, 0) \