diff --git a/CHANGELOG.md b/CHANGELOG.md index 66cf438..813f653 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.6.4...Unreleased) - ReleaseDate +* [Fixed] casting parse error [#8](https://github.com/dalance/sv-parser/issues/8) + ## [v0.6.4](https://github.com/dalance/sv-parser/compare/v0.6.3...v0.6.4) - 2020-03-12 * [Changed] error message of Error::Io diff --git a/sv-parser-parser/src/declarations/net_and_variable_types.rs b/sv-parser-parser/src/declarations/net_and_variable_types.rs index 93ffcbc..2d8b586 100644 --- a/sv-parser-parser/src/declarations/net_and_variable_types.rs +++ b/sv-parser-parser/src/declarations/net_and_variable_types.rs @@ -8,7 +8,9 @@ use crate::*; #[packrat_parser] pub(crate) fn casting_type(s: Span) -> IResult { alt(( - map(simple_type, |x| CastingType::SimpleType(Box::new(x))), + map(terminated(simple_type, peek(tag("'"))), |x| { + CastingType::SimpleType(Box::new(x)) + }), map(signing, |x| CastingType::Signing(Box::new(x))), map(keyword("string"), |x| CastingType::String(Box::new(x))), map(keyword("const"), |x| CastingType::Const(Box::new(x))), @@ -24,7 +26,9 @@ pub(crate) fn casting_type(s: Span) -> IResult { #[packrat_parser] pub(crate) fn constant_casting_type(s: Span) -> IResult { alt(( - map(simple_type, |x| CastingType::SimpleType(Box::new(x))), + map(terminated(simple_type, peek(tag("'"))), |x| { + CastingType::SimpleType(Box::new(x)) + }), map(signing, |x| CastingType::Signing(Box::new(x))), map(keyword("string"), |x| CastingType::String(Box::new(x))), map(keyword("const"), |x| CastingType::Const(Box::new(x))), diff --git a/sv-parser-parser/src/tests.rs b/sv-parser-parser/src/tests.rs index 793d569..4e5e00c 100644 --- a/sv-parser-parser/src/tests.rs +++ b/sv-parser-parser/src/tests.rs @@ -423,6 +423,11 @@ mod unit { r##"module a; assign a = a[$clog2(a)'(a)]; endmodule"##, Ok((_, _)) ); + test!( + source_text, + r##"module a; always begin a = b.c'(0); end endmodule"##, + Ok((_, _)) + ); } } @@ -15881,6 +15886,10 @@ mod spec { #[test] fn debug() { - test!(expression, r##"a[$clog2(a)'(a)]"##, Ok((_, _))); + test!( + source_text, + r##"module a; always begin a = b.c'(0); end endmodule"##, + Ok((_, _)) + ); nom_tracable::cumulative_histogram(); }