diff options
author | Michael Forney <mforney@mforney.org> | 2020-03-09 02:02:58 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2020-03-16 02:21:13 -0700 |
commit | ca7d50a3fef8d4f2bfa199a0e334217978fd6483 (patch) | |
tree | ca0eddd022a7e6c18ee5a3c83c87685420a20379 /pp.c | |
parent | d05ebf8bed8ac45b50263c85ce1c0d2327d66d55 (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.c | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -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; |