funny valgrind
This commit is contained in:
parent
ae48fca094
commit
d067119a90
3 changed files with 5 additions and 10 deletions
|
@ -136,7 +136,6 @@ next:
|
||||||
break;
|
break;
|
||||||
case LeaveTape:
|
case LeaveTape:
|
||||||
case Eof:
|
case Eof:
|
||||||
case Invalid:
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,8 @@ retest:
|
||||||
case EOF:
|
case EOF:
|
||||||
return Eof;
|
return Eof;
|
||||||
default:
|
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->data = malloc(capacity * sizeof(Symbol));
|
||||||
program->len = 0;
|
program->len = 0;
|
||||||
|
program->index = 0;
|
||||||
|
|
||||||
Symbol s;
|
Symbol s;
|
||||||
while(true) {
|
while(true) {
|
||||||
s = next_symbol();
|
s = next_symbol();
|
||||||
|
|
||||||
if (s == Invalid) {
|
|
||||||
printf("error: invalid symbol at character %d\n", count);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (program->len == capacity) {
|
if (program->len == capacity) {
|
||||||
capacity *= 2;
|
capacity *= 2;
|
||||||
program->data = realloc(program->data, capacity * sizeof(Symbol));
|
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) {
|
void program_last(Program* program, Symbol* symbol) {
|
||||||
if (program->index == 0) {
|
if (program->index < 1) {
|
||||||
*symbol = Eof;
|
*symbol = Eof;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,7 @@ typedef enum {
|
||||||
PutString,
|
PutString,
|
||||||
GetString,
|
GetString,
|
||||||
Clear,
|
Clear,
|
||||||
Eof,
|
Eof
|
||||||
Invalid
|
|
||||||
} Symbol;
|
} Symbol;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in a new issue