diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-02-11 17:33:23 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-02-11 17:33:23 +0000 |
| commit | 4306345ff10e9f8225b156633aa986fee3f97987 (patch) | |
| tree | a40e1363f48fe4d77111fcea0bf36b4f0ab3802f /src/parser.c | |
| parent | 346aa5f71ca4e3d6a71187024f809eaf2fc6da1b (diff) | |
Dynamic array syntax [...]Type; make entities private with a prefix of `_`; fix extension checking
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/parser.c b/src/parser.c index 06de58872..b4902982c 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1832,6 +1832,7 @@ bool is_literal_type(AstNode *node) { case AstNode_ArrayType: case AstNode_VectorType: case AstNode_StructType: + case AstNode_DynamicArrayType: case AstNode_MapType: return true; } @@ -2575,8 +2576,8 @@ AstNode *parse_type_or_ident(AstFile *f) { AstNode *count_expr = NULL; bool is_vector = false; - if (f->curr_token.kind == Token_Ellipsis) { - count_expr = ast_ellipsis(f, expect_token(f, Token_Ellipsis), NULL); + if (f->curr_token.kind == Token_Question) { + count_expr = ast_unary_expr(f, expect_token(f, Token_Question), NULL); } else if (f->curr_token.kind == Token_vector) { next_token(f); if (f->curr_token.kind != Token_CloseBracket) { @@ -2587,7 +2588,7 @@ AstNode *parse_type_or_ident(AstFile *f) { syntax_error(f->curr_token, "Vector type missing count"); } is_vector = true; - } else if (f->curr_token.kind == Token_dynamic) { + } else if (f->curr_token.kind == Token_Ellipsis) { next_token(f); expect_token(f, Token_CloseBracket); return ast_dynamic_array_type(f, token, parse_type(f)); @@ -3527,6 +3528,7 @@ AstNodeArray parse_stmt_list(AstFile *f) { ParseFileError init_ast_file(AstFile *f, String fullpath) { + fullpath = string_trim_whitespace(fullpath); // Just in case if (!string_has_extension(fullpath, str_lit("odin"))) { return ParseFile_WrongExtension; } @@ -3606,6 +3608,9 @@ void destroy_parser(Parser *p) { bool try_add_import_path(Parser *p, String path, String rel_path, TokenPos pos) { gb_mutex_lock(&p->mutex); + path = string_trim_whitespace(path); + rel_path = string_trim_whitespace(rel_path); + for_array(i, p->imports) { String import = p->imports.e[i].path; if (str_eq(import, path)) { @@ -3786,7 +3791,7 @@ ParseFileError parse_files(Parser *p, char *init_filename) { gb_printf_err("Invalid file extension: File must have the extension `.odin`"); break; case ParseFile_InvalidFile: - gb_printf_err("Invalid file"); + gb_printf_err("Invalid file or cannot be found"); break; case ParseFile_Permission: gb_printf_err("File permissions problem"); |