#![allow(clippy::manual_is_ascii_check)]
use super::combinator::*;
use nom::{
branch::alt,
character::complete::{char, satisfy},
Parser,
};
pub fn latin_codepoint(input: &str) -> ParseResult<char> {
alt((
space,
digit,
lower,
upper,
special,
reverse_solidus,
apostrophe,
))
.parse(input)
}
pub fn space(input: &str) -> ParseResult<char> {
char(' ')(input)
}
pub fn digit(input: &str) -> ParseResult<char> {
satisfy(|c| matches!(c, '0'..='9')).parse(input)
}
pub fn lower(input: &str) -> ParseResult<char> {
satisfy(|c| matches!(c, 'a'..='z')).parse(input)
}
pub fn upper(input: &str) -> ParseResult<char> {
satisfy(|c| matches!(c, 'A'..='Z' | '_')).parse(input)
}
pub fn special(input: &str) -> ParseResult<char> {
satisfy(|c| {
matches!(
c,
'!' | '"'
| '*'
| '$'
| '%'
| '&'
| '.'
| '#'
| '+'
| ','
| '-'
| '('
| ')'
| '?'
| '/'
| ':'
| ';'
| '<'
| '='
| '>'
| '@'
| '['
| ']'
| '{'
| '|'
| '}'
| '^'
| '`'
| '~'
)
})
.parse(input)
}
pub fn reverse_solidus(input: &str) -> ParseResult<char> {
char('\\')(input)
}
pub fn apostrophe(input: &str) -> ParseResult<char> {
char('\'')(input)
}