sv_parser_parser/declarations/
strengths.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[tracable_parser]
6#[packrat_parser]
7pub(crate) fn drive_strength(s: Span) -> IResult<Span, DriveStrength> {
8    alt((
9        drive_strength01,
10        drive_strength10,
11        drive_strength0z,
12        drive_strength1z,
13        drive_strengthz1,
14        drive_strengthz0,
15    ))(s)
16}
17
18#[tracable_parser]
19#[packrat_parser]
20pub(crate) fn drive_strength01(s: Span) -> IResult<Span, DriveStrength> {
21    let (s, a) = paren(triple(strength0, symbol(","), strength1))(s)?;
22    Ok((
23        s,
24        DriveStrength::Strength01(Box::new(DriveStrength01 { nodes: (a,) })),
25    ))
26}
27
28#[tracable_parser]
29#[packrat_parser]
30pub(crate) fn drive_strength10(s: Span) -> IResult<Span, DriveStrength> {
31    let (s, a) = paren(triple(strength1, symbol(","), strength0))(s)?;
32    Ok((
33        s,
34        DriveStrength::Strength10(Box::new(DriveStrength10 { nodes: (a,) })),
35    ))
36}
37
38#[tracable_parser]
39#[packrat_parser]
40pub(crate) fn drive_strength0z(s: Span) -> IResult<Span, DriveStrength> {
41    let (s, a) = paren(triple(strength0, symbol(","), keyword("highz1")))(s)?;
42    Ok((
43        s,
44        DriveStrength::Strength0z(Box::new(DriveStrength0z { nodes: (a,) })),
45    ))
46}
47
48#[tracable_parser]
49#[packrat_parser]
50pub(crate) fn drive_strength1z(s: Span) -> IResult<Span, DriveStrength> {
51    let (s, a) = paren(triple(strength1, symbol(","), keyword("highz0")))(s)?;
52    Ok((
53        s,
54        DriveStrength::Strength1z(Box::new(DriveStrength1z { nodes: (a,) })),
55    ))
56}
57
58#[tracable_parser]
59#[packrat_parser]
60pub(crate) fn drive_strengthz1(s: Span) -> IResult<Span, DriveStrength> {
61    let (s, a) = paren(triple(keyword("highz0"), symbol(","), strength1))(s)?;
62    Ok((
63        s,
64        DriveStrength::Strengthz1(Box::new(DriveStrengthz1 { nodes: (a,) })),
65    ))
66}
67
68#[tracable_parser]
69#[packrat_parser]
70pub(crate) fn drive_strengthz0(s: Span) -> IResult<Span, DriveStrength> {
71    let (s, a) = paren(triple(keyword("highz1"), symbol(","), strength0))(s)?;
72    Ok((
73        s,
74        DriveStrength::Strengthz0(Box::new(DriveStrengthz0 { nodes: (a,) })),
75    ))
76}
77
78#[tracable_parser]
79#[packrat_parser]
80pub(crate) fn strength0(s: Span) -> IResult<Span, Strength0> {
81    alt((
82        map(keyword("supply0"), |x| Strength0::Supply0(Box::new(x))),
83        map(keyword("strong0"), |x| Strength0::Strong0(Box::new(x))),
84        map(keyword("pull0"), |x| Strength0::Pull0(Box::new(x))),
85        map(keyword("weak0"), |x| Strength0::Weak0(Box::new(x))),
86    ))(s)
87}
88
89#[tracable_parser]
90#[packrat_parser]
91pub(crate) fn strength1(s: Span) -> IResult<Span, Strength1> {
92    alt((
93        map(keyword("supply1"), |x| Strength1::Supply1(Box::new(x))),
94        map(keyword("strong1"), |x| Strength1::Strong1(Box::new(x))),
95        map(keyword("pull1"), |x| Strength1::Pull1(Box::new(x))),
96        map(keyword("weak1"), |x| Strength1::Weak1(Box::new(x))),
97    ))(s)
98}
99
100#[tracable_parser]
101#[packrat_parser]
102pub(crate) fn charge_strength(s: Span) -> IResult<Span, ChargeStrength> {
103    alt((
104        charge_strength_small,
105        charge_strength_medium,
106        charge_strength_large,
107    ))(s)
108}
109
110#[tracable_parser]
111#[packrat_parser]
112pub(crate) fn charge_strength_small(s: Span) -> IResult<Span, ChargeStrength> {
113    let (s, a) = paren(keyword("small"))(s)?;
114    Ok((
115        s,
116        ChargeStrength::Small(Box::new(ChargeStrengthSmall { nodes: (a,) })),
117    ))
118}
119
120#[tracable_parser]
121#[packrat_parser]
122pub(crate) fn charge_strength_medium(s: Span) -> IResult<Span, ChargeStrength> {
123    let (s, a) = paren(keyword("medium"))(s)?;
124    Ok((
125        s,
126        ChargeStrength::Medium(Box::new(ChargeStrengthMedium { nodes: (a,) })),
127    ))
128}
129
130#[tracable_parser]
131#[packrat_parser]
132pub(crate) fn charge_strength_large(s: Span) -> IResult<Span, ChargeStrength> {
133    let (s, a) = paren(keyword("large"))(s)?;
134    Ok((
135        s,
136        ChargeStrength::Large(Box::new(ChargeStrengthLarge { nodes: (a,) })),
137    ))
138}