summaryrefslogtreecommitdiff
path: root/dhall_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'dhall_syntax')
-rw-r--r--dhall_syntax/src/core/expr.rs2
-rw-r--r--dhall_syntax/src/core/visitor.rs3
-rw-r--r--dhall_syntax/src/parser.rs8
-rw-r--r--dhall_syntax/src/printer.rs11
4 files changed, 23 insertions, 1 deletions
diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs
index 2d73a64..51b6c47 100644
--- a/dhall_syntax/src/core/expr.rs
+++ b/dhall_syntax/src/core/expr.rs
@@ -243,6 +243,8 @@ pub enum ExprF<SubExpr, Embed> {
UnionType(DupTreeMap<Label, Option<SubExpr>>),
/// `merge x y : t`
Merge(SubExpr, SubExpr, Option<SubExpr>),
+ /// `toMap x : t`
+ ToMap(SubExpr, Option<SubExpr>),
/// `e.x`
Field(SubExpr, Label),
/// `e.{ x, y, z }`
diff --git a/dhall_syntax/src/core/visitor.rs b/dhall_syntax/src/core/visitor.rs
index 49fff60..435771e 100644
--- a/dhall_syntax/src/core/visitor.rs
+++ b/dhall_syntax/src/core/visitor.rs
@@ -150,6 +150,9 @@ where
v.visit_subexpr(y)?,
opt(t, |e| v.visit_subexpr(e))?,
),
+ ToMap(x, t) => {
+ ToMap(v.visit_subexpr(x)?, opt(t, |e| v.visit_subexpr(e))?)
+ }
Field(e, l) => Field(v.visit_subexpr(e)?, l.clone()),
Projection(e, ls) => Projection(v.visit_subexpr(e)?, ls.clone()),
Assert(e) => Assert(v.visit_subexpr(e)?),
diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs
index defa79b..24ecc1e 100644
--- a/dhall_syntax/src/parser.rs
+++ b/dhall_syntax/src/parser.rs
@@ -827,6 +827,7 @@ make_parser! {
rule!(assert<()>);
rule!(if_<()>);
rule!(in_<()>);
+ rule!(toMap<()>);
rule!(empty_list_literal<ParsedExpr>; span; children!(
[application_expression(e)] => {
@@ -863,6 +864,9 @@ make_parser! {
[assert(()), expression(x)] => {
spanned(span, Assert(x))
},
+ [toMap(()), import_expression(x), application_expression(y)] => {
+ spanned(span, ToMap(x, Some(y)))
+ },
[operator_expression(e)] => e,
[operator_expression(e), expression(annot)] => {
spanned(span, Annot(e, annot))
@@ -934,7 +938,6 @@ make_parser! {
));
rule!(Some_<()>);
- rule!(toMap<()>);
rule!(application_expression<ParsedExpr>; children!(
[first_application_expression(e)] => e,
@@ -951,6 +954,9 @@ make_parser! {
[merge(()), import_expression(x), import_expression(y)] => {
spanned(span, Merge(x, y, None))
},
+ [toMap(()), import_expression(x)] => {
+ spanned(span, ToMap(x, None))
+ },
[import_expression(e)] => e,
));
diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs
index 276590e..8571d11 100644
--- a/dhall_syntax/src/printer.rs
+++ b/dhall_syntax/src/printer.rs
@@ -41,6 +41,12 @@ impl<SE: Display + Clone, E: Display> Display for ExprF<SE, E> {
write!(f, " : {}", c)?;
}
}
+ ToMap(a, b) => {
+ write!(f, "toMap {}", a)?;
+ if let Some(b) = b {
+ write!(f, " : {}", b)?;
+ }
+ }
Annot(a, b) => {
write!(f, "{} : {}", a, b)?;
}
@@ -144,6 +150,7 @@ impl<A: Display + Clone> RawExpr<A> {
| NEListLit(_)
| SomeLit(_)
| Merge(_, _, _)
+ | ToMap(_, _)
| Annot(_, _)
if phase > Base =>
{
@@ -172,6 +179,10 @@ impl<A: Display + Clone> RawExpr<A> {
b.phase(PrintPhase::Import),
c.map(|x| x.phase(PrintPhase::App)),
),
+ ToMap(a, b) => ToMap(
+ a.phase(PrintPhase::Import),
+ b.map(|x| x.phase(PrintPhase::App)),
+ ),
Annot(a, b) => Annot(a.phase(Operator), b),
ExprF::BinOp(op, a, b) => ExprF::BinOp(
op,