Commit 69de0798 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added 'and' expression parser/compiler implementation.

parent f9edb683
...@@ -356,6 +356,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) ...@@ -356,6 +356,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
switch(expr->type) { switch(expr->type) {
case EXPR_ADD: case EXPR_ADD:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add); return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add);
case EXPR_AND:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_and);
case EXPR_BOOL: case EXPR_BOOL:
return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value); return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value);
case EXPR_CONCAT: case EXPR_CONCAT:
......
...@@ -564,6 +564,12 @@ static HRESULT interp_not(exec_ctx_t *ctx) ...@@ -564,6 +564,12 @@ static HRESULT interp_not(exec_ctx_t *ctx)
return stack_push(ctx, &v); return stack_push(ctx, &v);
} }
static HRESULT interp_and(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT cmp_oper(exec_ctx_t *ctx) static HRESULT cmp_oper(exec_ctx_t *ctx)
{ {
variant_val_t l, r; variant_val_t l, r;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
typedef enum { typedef enum {
EXPR_ADD, EXPR_ADD,
EXPR_AND,
EXPR_BOOL, EXPR_BOOL,
EXPR_CONCAT, EXPR_CONCAT,
EXPR_DIV, EXPR_DIV,
......
...@@ -98,7 +98,7 @@ static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL); ...@@ -98,7 +98,7 @@ static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL);
%type <statement> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt %type <statement> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt
%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
%type <expression> NotExpression UnaryExpression %type <expression> NotExpression UnaryExpression AndExpression
%type <member> MemberExpression %type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt ArgumentList %type <expression> Arguments_opt ArgumentList_opt ArgumentList
%type <bool> OptionExplicit_opt %type <bool> OptionExplicit_opt
...@@ -188,7 +188,11 @@ EmptyBrackets_opt ...@@ -188,7 +188,11 @@ EmptyBrackets_opt
| tEMPTYBRACKETS | tEMPTYBRACKETS
Expression Expression
: NotExpression { $$ = $1; } : AndExpression { $$ = $1; }
AndExpression
: NotExpression { $$ = $1; }
| AndExpression tAND NotExpression { $$ = new_binary_expression(ctx, EXPR_AND, $1, $3); CHECK_ERROR; }
NotExpression NotExpression
: EqualityExpression { $$ = $1; } : EqualityExpression { $$ = $1; }
......
...@@ -117,6 +117,7 @@ typedef enum { ...@@ -117,6 +117,7 @@ typedef enum {
#define OP_LIST \ #define OP_LIST \
X(add, 1, 0, 0) \ X(add, 1, 0, 0) \
X(and, 1, 0, 0) \
X(assign_ident, 1, ARG_BSTR, 0) \ X(assign_ident, 1, ARG_BSTR, 0) \
X(assign_member, 1, ARG_BSTR, 0) \ X(assign_member, 1, ARG_BSTR, 0) \
X(bool, 1, ARG_INT, 0) \ X(bool, 1, ARG_INT, 0) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment