s = sl_pp_context_cstr(context, input[i].data.identifier);
break;
- case SL_PP_NUMBER:
- s = sl_pp_context_cstr(context, input[i].data.number);
+ case SL_PP_UINT:
+ s = sl_pp_context_cstr(context, input[i].data._uint);
+ break;
+
+ case SL_PP_FLOAT:
+ s = sl_pp_context_cstr(context, input[i].data._float);
break;
case SL_PP_OTHER:
_parse_primary(struct parse_context *ctx,
int *result)
{
- if (ctx->input->token == SL_PP_NUMBER) {
- *result = atoi(sl_pp_context_cstr(ctx->context, ctx->input->data.number));
+ if (ctx->input->token == SL_PP_UINT) {
+ *result = atoi(sl_pp_context_cstr(ctx->context, ctx->input->data._uint));
ctx->input++;
} else {
if (ctx->input->token != SL_PP_LPAREN) {
(*pi)++;
}
- result.token = SL_PP_NUMBER;
+ result.token = SL_PP_UINT;
if (defined) {
- result.data.number = sl_pp_context_add_unique_str(context, "1");
+ result.data._uint = sl_pp_context_add_unique_str(context, "1");
} else {
- result.data.number = sl_pp_context_add_unique_str(context, "0");
+ result.data._uint = sl_pp_context_add_unique_str(context, "0");
}
- if (result.data.number == -1) {
+ if (result.data._uint == -1) {
return -1;
}
}
}
- if (state.out_len > 0 && state.out[0].token == SL_PP_NUMBER) {
- line_number = state.out[0].data.number;
+ if (state.out_len > 0 && state.out[0].token == SL_PP_UINT) {
+ line_number = state.out[0].data._uint;
} else {
strcpy(context->error_msg, "expected a number after `#line'");
free(state.out);
}
if (state.out_len > 1) {
- if (state.out[1].token == SL_PP_NUMBER) {
- file_number = state.out[1].data.number;
+ if (state.out[1].token == SL_PP_UINT) {
+ file_number = state.out[1].data._uint;
} else {
strcpy(context->error_msg, "expected a number after line number");
free(state.out);
sprintf(buf, "%u", number);
- ti.token = SL_PP_NUMBER;
- ti.data.number = sl_pp_context_add_unique_str(context, buf);
+ ti.token = SL_PP_UINT;
+ ti.data._uint = sl_pp_context_add_unique_str(context, buf);
if (sl_pp_process_out(state, &ti)) {
strcpy(context->error_msg, "out of memory");
return -1;
{
const char *input = *pinput;
unsigned int eaten;
+ unsigned int is_float = 0;
char number[256]; /* XXX: Remove this artifical limit. */
eaten = _parse_float(input);
eaten = _parse_dec(input);
}
}
+ } else {
+ is_float = 1;
}
if (!eaten || _is_identifier_char(input[eaten])) {
memcpy(number, input, eaten);
number[eaten] = '\0';
- info->token = SL_PP_NUMBER;
- info->data.number = sl_pp_context_add_unique_str(context, number);
- if (info->data.number == -1) {
- return -1;
+ if (is_float) {
+ info->token = SL_PP_FLOAT;
+ info->data._float = sl_pp_context_add_unique_str(context, number);
+ if (info->data._float == -1) {
+ return -1;
+ }
+ } else {
+ info->token = SL_PP_UINT;
+ info->data._uint = sl_pp_context_add_unique_str(context, number);
+ if (info->data._uint == -1) {
+ return -1;
+ }
}
*pinput = input + eaten;
SL_PP_IDENTIFIER,
- SL_PP_NUMBER,
+ SL_PP_UINT,
+ SL_PP_FLOAT,
SL_PP_OTHER,
union sl_pp_token_data {
int identifier;
- int number;
+ int _uint;
+ int _float;
char other;
int pragma;
int extension;
i++;
break;
- case SL_PP_NUMBER:
- *version = atoi(sl_pp_context_cstr(context, input[i].data.number));
+ case SL_PP_UINT:
+ *version = atoi(sl_pp_context_cstr(context, input[i].data._uint));
i++;
found_number = 1;
break;