Un-macro map_with_arena

This commit is contained in:
Jackson Wambolt 2024-04-15 20:35:08 -05:00
parent f6c977fb96
commit a9724dda5e
No known key found for this signature in database
GPG key ID: 76F29A42FEE8811C
5 changed files with 74 additions and 124 deletions

View file

@ -5,7 +5,8 @@ use crate::blankspace::space0_e;
use crate::expr::merge_spaces;
use crate::ident::{lowercase_ident, UppercaseIdent};
use crate::parser::{
and, byte, loc, skip_second, specialize_err, EPackageEntry, EPackageName, Parser,
and, byte, loc, map_with_arena, skip_second, specialize_err, EPackageEntry, EPackageName,
Parser,
};
use crate::parser::{optional, then};
use crate::string_literal;
@ -339,7 +340,7 @@ pub struct PackageEntry<'a> {
}
pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPackageEntry<'a>> {
map_with_arena!(
map_with_arena(
// You may optionally have a package shorthand,
// e.g. "uc" in `uc: roc/unicode 1.0.0`
//
@ -349,13 +350,13 @@ pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPac
skip_second(
and(
specialize_err(|_, pos| EPackageEntry::Shorthand(pos), lowercase_ident()),
space0_e(EPackageEntry::IndentPackage)
space0_e(EPackageEntry::IndentPackage),
),
byte(b':', EPackageEntry::Colon)
byte(b':', EPackageEntry::Colon),
),
space0_e(EPackageEntry::IndentPackage)
space0_e(EPackageEntry::IndentPackage),
)),
loc(specialize_err(EPackageEntry::BadPackage, package_name()))
loc(specialize_err(EPackageEntry::BadPackage, package_name())),
),
move |arena, (opt_shorthand, package_or_path)| {
let entry = match opt_shorthand {
@ -376,7 +377,7 @@ pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPac
};
Spaced::Item(entry)
}
},
)
}