fix(lexer): pop_token
This commit is contained in:
parent
00bc241c08
commit
ce6507c3a6
1 changed files with 24 additions and 2 deletions
|
|
@ -108,9 +108,31 @@ char *peek_token(void)
|
|||
|
||||
char *pop_token(void)
|
||||
{
|
||||
char *token = peek_token();
|
||||
char *stream = stream_init();
|
||||
|
||||
ssize_t i = 0;
|
||||
|
||||
while (i < remaining_chars)
|
||||
{
|
||||
if (is_special_char(stream[i]))
|
||||
{
|
||||
if (i == 0) // where we create spe_char token
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
if (isblank(stream[i]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (is_keyword(stream, i))
|
||||
{
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
save_state(stream, i);
|
||||
|
||||
return token;
|
||||
return new_token(stream, i);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue