dont mess up silly
This commit is contained in:
@ -9,6 +9,7 @@
|
|||||||
extern FILE *asc_flag;
|
extern FILE *asc_flag;
|
||||||
extern bool tc_flag;
|
extern bool tc_flag;
|
||||||
extern void insert_code_line(char * error_message, int line_number);
|
extern void insert_code_line(char * error_message, int line_number);
|
||||||
|
extern bool contains_errors;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ERROR_RUNTIME = 1,
|
ERROR_RUNTIME = 1,
|
||||||
|
@ -1536,6 +1536,7 @@ void throw_error(ErrorType error_type, const char *format, ...) {
|
|||||||
void yyerror(const char *err) {
|
void yyerror(const char *err) {
|
||||||
int line = yylloc.first_line;
|
int line = yylloc.first_line;
|
||||||
int column = yylloc.first_column;
|
int column = yylloc.first_column;
|
||||||
|
contains_errors = true;
|
||||||
|
|
||||||
// Grammar Fallback Case
|
// Grammar Fallback Case
|
||||||
if (strcmp(err, "syntax error") == 0) {
|
if (strcmp(err, "syntax error") == 0) {
|
||||||
|
17
src/runner.c
17
src/runner.c
@ -157,13 +157,22 @@ int run(FILE *alpha) {
|
|||||||
|
|
||||||
if (ir_flag != NULL) {
|
if (ir_flag != NULL) {
|
||||||
printdebug("[-ir] Intermediate code is enabled.");
|
printdebug("[-ir] Intermediate code is enabled.");
|
||||||
emit_as_file(ir_flag, begin);
|
if (contains_errors) {
|
||||||
|
emit_as_file(ir_flag, begin);
|
||||||
|
} else {
|
||||||
|
remove(ir_name);
|
||||||
|
}
|
||||||
fclose(ir_flag);
|
fclose(ir_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cg_flag != NULL) {
|
if (cg_flag != NULL) {
|
||||||
printdebug("[-cg] Code generation is enabled.");
|
printdebug("[-cg] Code generation is enabled.");
|
||||||
generate();
|
|
||||||
|
if (contains_errors) {
|
||||||
|
generate();
|
||||||
|
} else {
|
||||||
|
remove(cg_name);
|
||||||
|
}
|
||||||
fclose(cg_flag);
|
fclose(cg_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,8 +245,12 @@ int new_file(char *arg, char *alpha) {
|
|||||||
} else if (strcmp(arg, "-asc") == 0) {
|
} else if (strcmp(arg, "-asc") == 0) {
|
||||||
asc_flag = fopen(file_name, "w");
|
asc_flag = fopen(file_name, "w");
|
||||||
} else if (strcmp(arg, "-ir") == 0) {
|
} else if (strcmp(arg, "-ir") == 0) {
|
||||||
|
ir_name = malloc(strlen(file_name) + 1);
|
||||||
|
strcpy(ir_name, file_name);
|
||||||
ir_flag = fopen(file_name, "w");
|
ir_flag = fopen(file_name, "w");
|
||||||
} else if (strcmp(arg, "-cg") == 0) {
|
} else if (strcmp(arg, "-cg") == 0) {
|
||||||
|
cg_name = malloc(strlen(file_name) + 1);
|
||||||
|
strcpy(cg_name, file_name);
|
||||||
cg_flag = fopen(file_name, "w");
|
cg_flag = fopen(file_name, "w");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -58,6 +58,9 @@ bool tc_flag = false;
|
|||||||
bool DEBUG = false;
|
bool DEBUG = false;
|
||||||
int no_flag = 0;
|
int no_flag = 0;
|
||||||
int arg;
|
int arg;
|
||||||
|
bool contains_errors = false;
|
||||||
|
char * cg_name;
|
||||||
|
char * ir_name;
|
||||||
|
|
||||||
TableNode *funprime;
|
TableNode *funprime;
|
||||||
TableNode *arrayprim;
|
TableNode *arrayprim;
|
||||||
|
Reference in New Issue
Block a user