Herb C Reference
Loading...
Searching...
No Matches
token_matchers.h
Go to the documentation of this file.
1#ifndef HERB_TOKEN_MATCHERS_H
2#define HERB_TOKEN_MATCHERS_H
3
4#include "parser.h"
5#include "token.h"
6
7#include <stdarg.h>
8#include <stdbool.h>
9
10// This "TOKEN" is used to terminate the va_list arguments in the token_matches_any function
11#define TOKEN_SENTINEL 99999999
12
13bool token_is(parser_T* parser, token_type_T expected_type);
14bool token_is_not(parser_T* parser, token_type_T type);
15
16bool token_matches_any(token_type_T current_token, token_type_T first_token, ...);
17
18#define token_is_any_of(parser, ...) (token_matches_any((parser)->current_token->type, __VA_ARGS__, TOKEN_SENTINEL))
19#define token_is_none_of(parser, ...) (!token_matches_any((parser)->current_token->type, __VA_ARGS__, TOKEN_SENTINEL))
20
21#endif
Definition parser.h:8
bool token_is_not(parser_T *parser, token_type_T type)
Definition token_matchers.c:12
bool token_matches_any(token_type_T current_token, token_type_T first_token,...)
Definition token_matchers.c:16
bool token_is(parser_T *parser, token_type_T expected_type)
Definition token_matchers.c:8
token_type_T
Definition token_struct.h:7