Fix missing comment after macro name #29

This commit is contained in:
dalance 2021-01-19 21:10:56 +09:00
parent 9b84ee7044
commit 9360cda58f
4 changed files with 32 additions and 8 deletions

View File

@ -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

View File

@ -309,14 +309,9 @@ where
#[packrat_parser]
pub(crate) fn white_space(s: Span) -> IResult<Span, WhiteSpace> {
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)
})(s)
} else {
alt((
map(multispace1, |x: Span| {

View File

@ -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
"##
);
}

View File

@ -0,0 +1,6 @@
`ifndef X
// pragma translate_off
module A;
endmodule
// pragma translate_on
`endif