From 778b1829445967f34e2a3dad323ad2ea19d3de2d Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sat, 9 Mar 2024 23:12:03 +0100 Subject: [PATCH] Make block comments non-greedy Prevent the regex from matching `*/` within a block comment, so they can't "leak" from one to the next one --- src/parser.lalrpop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.lalrpop b/src/parser.lalrpop index 2027f5e..791d6a7 100644 --- a/src/parser.lalrpop +++ b/src/parser.lalrpop @@ -25,7 +25,7 @@ match { // Skip whitespace and comments r"\s*" => { }, r"//[^\n\r]*[\n\r]*" => { }, // `// comment` - r"/\*([^\*]*\*+[^\*/])*([^\*]*\*+|[^\*])*\*/" => { }, // `/* comment */` + r"/\*([^*]|\*[^/])*\*/" => { }, // `/* comment */` } pub File = { }