lang: lex: add function to check if tokens are available
if this function returns false, any attempt to read tokens from the lexer will cause another line of input to be retrieved from the lexer's line source.
This commit is contained in:
13
lang/lex.c
13
lang/lex.c
@@ -1049,6 +1049,19 @@ struct ivy_token *ivy_lexer_read(struct ivy_lexer *lex)
|
||||
return tok;
|
||||
}
|
||||
|
||||
bool ivy_lexer_tokens_available(struct ivy_lexer *lex)
|
||||
{
|
||||
if (lex->lex_queue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (input_available(lex)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ivy_token_destroy(struct ivy_token *tok)
|
||||
{
|
||||
switch (tok->t_type) {
|
||||
|
||||
Reference in New Issue
Block a user