1
1
mirror of https://github.com/tweag/nickel.git synced 2024-09-20 16:08:14 +03:00

Allow pipe syntax in records and toplevel lets

This commit is contained in:
Yann Hamdaoui 2021-02-01 14:57:03 +01:00
parent c9c90f3156
commit cb26243956

View File

@ -84,6 +84,15 @@ pub ExtendedTerm: ExtendedTerm = {
ExtendedTerm::ToplevelLet(id, t1)
},
"let" <id:Ident> <meta: MetaAnnot> "=" <t1: Term> => {
//TODO: bump LALRPOP version to >= 0.18.0 which allows mutable x in
//actions and remove this
let mut meta = meta;
let pos = t1.pos.clone();
meta.value = Some(t1);
ExtendedTerm::ToplevelLet(id, RichTerm::new(Term::MetaValue(meta), pos))
},
Term => ExtendedTerm::RichTerm(<>),
}
@ -272,6 +281,14 @@ RecordField: Either<(Ident, RichTerm), (RichTerm, RichTerm)> = {
Either::Left((id, t))
},
<l: @L> <id: Ident> <meta: MetaAnnot> <r: @R> <t: ("=" <Term>)?> => {
let mut meta = meta;
let pos = t.as_ref()
.map(|t| t.pos.clone())
.unwrap_or(Some(mk_span(src_id, l, r)));
meta.value = t;
Either::Left((id, RichTerm::new(Term::MetaValue(meta), pos)))
},
"$" <id: SpTerm<Atom>> <ann: TypeAnnot?> "=" <t: Term> => {
let t = if let Some((l, ty, r)) = ann {
let pos = t.pos.clone();