From dc767da12b0e03a6cd9ff20085565c95c06ef7bc Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Thu, 5 Sep 2024 21:17:40 +0200 Subject: Make tags use #+ syntax instead of //+ syntax so it no longer looks like a comment. Old style still works but is deprecated with a warning. Using unknown tags is now an error instead of a warning. There is a new token for #+ which consumes the whole line (or until it hits a comment). The tags are parsed like before. There are errors to tell you if you use something invalid in the pre-package-line block. --- src/parser.cpp | 155 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 108 insertions(+), 47 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index e3143dd33..03ed725c5 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -5337,6 +5337,12 @@ gb_internal Ast *parse_stmt(AstFile *f) { s = ast_empty_stmt(f, token); expect_semicolon(f); return s; + + case Token_FileTag: + // This is always an error because all valid file tags will have been processed in `parse_file` already. + // Any remaining file tags must be past the package line and thus invalid. + syntax_error(token, "Lines starting with #+ (file tags) are only allowed before the package line."); + return ast_bad_stmt(f, token, f->curr_token); } // Error correction statements @@ -6091,7 +6097,7 @@ gb_internal String build_tag_get_token(String s, String *out) { } gb_internal bool parse_build_tag(Token token_for_pos, String s) { - String const prefix = str_lit("+build"); + String const prefix = str_lit("build"); GB_ASSERT(string_starts_with(s, prefix)); s = string_trim_whitespace(substring(s, prefix.len, s.len)); @@ -6176,7 +6182,7 @@ gb_internal String vet_tag_get_token(String s, String *out) { gb_internal u64 parse_vet_tag(Token token_for_pos, String s) { - String const prefix = str_lit("+vet"); + String const prefix = str_lit("vet"); GB_ASSERT(string_starts_with(s, prefix)); s = string_trim_whitespace(substring(s, prefix.len, s.len)); @@ -6281,7 +6287,7 @@ gb_internal isize calc_decl_count(Ast *decl) { } gb_internal bool parse_build_project_directory_tag(Token token_for_pos, String s) { - String const prefix = str_lit("+build-project-name"); + String const prefix = str_lit("build-project-name"); GB_ASSERT(string_starts_with(s, prefix)); s = string_trim_whitespace(substring(s, prefix.len, s.len)); if (s.len == 0) { @@ -6325,6 +6331,48 @@ gb_internal bool parse_build_project_directory_tag(Token token_for_pos, String s return any_correct; } +gb_internal bool process_file_tag(const String &lc, const Token &tok, AstFile *f) { + if (string_starts_with(lc, str_lit("build-project-name"))) { + if (!parse_build_project_directory_tag(tok, lc)) { + return false; + } + } else if (string_starts_with(lc, str_lit("build"))) { + if (!parse_build_tag(tok, lc)) { + return false; + } + } else if (string_starts_with(lc, str_lit("vet"))) { + f->vet_flags = parse_vet_tag(tok, lc); + f->vet_flags_set = true; + } else if (string_starts_with(lc, str_lit("ignore"))) { + return false; + } else if (string_starts_with(lc, str_lit("private"))) { + f->flags |= AstFile_IsPrivatePkg; + String command = string_trim_starts_with(lc, str_lit("private ")); + command = string_trim_whitespace(command); + if (lc == "private") { + f->flags |= AstFile_IsPrivatePkg; + } else if (command == "package") { + f->flags |= AstFile_IsPrivatePkg; + } else if (command == "file") { + f->flags |= AstFile_IsPrivateFile; + } + } else if (lc == "lazy") { + if (build_context.ignore_lazy) { + // Ignore + } else if (f->pkg->kind == Package_Init && build_context.command_kind == Command_doc) { + // Ignore + } else { + f->flags |= AstFile_IsLazy; + } + } else if (lc == "no-instrumentation") { + f->flags |= AstFile_NoInstrumentation; + } else { + error(tok, "Unknown tag '%.*s'", LIT(lc)); + } + + return true; +} + gb_internal bool parse_file(Parser *p, AstFile *f) { if (f->tokens.count == 0) { return true; @@ -6337,15 +6385,38 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { String filepath = f->tokenizer.fullpath; String base_dir = dir_from_path(filepath); - if (f->curr_token.kind == Token_Comment) { - consume_comment_groups(f, f->prev_token); + + Array tags = array_make(ast_allocator(f)); + + bool has_first_invalid_pre_package_token = false; + Token first_invalid_pre_package_token; + + while (f->curr_token.kind != Token_package && f->curr_token.kind != Token_EOF) { + if (f->curr_token.kind == Token_Comment) { + consume_comment_groups(f, f->prev_token); + } else if (f->curr_token.kind == Token_FileTag) { + array_add(&tags, f->curr_token); + advance_token(f); + } else { + if (!has_first_invalid_pre_package_token) { + has_first_invalid_pre_package_token = true; + first_invalid_pre_package_token = f->curr_token; + } + + advance_token(f); + } } CommentGroup *docs = f->lead_comment; if (f->curr_token.kind != Token_package) { ERROR_BLOCK(); - syntax_error(f->curr_token, "Expected a package declaration at the beginning of the file"); + + // The while loop above scanned until it found the package token. If we never + // found one, then make this error appear on the first invalid token line. + Token t = has_first_invalid_pre_package_token ? first_invalid_pre_package_token : f->curr_token; + syntax_error(t, "Expected a package declaration at the beginning of the file"); + // IMPORTANT NOTE(bill): this is technically a race condition with the suggestion, but it's ony a suggession // so in practice is should be "fine" if (f->pkg && f->pkg->name != "") { @@ -6354,6 +6425,12 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { return false; } + // There was an OK package declaration. But there some invalid token was hit before the package declaration. + if (has_first_invalid_pre_package_token) { + syntax_error(first_invalid_pre_package_token, "There can only be lines starting with #+ or // before package declaration"); + return false; + } + f->package_token = expect_token(f, Token_package); if (f->package_token.kind != Token_package) { return false; @@ -6379,55 +6456,39 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { } f->package_name = package_name.string; - if (!f->pkg->is_single_file && docs != nullptr && docs->list.count > 0) { - for (Token const &tok : docs->list) { - GB_ASSERT(tok.kind == Token_Comment); - String str = tok.string; - if (string_starts_with(str, str_lit("//"))) { - String lc = string_trim_whitespace(substring(str, 2, str.len)); - if (lc.len > 0 && lc[0] == '+') { - if (string_starts_with(lc, str_lit("+build-project-name"))) { - if (!parse_build_project_directory_tag(tok, lc)) { - return false; - } - } else if (string_starts_with(lc, str_lit("+build"))) { - if (!parse_build_tag(tok, lc)) { + if (!f->pkg->is_single_file) { + if (docs != nullptr && docs->list.count > 0) { + for (Token const &tok : docs->list) { + GB_ASSERT(tok.kind == Token_Comment); + String str = tok.string; + if (string_starts_with(str, str_lit("//"))) { + String lc = string_trim_whitespace(substring(str, 2, str.len)); + if (string_starts_with(lc, str_lit("+"))) { + syntax_warning(tok, "//+ is deprecated: Use #+ instead"); + String lt = substring(lc, 1, lc.len); + if (process_file_tag(lt, tok, f) == false) { return false; } - } else if (string_starts_with(lc, str_lit("+vet"))) { - f->vet_flags = parse_vet_tag(tok, lc); - f->vet_flags_set = true; - } else if (string_starts_with(lc, str_lit("+ignore"))) { - return false; - } else if (string_starts_with(lc, str_lit("+private"))) { - f->flags |= AstFile_IsPrivatePkg; - String command = string_trim_starts_with(lc, str_lit("+private ")); - command = string_trim_whitespace(command); - if (lc == "+private") { - f->flags |= AstFile_IsPrivatePkg; - } else if (command == "package") { - f->flags |= AstFile_IsPrivatePkg; - } else if (command == "file") { - f->flags |= AstFile_IsPrivateFile; - } - } else if (lc == "+lazy") { - if (build_context.ignore_lazy) { - // Ignore - } else if (f->pkg->kind == Package_Init && build_context.command_kind == Command_doc) { - // Ignore - } else { - f->flags |= AstFile_IsLazy; - } - } else if (lc == "+no-instrumentation") { - f->flags |= AstFile_NoInstrumentation; - } else { - warning(tok, "Ignoring unknown tag '%.*s'", LIT(lc)); } } } } + + for (Token const &tok : tags) { + GB_ASSERT(tok.kind == Token_FileTag); + String str = tok.string; + + if (string_starts_with(str, str_lit("#+"))) { + String lt = string_trim_whitespace(substring(str, 2, str.len)); + if (process_file_tag(lt, tok, f) == false) { + return false; + } + } + } } + array_free(&tags); + Ast *pd = ast_package_decl(f, f->package_token, package_name, docs, f->line_comment); expect_semicolon(f); f->pkg_decl = pd; -- cgit v1.2.3 From 73e495434666b230e16ea7300c957ddc978e3e1a Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Sun, 8 Sep 2024 02:52:43 +0200 Subject: Better #+build tag error messages: Error when using more than one !notted operating system per build line. Error when using more than one operating system within a 'kind', such as writing #+build windows linux. --- src/parser.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 03ed725c5..7f2fa9b70 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6106,9 +6106,12 @@ gb_internal bool parse_build_tag(Token token_for_pos, String s) { } bool any_correct = false; + bool any_notted_os_seen = false; + bool any_os_seen = false; while (s.len > 0) { bool this_kind_correct = true; + bool this_kind_os_seen = false; do { String p = string_trim_whitespace(build_tag_get_token(s, &s)); @@ -6133,12 +6136,30 @@ gb_internal bool parse_build_tag(Token token_for_pos, String s) { continue; } + TargetOsKind os = get_target_os_from_string(p); TargetArchKind arch = get_target_arch_from_string(p); if (os != TargetOs_Invalid) { + // Catches cases where you have multiple !notted operating systems on a line. This never does what you think since + // you need a new build line to get a logical AND. + if (any_notted_os_seen && is_notted) { + syntax_error(token_for_pos, "Invalid build tag: Use a separate '#+build' line for each platform that has '!' in front."); + break; + } + + // Catches 'windows linux', which is an impossible combination. + if (this_kind_os_seen) { + syntax_error(token_for_pos, "Invalid build tag: Missing ',' before '%.*s'. Format: '#+build linux, windows, darwin' or '#+build linux amd64, darwin, windows i386'", LIT(p)); + break; + } + + this_kind_os_seen = true; + any_os_seen = true; + GB_ASSERT(arch == TargetArch_Invalid); if (is_notted) { this_kind_correct = this_kind_correct && (os != build_context.metrics.os); + any_notted_os_seen = true; } else { this_kind_correct = this_kind_correct && (os == build_context.metrics.os); } @@ -6427,7 +6448,7 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { // There was an OK package declaration. But there some invalid token was hit before the package declaration. if (has_first_invalid_pre_package_token) { - syntax_error(first_invalid_pre_package_token, "There can only be lines starting with #+ or // before package declaration"); + syntax_error(first_invalid_pre_package_token, "There can only be lines starting with '#+' or '//' before package declaration"); return false; } @@ -6464,7 +6485,7 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { if (string_starts_with(str, str_lit("//"))) { String lc = string_trim_whitespace(substring(str, 2, str.len)); if (string_starts_with(lc, str_lit("+"))) { - syntax_warning(tok, "//+ is deprecated: Use #+ instead"); + syntax_warning(tok, "'//+' is deprecated: Use '#+' instead"); String lt = substring(lc, 1, lc.len); if (process_file_tag(lt, tok, f) == false) { return false; -- cgit v1.2.3 From 3637dcbd04d328a110f0626171f2d49f7a96b09b Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Mon, 9 Sep 2024 21:03:23 +0200 Subject: Simplified error messages in parse_build_tag, removed the idea of making multiple notted operating systems since it was misinformed. --- src/parser.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 7f2fa9b70..2df876d73 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6106,12 +6106,13 @@ gb_internal bool parse_build_tag(Token token_for_pos, String s) { } bool any_correct = false; - bool any_notted_os_seen = false; - bool any_os_seen = false; while (s.len > 0) { bool this_kind_correct = true; + bool this_kind_os_seen = false; + bool this_kind_arch_seen = false; + int num_tokens = 0; do { String p = string_trim_whitespace(build_tag_get_token(s, &s)); @@ -6136,34 +6137,29 @@ gb_internal bool parse_build_tag(Token token_for_pos, String s) { continue; } - TargetOsKind os = get_target_os_from_string(p); TargetArchKind arch = get_target_arch_from_string(p); - if (os != TargetOs_Invalid) { - // Catches cases where you have multiple !notted operating systems on a line. This never does what you think since - // you need a new build line to get a logical AND. - if (any_notted_os_seen && is_notted) { - syntax_error(token_for_pos, "Invalid build tag: Use a separate '#+build' line for each platform that has '!' in front."); - break; - } + num_tokens += 1; - // Catches 'windows linux', which is an impossible combination. - if (this_kind_os_seen) { - syntax_error(token_for_pos, "Invalid build tag: Missing ',' before '%.*s'. Format: '#+build linux, windows, darwin' or '#+build linux amd64, darwin, windows i386'", LIT(p)); - break; - } + // Catches 'windows linux', which is an impossible combination. + // Also catches usage of more than two things within a comma separated group. + if (num_tokens > 2 || (this_kind_os_seen && os != TargetOs_Invalid) || (this_kind_arch_seen && arch != TargetArch_Invalid)) { + syntax_error(token_for_pos, "Invalid build tag: Missing ',' before '%.*s'. Format: '#+build linux, windows amd64, darwin'", LIT(p)); + break; + } + if (os != TargetOs_Invalid) { this_kind_os_seen = true; - any_os_seen = true; GB_ASSERT(arch == TargetArch_Invalid); if (is_notted) { this_kind_correct = this_kind_correct && (os != build_context.metrics.os); - any_notted_os_seen = true; } else { this_kind_correct = this_kind_correct && (os == build_context.metrics.os); } } else if (arch != TargetArch_Invalid) { + this_kind_arch_seen = true; + if (is_notted) { this_kind_correct = this_kind_correct && (arch != build_context.metrics.arch); } else { -- cgit v1.2.3 From 957cd64699f1f8f1d1f689025c708aebc3c32476 Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Mon, 9 Sep 2024 21:06:43 +0200 Subject: Rename process_file_tag -> parse_file_tag --- src/parser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 2df876d73..3634da7fa 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6348,7 +6348,7 @@ gb_internal bool parse_build_project_directory_tag(Token token_for_pos, String s return any_correct; } -gb_internal bool process_file_tag(const String &lc, const Token &tok, AstFile *f) { +gb_internal bool parse_file_tag(const String &lc, const Token &tok, AstFile *f) { if (string_starts_with(lc, str_lit("build-project-name"))) { if (!parse_build_project_directory_tag(tok, lc)) { return false; @@ -6483,7 +6483,7 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { if (string_starts_with(lc, str_lit("+"))) { syntax_warning(tok, "'//+' is deprecated: Use '#+' instead"); String lt = substring(lc, 1, lc.len); - if (process_file_tag(lt, tok, f) == false) { + if (parse_file_tag(lt, tok, f) == false) { return false; } } @@ -6497,7 +6497,7 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { if (string_starts_with(str, str_lit("#+"))) { String lt = string_trim_whitespace(substring(str, 2, str.len)); - if (process_file_tag(lt, tok, f) == false) { + if (parse_file_tag(lt, tok, f) == false) { return false; } } -- cgit v1.2.3 From cc724ff5d2ecc358f36c6c0ed3a25db6373ac95c Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Mon, 9 Sep 2024 21:13:39 +0200 Subject: Made error handling code in parse_file clearer. --- src/parser.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 3634da7fa..aaaf02cee 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6405,8 +6405,8 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { Array tags = array_make(ast_allocator(f)); - bool has_first_invalid_pre_package_token = false; - Token first_invalid_pre_package_token; + bool first_invalid_token_set = false; + Token first_invalid_token = {}; while (f->curr_token.kind != Token_package && f->curr_token.kind != Token_EOF) { if (f->curr_token.kind == Token_Comment) { @@ -6415,9 +6415,9 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { array_add(&tags, f->curr_token); advance_token(f); } else { - if (!has_first_invalid_pre_package_token) { - has_first_invalid_pre_package_token = true; - first_invalid_pre_package_token = f->curr_token; + if (!first_invalid_token_set) { + first_invalid_token_set = true; + first_invalid_token = f->curr_token; } advance_token(f); @@ -6431,7 +6431,7 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { // The while loop above scanned until it found the package token. If we never // found one, then make this error appear on the first invalid token line. - Token t = has_first_invalid_pre_package_token ? first_invalid_pre_package_token : f->curr_token; + Token t = first_invalid_token_set ? first_invalid_token : f->curr_token; syntax_error(t, "Expected a package declaration at the beginning of the file"); // IMPORTANT NOTE(bill): this is technically a race condition with the suggestion, but it's ony a suggession @@ -6443,8 +6443,8 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { } // There was an OK package declaration. But there some invalid token was hit before the package declaration. - if (has_first_invalid_pre_package_token) { - syntax_error(first_invalid_pre_package_token, "There can only be lines starting with '#+' or '//' before package declaration"); + if (first_invalid_token_set) { + syntax_error(first_invalid_token, "There can only be lines starting with '#+' or '//' before package declaration"); return false; } @@ -6481,7 +6481,7 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { if (string_starts_with(str, str_lit("//"))) { String lc = string_trim_whitespace(substring(str, 2, str.len)); if (string_starts_with(lc, str_lit("+"))) { - syntax_warning(tok, "'//+' is deprecated: Use '#+' instead"); + //syntax_warning(tok, "'//+' is deprecated: Use '#+' instead"); String lt = substring(lc, 1, lc.len); if (parse_file_tag(lt, tok, f) == false) { return false; -- cgit v1.2.3 From 580f0599cde713f5e1c7495174821abe6dc4a2a1 Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Mon, 9 Sep 2024 21:24:41 +0200 Subject: parse_file: Removed some nesting and removed probable incorrect safety check. --- src/parser.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index aaaf02cee..c2a9ff138 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6452,14 +6452,6 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { if (f->package_token.kind != Token_package) { return false; } - if (docs != nullptr) { - TokenPos end = token_pos_end(docs->list[docs->list.count-1]); - if (end.line == f->package_token.pos.line || end.line+1 == f->package_token.pos.line) { - // Okay - } else { - docs = nullptr; - } - } Token package_name = expect_token_after(f, Token_Ident, "package"); if (package_name.kind == Token_Ident) { @@ -6478,14 +6470,17 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { for (Token const &tok : docs->list) { GB_ASSERT(tok.kind == Token_Comment); String str = tok.string; - if (string_starts_with(str, str_lit("//"))) { - String lc = string_trim_whitespace(substring(str, 2, str.len)); - if (string_starts_with(lc, str_lit("+"))) { - //syntax_warning(tok, "'//+' is deprecated: Use '#+' instead"); - String lt = substring(lc, 1, lc.len); - if (parse_file_tag(lt, tok, f) == false) { - return false; - } + + if (!string_starts_with(str, str_lit("//"))) { + continue; + } + + String lc = string_trim_whitespace(substring(str, 2, str.len)); + if (string_starts_with(lc, str_lit("+"))) { + syntax_warning(tok, "'//+' is deprecated: Use '#+' instead"); + String lt = substring(lc, 1, lc.len); + if (parse_file_tag(lt, tok, f) == false) { + return false; } } } -- cgit v1.2.3 From 8b84b9a4a26d7f2fb07a7e5dcd49b678d1c9be91 Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Sat, 14 Sep 2024 14:32:46 +0200 Subject: Docs are generated as expected again. --- src/parser.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 51da21e9d..523dad8b8 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6388,9 +6388,13 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { String filepath = f->tokenizer.fullpath; String base_dir = dir_from_path(filepath); + if (f->curr_token.kind == Token_Comment) { + consume_comment_groups(f, f->prev_token); + } - Array tags = array_make(ast_allocator(f)); + CommentGroup *docs = f->lead_comment; + Array tags = array_make(temporary_allocator()); bool first_invalid_token_set = false; Token first_invalid_token = {}; @@ -6410,8 +6414,6 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { } } - CommentGroup *docs = f->lead_comment; - if (f->curr_token.kind != Token_package) { ERROR_BLOCK(); @@ -6451,6 +6453,8 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { } f->package_name = package_name.string; + // TODO: Shouldn't single file only matter for build tags? no-instrumentation for example + // should be respected even when in single file mode. if (!f->pkg->is_single_file) { if (docs != nullptr && docs->list.count > 0) { for (Token const &tok : docs->list) { @@ -6485,8 +6489,6 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { } } - array_free(&tags); - Ast *pd = ast_package_decl(f, f->package_token, package_name, docs, f->line_comment); expect_semicolon(f); f->pkg_decl = pd; -- cgit v1.2.3 From c24e18bf1063cd86c200d51d585059f8aa099615 Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Sat, 14 Sep 2024 14:36:33 +0200 Subject: Fix incorrect syntax error in parse_file --- src/parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 523dad8b8..22d92e87b 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -6432,7 +6432,7 @@ gb_internal bool parse_file(Parser *p, AstFile *f) { // There was an OK package declaration. But there some invalid token was hit before the package declaration. if (first_invalid_token_set) { - syntax_error(first_invalid_token, "There can only be lines starting with '#+' or '//' before package declaration"); + syntax_error(first_invalid_token, "Expected only comments or lines starting with '#+' before the package declaration"); return false; } -- cgit v1.2.3 From 29fedc1808c347774971666ecc90b44e1900dc90 Mon Sep 17 00:00:00 2001 From: Karl Zylinski Date: Tue, 17 Sep 2024 19:39:48 +0200 Subject: Changed some recently added //+ usages to #+ and also fixed some //+ usages in some code generators. --- core/testing/runner_windows.odin | 2 +- src/parser.cpp | 2 +- tests/core/sys/windows/win32gen/win32gen.cpp | 2 +- tests/documentation/documentation_tester.odin | 2 +- vendor/box2d/box2d_wasm.odin | 2 +- vendor/cgltf/cgltf_wasm.odin | 2 +- vendor/stb/image/stb_image_wasm.odin | 2 +- vendor/stb/rect_pack/stb_rect_pack_wasm.odin | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/parser.cpp') diff --git a/core/testing/runner_windows.odin b/core/testing/runner_windows.odin index fa233ff84..401804c71 100644 --- a/core/testing/runner_windows.odin +++ b/core/testing/runner_windows.odin @@ -1,4 +1,4 @@ -//+private +#+private package testing import win32 "core:sys/windows" diff --git a/src/parser.cpp b/src/parser.cpp index 242671af0..520a23c5a 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -4967,7 +4967,7 @@ gb_internal Ast *parse_import_decl(AstFile *f, ImportDeclKind kind) { } if (f->in_when_statement) { - syntax_error(import_name, "Cannot use 'import' within a 'when' statement. Prefer using the file suffixes (e.g. foo_windows.odin) or '//+build' tags"); + syntax_error(import_name, "Cannot use 'import' within a 'when' statement. Prefer using the file suffixes (e.g. foo_windows.odin) or '#+build' tags"); } if (kind != ImportDecl_Standard) { diff --git a/tests/core/sys/windows/win32gen/win32gen.cpp b/tests/core/sys/windows/win32gen/win32gen.cpp index 731173aa6..57a094cd5 100644 --- a/tests/core/sys/windows/win32gen/win32gen.cpp +++ b/tests/core/sys/windows/win32gen/win32gen.cpp @@ -902,7 +902,7 @@ static void verify_error_helpers(ofstream& out) { } static void test_core_sys_windows(ofstream& out) { - out << "//+build windows" << endl + out << "#+build windows" << endl << "package " << __func__ << " // generated by " << path(__FILE__).filename().replace_extension("").string() << endl << endl diff --git a/tests/documentation/documentation_tester.odin b/tests/documentation/documentation_tester.odin index ce1849e1c..7b125d4e4 100644 --- a/tests/documentation/documentation_tester.odin +++ b/tests/documentation/documentation_tester.odin @@ -264,7 +264,7 @@ write_test_suite :: proc(example_tests: []Example_Test) { test_runner := strings.builder_make() strings.write_string(&test_runner, -`//+private +`#+private package documentation_verification import "core:os" diff --git a/vendor/box2d/box2d_wasm.odin b/vendor/box2d/box2d_wasm.odin index eab369a0d..0fcaf753f 100644 --- a/vendor/box2d/box2d_wasm.odin +++ b/vendor/box2d/box2d_wasm.odin @@ -1,4 +1,4 @@ -//+build wasm32, wasm64p32 +#+build wasm32, wasm64p32 package vendor_box2d @(require) import _ "vendor:libc" diff --git a/vendor/cgltf/cgltf_wasm.odin b/vendor/cgltf/cgltf_wasm.odin index f2da86a2c..fb612b2ac 100644 --- a/vendor/cgltf/cgltf_wasm.odin +++ b/vendor/cgltf/cgltf_wasm.odin @@ -1,4 +1,4 @@ -//+build wasm32, wasm64p32 +#+build wasm32, wasm64p32 package cgltf @(require) import _ "vendor:libc" diff --git a/vendor/stb/image/stb_image_wasm.odin b/vendor/stb/image/stb_image_wasm.odin index 77bb44f02..f43012383 100644 --- a/vendor/stb/image/stb_image_wasm.odin +++ b/vendor/stb/image/stb_image_wasm.odin @@ -1,4 +1,4 @@ -//+build wasm32, wasm64p32 +#+build wasm32, wasm64p32 package stb_image @(require) import _ "vendor:libc" diff --git a/vendor/stb/rect_pack/stb_rect_pack_wasm.odin b/vendor/stb/rect_pack/stb_rect_pack_wasm.odin index fb75552ec..c4e2e5160 100644 --- a/vendor/stb/rect_pack/stb_rect_pack_wasm.odin +++ b/vendor/stb/rect_pack/stb_rect_pack_wasm.odin @@ -1,4 +1,4 @@ -//+build wasm32, wasm64p32 +#+build wasm32, wasm64p32 package stb_rect_pack @(require) import _ "vendor:libc" -- cgit v1.2.3