aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <ginger.bill.22@gmail.com>2016-07-21 00:38:15 +0100
committergingerBill <ginger.bill.22@gmail.com>2016-07-21 00:38:15 +0100
commit51d0532c3e56ca0816da20f6f3e59d2d0f2c55c9 (patch)
tree5449b119787acd8e49b08af2003aaa7c423597e8 /src/parser.cpp
parentcbd82e3c02cbeff8fe3ba5198d6ca730f8c1eace (diff)
Only allow .odin files to be parsed
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 223229f03..a1d08666e 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1670,10 +1670,12 @@ AstNode *parse_statement_list(AstFile *f, isize *list_count_) {
}
-// void parse_file(AstFile *f, )
-
b32 init_ast_file(AstFile *f, String fullpath) {
+ if (!string_has_extension(fullpath, make_string("odin"))) {
+ gb_printf_err("Only `.odin` files are allowed\n");
+ return false;
+ }
if (init_tokenizer(&f->tokenizer, fullpath)) {
gb_array_init(f->tokens, gb_heap_allocator());
for (;;) {
@@ -1804,7 +1806,7 @@ void parse_files(Parser *p, char *init_filename) {
AstFile file = {};
b32 ok = init_ast_file(&file, import_path);
if (!ok) {
- gb_printf_err("Failed to parse file: %.*s", LIT(import_path));
+ gb_printf_err("Failed to parse file: %.*s\n", LIT(import_path));
return;
}
parse_file(p, &file);