va_list* toks = va_arg(ap, va_list*);
const char* const delimiter = va_arg(ap, const char*);
for (;;) {
- const token_kind_t tok = va_arg(*toks, token_kind_t);
+ const token_kind_t tok = (token_kind_t)va_arg(*toks, int);
if (tok == 0)
break;
if (first) {
print_token_kind(stderr, tok);
}
} else {
- const token_kind_t token = va_arg(ap, token_kind_t);
+ const token_kind_t token = (token_kind_t)va_arg(ap, int);
print_token_kind(stderr, token);
}
break;
#endif
}
-#define eat(token_kind) (assert(token.kind == (token_kind)), next_token())
+static inline void eat(token_kind_t const kind)
+{
+ assert(token.kind == kind);
+ (void)kind;
+ next_token();
+}
-static inline bool next_if(token_kind_t const type)
+static inline bool next_if(token_kind_t const kind)
{
- if (token.kind == type) {
- eat(type);
+ if (token.kind == kind) {
+ eat(kind);
return true;
} else {
return false;
static source_position_t expansion_pos;
static pp_definition_t *current_expansion = NULL;
static strset_t stringset;
-static preprocessor_token_kind_t last_token;
+static token_kind_t last_token;
static searchpath_entry_t *searchpath;
return (string_t){ result, len, enc };
}
-static void parse_string(utf32 const delimiter, preprocessor_token_kind_t const kind, string_encoding_t const enc, char const *const context)
+static void parse_string(utf32 const delimiter, token_kind_t const kind,
+ string_encoding_t const enc,
+ char const *const context)
{
const unsigned start_linenr = input.position.lineno;
}
}
-static void eat_pp(preprocessor_token_kind_t const type)
+static inline void eat_pp(token_kind_t const kind)
{
- (void) type;
- assert(pp_token.kind == type);
+ assert(pp_token.kind == kind);
+ (void) kind;
next_preprocessing_token();
}
return symbol;
}
-static symbol_t *intern_register_pp_token(preprocessor_token_kind_t id, const char *string)
+static symbol_t *intern_register_pp_token(token_kind_t id, const char *string)
{
assert(id < TP_LAST_TOKEN);
symbol_t *symbol = symbol_table_insert(string);
}
}
-static void register_pp_token(unsigned mode, preprocessor_token_kind_t id,
+static void register_pp_token(unsigned mode, token_kind_t id,
const char *string)
{
if (! (c_mode & mode))
void print_pp_token(FILE *f, const token_t *token)
{
- switch((preprocessor_token_kind_t) token->kind) {
+ switch ((token_kind_t)token->kind) {
case TP_IDENTIFIER:
fprintf(f, "identifier '%s'", token->base.symbol->string);
break;
fprintf(f, "string \"%s\"", token->literal.string.begin);
break;
default:
- print_pp_token_kind(f, (preprocessor_token_kind_t) token->kind);
+ print_pp_token_kind(f, (token_kind_t) token->kind);
break;
}
}
-bool tokens_would_paste(preprocessor_token_kind_t token1,
- preprocessor_token_kind_t token2)
+bool tokens_would_paste(token_kind_t token1, token_kind_t token2)
{
char c = token2 < 256 ? (char) token2 : pp_token_symbols[token2]->string[0];
#include "symbol_table.h"
#include "type.h"
-typedef enum token_kind_t {
+typedef enum token_kind_tag_t {
T_NULL = 0,
T_EOF = '\x04', // EOT
#define T(mode,x,str,val) T_##x val,
#undef TS
#undef T
T_LAST_TOKEN
-} token_kind_t;
+} token_kind_tag_t;
-typedef enum preprocessor_token_kind_t {
+typedef enum preprocessor_token_kind_tag_t {
TP_NULL = T_NULL,
TP_EOF = T_EOF,
#define T(mode,x,str,val) TP_##x val,
#undef TS
#undef T
TP_LAST_TOKEN
-} preprocessor_token_kind_t;
+} preprocessor_token_kind_tag_t;
+typedef unsigned short token_kind_t;
typedef struct source_position_t source_position_t;
struct source_position_t {
typedef union token_t token_t;
struct token_base_t {
- unsigned kind;
+ token_kind_t kind;
source_position_t source_position;
symbol_t *symbol;
};
* returns true if pasting 2 preprocessing tokens next to each other
* without a space in between would generate (an)other preprocessing token(s)
*/
-bool tokens_would_paste(preprocessor_token_kind_t token1,
- preprocessor_token_kind_t token2);
+bool tokens_would_paste(token_kind_t token1, token_kind_t token2);
#endif