vbscript: Added bool literals parsing support.
This commit is contained in:
parent
7cbc5235bd
commit
d145d0c037
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
EXPR_BOOL,
|
||||||
EXPR_MEMBER
|
EXPR_MEMBER
|
||||||
} expression_type_t;
|
} expression_type_t;
|
||||||
|
|
||||||
|
@ -25,6 +26,11 @@ typedef struct _expression_t {
|
||||||
struct _expression_t *next;
|
struct _expression_t *next;
|
||||||
} expression_t;
|
} expression_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
expression_t expr;
|
||||||
|
VARIANT_BOOL value;
|
||||||
|
} bool_expression_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
expression_t expr;
|
expression_t expr;
|
||||||
expression_t *obj_expr;
|
expression_t *obj_expr;
|
||||||
|
|
|
@ -35,6 +35,8 @@ static void parse_complete(parser_ctx_t*);
|
||||||
|
|
||||||
static void source_add_statement(parser_ctx_t*,statement_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 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*);
|
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
|
%token <string> tIdentifier
|
||||||
|
|
||||||
%type <statement> Statement StatementNl
|
%type <statement> Statement StatementNl
|
||||||
|
%type <expression> Expression LiteralExpression
|
||||||
%type <member> MemberExpression
|
%type <member> MemberExpression
|
||||||
%type <expression> Arguments_opt ArgumentList_opt
|
%type <expression> Arguments_opt ArgumentList_opt ArgumentList
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
@ -98,7 +101,18 @@ Arguments_opt
|
||||||
|
|
||||||
ArgumentList_opt
|
ArgumentList_opt
|
||||||
: /* empty */ { $$ = NULL; }
|
: /* 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;
|
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)
|
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;
|
||||||
|
|
Loading…
Reference in New Issue