fn ch(input: &str) -> ParseResult<Literal> {
    let (input, _) = char('\'')(input)?;
    let (input, ch) = alt((
        // This lambda function accounts for escape characters
        |input| {
            let (input, _) = tag("\\")(input)?;
            let (input, ch) = anychar(input)?;
            Ok((
                input,
                // convert the escaped character into its escaped form
                match ch {
                    'n' => '\n',
                    'r' => '\r',
                    't' => '\t',
                    '0' => '\0',
                    // if the character isnt recognized as an escape character,
                    // just pass it along as a non-escaped character
                    other => other,
                },
            ))
        },
        anychar,
    ))(input)?;
    let (input, _) = char('\'')(input)?;
    Ok((input, Literal::ch(ch)))
}
/// Parses a character literal as an actual instance of Literal.
/// This makes defining the `literal` parser much simpler
Parses a character literal as an actual instance of Literal.
This makes defining the `literal` parser much simpler
Parses a character literal as an actual instance of Literal . This makes defining the ` literal ` parser much simpler
fn ch(input: &str) -> ParseResult<Literal> {
    let (input, _) = char('\'')(input)?;
    let (input, ch) = alt((
        // This lambda function accounts for escape characters
        |input| {
            let (input, _) = tag("\\")(input)?;
            let (input, ch) = anychar(input)?;
            Ok((
                input,
                // convert the escaped character into its escaped form
                match ch {
                    'n' => '\n',
                    'r' => '\r',
                    't' => '\t',
                    '0' => '\0',
                    // if the character isnt recognized as an escape character,
                    // just pass it along as a non-escaped character
                    other => other,
                },
            ))
        },
        anychar,
    ))(input)?;
    let (input, _) = char('\'')(input)?;
    Ok((input, Literal::ch(ch)))
}
fn ch ( input : & str ) -> ParseResult < Literal > { let ( input , _ ) = char ( '\'' ) ( input ) ? ; let ( input , ch ) = alt ( ( // This lambda function accounts for escape characters | input | { let ( input , _ ) = tag ( " \\ " ) ( input ) ? ; let ( input , ch ) = anychar ( input ) ? ; Ok ( ( input , // convert the escaped character into its escaped form match ch { 'n' => '\n' , 'r' => '\r' , 't' => '\t' , '0' => '\0' , // if the character isnt recognized as an escape character, // just pass it along as a non-escaped character other => other , } , ) ) } , anychar , ) ) ( input ) ? ; let ( input , _ ) = char ( '\'' ) ( input ) ? ; Ok ( ( input , Literal :: ch ( ch ) ) ) }
Parses a character literal as an actual instance of Literal.
Parses a character literal as an actual instance of Literal .
input
&str
input
&str