This commit is contained in:
dalance 2020-04-01 11:56:45 +09:00
parent 23a54652d0
commit 2c63dcaeba
3 changed files with 18 additions and 3 deletions

View File

@ -2,6 +2,8 @@
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.6.4...Unreleased) - ReleaseDate ## [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 ## [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 * [Changed] error message of Error::Io

View File

@ -8,7 +8,9 @@ use crate::*;
#[packrat_parser] #[packrat_parser]
pub(crate) fn casting_type(s: Span) -> IResult<Span, CastingType> { pub(crate) fn casting_type(s: Span) -> IResult<Span, CastingType> {
alt(( 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(signing, |x| CastingType::Signing(Box::new(x))),
map(keyword("string"), |x| CastingType::String(Box::new(x))), map(keyword("string"), |x| CastingType::String(Box::new(x))),
map(keyword("const"), |x| CastingType::Const(Box::new(x))), map(keyword("const"), |x| CastingType::Const(Box::new(x))),
@ -24,7 +26,9 @@ pub(crate) fn casting_type(s: Span) -> IResult<Span, CastingType> {
#[packrat_parser] #[packrat_parser]
pub(crate) fn constant_casting_type(s: Span) -> IResult<Span, CastingType> { pub(crate) fn constant_casting_type(s: Span) -> IResult<Span, CastingType> {
alt(( 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(signing, |x| CastingType::Signing(Box::new(x))),
map(keyword("string"), |x| CastingType::String(Box::new(x))), map(keyword("string"), |x| CastingType::String(Box::new(x))),
map(keyword("const"), |x| CastingType::Const(Box::new(x))), map(keyword("const"), |x| CastingType::Const(Box::new(x))),

View File

@ -423,6 +423,11 @@ mod unit {
r##"module a; assign a = a[$clog2(a)'(a)]; endmodule"##, r##"module a; assign a = a[$clog2(a)'(a)]; endmodule"##,
Ok((_, _)) Ok((_, _))
); );
test!(
source_text,
r##"module a; always begin a = b.c'(0); end endmodule"##,
Ok((_, _))
);
} }
} }
@ -15881,6 +15886,10 @@ mod spec {
#[test] #[test]
fn debug() { 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(); nom_tracable::cumulative_histogram();
} }