sv_parser_parser/behavioral_statements/
parallel_and_sequential_blocks.rs1use crate::*;
2
3#[tracable_parser]
6#[packrat_parser]
7pub(crate) fn action_block(s: Span) -> IResult<Span, ActionBlock> {
8 alt((
9 action_block_else,
10 map(statement_or_null, |x| {
11 ActionBlock::StatementOrNull(Box::new(x))
12 }),
13 ))(s)
14}
15
16#[tracable_parser]
17#[packrat_parser]
18pub(crate) fn action_block_else(s: Span) -> IResult<Span, ActionBlock> {
19 let (s, a) = opt(statement)(s)?;
20 let (s, b) = keyword("else")(s)?;
21 let (s, c) = statement_or_null(s)?;
22 Ok((
23 s,
24 ActionBlock::Else(Box::new(ActionBlockElse { nodes: (a, b, c) })),
25 ))
26}
27
28#[tracable_parser]
29#[packrat_parser]
30pub(crate) fn seq_block(s: Span) -> IResult<Span, SeqBlock> {
31 let (s, a) = keyword("begin")(s)?;
32 let (s, b) = opt(pair(symbol(":"), block_identifier))(s)?;
33 let (s, c) = many0(block_item_declaration)(s)?;
34 let (s, (d, e)) = many_till(statement_or_null, keyword("end"))(s)?;
35 let (s, f) = opt(pair(symbol(":"), block_identifier))(s)?;
36 Ok((
37 s,
38 SeqBlock {
39 nodes: (a, b, c, d, e, f),
40 },
41 ))
42}
43
44#[tracable_parser]
45#[packrat_parser]
46pub(crate) fn par_block(s: Span) -> IResult<Span, ParBlock> {
47 let (s, a) = keyword("fork")(s)?;
48 let (s, b) = opt(pair(symbol(":"), block_identifier))(s)?;
49 let (s, c) = many0(block_item_declaration)(s)?;
50 let (s, (d, e)) = many_till(statement_or_null, join_keyword)(s)?;
51 let (s, f) = opt(pair(symbol(":"), block_identifier))(s)?;
52 Ok((
53 s,
54 ParBlock {
55 nodes: (a, b, c, d, e, f),
56 },
57 ))
58}
59
60#[tracable_parser]
61#[packrat_parser]
62pub(crate) fn join_keyword(s: Span) -> IResult<Span, JoinKeyword> {
63 alt((
64 map(keyword("join_any"), |x| JoinKeyword::JoinAny(Box::new(x))),
65 map(keyword("join_none"), |x| JoinKeyword::JoinNone(Box::new(x))),
66 map(keyword("join"), |x| JoinKeyword::Join(Box::new(x))),
67 ))(s)
68}