aboutsummaryrefslogtreecommitdiff
path: root/src/lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lex.c')
-rw-r--r--src/lex.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lex.c b/src/lex.c
index 80c1c5b..89d1fc6 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -392,3 +392,14 @@ unlex(struct lexer *lexer, const struct token *in)
assert(lexer->un.token == T_NONE);
lexer->un = *in;
}
+
+bool
+match(struct lexer *lexer, enum lexical_token token)
+{
+ struct token tmp;
+ enum lexical_token kind = lex(lexer, &tmp);
+ if (kind != token) {
+ unlex(lexer, &tmp);
+ }
+ return kind == token;
+}