1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use crate::*;
#[tracable_parser]
#[packrat_parser]
pub(crate) fn delay3(s: Span) -> IResult<Span, Delay3> {
alt((delay3_single, delay3_mintypmax))(s)
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn delay3_single(s: Span) -> IResult<Span, Delay3> {
let (s, a) = symbol("#")(s)?;
let (s, b) = delay_value(s)?;
Ok((s, Delay3::Single(Box::new(Delay3Single { nodes: (a, b) }))))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn delay3_mintypmax(s: Span) -> IResult<Span, Delay3> {
let (s, a) = symbol("#")(s)?;
let (s, b) = paren(pair(
mintypmax_expression,
opt(triple(
symbol(","),
mintypmax_expression,
opt(pair(symbol(","), mintypmax_expression)),
)),
))(s)?;
Ok((
s,
Delay3::Mintypmax(Box::new(Delay3Mintypmax { nodes: (a, b) })),
))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn delay2(s: Span) -> IResult<Span, Delay2> {
alt((delay2_single, delay2_mintypmax))(s)
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn delay2_single(s: Span) -> IResult<Span, Delay2> {
let (s, a) = symbol("#")(s)?;
let (s, b) = delay_value(s)?;
Ok((s, Delay2::Single(Box::new(Delay2Single { nodes: (a, b) }))))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn delay2_mintypmax(s: Span) -> IResult<Span, Delay2> {
let (s, a) = symbol("#")(s)?;
let (s, b) = paren(pair(
mintypmax_expression,
opt(pair(symbol(","), mintypmax_expression)),
))(s)?;
Ok((
s,
Delay2::Mintypmax(Box::new(Delay2Mintypmax { nodes: (a, b) })),
))
}
#[tracable_parser]
#[packrat_parser]
pub(crate) fn delay_value(s: Span) -> IResult<Span, DelayValue> {
alt((
map(keyword("1step"), |x| DelayValue::Step1(Box::new(x))),
map(time_literal, |x| DelayValue::TimeLiteral(Box::new(x))),
map(real_number, |x| DelayValue::RealNumber(Box::new(x))),
map(unsigned_number, |x| DelayValue::UnsignedNumber(Box::new(x))),
map(hierarchical_identifier, |x| {
DelayValue::HierarchicalIdentifier(Box::new(x))
}),
map(ps_identifier, |x| DelayValue::PsIdentifier(Box::new(x))),
))(s)
}