diff options
Diffstat (limited to 'libcpp/lex.c')
-rw-r--r-- | libcpp/lex.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libcpp/lex.c b/libcpp/lex.c index 37df6efc0b7..7eafb13d3b4 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1556,3 +1556,25 @@ _cpp_aligned_alloc (cpp_reader *pfile, size_t len) buff->cur = result + len; return result; } + +/* Say which field of TOK is in use. */ + +enum cpp_token_fld_kind +cpp_token_val_index (cpp_token *tok) +{ + switch (TOKEN_SPELL (tok)) + { + case SPELL_IDENT: + return CPP_TOKEN_FLD_NODE; + case SPELL_LITERAL: + return CPP_TOKEN_FLD_STR; + case SPELL_NONE: + if (tok->type == CPP_MACRO_ARG) + return CPP_TOKEN_FLD_ARG_NO; + else if (tok->type == CPP_PADDING) + return CPP_TOKEN_FLD_SOURCE; + /* else fall through */ + default: + return CPP_TOKEN_FLD_NONE; + } +} |