lang: lex: add function for creating fake ident tokens
This commit is contained in:
21
lang/lex.c
21
lang/lex.c
@@ -1066,6 +1066,27 @@ bool ivy_lexer_tokens_available(struct ivy_lexer *lex)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct ivy_token *ivy_token_create_ident(const char *s)
|
||||
{
|
||||
struct ivy_token *tok = malloc(sizeof *tok);
|
||||
|
||||
if (!tok) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(tok, 0x0, sizeof *tok);
|
||||
|
||||
tok->t_type = IVY_TOK_IDENT;
|
||||
tok->t_str = b_strdup(s);
|
||||
|
||||
if (!tok->t_str) {
|
||||
free(tok);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return tok;
|
||||
}
|
||||
|
||||
void ivy_token_destroy(struct ivy_token *tok)
|
||||
{
|
||||
switch (tok->t_type) {
|
||||
|
||||
Reference in New Issue
Block a user