diff --git a/CHANGELOG.md b/CHANGELOG.md index ace49f2..821975d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.10.4...Unreleased) - ReleaseDate +* [Fixed] missing comment after macro name [#29](https://github.com/dalance/sv-parser/issues/29) + ## [v0.10.4](https://github.com/dalance/sv-parser/compare/v0.10.3...v0.10.4) - 2021-01-08 * [Fixed] uncleared internal state diff --git a/sv-parser-parser/src/utils.rs b/sv-parser-parser/src/utils.rs index 824a749..c94365e 100644 --- a/sv-parser-parser/src/utils.rs +++ b/sv-parser-parser/src/utils.rs @@ -309,14 +309,9 @@ where #[packrat_parser] pub(crate) fn white_space(s: Span) -> IResult { if in_directive() { - alt(( - map(multispace1, |x: Span| { - WhiteSpace::Space(Box::new(into_locate(x))) - }), - map(preceded(peek(char('/')), comment), |x| { - WhiteSpace::Comment(Box::new(x)) - }), - ))(s) + map(multispace1, |x: Span| { + WhiteSpace::Space(Box::new(into_locate(x))) + })(s) } else { alt(( map(multispace1, |x: Span| { diff --git a/sv-parser-pp/src/preprocess.rs b/sv-parser-pp/src/preprocess.rs index 29534fb..12ea599 100644 --- a/sv-parser-pp/src/preprocess.rs +++ b/sv-parser-pp/src/preprocess.rs @@ -1190,6 +1190,27 @@ module test(); initial begin end endmodule +"## + ); + } + + #[test] + fn test18() { + let (ret, _) = preprocess( + get_testcase("test18.sv"), + &HashMap::new(), + &[] as &[String], + false, + false, + ) + .unwrap(); + assert_eq!( + ret.text(), + r##"// pragma translate_off +module A; +endmodule +// pragma translate_on + "## ); } diff --git a/sv-parser-pp/testcases/test18.sv b/sv-parser-pp/testcases/test18.sv new file mode 100644 index 0000000..9674062 --- /dev/null +++ b/sv-parser-pp/testcases/test18.sv @@ -0,0 +1,6 @@ +`ifndef X +// pragma translate_off +module A; +endmodule +// pragma translate_on +`endif