aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-07-11 18:41:40 +0100
committergingerBill <gingerBill@users.noreply.github.com>2025-07-11 18:41:40 +0100
commit38faec757d4e4648a86fb17a1fda0e2399a3ea19 (patch)
tree542316439682ad4a50faeacc3dd1d883fbd74009 /core
parente647f560db721e733a4f331e63d23de46193aef6 (diff)
Correct consume comment groups in both parsers
Diffstat (limited to 'core')
-rw-r--r--core/odin/parser/parser.odin37
1 files changed, 20 insertions, 17 deletions
diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin
index 27b7edbf6..18dd9aa88 100644
--- a/core/odin/parser/parser.odin
+++ b/core/odin/parser/parser.odin
@@ -348,27 +348,30 @@ consume_comment_group :: proc(p: ^Parser, n: int) -> (comments: ^ast.Comment_Gro
}
consume_comment_groups :: proc(p: ^Parser, prev: tokenizer.Token) {
- if p.curr_tok.kind == .Comment {
- comment: ^ast.Comment_Group
- end_line := 0
-
- if p.curr_tok.pos.line == prev.pos.line {
- comment, end_line = consume_comment_group(p, 0)
- if p.curr_tok.pos.line != end_line || p.curr_tok.kind == .EOF {
- p.line_comment = comment
- }
- }
+ if p.curr_tok.kind != .Comment {
+ return
+ }
+ comment: ^ast.Comment_Group
+ end_line := 0
- end_line = -1
- for p.curr_tok.kind == .Comment {
- comment, end_line = consume_comment_group(p, 1)
- }
- if end_line+1 >= p.curr_tok.pos.line || end_line < 0 {
- p.lead_comment = comment
+ if p.curr_tok.pos.line == prev.pos.line {
+ comment, end_line = consume_comment_group(p, 0)
+ if p.curr_tok.pos.line != end_line ||
+ p.curr_tok.pos.line == prev.pos.line+1 ||
+ p.curr_tok.kind == .EOF {
+ p.line_comment = comment
}
+ }
- assert(p.curr_tok.kind != .Comment)
+ end_line = -1
+ for p.curr_tok.kind == .Comment {
+ comment, end_line = consume_comment_group(p, 1)
}
+ if end_line+1 >= p.curr_tok.pos.line || end_line < 0 {
+ p.lead_comment = comment
+ }
+
+ assert(p.curr_tok.kind != .Comment)
}
advance_token :: proc(p: ^Parser) -> tokenizer.Token {