From f502176dca2b0eedd1ae5ff3e8d8e8b5918b4c78 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 3 Mar 2019 20:19:30 +0100 Subject: Parse more of the AST --- dhall/src/core.rs | 14 +++++++++++--- dhall/src/grammar.lalrpop | 2 +- dhall/src/parser.rs | 21 ++++++++++----------- dhall/tests/macros.rs | 5 ++--- dhall/tests/tests.rs | 2 +- 5 files changed, 25 insertions(+), 19 deletions(-) (limited to 'dhall') diff --git a/dhall/src/core.rs b/dhall/src/core.rs index 88eff36..5b82160 100644 --- a/dhall/src/core.rs +++ b/dhall/src/core.rs @@ -169,6 +169,14 @@ pub enum Expr<'i, S, A> { UnionLit(&'i str, Box>, BTreeMap<&'i str, Expr<'i, S, A>>), /// `Combine x y ~ x ∧ y` Combine(Box>, Box>), + /// x //\\ y + CombineTypes(Box>, Box>), + /// x ? y + ImportAlt(Box>, Box>), + /// x // y + Prefer(Box>, Box>), + /// x # y + ListAppend(Box>, Box>), /// `Merge x y t ~ merge x y : t` Merge(Box>, Box>, Box>), /// `Field e x ~ e.x` @@ -696,7 +704,7 @@ pub fn shift<'i, S, T, A: Clone>(d: isize, v: V, e: &Expr<'i, S, A>) -> Expr<'i, // The Dhall compiler enforces that all embedded values are closed expressions // and `shift` does nothing to a closed expression Embed(ref p) => Embed(p.clone()), - FailedParse(_, _) => unreachable!(), + _ => panic!(), } } @@ -793,7 +801,7 @@ pub fn subst<'i, S, T, A>(v: V<'i>, e: &Expr<'i, S, A>, b: &Expr<'i, T, A>) -> E Field(ref a, b) => Field(bx(subst(v, e, a)), b), Note(_, ref b) => subst(v, e, b), Embed(ref p) => Embed(p.clone()), - FailedParse(_, _) => unreachable!(), + _ => panic!(), } } @@ -1038,7 +1046,7 @@ pub fn normalize<'i, S, T, A>(e: &Expr<'i, S, A>) -> Expr<'i, T, A> }, Note(_, ref e) => normalize(e), Embed(ref a) => Embed(a.clone()), - FailedParse(_, _) => unreachable!(), + _ => panic!(), } } diff --git a/dhall/src/grammar.lalrpop b/dhall/src/grammar.lalrpop index 250a45e..1d832b7 100644 --- a/dhall/src/grammar.lalrpop +++ b/dhall/src/grammar.lalrpop @@ -58,7 +58,6 @@ extern { } pub Expr: BoxExpr<'input> = { // exprA - ":" => bx(Annot(<>)), ExprB, }; @@ -69,6 +68,7 @@ ExprB: BoxExpr<'input> = { "->" => bx(Pi("_", <>)), Let