mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Enable parsing multiple signitures for requires header
This commit is contained in:
parent
f1a1f57adf
commit
bdb6651c13
4 changed files with 31 additions and 25 deletions
|
@ -4,7 +4,7 @@ use crate::ast::{
|
|||
Collection, CommentOrNewline, Defs, Header, Malformed, Pattern, Spaced, Spaces, SpacesBefore,
|
||||
StrLiteral, TypeAnnotation,
|
||||
};
|
||||
use crate::blankspace::{space0_around_ee, space0_before_e, space0_e};
|
||||
use crate::blankspace::{space0_before_e, space0_e};
|
||||
use crate::expr::merge_spaces;
|
||||
use crate::ident::{self, lowercase_ident, unqualified_ident, UppercaseIdent};
|
||||
use crate::parser::Progress::{self, *};
|
||||
|
@ -587,7 +587,7 @@ fn requires<'a>(
|
|||
fn platform_requires<'a>() -> impl Parser<'a, PlatformRequires<'a>, ERequires<'a>> {
|
||||
record!(PlatformRequires {
|
||||
rigids: skip_second(requires_rigids(), space0_e(ERequires::ListStart)),
|
||||
signature: requires_typed_ident()
|
||||
signatures: requires_typed_ident()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -607,16 +607,15 @@ fn requires_rigids<'a>(
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn requires_typed_ident<'a>() -> impl Parser<'a, Loc<Spaced<'a, TypedIdent<'a>>>, ERequires<'a>> {
|
||||
skip_first(
|
||||
byte(b'{', ERequires::ListStart),
|
||||
skip_second(
|
||||
reset_min_indent(space0_around_ee(
|
||||
specialize_err(ERequires::TypedIdent, loc(typed_ident())),
|
||||
ERequires::ListStart,
|
||||
ERequires::ListEnd,
|
||||
)),
|
||||
byte(b'}', ERequires::ListStart),
|
||||
fn requires_typed_ident<'a>(
|
||||
) -> impl Parser<'a, Collection<'a, Loc<Spaced<'a, TypedIdent<'a>>>>, ERequires<'a>> {
|
||||
reset_min_indent(
|
||||
collection_trailing_sep_e(
|
||||
byte(b'{', ERequires::ListStart),
|
||||
specialize_err(ERequires::TypedIdent, loc(typed_ident())),
|
||||
byte(b',', ERequires::ListEnd),
|
||||
byte(b'}', ERequires::ListEnd),
|
||||
Spaced::SpaceBefore,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -1239,7 +1238,7 @@ pub struct PackageHeader<'a> {
|
|||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct PlatformRequires<'a> {
|
||||
pub rigids: Collection<'a, Loc<Spaced<'a, UppercaseIdent<'a>>>>,
|
||||
pub signature: Loc<Spaced<'a, TypedIdent<'a>>>,
|
||||
pub signatures: Collection<'a, Loc<Spaced<'a, TypedIdent<'a>>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
@ -1393,7 +1392,7 @@ impl<'a> Malformed for PackageHeader<'a> {
|
|||
|
||||
impl<'a> Malformed for PlatformRequires<'a> {
|
||||
fn is_malformed(&self) -> bool {
|
||||
self.signature.is_malformed()
|
||||
self.signatures.items.iter().any(|x| x.is_malformed())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ impl<'a> Normalize<'a> for PlatformRequires<'a> {
|
|||
fn normalize(&self, arena: &'a Bump) -> Self {
|
||||
PlatformRequires {
|
||||
rigids: self.rigids.normalize(arena),
|
||||
signature: self.signature.normalize(arena),
|
||||
signatures: self.signatures.map_items(arena, |x| x.normalize(arena)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue