vbscript: Added bool literals parsing support.

This commit is contained in:
Jacek Caban 2011-09-08 14:56:36 +02:00 committed by Alexandre Julliard
parent 7cbc5235bd
commit d145d0c037
2 changed files with 34 additions and 2 deletions

View File

@ -17,6 +17,7 @@
*/
typedef enum {
EXPR_BOOL,
EXPR_MEMBER
} expression_type_t;
@ -25,6 +26,11 @@ typedef struct _expression_t {
struct _expression_t *next;
} expression_t;
typedef struct {
expression_t expr;
VARIANT_BOOL value;
} bool_expression_t;
typedef struct {
expression_t expr;
expression_t *obj_expr;

View File

@ -35,6 +35,8 @@ static void parse_complete(parser_ctx_t*);
static void source_add_statement(parser_ctx_t*,statement_t*);
static expression_t *new_bool_expression(parser_ctx_t*,VARIANT_BOOL);
static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*);
static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
@ -69,8 +71,9 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
%token <string> tIdentifier
%type <statement> Statement StatementNl
%type <expression> Expression LiteralExpression
%type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt
%type <expression> Arguments_opt ArgumentList_opt ArgumentList
%%
@ -98,7 +101,18 @@ Arguments_opt
ArgumentList_opt
: /* empty */ { $$ = NULL; }
/* | ArgumentList { $$ = $1; } */
| ArgumentList { $$ = $1; }
ArgumentList
: Expression { $$ = $1; }
| Expression ',' ArgumentList { $1->next = $3; $$ = $1; }
Expression
: LiteralExpression /* FIXME */ { $$ = $1; }
LiteralExpression
: tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; }
| tFALSE { $$ = new_bool_expression(ctx, VARIANT_FALSE); CHECK_ERROR; }
%%
@ -135,6 +149,18 @@ static void *new_expression(parser_ctx_t *ctx, expression_type_t type, unsigned
return expr;
}
static expression_t *new_bool_expression(parser_ctx_t *ctx, VARIANT_BOOL value)
{
bool_expression_t *expr;
expr = new_expression(ctx, EXPR_BOOL, sizeof(*expr));
if(!expr)
return NULL;
expr->value = value;
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;