[util] Support size_t constants

Much like 1u and 1l, 1z is for size_t.
This commit is contained in:
Bill Currie 2021-01-20 01:24:32 +09:00
parent df82cb88ee
commit 0622a24380

View file

@ -71,6 +71,7 @@ FILE *cexpr_yyget_in (yyscan_t yyscanner) __attribute__((pure));
static exprval_t *parse_int (const char *str, exprctx_t *context);
static exprval_t *parse_uint (const char *str, exprctx_t *context);
static exprval_t *parse_size_t (const char *str, exprctx_t *context);
static exprval_t *parse_float (const char *str, exprctx_t *context);
static exprval_t *parse_double (const char *str, exprctx_t *context);
static exprsym_t *parse_name (const char *str, exprctx_t *context);
@ -127,6 +128,11 @@ STRING \"(\\.|[^"\\])*\"
return VALUE;
}
{INT}+[zZ] {
yylval->value = parse_size_t (yytext, context);
return VALUE;
}
{FLOAT} {
yylval->value = parse_double (yytext, context);
return VALUE;
@ -239,6 +245,13 @@ static exprval_t *parse_uint (const char *str, exprctx_t *context)
return val;
}
static exprval_t *parse_size_t (const char *str, exprctx_t *context)
{
exprval_t *val = cexpr_value (&cexpr_size_t, context);
*(unsigned *) val->value = strtoumax (str, 0, 0);
return val;
}
static exprval_t *parse_float (const char *str, exprctx_t *context)
{
exprval_t *val = cexpr_value (&cexpr_float, context);