aboutsummaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-03-09 02:02:58 -0700
committerMichael Forney <mforney@mforney.org>2020-03-16 02:21:13 -0700
commitca7d50a3fef8d4f2bfa199a0e334217978fd6483 (patch)
treeca0eddd022a7e6c18ee5a3c83c87685420a20379 /pp.c
parentd05ebf8bed8ac45b50263c85ce1c0d2327d66d55 (diff)
token: Add tokencheck utility function
This function is like expect(), but operates on a specific token and does not read the following token.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/pp.c b/pp.c
index e62845f..4831cd6 100644
--- a/pp.c
+++ b/pp.c
@@ -133,14 +133,9 @@ peek(int kind)
char *
expect(enum tokenkind kind, const char *msg)
{
- char *lit, want[64], got[64];
+ char *lit;
- if (tok.kind != kind) {
- tokendesc(want, sizeof(want), kind, NULL);
- tokendesc(got, sizeof(got), tok.kind, tok.lit);
- error(&tok.loc, "expected %s %s, saw %s", want, msg, got);
- }
- lit = tok.lit;
+ lit = tokencheck(&tok, kind, msg);
next();
return lit;