sv_parser_parser/expressions/
expression_leftside_values.rs

1use crate::*;
2
3// -----------------------------------------------------------------------------
4
5#[tracable_parser]
6#[packrat_parser]
7pub(crate) fn net_lvalue(s: Span) -> IResult<Span, NetLvalue> {
8    alt((net_lvalue_identifier, net_lvalue_lvalue, net_lvalue_pattern))(s)
9}
10
11#[tracable_parser]
12#[packrat_parser]
13pub(crate) fn net_lvalue_identifier(s: Span) -> IResult<Span, NetLvalue> {
14    let (s, a) = ps_or_hierarchical_net_identifier(s)?;
15    let (s, b) = constant_select(s)?;
16    Ok((
17        s,
18        NetLvalue::Identifier(Box::new(NetLvalueIdentifier { nodes: (a, b) })),
19    ))
20}
21
22#[tracable_parser]
23#[packrat_parser]
24pub(crate) fn net_lvalue_pattern(s: Span) -> IResult<Span, NetLvalue> {
25    let (s, a) = opt(assignment_pattern_expression_type)(s)?;
26    let (s, b) = assignment_pattern_net_lvalue(s)?;
27    Ok((
28        s,
29        NetLvalue::Pattern(Box::new(NetLvaluePattern { nodes: (a, b) })),
30    ))
31}
32
33#[tracable_parser]
34#[packrat_parser]
35pub(crate) fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
36    let (s, a) = brace(list(symbol(","), net_lvalue))(s)?;
37    Ok((
38        s,
39        NetLvalue::Lvalue(Box::new(NetLvalueLvalue { nodes: (a,) })),
40    ))
41}
42
43#[tracable_parser]
44#[packrat_parser]
45pub(crate) fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
46    alt((
47        variable_lvalue_pattern,
48        variable_lvalue_identifier,
49        variable_lvalue_lvalue,
50        map(streaming_concatenation, |x| {
51            VariableLvalue::StreamingConcatenation(Box::new(x))
52        }),
53    ))(s)
54}
55
56#[tracable_parser]
57#[packrat_parser]
58pub(crate) fn variable_lvalue_identifier(s: Span) -> IResult<Span, VariableLvalue> {
59    let (s, a) = opt(implicit_class_handle_or_package_scope)(s)?;
60    let (s, b) = hierarchical_variable_identifier(s)?;
61    let (s, c) = select(s)?;
62    Ok((
63        s,
64        VariableLvalue::Identifier(Box::new(VariableLvalueIdentifier { nodes: (a, b, c) })),
65    ))
66}
67
68#[tracable_parser]
69#[packrat_parser]
70pub(crate) fn variable_lvalue_pattern(s: Span) -> IResult<Span, VariableLvalue> {
71    let (s, a) = opt(assignment_pattern_expression_type)(s)?;
72    let (s, b) = assignment_pattern_variable_lvalue(s)?;
73    Ok((
74        s,
75        VariableLvalue::Pattern(Box::new(VariableLvaluePattern { nodes: (a, b) })),
76    ))
77}
78
79#[tracable_parser]
80#[packrat_parser]
81pub(crate) fn variable_lvalue_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
82    let (s, a) = brace(list(symbol(","), variable_lvalue))(s)?;
83    Ok((
84        s,
85        VariableLvalue::Lvalue(Box::new(VariableLvalueLvalue { nodes: (a,) })),
86    ))
87}
88
89#[tracable_parser]
90#[packrat_parser]
91pub(crate) fn nonrange_variable_lvalue(s: Span) -> IResult<Span, NonrangeVariableLvalue> {
92    let (s, a) = opt(implicit_class_handle_or_package_scope)(s)?;
93    let (s, b) = hierarchical_variable_identifier(s)?;
94    let (s, c) = nonrange_select(s)?;
95    Ok((s, NonrangeVariableLvalue { nodes: (a, b, c) }))
96}