aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorMikkel Hjortshoej <Hjortshoej@handmade.network>2017-09-25 21:42:02 +0200
committerMikkel Hjortshoej <Hjortshoej@handmade.network>2017-09-25 21:42:23 +0200
commit67ac551a2fe6b82c70d4a6bfc83e793cd4aadbe5 (patch)
tree495170406c2fcfb9aee911795df5c869e289e091 /src/parser.cpp
parent572ac616c1b82bc708c1d02db64cd5913a23568a (diff)
The position that the invalid token was found at is printed
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 37412c157..26fcd4935 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -4663,7 +4663,7 @@ Array<AstNode *> parse_stmt_list(AstFile *f) {
}
-ParseFileError init_ast_file(AstFile *f, String fullpath) {
+ParseFileError init_ast_file(AstFile *f, String fullpath, TokenPos *err_pos) {
f->fullpath = string_trim_whitespace(fullpath); // Just in case
if (!string_has_extension(f->fullpath, str_lit("odin"))) {
return ParseFile_WrongExtension;
@@ -4689,6 +4689,8 @@ ParseFileError init_ast_file(AstFile *f, String fullpath) {
for (;;) {
Token token = tokenizer_get_token(&f->tokenizer);
if (token.kind == Token_Invalid) {
+ err_pos->line = token.pos.line;
+ err_pos->column = token.pos.column;
return ParseFile_InvalidToken;
}
array_add(&f->tokens, token);
@@ -4967,7 +4969,8 @@ ParseFileError parse_import(Parser *p, ImportedFile imported_file) {
file->is_global_scope = true;
}
- ParseFileError err = init_ast_file(file, import_path);
+ TokenPos err_pos = {0};
+ ParseFileError err = init_ast_file(file, import_path, &err_pos);
if (err != ParseFile_None) {
if (err == ParseFile_EmptyFile) {
@@ -4996,7 +4999,7 @@ ParseFileError parse_import(Parser *p, ImportedFile imported_file) {
gb_printf_err("File cannot be found (`%.*s`)", LIT(import_path));
break;
case ParseFile_InvalidToken:
- gb_printf_err("Invalid token found in file");
+ gb_printf_err("Invalid token found in file at (%td:%td)", err_pos.line, err_pos.column);
break;
}
gb_printf_err("\n");