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
use crate::*;

// -----------------------------------------------------------------------------

#[tracable_parser]
#[packrat_parser]
pub(crate) fn subroutine_call_statement(s: Span) -> IResult<Span, SubroutineCallStatement> {
    alt((
        map(pair(subroutine_call, symbol(";")), |x| {
            SubroutineCallStatement::SubroutineCall(Box::new(x))
        }),
        subroutine_call_statement_function,
    ))(s)
}

#[tracable_parser]
#[packrat_parser]
pub(crate) fn subroutine_call_statement_function(
    s: Span,
) -> IResult<Span, SubroutineCallStatement> {
    let (s, a) = keyword("void")(s)?;
    let (s, b) = symbol("'")(s)?;
    let (s, c) = paren(function_subroutine_call)(s)?;
    let (s, d) = symbol(";")(s)?;
    Ok((
        s,
        SubroutineCallStatement::Function(Box::new(SubroutineCallStatementFunction {
            nodes: (a, b, c, d),
        })),
    ))
}