summaryrefslogtreecommitdiff
path: root/dhall_core
diff options
context:
space:
mode:
authorNadrieril2019-04-16 22:06:01 +0200
committerNadrieril2019-04-16 22:06:01 +0200
commit47d5dbcfffa7842466187197513ffa403a0fdb59 (patch)
tree9fb5c54ae85957c259cddf8bf81aeb3f51f731b4 /dhall_core
parentd93be73890d0db0d34afaaebd3db1b87d68fb9b7 (diff)
Handle nullary union variants
Closes #36
Diffstat (limited to 'dhall_core')
-rw-r--r--dhall_core/src/parser.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs
index a335ccc..b463073 100644
--- a/dhall_core/src/parser.rs
+++ b/dhall_core/src/parser.rs
@@ -895,7 +895,8 @@ make_parser! {
));
rule!(union_type_entry<(Label, Option<ParsedSubExpr<'a>>)>; children!(
- [label(name), expression(expr)] => (name, Option::Some(rc(expr)))
+ [label(name), expression(expr)] => (name, Option::Some(rc(expr))),
+ [label(name)] => (name, Option::None),
));
// TODO: unary union variants
@@ -910,6 +911,12 @@ make_parser! {
[expression(e)] => {
(Option::Some(rc(e)), (Option::None, BTreeMap::new()))
},
+ [non_empty_union_type_or_literal(rest)] => {
+ (Option::None, rest)
+ },
+ [] => {
+ (Option::None, (Option::None, BTreeMap::new()))
+ },
));
rule!(non_empty_list_literal<ParsedExpr<'a>> as expression; span;