mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Revert "Require packages and imports once again"
This reverts commit 119329dffc86edbb2bc0475dfcded905f0f19c04.
This commit is contained in:
parent
09d107e469
commit
ecfdadb5e3
4 changed files with 67 additions and 12 deletions
|
@ -175,30 +175,50 @@ pub fn module_name<'a>() -> impl Parser<'a, ModuleName<'a>> {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn app_header<'a>() -> impl Parser<'a, AppHeader<'a>> {
|
||||
map!(
|
||||
map_with_arena!(
|
||||
and!(
|
||||
skip_first!(
|
||||
ascii_string("app"),
|
||||
and!(space1(1), loc!(string_literal::parse()))
|
||||
),
|
||||
and!(packages(), and!(imports(), provides_to()))
|
||||
and!(
|
||||
optional(packages()),
|
||||
and!(optional(imports()), provides_to())
|
||||
)
|
||||
),
|
||||
|(
|
||||
(after_app_keyword, name),
|
||||
(pkgs, (((before_imports, after_imports), imports), provides)),
|
||||
)| {
|
||||
let pkgs: Packages<'a> = pkgs; // rustc must be told the type here
|
||||
|arena, ((after_app_keyword, name), (opt_pkgs, (opt_imports, provides)))| {
|
||||
let (before_packages, after_packages, package_entries) = match opt_pkgs {
|
||||
Some(pkgs) => {
|
||||
let pkgs: Packages<'a> = pkgs; // rustc must be told the type here
|
||||
|
||||
(
|
||||
pkgs.before_packages_keyword,
|
||||
pkgs.after_packages_keyword,
|
||||
pkgs.entries,
|
||||
)
|
||||
}
|
||||
None => (&[] as _, &[] as _, Vec::new_in(arena)),
|
||||
};
|
||||
|
||||
// rustc must be told the type here
|
||||
let opt_imports: Option<(
|
||||
(&'a [CommentOrNewline<'a>], &'a [CommentOrNewline<'a>]),
|
||||
Vec<'a, Located<ImportsEntry<'a>>>,
|
||||
)> = opt_imports;
|
||||
|
||||
let ((before_imports, after_imports), imports) =
|
||||
opt_imports.unwrap_or_else(|| ((&[] as _, &[] as _), Vec::new_in(arena)));
|
||||
let provides: ProvidesTo<'a> = provides; // rustc must be told the type here
|
||||
|
||||
AppHeader {
|
||||
name,
|
||||
packages: pkgs.entries,
|
||||
packages: package_entries,
|
||||
imports,
|
||||
provides: provides.entries,
|
||||
to: provides.to,
|
||||
after_app_keyword,
|
||||
before_packages: pkgs.before_packages_keyword,
|
||||
after_packages: pkgs.after_packages_keyword,
|
||||
before_packages,
|
||||
after_packages,
|
||||
before_imports,
|
||||
after_imports,
|
||||
before_provides: provides.before_provides_keyword,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue