Merge branch 'main' into builtin-task

This commit is contained in:
Sam Mohr 2024-06-26 03:17:29 -07:00
commit cd488300fd
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
24 changed files with 964 additions and 953 deletions

View file

@ -4,7 +4,10 @@ use crate::ast::{
use crate::blankspace::space0_e;
use crate::expr::merge_spaces;
use crate::ident::{lowercase_ident, UppercaseIdent};
use crate::parser::{byte, specialize_err, EPackageEntry, EPackageName, Parser};
use crate::parser::{
and, byte, loc, map_with_arena, skip_first, skip_second, specialize_err, EPackageEntry,
EPackageName, Parser,
};
use crate::parser::{optional, then};
use crate::string_literal;
use roc_module::symbol::ModuleId;
@ -355,29 +358,29 @@ 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`
//
// (Indirect dependencies don't have a shorthand.)
and!(
optional(and!(
skip_second!(
and!(
and(
optional(and(
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),
)),
and!(
optional(skip_first!(
and(
optional(skip_first(
crate::parser::keyword(crate::keyword::PLATFORM, EPackageEntry::Platform),
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, (platform_marker, package_or_path))| {
let entry = match opt_shorthand {
@ -400,15 +403,15 @@ pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPac
};
Spaced::Item(entry)
}
},
)
}
pub fn package_name<'a>() -> impl Parser<'a, PackageName<'a>, EPackageName<'a>> {
then(
loc!(specialize_err(
loc(specialize_err(
EPackageName::BadPath,
string_literal::parse_str_literal()
string_literal::parse_str_literal(),
)),
move |_arena, state, progress, text| match text.value {
StrLiteral::PlainLine(text) => Ok((progress, PackageName(text), state)),