use unit error type

This commit is contained in:
Folkert 2021-03-10 23:06:47 +01:00
parent 21f58b947a
commit 37462d6ec6

View file

@ -179,12 +179,32 @@ pub fn lowercase_ident<'a>() -> impl Parser<'a, &'a str, SyntaxError<'a>> {
/// * A module name /// * A module name
/// * A type name /// * A type name
/// * A global tag /// * A global tag
pub fn uppercase_ident<'a>() -> impl Parser<'a, &'a str, SyntaxError<'a>> { pub fn uppercase_ident<'a>() -> impl Parser<'a, &'a str, ()> {
global_tag_or_ident(|first_char| first_char.is_uppercase()) move |_, mut state: State<'a>| match chomp_uppercase_part(state.bytes) {
Err(progress) => Err((progress, (), state)),
Ok(ident) => {
let width = ident.len();
state.column += width as u16;
state.bytes = &state.bytes[width..];
Ok((MadeProgress, ident, state))
}
}
} }
pub fn unqualified_ident<'a>() -> impl Parser<'a, &'a str, SyntaxError<'a>> { pub fn unqualified_ident<'a>() -> impl Parser<'a, &'a str, ()> {
global_tag_or_ident(|first_char| first_char.is_alphabetic()) move |_, mut state: State<'a>| match chomp_part(|c| c.is_alphabetic(), state.bytes) {
Err(progress) => Err((progress, (), state)),
Ok(ident) => {
if crate::keyword::KEYWORDS.iter().any(|kw| &ident == kw) {
Err((MadeProgress, (), state))
} else {
let width = ident.len();
state.column += width as u16;
state.bytes = &state.bytes[width..];
Ok((MadeProgress, ident, state))
}
}
}
} }
pub fn join_module_parts<'a>(arena: &'a Bump, module_parts: &[&str]) -> &'a str { pub fn join_module_parts<'a>(arena: &'a Bump, module_parts: &[&str]) -> &'a str {