From 608acbe2c367a372ae1b1e8a5cbf6f5f18f8c232 Mon Sep 17 00:00:00 2001 From: Yutaka Ichibangase Date: Thu, 3 Oct 2024 09:39:25 +0900 Subject: [PATCH] fix mishandling of **/ at the end of bracketed comment. --- engine/lexer.go | 2 ++ engine/lexer_test.go | 1 + 2 files changed, 3 insertions(+) diff --git a/engine/lexer.go b/engine/lexer.go index 4d9b887..637a878 100644 --- a/engine/lexer.go +++ b/engine/lexer.go @@ -296,6 +296,8 @@ func (l *Lexer) commentClose() (Token, error) { return Token{}, err case r == '/': return l.layoutTextSequence(true) + case r == '*': + return l.commentClose() default: return l.commentText(true) } diff --git a/engine/lexer_test.go b/engine/lexer_test.go index 814f06b..2be6d98 100644 --- a/engine/lexer_test.go +++ b/engine/lexer_test.go @@ -40,6 +40,7 @@ func TestLexer_Token(t *testing.T) { {input: `/ *`, token: Token{kind: tokenGraphic, val: `/`}}, {input: "/* comment *", err: io.EOF}, {input: `/🙈`, err: errMonkey}, + {input: `/* **/foo`, token: Token{kind: tokenLetterDigit, val: "foo"}}, // https://github.com/ichiban/prolog/issues/326 {input: `改善`, token: Token{kind: tokenLetterDigit, val: `改善`}}, {input: `プロログ`, token: Token{kind: tokenLetterDigit, val: `プロログ`}},