Commit 40dda77c authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Added support for floating-point constants.

parent 7e191785
......@@ -358,6 +358,9 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
case EXPR_HEXNUM:
fprintf(h, "0x%lx", e->u.lval);
break;
case EXPR_DOUBLE:
fprintf(h, "%#.15g", e->u.dval);
break;
case EXPR_TRUEFALSE:
if (e->u.lval == 0)
fprintf(h, "FALSE");
......
......@@ -29,6 +29,7 @@ int [0-9]+
hexd [0-9a-fA-F]
hex 0x{hexd}+
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
%x QUOTE
%x ATTR
......@@ -150,6 +151,10 @@ static UUID* parse_uuid(const char*u)
parser_lval.num = strtoul(yytext, NULL, 0);
return aNUM;
}
<INITIAL>{double} {
parser_lval.dbl = strtod(yytext, NULL);
return aDOUBLE;
}
SAFEARRAY{ws}*/\( return tSAFEARRAY;
{cident} return kw_token(yytext);
<INITIAL,ATTR>\n line_number++;
......
......@@ -83,6 +83,7 @@ static attr_t *make_attrv(enum attr_type type, unsigned long val);
static attr_t *make_attrp(enum attr_type type, void *val);
static expr_t *make_expr(enum expr_type type);
static expr_t *make_exprl(enum expr_type type, long val);
static expr_t *make_exprd(enum expr_type type, double val);
static expr_t *make_exprs(enum expr_type type, char *val);
static expr_t *make_exprt(enum expr_type type, type_t *tref, expr_t *expr);
static expr_t *make_expr1(enum expr_type type, expr_t *expr);
......@@ -151,11 +152,13 @@ static void check_all_user_types(ifref_list_t *ifaces);
char *str;
UUID *uuid;
unsigned int num;
double dbl;
}
%token <str> aIDENTIFIER
%token <str> aKNOWNTYPE
%token <num> aNUM aHEXNUM
%token <dbl> aDOUBLE
%token <str> aSTRING
%token <uuid> aUUID
%token aEOF
......@@ -581,6 +584,7 @@ m_expr: { $$ = make_expr(EXPR_VOID); }
expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| aHEXNUM { $$ = make_exprl(EXPR_HEXNUM, $1); }
| aDOUBLE { $$ = make_exprd(EXPR_DOUBLE, $1); }
| tFALSE { $$ = make_exprl(EXPR_TRUEFALSE, 0); }
| tTRUE { $$ = make_exprl(EXPR_TRUEFALSE, 1); }
| aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
......@@ -1033,6 +1037,17 @@ static expr_t *make_exprl(enum expr_type type, long val)
return e;
}
static expr_t *make_exprd(enum expr_type type, double val)
{
expr_t *e = xmalloc(sizeof(expr_t));
e->type = type;
e->ref = NULL;
e->u.dval = val;
e->is_const = TRUE;
e->cval = val;
return e;
}
static expr_t *make_exprs(enum expr_type type, char *val)
{
expr_t *e;
......
......@@ -227,6 +227,8 @@ static int compare_expr(const expr_t *a, const expr_t *b)
case EXPR_HEXNUM:
case EXPR_TRUEFALSE:
return a->u.lval - b->u.lval;
case EXPR_DOUBLE:
return a->u.dval - b->u.dval;
case EXPR_IDENTIFIER:
return strcmp(a->u.sval, b->u.sval);
case EXPR_COND:
......@@ -2690,6 +2692,9 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
case EXPR_HEXNUM:
fprintf(h, "0x%lx", e->u.lval);
break;
case EXPR_DOUBLE:
fprintf(h, "%#.15g", e->u.dval);
break;
case EXPR_TRUEFALSE:
if (e->u.lval == 0)
fprintf(h, "FALSE");
......
......@@ -135,6 +135,7 @@ enum expr_type
EXPR_VOID,
EXPR_NUM,
EXPR_HEXNUM,
EXPR_DOUBLE,
EXPR_IDENTIFIER,
EXPR_NEG,
EXPR_NOT,
......@@ -188,6 +189,7 @@ struct _expr_t {
const expr_t *ref;
union {
long lval;
double dval;
const char *sval;
const expr_t *ext;
type_t *tref;
......
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