From ba02ef8f252c1ee93df0d456e25fc4d920cc54ba Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 21 Mar 2023 13:16:03 +0000 Subject: Change trailing comma require to `-strict-style` only --- 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 0d9fad8c7..437d6300e 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1434,7 +1434,7 @@ gb_internal Token expect_closing_brace_of_field_list(AstFile *f) { return token; } bool ok = true; - if (!f->allow_newline) { + if (f->allow_newline) { ok = !skip_possible_newline(f); } if (ok && allow_token(f, Token_Semicolon)) { -- cgit v1.2.3 From b3e712e0b80afcf0396a94d46f5083f429ece557 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 21 Mar 2023 15:22:11 +0000 Subject: Correctly handle end comment for doc generation --- src/docs_writer.cpp | 12 +++++++----- src/parser.cpp | 13 ++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp index 814769f57..3c60145c9 100644 --- a/src/docs_writer.cpp +++ b/src/docs_writer.cpp @@ -915,18 +915,20 @@ gb_internal void odin_doc_update_entities(OdinDocWriter *w) { auto entities = array_make(heap_allocator(), 0, w->entity_cache.count); defer (array_free(&entities)); - for (auto const &entry : w->entity_cache) { - array_add(&entities, entry.key); + ffor (u32 i = 0; i < w->entity_cache.count; i++) { + Entity *e = w->entity_cache.entries[i].key; + array_add(&entities, e); } for (Entity *e : entities) { + GB_ASSERT(e != nullptr); OdinDocTypeIndex type_index = odin_doc_type(w, e->type); gb_unused(type_index); } } - for (auto const &entry : w->entity_cache) { - Entity *e = entry.key; - OdinDocEntityIndex entity_index = entry.value; + for (u32 i = 0; i < w->entity_cache.count; i++) { + Entity *e = w->entity_cache.entries[i].key; + OdinDocEntityIndex entity_index = w->entity_cache.entries[i].value; OdinDocTypeIndex type_index = odin_doc_type(w, e->type); OdinDocEntityIndex foreign_library = 0; diff --git a/src/parser.cpp b/src/parser.cpp index 437d6300e..07afc56d6 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3191,6 +3191,15 @@ gb_internal Ast *parse_foreign_block(AstFile *f, Token token) { return decl; } +gb_internal void print_comment_group(CommentGroup *group) { + if (group) { + for (Token const &token : group->list) { + gb_printf_err("%.*s\n", LIT(token.string)); + } + gb_printf_err("\n"); + } +} + gb_internal Ast *parse_value_decl(AstFile *f, Array names, CommentGroup *docs) { bool is_mutable = true; @@ -3232,6 +3241,8 @@ gb_internal Ast *parse_value_decl(AstFile *f, Array names, CommentGroup * values.allocator = heap_allocator(); } + CommentGroup *end_comment = f->lead_comment; + if (f->expr_level >= 0) { if (f->curr_token.kind == Token_CloseBrace && f->curr_token.pos.line == f->prev_token.pos.line) { @@ -3252,7 +3263,7 @@ gb_internal Ast *parse_value_decl(AstFile *f, Array names, CommentGroup * } } - return ast_value_decl(f, names, type, values, is_mutable, docs, f->line_comment); + return ast_value_decl(f, names, type, values, is_mutable, docs, end_comment); } gb_internal Ast *parse_simple_stmt(AstFile *f, u32 flags) { -- cgit v1.2.3