Commit 82b76518 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added parser support for equality expression.

parent 6ca3cb62
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
typedef enum { typedef enum {
EXPR_BOOL, EXPR_BOOL,
EXPR_EQUAL,
EXPR_MEMBER, EXPR_MEMBER,
EXPR_NOT, EXPR_NOT,
EXPR_STRING EXPR_STRING
...@@ -45,6 +46,12 @@ typedef struct { ...@@ -45,6 +46,12 @@ typedef struct {
typedef struct { typedef struct {
expression_t expr; expression_t expr;
expression_t *left;
expression_t *right;
} binary_expression_t;
typedef struct {
expression_t expr;
expression_t *obj_expr; expression_t *obj_expr;
const WCHAR *identifier; const WCHAR *identifier;
expression_t *args; expression_t *args;
......
...@@ -38,6 +38,7 @@ static void source_add_statement(parser_ctx_t*,statement_t*); ...@@ -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_bool_expression(parser_ctx_t*,VARIANT_BOOL);
static expression_t *new_string_expression(parser_ctx_t*,const WCHAR*); 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_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*); 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*); ...@@ -74,7 +75,8 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
%token <string> tIdentifier tString %token <string> tIdentifier tString
%type <statement> Statement StatementNl %type <statement> Statement StatementNl
%type <expression> Expression LiteralExpression PrimaryExpression %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression
%type <expression> ConcatExpression
%type <expression> NotExpression %type <expression> NotExpression
%type <member> MemberExpression %type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt ArgumentList %type <expression> Arguments_opt ArgumentList_opt ArgumentList
...@@ -124,9 +126,16 @@ Expression ...@@ -124,9 +126,16 @@ Expression
: NotExpression { $$ = $1; } : NotExpression { $$ = $1; }
NotExpression 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; } : LiteralExpression /* FIXME */ { $$ = $1; }
| PrimaryExpression /* FIXME */ { $$ = $1; } | PrimaryExpression /* FIXME */ { $$ = $1; }
| tNOT NotExpression { $$ = new_unary_expression(ctx, EXPR_NOT, $2); CHECK_ERROR; }
LiteralExpression LiteralExpression
: tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; } : 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 ...@@ -208,6 +217,19 @@ static expression_t *new_unary_expression(parser_ctx_t *ctx, expression_type_t t
return &expr->expr; 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) static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *obj_expr, const WCHAR *identifier)
{ {
member_expression_t *expr; member_expression_t *expr;
......
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