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){
|
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'){
|
if (page.chunks[cursor.chunk][cursor.offset+1] == '\0'){
|
||||||
cursor.chunk++;
|
cursor.chunk++;
|
||||||
cursor.offset = 0;
|
cursor.offset = 0;
|
||||||
} else {
|
} else {
|
||||||
cursor.offset++;
|
cursor.offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return &page.chunks[cursor.chunk][cursor.offset];
|
return &page.chunks[cursor.chunk][cursor.offset];
|
||||||
}
|
}
|
||||||
|
@ -23,17 +25,6 @@ Token* nexttoken(void){
|
||||||
Token* token = malloc(sizeof(Token));
|
Token* token = malloc(sizeof(Token));
|
||||||
token->type = NO_TYPE;
|
token->type = NO_TYPE;
|
||||||
|
|
||||||
/*
|
|
||||||
while (nextchar() == '<');
|
|
||||||
|
|
||||||
char c = '\0';
|
|
||||||
do {
|
|
||||||
c = nextchar();
|
|
||||||
printf("%c", c);;
|
|
||||||
} while (c != '>');
|
|
||||||
puts("");
|
|
||||||
*/
|
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
char* c = nextchar();
|
char* c = nextchar();
|
||||||
do {
|
do {
|
||||||
|
|
Loading…
Reference in New Issue