mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Merge branch 'main' into builtin-task
This commit is contained in:
commit
cd488300fd
24 changed files with 964 additions and 953 deletions
|
@ -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)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue