Commit 7f835c96 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added parser support for numeric literals.

parent 1e224b4e
...@@ -18,12 +18,15 @@ ...@@ -18,12 +18,15 @@
typedef enum { typedef enum {
EXPR_BOOL, EXPR_BOOL,
EXPR_DOUBLE,
EXPR_EMPTY, EXPR_EMPTY,
EXPR_EQUAL, EXPR_EQUAL,
EXPR_MEMBER, EXPR_MEMBER,
EXPR_NOT, EXPR_NOT,
EXPR_NULL, EXPR_NULL,
EXPR_STRING EXPR_STRING,
EXPR_ULONG,
EXPR_USHORT
} expression_type_t; } expression_type_t;
typedef struct _expression_t { typedef struct _expression_t {
...@@ -38,6 +41,16 @@ typedef struct { ...@@ -38,6 +41,16 @@ typedef struct {
typedef struct { typedef struct {
expression_t expr; expression_t expr;
LONG value;
} int_expression_t;
typedef struct {
expression_t expr;
double value;
} double_expression_t;
typedef struct {
expression_t expr;
const WCHAR *value; const WCHAR *value;
} string_expression_t; } string_expression_t;
......
...@@ -38,6 +38,8 @@ static void source_add_statement(parser_ctx_t*,statement_t*); ...@@ -38,6 +38,8 @@ static void source_add_statement(parser_ctx_t*,statement_t*);
static void *new_expression(parser_ctx_t*,expression_type_t,size_t); static void *new_expression(parser_ctx_t*,expression_type_t,size_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_long_expression(parser_ctx_t*,expression_type_t,LONG);
static expression_t *new_double_expression(parser_ctx_t*,double);
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 expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expression_t*,expression_t*);
...@@ -57,7 +59,9 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); ...@@ -57,7 +59,9 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
statement_t *statement; statement_t *statement;
expression_t *expression; expression_t *expression;
member_expression_t *member; member_expression_t *member;
LONG lng;
BOOL bool; BOOL bool;
double dbl;
} }
%token tEOF tNL tREM tEMPTYBRACKETS %token tEOF tNL tREM tEMPTYBRACKETS
...@@ -148,6 +152,10 @@ LiteralExpression ...@@ -148,6 +152,10 @@ LiteralExpression
: tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; } : tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; }
| tFALSE { $$ = new_bool_expression(ctx, VARIANT_FALSE); CHECK_ERROR; } | tFALSE { $$ = new_bool_expression(ctx, VARIANT_FALSE); CHECK_ERROR; }
| tString { $$ = new_string_expression(ctx, $1); CHECK_ERROR; } | tString { $$ = new_string_expression(ctx, $1); CHECK_ERROR; }
| tShort { $$ = new_long_expression(ctx, EXPR_USHORT, $1); CHECK_ERROR; }
| '0' { $$ = new_long_expression(ctx, EXPR_USHORT, 0); CHECK_ERROR; }
| tLong { $$ = new_long_expression(ctx, EXPR_ULONG, $1); CHECK_ERROR; }
| tDouble { $$ = new_double_expression(ctx, $1); CHECK_ERROR; }
| tEMPTY { $$ = new_expression(ctx, EXPR_EMPTY, 0); CHECK_ERROR; } | tEMPTY { $$ = new_expression(ctx, EXPR_EMPTY, 0); CHECK_ERROR; }
| tNULL { $$ = new_expression(ctx, EXPR_NULL, 0); CHECK_ERROR; } | tNULL { $$ = new_expression(ctx, EXPR_NULL, 0); CHECK_ERROR; }
...@@ -214,6 +222,30 @@ static expression_t *new_string_expression(parser_ctx_t *ctx, const WCHAR *value ...@@ -214,6 +222,30 @@ static expression_t *new_string_expression(parser_ctx_t *ctx, const WCHAR *value
return &expr->expr; return &expr->expr;
} }
static expression_t *new_long_expression(parser_ctx_t *ctx, expression_type_t type, LONG value)
{
int_expression_t *expr;
expr = new_expression(ctx, type, sizeof(*expr));
if(!expr)
return NULL;
expr->value = value;
return &expr->expr;
}
static expression_t *new_double_expression(parser_ctx_t *ctx, double value)
{
double_expression_t *expr;
expr = new_expression(ctx, EXPR_DOUBLE, sizeof(*expr));
if(!expr)
return NULL;
expr->value = value;
return &expr->expr;
}
static expression_t *new_unary_expression(parser_ctx_t *ctx, expression_type_t type, expression_t *subexpr) static expression_t *new_unary_expression(parser_ctx_t *ctx, expression_type_t type, expression_t *subexpr)
{ {
unary_expression_t *expr; unary_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