mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Merge attempt
This commit is contained in:
parent
7c15c16ae0
commit
12df3a04de
236 changed files with 9053 additions and 6428 deletions
|
@ -123,7 +123,7 @@ fn module_header<'a>() -> impl Parser<'a, ModuleHeader<'a>, EHeader<'a>> {
|
|||
|
||||
fn module_params<'a>() -> impl Parser<'a, ModuleParams<'a>, EParams<'a>> {
|
||||
record!(ModuleParams {
|
||||
params: specialize_err(EParams::Pattern, record_pattern_fields()),
|
||||
pattern: specialize_err(EParams::Pattern, loc(record_pattern_fields())),
|
||||
before_arrow: skip_second(
|
||||
space0_e(EParams::BeforeArrow),
|
||||
loc(two_bytes(b'-', b'>', EParams::Arrow))
|
||||
|
@ -943,6 +943,7 @@ pub enum HeaderType<'a> {
|
|||
Builtin {
|
||||
name: ModuleName<'a>,
|
||||
exposes: &'a [Loc<ExposedName<'a>>],
|
||||
opt_params: Option<ModuleParams<'a>>,
|
||||
},
|
||||
Package {
|
||||
/// usually something other than `pf`
|
||||
|
@ -966,6 +967,7 @@ pub enum HeaderType<'a> {
|
|||
Module {
|
||||
name: ModuleName<'a>,
|
||||
exposes: &'a [Loc<ExposedName<'a>>],
|
||||
opt_params: Option<ModuleParams<'a>>,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -990,11 +992,54 @@ impl<'a> HeaderType<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_params(&self) -> &Option<ModuleParams<'a>> {
|
||||
match self {
|
||||
Self::Module {
|
||||
opt_params,
|
||||
name: _,
|
||||
exposes: _,
|
||||
}
|
||||
| Self::Builtin {
|
||||
opt_params,
|
||||
name: _,
|
||||
exposes: _,
|
||||
} => opt_params,
|
||||
Self::App {
|
||||
provides: _,
|
||||
to_platform: _,
|
||||
}
|
||||
| Self::Package {
|
||||
config_shorthand: _,
|
||||
exposes: _,
|
||||
exposes_ids: _,
|
||||
}
|
||||
| Self::Hosted {
|
||||
name: _,
|
||||
exposes: _,
|
||||
}
|
||||
| Self::Platform {
|
||||
opt_app_module_id: _,
|
||||
provides: _,
|
||||
requires: _,
|
||||
requires_types: _,
|
||||
exposes: _,
|
||||
exposes_ids: _,
|
||||
config_shorthand: _,
|
||||
} => &None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_maybe_builtin(self, module_id: ModuleId) -> Self {
|
||||
match self {
|
||||
HeaderType::Module { name, exposes } if module_id.is_builtin() => {
|
||||
HeaderType::Builtin { name, exposes }
|
||||
}
|
||||
HeaderType::Module {
|
||||
name,
|
||||
exposes,
|
||||
opt_params,
|
||||
} if module_id.is_builtin() => HeaderType::Builtin {
|
||||
name,
|
||||
exposes,
|
||||
opt_params,
|
||||
},
|
||||
_ => self,
|
||||
}
|
||||
}
|
||||
|
@ -1139,7 +1184,7 @@ pub struct ModuleHeader<'a> {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ModuleParams<'a> {
|
||||
pub params: Collection<'a, Loc<Pattern<'a>>>,
|
||||
pub pattern: Loc<Collection<'a, Loc<Pattern<'a>>>>,
|
||||
pub before_arrow: &'a [CommentOrNewline<'a>],
|
||||
pub after_arrow: &'a [CommentOrNewline<'a>],
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue