paralegal_flow::ann::parse

Function lit

Source
pub fn lit<'a, A, F: Fn(&str) -> Result<A, String> + 'a>(
    k: LitKind,
    f: F,
) -> impl FnMut(I<'a>) -> IResult<I<'a>, A>
Expand description

Parse a TokenKind::Literal if it has a specific LitKind and return the payload of the literal.

This can parse all types of literals since the literal payloads in these token treed are uniformly represented as strings and need to be parsed to extract the actual type of the literal. So you will likely want to call str::parse on the result.