From cd7e668d13cec9b63e5d48302ce24740e52113dc Mon Sep 17 00:00:00 2001 From: dalance Date: Tue, 17 Sep 2019 18:58:04 +0900 Subject: [PATCH] Fix multiline comment --- sv-parser-parser/src/general/comments.rs | 7 +++++-- sv-parser-parser/src/tests.rs | 7 ++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sv-parser-parser/src/general/comments.rs b/sv-parser-parser/src/general/comments.rs index dd63b51..189252d 100644 --- a/sv-parser-parser/src/general/comments.rs +++ b/sv-parser-parser/src/general/comments.rs @@ -30,9 +30,12 @@ pub(crate) fn one_line_comment(s: Span) -> IResult { #[packrat_parser] pub(crate) fn block_comment(s: Span) -> IResult { let (s, a) = tag("/*")(s)?; - let (s, b) = is_not("*/")(s)?; + let (s, b) = many0(alt((is_not("*"), terminated(tag("*"), is_not("/")))))(s)?; let (s, c) = tag("*/")(s)?; - let a = concat(a, b).unwrap(); + let mut a = a; + for b in b { + a = concat(a, b).unwrap(); + } let a = concat(a, c).unwrap(); Ok(( s, diff --git a/sv-parser-parser/src/tests.rs b/sv-parser-parser/src/tests.rs index 7e9bdcf..7f8becb 100644 --- a/sv-parser-parser/src/tests.rs +++ b/sv-parser-parser/src/tests.rs @@ -285,6 +285,7 @@ mod unit { test!(comment, "// comment", Ok((_, _))); test!(comment, "//", Ok((_, _))); test!(comment, "/* comment\n\n */", Ok((_, _))); + test!(comment, "/* comment\n//aaa\n */", Ok((_, _))); } #[test] @@ -15786,10 +15787,6 @@ mod spec { #[test] fn debug() { - test!( - source_text, - r##"module secret (a, b); `pragma protect encoding=(enctype="raw") `pragma protect data_method="x-caesar", data_keyname="rot13", begin endmodule"##, - Ok((_, _)) - ); + test!(source_text, r##"/* comment\n//aaa\n */"##, Ok((_, _))); nom_tracable::cumulative_histogram(); }