summaryrefslogtreecommitdiff
path: root/src/program.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/program.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/program.c b/src/program.c
index aa113b6..dcec0f7 100644
--- a/src/program.c
+++ b/src/program.c
@@ -64,7 +64,8 @@ retest:
case EOF:
return Eof;
default:
- return Invalid;
+ c = next_char();
+ goto retest;
}
}
@@ -80,16 +81,12 @@ void program_init(char* file_path, Program* program) {
program->data = malloc(capacity * sizeof(Symbol));
program->len = 0;
+ program->index = 0;
Symbol s;
while(true) {
s = next_symbol();
- if (s == Invalid) {
- printf("error: invalid symbol at character %d\n", count);
- exit(EXIT_FAILURE);
- }
-
if (program->len == capacity) {
capacity *= 2;
program->data = realloc(program->data, capacity * sizeof(Symbol));
@@ -118,7 +115,7 @@ void program_next(Program* program, Symbol* symbol) {
}
void program_last(Program* program, Symbol* symbol) {
- if (program->index == 0) {
+ if (program->index < 1) {
*symbol = Eof;
return;
}