diff options
author | Michael Forney <mforney@mforney.org> | 2020-03-17 16:27:02 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2020-03-17 16:27:02 -0700 |
commit | 644367cdb8a939b9b817931e37ee82119551e92b (patch) | |
tree | d4e38fc06ddb782eeb466ddb7aee724a6b7b6058 | |
parent | 46db27cb5171a91d49fa653b6c4bc429efa9e695 (diff) | |
download | cproc-644367cdb8a939b9b817931e37ee82119551e92b.tar.xz |
pp: Use tokencheck in a few more places
-rw-r--r-- | pp.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -211,10 +211,8 @@ define(void) bool stringize; size_t i; - if (tok.kind != TIDENT) - error(&tok.loc, "expected identifier after #define"); m = xmalloc(sizeof(*m)); - m->name = tok.lit; + m->name = tokencheck(&tok, TIDENT, "after #define"); m->hide = false; t = arrayadd(&repl, sizeof(*t)); scan(t); @@ -228,8 +226,7 @@ define(void) if (scan(&tok), tok.kind != TCOMMA) break; } - if (tok.kind != TRPAREN) - error(&tok.loc, "expected ')' after macro parameter list"); + tokencheck(&tok, TRPAREN, "after macro parameter list"); scan(t); /* first token in replacement list */ } else { m->kind = MACROOBJ; @@ -245,8 +242,7 @@ define(void) t = arrayadd(&repl, sizeof(*t)); scan(t); if (stringize && m->kind == MACROFUNC) { - if (t->kind != TIDENT) - error(&t->loc, "expected macro parameter name after '#' operator"); + tokencheck(t, TIDENT, "after '#' operator"); i = macroparam(m, t->lit); if (i == -1) error(&t->loc, "'%s' is not a macro parameter name", t->lit); |