This commit is contained in:
dalance 2019-08-14 17:42:56 +09:00
parent 283b310254
commit acbf769db8
4 changed files with 590 additions and 691 deletions

View File

@ -307,6 +307,7 @@ pub(crate) fn property_spec(s: Span) -> IResult<Span, PropertySpec> {
pub(crate) fn property_expr(s: Span) -> IResult<Span, PropertyExpr> { pub(crate) fn property_expr(s: Span) -> IResult<Span, PropertyExpr> {
alt(( alt((
alt(( alt((
property_expr_binary,
property_expr_implication_overlapped, property_expr_implication_overlapped,
property_expr_implication_nonoverlapped, property_expr_implication_nonoverlapped,
property_expr_followed_by_overlapped, property_expr_followed_by_overlapped,
@ -316,26 +317,18 @@ pub(crate) fn property_expr(s: Span) -> IResult<Span, PropertyExpr> {
}), }),
property_expr_strong, property_expr_strong,
property_expr_weak, property_expr_weak,
property_expr_paren,
property_expr_not, property_expr_not,
property_expr_or, property_expr_paren,
property_expr_and, )),
alt((
property_expr_if, property_expr_if,
property_expr_case, property_expr_case,
property_expr_nexttime, property_expr_nexttime,
property_expr_s_nexttime, property_expr_s_nexttime,
)),
alt((
property_expr_always, property_expr_always,
property_expr_s_always, property_expr_s_always,
property_expr_eventually, property_expr_eventually,
property_expr_s_eventually, property_expr_s_eventually,
property_expr_until,
property_expr_s_until,
property_expr_until_with,
property_expr_s_until_with,
property_expr_implies,
property_expr_iff,
property_expr_accept_on, property_expr_accept_on,
property_expr_reject_on, property_expr_reject_on,
property_expr_sync_accept_on, property_expr_sync_accept_on,
@ -373,7 +366,7 @@ pub(crate) fn property_expr_weak(s: Span) -> IResult<Span, PropertyExpr> {
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn property_expr_paren(s: Span) -> IResult<Span, PropertyExpr> { pub(crate) fn property_expr_paren(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = paren(sequence_expr)(s)?; let (s, a) = paren(property_expr)(s)?;
Ok(( Ok((
s, s,
PropertyExpr::Paren(Box::new(PropertyExprParen { nodes: (a,) })), PropertyExpr::Paren(Box::new(PropertyExprParen { nodes: (a,) })),
@ -394,26 +387,22 @@ pub(crate) fn property_expr_not(s: Span) -> IResult<Span, PropertyExpr> {
#[recursive_parser] #[recursive_parser]
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn property_expr_or(s: Span) -> IResult<Span, PropertyExpr> { pub(crate) fn property_expr_binary(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?; let (s, a) = property_expr(s)?;
let (s, b) = keyword("or")(s)?; let (s, b) = alt((
keyword("or"),
keyword("and"),
keyword("until_with"),
keyword("until"),
keyword("s_until_with"),
keyword("s_until"),
keyword("implies"),
keyword("iff"),
))(s)?;
let (s, c) = property_expr(s)?; let (s, c) = property_expr(s)?;
Ok(( Ok((
s, s,
PropertyExpr::Or(Box::new(PropertyExprOr { nodes: (a, b, c) })), PropertyExpr::Binary(Box::new(PropertyExprBinary { nodes: (a, b, c) })),
))
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn property_expr_and(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = keyword("and")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
PropertyExpr::And(Box::new(PropertyExprAnd { nodes: (a, b, c) })),
)) ))
} }
@ -580,84 +569,6 @@ pub(crate) fn property_expr_s_eventually(s: Span) -> IResult<Span, PropertyExpr>
)) ))
} }
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn property_expr_until(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = keyword("until")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
PropertyExpr::Until(Box::new(PropertyExprUntil { nodes: (a, b, c) })),
))
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn property_expr_s_until(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = keyword("s_until")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
PropertyExpr::SUntil(Box::new(PropertyExprSUntil { nodes: (a, b, c) })),
))
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn property_expr_until_with(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = keyword("until_with")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
PropertyExpr::UntilWith(Box::new(PropertyExprUntilWith { nodes: (a, b, c) })),
))
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn property_expr_s_until_with(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = keyword("s_until_with")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
PropertyExpr::SUntilWith(Box::new(PropertyExprSUntilWith { nodes: (a, b, c) })),
))
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn property_expr_implies(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = keyword("implies")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
PropertyExpr::Implies(Box::new(PropertyExprImplies { nodes: (a, b, c) })),
))
}
#[recursive_parser]
#[tracable_parser]
#[packrat_parser]
pub(crate) fn property_expr_iff(s: Span) -> IResult<Span, PropertyExpr> {
let (s, a) = property_expr(s)?;
let (s, b) = keyword("iff")(s)?;
let (s, c) = property_expr(s)?;
Ok((
s,
PropertyExpr::Iff(Box::new(PropertyExprIff { nodes: (a, b, c) })),
))
}
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn property_expr_accept_on(s: Span) -> IResult<Span, PropertyExpr> { pub(crate) fn property_expr_accept_on(s: Span) -> IResult<Span, PropertyExpr> {
@ -852,15 +763,15 @@ pub(crate) fn sequence_expr(s: Span) -> IResult<Span, SequenceExpr> {
alt(( alt((
sequence_expr_cycle_delay_expr, sequence_expr_cycle_delay_expr,
sequence_expr_expr_cycle_delay_expr, sequence_expr_expr_cycle_delay_expr,
sequence_expr_expression,
sequence_expr_instance,
sequence_expr_paren,
sequence_expr_and,
sequence_expr_intersect,
sequence_expr_or,
sequence_expr_first_match,
sequence_expr_throughout, sequence_expr_throughout,
terminated(sequence_expr_expression, peek(not(symbol("(")))),
sequence_expr_instance,
sequence_expr_and,
sequence_expr_or,
sequence_expr_intersect,
sequence_expr_within, sequence_expr_within,
sequence_expr_paren,
sequence_expr_first_match,
sequence_expr_clocking_event, sequence_expr_clocking_event,
))(s) ))(s)
} }
@ -1155,12 +1066,12 @@ pub(crate) fn sequence_list_of_arguments_named(s: Span) -> IResult<Span, Sequenc
#[packrat_parser] #[packrat_parser]
pub(crate) fn sequence_actual_arg(s: Span) -> IResult<Span, SequenceActualArg> { pub(crate) fn sequence_actual_arg(s: Span) -> IResult<Span, SequenceActualArg> {
alt(( alt((
map(event_expression_sequence_actual_arg, |x| {
SequenceActualArg::EventExpression(Box::new(x))
}),
map(sequence_expr, |x| { map(sequence_expr, |x| {
SequenceActualArg::SequenceExpr(Box::new(x)) SequenceActualArg::SequenceExpr(Box::new(x))
}), }),
map(event_expression_sequence_actual_arg, |x| {
SequenceActualArg::EventExpression(Box::new(x))
}),
))(s) ))(s)
} }

View File

@ -104,8 +104,18 @@ pub(crate) fn hex_number(s: Span) -> IResult<Span, HexNumber> {
#[packrat_parser] #[packrat_parser]
pub(crate) fn sign(s: Span) -> IResult<Span, Sign> { pub(crate) fn sign(s: Span) -> IResult<Span, Sign> {
alt(( alt((
map(symbol("+"), |x| Sign::Plus(Box::new(x))), map(
map(symbol("-"), |x| Sign::Minus(Box::new(x))), map(tag("+"), |x: Span| Symbol {
nodes: (into_locate(x), vec![]),
}),
|x| Sign::Plus(Box::new(x)),
),
map(
map(tag("-"), |x: Span| Symbol {
nodes: (into_locate(x), vec![]),
}),
|x| Sign::Minus(Box::new(x)),
),
))(s) ))(s)
} }
@ -146,8 +156,13 @@ pub(crate) fn real_number(s: Span) -> IResult<Span, RealNumber> {
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn real_number_floating(s: Span) -> IResult<Span, RealNumber> { pub(crate) fn real_number_floating(s: Span) -> IResult<Span, RealNumber> {
let (s, a) = unsigned_number(s)?; let (s, a) = unsigned_number_without_ws(s)?;
let (s, b) = opt(pair(symbol("."), unsigned_number))(s)?; let (s, b) = opt(pair(
map(tag("."), |x: Span| Symbol {
nodes: (into_locate(x), vec![]),
}),
unsigned_number_without_ws,
))(s)?;
let (s, c) = exp(s)?; let (s, c) = exp(s)?;
let (s, d) = opt(sign)(s)?; let (s, d) = opt(sign)(s)?;
let (s, e) = unsigned_number(s)?; let (s, e) = unsigned_number(s)?;
@ -162,7 +177,7 @@ pub(crate) fn real_number_floating(s: Span) -> IResult<Span, RealNumber> {
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn fixed_point_number(s: Span) -> IResult<Span, FixedPointNumber> { pub(crate) fn fixed_point_number(s: Span) -> IResult<Span, FixedPointNumber> {
let (s, a) = unsigned_number(s)?; let (s, a) = unsigned_number_without_ws(s)?;
let (s, b) = map(tag("."), |x: Span| Symbol { let (s, b) = map(tag("."), |x: Span| Symbol {
nodes: (into_locate(x), vec![]), nodes: (into_locate(x), vec![]),
})(s)?; })(s)?;
@ -173,10 +188,24 @@ pub(crate) fn fixed_point_number(s: Span) -> IResult<Span, FixedPointNumber> {
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn exp(s: Span) -> IResult<Span, Exp> { pub(crate) fn exp(s: Span) -> IResult<Span, Exp> {
let (s, a) = alt((symbol("e"), symbol("E")))(s)?; let (s, a) = alt((
map(tag("e"), |x: Span| Symbol {
nodes: (into_locate(x), vec![]),
}),
map(tag("E"), |x: Span| Symbol {
nodes: (into_locate(x), vec![]),
}),
))(s)?;
Ok((s, Exp { nodes: (a,) })) Ok((s, Exp { nodes: (a,) }))
} }
#[tracable_parser]
#[packrat_parser]
pub(crate) fn unsigned_number_without_ws(s: Span) -> IResult<Span, UnsignedNumber> {
let (s, a) = unsigned_number_impl(s)?;
Ok((s, UnsignedNumber { nodes: (a, vec![]) }))
}
#[tracable_parser] #[tracable_parser]
#[packrat_parser] #[packrat_parser]
pub(crate) fn unsigned_number(s: Span) -> IResult<Span, UnsignedNumber> { pub(crate) fn unsigned_number(s: Span) -> IResult<Span, UnsignedNumber> {

File diff suppressed because it is too large Load Diff

View File

@ -163,8 +163,7 @@ pub enum PropertyExpr {
Weak(Box<PropertyExprWeak>), Weak(Box<PropertyExprWeak>),
Paren(Box<PropertyExprParen>), Paren(Box<PropertyExprParen>),
Not(Box<PropertyExprNot>), Not(Box<PropertyExprNot>),
Or(Box<PropertyExprOr>), Binary(Box<PropertyExprBinary>),
And(Box<PropertyExprAnd>),
ImplicationOverlapped(Box<PropertyExprImplicationOverlapped>), ImplicationOverlapped(Box<PropertyExprImplicationOverlapped>),
ImplicationNonoverlapped(Box<PropertyExprImplicationNonoverlapped>), ImplicationNonoverlapped(Box<PropertyExprImplicationNonoverlapped>),
If(Box<PropertyExprIf>), If(Box<PropertyExprIf>),
@ -177,12 +176,6 @@ pub enum PropertyExpr {
SAlways(Box<PropertyExprSAlways>), SAlways(Box<PropertyExprSAlways>),
Eventually(Box<PropertyExprEventually>), Eventually(Box<PropertyExprEventually>),
SEventually(Box<PropertyExprSEventually>), SEventually(Box<PropertyExprSEventually>),
Until(Box<PropertyExprUntil>),
SUntil(Box<PropertyExprSUntil>),
UntilWith(Box<PropertyExprUntilWith>),
SUntilWith(Box<PropertyExprSUntilWith>),
Implies(Box<PropertyExprImplies>),
Iff(Box<PropertyExprIff>),
AcceptOn(Box<PropertyExprAcceptOn>), AcceptOn(Box<PropertyExprAcceptOn>),
RejectOn(Box<PropertyExprRejectOn>), RejectOn(Box<PropertyExprRejectOn>),
SyncAcceptOn(Box<PropertyExprSyncAcceptOn>), SyncAcceptOn(Box<PropertyExprSyncAcceptOn>),
@ -203,7 +196,7 @@ pub struct PropertyExprWeak {
#[derive(Clone, Debug, Node)] #[derive(Clone, Debug, Node)]
pub struct PropertyExprParen { pub struct PropertyExprParen {
pub nodes: (Paren<SequenceExpr>,), pub nodes: (Paren<PropertyExpr>,),
} }
#[derive(Clone, Debug, Node)] #[derive(Clone, Debug, Node)]
@ -212,12 +205,7 @@ pub struct PropertyExprNot {
} }
#[derive(Clone, Debug, Node)] #[derive(Clone, Debug, Node)]
pub struct PropertyExprOr { pub struct PropertyExprBinary {
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
}
#[derive(Clone, Debug, Node)]
pub struct PropertyExprAnd {
pub nodes: (PropertyExpr, Keyword, PropertyExpr), pub nodes: (PropertyExpr, Keyword, PropertyExpr),
} }
@ -304,36 +292,6 @@ pub struct PropertyExprSEventually {
), ),
} }
#[derive(Clone, Debug, Node)]
pub struct PropertyExprUntil {
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
}
#[derive(Clone, Debug, Node)]
pub struct PropertyExprSUntil {
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
}
#[derive(Clone, Debug, Node)]
pub struct PropertyExprUntilWith {
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
}
#[derive(Clone, Debug, Node)]
pub struct PropertyExprSUntilWith {
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
}
#[derive(Clone, Debug, Node)]
pub struct PropertyExprImplies {
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
}
#[derive(Clone, Debug, Node)]
pub struct PropertyExprIff {
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
}
#[derive(Clone, Debug, Node)] #[derive(Clone, Debug, Node)]
pub struct PropertyExprAcceptOn { pub struct PropertyExprAcceptOn {
pub nodes: (Keyword, Paren<ExpressionOrDist>, PropertyExpr), pub nodes: (Keyword, Paren<ExpressionOrDist>, PropertyExpr),