Improve lexer
This commit is contained in:
parent
250a91bc52
commit
6337d202d6
|
@ -71,7 +71,8 @@ State_to_token_type(const enum State state, enum TokenType *const token_type)
|
|||
void buffer_add(char chr)
|
||||
{
|
||||
assert(buffer_index < 1000);
|
||||
buffer[buffer_index++] = chr;
|
||||
buffer[buffer_index] = chr;
|
||||
++buffer_index;
|
||||
buffer[buffer_index] = 0;
|
||||
}
|
||||
|
||||
|
@ -176,12 +177,12 @@ void Lexer_lex(const Lexer self, const char chr)
|
|||
token_add(self->tokens, state, buffer);
|
||||
buffer_clean();
|
||||
state = STATE_IDENT;
|
||||
buffer[buffer_index++] = chr;
|
||||
buffer_add(chr);
|
||||
} else if (is_number(chr)) {
|
||||
token_add(self->tokens, state, buffer);
|
||||
buffer_clean();
|
||||
state = STATE_NUM;
|
||||
buffer[buffer_index++] = chr;
|
||||
buffer_add(chr);
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue