From bc5c51c82fa5109d44094fb034cc50cc44f1016e Mon Sep 17 00:00:00 2001 From: itchyny Date: Sun, 25 Feb 2024 21:35:09 +0900 Subject: [PATCH] Support multi-line comment with backslash --- crates/lang/src/lexer.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/lang/src/lexer.rs b/crates/lang/src/lexer.rs index d06cb53..cfed42e 100644 --- a/crates/lang/src/lexer.rs +++ b/crates/lang/src/lexer.rs @@ -416,7 +416,7 @@ lexer! { type Error = LexicalError; let ws = [' ' '\t' '\n'] | "\r\n"; - let comment = '#' (_ # ['\r' '\n'])*; + let comment = '#' (_ # ['\\' '\r' '\n'] | '\\' (_ # '\r' | "\r\n"))*; let ident_start = ['a'-'z' 'A'-'Z' '_']; let digit = ['0'-'9']; let hex_digit = $digit | ['a'-'f' 'A'-'F']; @@ -671,7 +671,8 @@ mod test { assert_lex( r#""\( 1# This - + # is + + # is \ + test 2 # )" # comment"#, &[