mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Add extra error checking in parser.cpp
This commit is contained in:
@@ -5320,6 +5320,7 @@ ParseFileError process_imported_file(Parser *p, ImportedFile const &imported_fil
|
|||||||
TokenPos err_pos = {0};
|
TokenPos err_pos = {0};
|
||||||
ParseFileError err = init_ast_file(file, fi->fullpath, &err_pos);
|
ParseFileError err = init_ast_file(file, fi->fullpath, &err_pos);
|
||||||
err_pos.file = fi->fullpath;
|
err_pos.file = fi->fullpath;
|
||||||
|
file->last_error = err;
|
||||||
|
|
||||||
if (err != ParseFile_None) {
|
if (err != ParseFile_None) {
|
||||||
if (err == ParseFile_EmptyFile) {
|
if (err == ParseFile_EmptyFile) {
|
||||||
@@ -5426,6 +5427,18 @@ ParseFileError parse_packages(Parser *p, String init_filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (isize i = p->packages.count-1; i >= 0; i--) {
|
||||||
|
AstPackage *pkg = p->packages[i];
|
||||||
|
for (isize j = pkg->files.count-1; j >= 0; j--) {
|
||||||
|
AstFile *file = pkg->files[j];
|
||||||
|
if (file->error_count != 0) {
|
||||||
|
if (file->last_error != ParseFile_None) {
|
||||||
|
return file->last_error;
|
||||||
|
}
|
||||||
|
return ParseFile_GeneralError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return ParseFile_None;
|
return ParseFile_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -41,6 +41,7 @@ enum ParseFileError {
|
|||||||
ParseFile_Permission,
|
ParseFile_Permission,
|
||||||
ParseFile_NotFound,
|
ParseFile_NotFound,
|
||||||
ParseFile_InvalidToken,
|
ParseFile_InvalidToken,
|
||||||
|
ParseFile_GeneralError,
|
||||||
|
|
||||||
ParseFile_Count,
|
ParseFile_Count,
|
||||||
};
|
};
|
||||||
@@ -102,10 +103,11 @@ struct AstFile {
|
|||||||
Array<Ast *> imports; // 'import'
|
Array<Ast *> imports; // 'import'
|
||||||
isize directive_count;
|
isize directive_count;
|
||||||
|
|
||||||
Ast * curr_proc;
|
Ast * curr_proc;
|
||||||
isize error_count;
|
isize error_count;
|
||||||
f64 time_to_tokenize; // seconds
|
ParseFileError last_error;
|
||||||
f64 time_to_parse; // seconds
|
f64 time_to_tokenize; // seconds
|
||||||
|
f64 time_to_parse; // seconds
|
||||||
|
|
||||||
bool is_test;
|
bool is_test;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user