mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Refactor collections
This commit is contained in:
parent
9ce2f4e1ff
commit
451b2c0ded
7 changed files with 54 additions and 53 deletions
|
@ -111,6 +111,22 @@ pub fn integer_ident<'a>() -> impl Parser<'a, &'a str, ()> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Like `lowercase_ident`, but returns an error with MadeProgress if the
|
||||
/// identifier is a keyword.
|
||||
pub fn lowercase_ident_keyword_e<'a>() -> impl Parser<'a, &'a str, ()> {
|
||||
move |_, state: State<'a>, _min_indent: u32| match chomp_lowercase_part(state.bytes()) {
|
||||
Err(progress) => Err((progress, ())),
|
||||
Ok(ident) => {
|
||||
if crate::keyword::KEYWORDS.iter().any(|kw| &ident == kw) {
|
||||
Err((MadeProgress, ()))
|
||||
} else {
|
||||
let width = ident.len();
|
||||
Ok((MadeProgress, ident, state.advance(width)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tag_name<'a>() -> impl Parser<'a, &'a str, ()> {
|
||||
move |arena, state: State<'a>, min_indent: u32| {
|
||||
uppercase_ident().parse(arena, state, min_indent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue