From 644367cdb8a939b9b817931e37ee82119551e92b Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 17 Mar 2020 16:27:02 -0700 Subject: pp: Use tokencheck in a few more places --- pp.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pp.c b/pp.c index b921434..c861852 100644 --- a/pp.c +++ b/pp.c @@ -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); -- cgit v1.2.3