From 82b7651841088c3a44b60a182490fd2a3976229f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 9 Sep 2011 14:48:13 +0200 Subject: [PATCH] vbscript: Added parser support for equality expression. --- dlls/vbscript/parse.h | 7 +++++++ dlls/vbscript/parser.y | 26 ++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 0e1b4d187f4..607bdecf05b 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -18,6 +18,7 @@ typedef enum { EXPR_BOOL, + EXPR_EQUAL, EXPR_MEMBER, EXPR_NOT, EXPR_STRING @@ -43,6 +44,12 @@ typedef struct { expression_t *subexpr; } unary_expression_t; +typedef struct { + expression_t expr; + expression_t *left; + expression_t *right; +} binary_expression_t; + typedef struct { expression_t expr; expression_t *obj_expr; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index a743b97c4c1..7703402511d 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -38,6 +38,7 @@ static void source_add_statement(parser_ctx_t*,statement_t*); static expression_t *new_bool_expression(parser_ctx_t*,VARIANT_BOOL); static expression_t *new_string_expression(parser_ctx_t*,const WCHAR*); static expression_t *new_unary_expression(parser_ctx_t*,expression_type_t,expression_t*); +static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expression_t*,expression_t*); static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*); @@ -74,7 +75,8 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); %token tIdentifier tString %type Statement StatementNl -%type Expression LiteralExpression PrimaryExpression +%type Expression LiteralExpression PrimaryExpression EqualityExpression +%type ConcatExpression %type NotExpression %type MemberExpression %type Arguments_opt ArgumentList_opt ArgumentList @@ -124,9 +126,16 @@ Expression : NotExpression { $$ = $1; } NotExpression + : EqualityExpression { $$ = $1; } + | tNOT NotExpression { $$ = new_unary_expression(ctx, EXPR_NOT, $2); CHECK_ERROR; } + +EqualityExpression + : ConcatExpression { $$ = $1; } + | EqualityExpression '=' ConcatExpression { $$ = new_binary_expression(ctx, EXPR_EQUAL, $1, $3); CHECK_ERROR; } + +ConcatExpression : LiteralExpression /* FIXME */ { $$ = $1; } | PrimaryExpression /* FIXME */ { $$ = $1; } - | tNOT NotExpression { $$ = new_unary_expression(ctx, EXPR_NOT, $2); CHECK_ERROR; } LiteralExpression : tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; } @@ -208,6 +217,19 @@ static expression_t *new_unary_expression(parser_ctx_t *ctx, expression_type_t t return &expr->expr; } +static expression_t *new_binary_expression(parser_ctx_t *ctx, expression_type_t type, expression_t *left, expression_t *right) +{ + binary_expression_t *expr; + + expr = new_expression(ctx, type, sizeof(*expr)); + if(!expr) + return NULL; + + expr->left = left; + expr->right = right; + return &expr->expr; +} + static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *obj_expr, const WCHAR *identifier) { member_expression_t *expr;