From 34ca4e92eb5316cebb66aa1c69d4ced5719e7773 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 17 Nov 2020 15:45:55 +0000 Subject: Fix parser logic for first comment group line in a file --- src/parser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index ce5e53d92..9e9708f9c 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1193,6 +1193,12 @@ CommentGroup *consume_comment_group(AstFile *f, isize n, isize *end_line_) { Array list = {}; list.allocator = heap_allocator(); isize end_line = f->curr_token.pos.line; + if (f->curr_token_index == 1 && + f->prev_token.kind == Token_Comment && + f->prev_token.pos.line+1 == f->curr_token.pos.line) { + // NOTE(bill): Special logic for the first comment in the file + array_add(&list, f->prev_token); + } while (f->curr_token.kind == Token_Comment && f->curr_token.pos.line <= end_line+n) { array_add(&list, consume_comment(f, &end_line)); -- cgit v1.2.3