pub(crate) fn identifier(input: &str) -> IResult<&str, &str> {
    let res = take_while1(|c: char| c.is_alphanumeric() || c == '-')(input)?;

    let first_char = res.1.chars().nth(0).unwrap();
    let last_char = res.1.chars().last().unwrap();

    if !first_char.is_ascii_alphabetic() || !last_char.is_ascii_alphanumeric() {
        return Err(nom::Err::Error(ParseError::from_error_kind(
            input,
            ErrorKind::Char,
        )));
    }

    Ok(res)
}
/// Parse an identifier from the start of the input.
///
/// An identifier begins with an alphabetic character, ends with an alphanumeric
/// character, and can have alphanumeric characters (or dashes) in the middle.
Parse an identifier from the start of the input.
An identifier begins with an alphabetic character, ends with an alphanumeric
character, and can have alphanumeric characters (or dashes) in the middle.
Parse an identifier from the start of the input . An identifier begins with an alphabetic character ends with an alphanumeric character and can have alphanumeric characters ( or dashes ) in the middle .
pub(crate) fn identifier(input: &str) -> IResult<&str, &str> {
    let res = take_while1(|c: char| c.is_alphanumeric() || c == '-')(input)?;
    let first_char = res.1.chars().nth(0).unwrap();
    let last_char = res.1.chars().last().unwrap();
    if !first_char.is_ascii_alphabetic() || !last_char.is_ascii_alphanumeric() {
        return Err(nom::Err::Error(ParseError::from_error_kind(
            input,
            ErrorKind::Char,
        )));
    }
    Ok(res)
}
pub ( crate ) fn identifier ( input : & str ) -> IResult < & str , & str > { let res = take_while1 ( | c : char | c . is_alphanumeric ( ) || c == '-' ) ( input ) ? ; let first_char = res . 1 . chars ( ) . nth ( 0 ) . unwrap ( ) ; let last_char = res . 1 . chars ( ) . last ( ) . unwrap ( ) ; if ! first_char . is_ascii_alphabetic ( ) || ! last_char . is_ascii_alphanumeric ( ) { return Err ( nom :: Err :: Error ( ParseError :: from_error_kind ( input , ErrorKind :: Char , ) ) ) ; } Ok ( res ) }
Parse an identifier from the start of the input.
Parse an identifier from the start of the input .
input
&str
input
&str