summaryrefslogtreecommitdiff
path: root/dhall/src/syntax/text
diff options
context:
space:
mode:
authorNadrieril2020-02-20 19:04:13 +0000
committerNadrieril2020-02-20 19:04:13 +0000
commit6642077368497583113d685d351ec93d230ffcad (patch)
tree51f42d5525bdcde81834a28b2b3742472cbac56a /dhall/src/syntax/text
parent0e07c9cd012efaeae7e1c50a3499a13aef4d2b61 (diff)
Add support for dotted field syntax
Diffstat (limited to 'dhall/src/syntax/text')
-rw-r--r--dhall/src/syntax/text/parser.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs
index f74794b..ba64a75 100644
--- a/dhall/src/syntax/text/parser.rs
+++ b/dhall/src/syntax/text/parser.rs
@@ -915,7 +915,18 @@ impl DhallParser {
fn record_literal_entry(input: ParseInput) -> ParseResult<(Label, Expr)> {
Ok(match_nodes!(input.into_children();
- [label(name), expression(expr)] => (name, expr)
+ [label(name), expression(expr)] => (name, expr),
+ [label(first_name), label(names).., expression(expr)] => {
+ // Desugar dotted field syntax into nested records
+ let expr = names.rev().fold(expr, |e, l| {
+ let map = Some((l, e)).into_iter().collect();
+ Expr::new(
+ RecordLit(map),
+ Span::DottedFieldSugar,
+ )
+ });
+ (first_name, expr)
+ },
))
}