next_preprocessing_token();
}
+static inline void eat_token(token_kind_t const kind)
+{
+ assert(pp_token.kind == kind);
+ (void)kind;
+ next_preprocessing_token();
+}
+
static void parse_symbol(void)
{
obstack_1grow(&symbol_obstack, (char) input.c);
* lexer (except for the fact that they separate tokens). #define b(x)
* is something else than #define b (x) */
if (input.c == '(') {
- /* eat the '(' */
- next_preprocessing_token();
- /* get next token after '(' */
- next_preprocessing_token();
+ eat_token(T_IDENTIFIER);
+ eat_token('(');
while (true) {
switch (pp_token.kind) {
case T_DOTDOTDOT:
new_definition->is_variadic = true;
- next_preprocessing_token();
+ eat_token(T_DOTDOTDOT);
if (pp_token.kind != ')') {
errorf(&input.position,
"'...' not at end of macro argument list");
goto error_out;
}
break;
+
case T_IDENTIFIER:
obstack_ptr_grow(&pp_obstack, pp_token.base.symbol);
- next_preprocessing_token();
+ eat_token(T_IDENTIFIER);
if (pp_token.kind == ',') {
- next_preprocessing_token();
+ eat_token(',');
break;
}
goto error_out;
}
break;
+
case ')':
- next_preprocessing_token();
+ eat_token(')');
goto finish_argument_list;
+
default:
errorf(&pp_token.base.source_position,
"expected identifier, '...' or ')' in #define argument list, got %K",
= obstack_object_size(&pp_obstack) / sizeof(new_definition->parameters[0]);
new_definition->parameters = obstack_finish(&pp_obstack);
} else {
- next_preprocessing_token();
+ eat_token(T_IDENTIFIER);
}
/* construct a new pp_definition on the obstack */
}
pp_token.base.symbol->pp_definition = NULL;
- next_preprocessing_token();
+ eat_token(T_IDENTIFIER);
if (!info.at_line_begin) {
warningf(WARN_OTHER, &input.position, "extra tokens at end of #undef directive");
{
bool is_ifndef = pp_token.base.symbol->pp_ID == TP_ifndef;
bool condition;
- next_preprocessing_token();
+ eat_pp(is_ifndef ? TP_ifndef : TP_ifdef);
if (skip_mode) {
eat_pp_directive();
} else {
/* evaluate wether we are in true or false case */
condition = (bool)!pp_token.base.symbol->pp_definition == is_ifndef;
-
- next_preprocessing_token();
+ eat_token(T_IDENTIFIER);
if (!info.at_line_begin) {
errorf(&pp_token.base.source_position,
static void parse_preprocessing_directive(void)
{
- next_preprocessing_token(); /* Eat '#'. */
+ eat_token('#');
if (info.at_line_begin) {
/* empty directive */
if (pp_definition->has_parameters) {
source_position_t position = pp_token.base.source_position;
add_token_info_t old_info = info;
- next_preprocessing_token();
+ eat_token(T_IDENTIFIER);
add_token_info_t new_info = info;
/* no opening brace -> no expansion */
if (pp_token.kind == '(') {
- next_preprocessing_token(); /* Eat '('. */
+ eat_token('(');
/* parse arguments (TODO) */
while (pp_token.kind != T_EOF && pp_token.kind != ')')