fix: lexer nextchar go out of available chunks
This commit is contained in:
parent
3bdd778b56
commit
18d4c9d9b2
17
lexer.c
17
lexer.c
|
@ -8,13 +8,15 @@ Cursor cursor = {
|
|||
};
|
||||
|
||||
char* nextchar(void){
|
||||
if (cursor.chunk >= page.len) return NULL;
|
||||
if (cursor.chunk >= page.len){
|
||||
return NULL;
|
||||
}
|
||||
if (page.chunks[cursor.chunk][cursor.offset+1] == '\0'){
|
||||
cursor.chunk++;
|
||||
cursor.offset = 0;
|
||||
} else {
|
||||
cursor.offset++;
|
||||
}
|
||||
}
|
||||
|
||||
return &page.chunks[cursor.chunk][cursor.offset];
|
||||
}
|
||||
|
@ -23,17 +25,6 @@ Token* nexttoken(void){
|
|||
Token* token = malloc(sizeof(Token));
|
||||
token->type = NO_TYPE;
|
||||
|
||||
/*
|
||||
while (nextchar() == '<');
|
||||
|
||||
char c = '\0';
|
||||
do {
|
||||
c = nextchar();
|
||||
printf("%c", c);;
|
||||
} while (c != '>');
|
||||
puts("");
|
||||
*/
|
||||
|
||||
puts("");
|
||||
char* c = nextchar();
|
||||
do {
|
||||
|
|
Loading…
Reference in New Issue