Go to the documentation of this file.
70 ID, DECLIT, HEXLIT, STRLIT, KEY, SYM
Token * TokenQueue_remove(TokenQueue *queue)
Remove a token from a queue (first-in-first-out)
Definition: token.c:90
struct Token * next
Pointer to next token (used to store in a list)
Definition: token.h:98
TokenQueue * TokenQueue_new()
Allocate and initialize a new, empty queue of tokens.
Definition: token.c:65
void TokenQueue_free(TokenQueue *queue)
Deallocate a token queue.
Definition: token.c:129
char text[256]
Raw text of the token.
Definition: token.h:88
Linked list of tokens.
Definition: token.h:152
struct Token Token
Single token.
int line
Source line number.
Definition: token.h:93
Single token.
Definition: token.h:78
bool TokenQueue_is_empty(TokenQueue *queue)
Check whether a queue is empty.
Definition: token.c:106
void TokenQueue_add(TokenQueue *queue, Token *token)
Add a token to a queue.
Definition: token.c:72
void Regex_free(Regex *regex)
Deallocate a regular expression.
Definition: token.c:25
size_t TokenQueue_size(TokenQueue *queue)
Calculate size of the queue.
Definition: token.c:111
TokenType type
Type of the token.
Definition: token.h:83
void TokenQueue_print(TokenQueue *queue, FILE *out)
Print a queue to the given file descriptor (debug output)
Definition: token.c:120
#define MAX_TOKEN_LEN
Maximum length (in characters) of any single token.
Definition: common.h:47
TokenType
Valid token types.
Definition: token.h:69
regex_t Regex
Compiled regular expression.
Definition: token.h:25
Token * head
Front of list (or NULL if list is empty)
Definition: token.h:157
void Token_free(Token *token)
Deallocate a token.
Definition: token.c:60
Regex * Regex_new(const char *regex)
Allocate and compile a new regular expression.
Definition: token.c:3
Includes, constants, declarations, and macros used across the compiler.
Token * TokenQueue_peek(TokenQueue *queue)
Return the next token from a queue without removing it (first-in-first-out)
Definition: token.c:85
Token * Token_new(TokenType type, const char *text, int line)
Allocate and initialize a new token.
Definition: token.c:49
Token * tail
Back of list (or NULL if list is empty)
Definition: token.h:162
bool token_str_eq(const char *str1, const char *str2)
Check string equality for tokens. Limits comparison to MAX_TOKEN_LEN for safety.
Definition: token.c:44
const char * TokenType_to_string(TokenType type)
Convert a token type to a string for output.
Definition: token.c:31
struct TokenQueue TokenQueue
Linked list of tokens.
bool Regex_match(Regex *regex, const char *text, char *match)
Match a regular expression against some text.
Definition: token.c:12