summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src')
-rw-r--r--dhall/src/operations/kind.rs4
-rw-r--r--dhall/src/syntax/ast/span.rs6
-rw-r--r--dhall/src/syntax/text/dhall.abnf22
-rw-r--r--dhall/src/syntax/text/parser.rs2
4 files changed, 23 insertions, 11 deletions
diff --git a/dhall/src/operations/kind.rs b/dhall/src/operations/kind.rs
index 5415637..0ee9671 100644
--- a/dhall/src/operations/kind.rs
+++ b/dhall/src/operations/kind.rs
@@ -6,6 +6,8 @@ use crate::syntax::{trivial_result, Label};
// pretty-printing to work correctly
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum BinOp {
+ /// x === y
+ Equivalence,
/// `x ? y`
ImportAlt,
/// `x || y`
@@ -30,8 +32,6 @@ pub enum BinOp {
BoolEQ,
/// `x != y`
BoolNE,
- /// x === y
- Equivalence,
}
/// Operations
diff --git a/dhall/src/syntax/ast/span.rs b/dhall/src/syntax/ast/span.rs
index e250602..ab3279b 100644
--- a/dhall/src/syntax/ast/span.rs
+++ b/dhall/src/syntax/ast/span.rs
@@ -66,6 +66,12 @@ impl Span {
end: max(x.end, y.end),
})
}
+ (Parsed(_), Parsed(_)) => panic!(
+ "Tried to union incompatible spans: {:?} and {:?}",
+ self, other
+ ),
+ (Parsed(x), _) => Parsed(x.clone()),
+ (_, Parsed(x)) => Parsed(x.clone()),
_ => panic!(
"Tried to union incompatible spans: {:?} and {:?}",
self, other
diff --git a/dhall/src/syntax/text/dhall.abnf b/dhall/src/syntax/text/dhall.abnf
index 1c3a980..861f7b3 100644
--- a/dhall/src/syntax/text/dhall.abnf
+++ b/dhall/src/syntax/text/dhall.abnf
@@ -757,6 +757,11 @@ expression =
; NOTE: Backtrack if parsing this alternative fails
/ operator-expression whsp arrow whsp expression
+ ; "a with x = b"
+ ;
+ ; NOTE: Backtrack if parsing this alternative fails
+ / with-expression
+
; "merge e1 e2 : t"
;
; NOTE: Backtrack if parsing this alternative fails since we can't tell
@@ -792,9 +797,16 @@ let-binding = let whsp1 nonreserved-label whsp [ ":" whsp1 expression whsp ] "="
empty-list-literal =
"[" whsp [ "," whsp ] "]" whsp ":" whsp1 application-expression
-operator-expression = import-alt-expression
+with-expression =
+ import-expression 1*(whsp1 with whsp1 with-clause)
+
+with-clause =
+ any-label-or-some *(whsp "." whsp any-label-or-some) whsp "=" whsp operator-expression
+
+operator-expression = equivalent-expression
; Nonempty-whitespace to disambiguate `http://a/a?a`
+equivalent-expression = import-alt-expression *(whsp equivalent whsp import-alt-expression)
import-alt-expression = or-expression *(whsp "?" whsp1 or-expression)
or-expression = plus-expression *(whsp "||" whsp plus-expression)
; Nonempty-whitespace to disambiguate `f +2`
@@ -807,13 +819,7 @@ prefer-expression = combine-types-expression *(whsp prefer whsp combine-t
combine-types-expression = times-expression *(whsp combine-types whsp times-expression)
times-expression = equal-expression *(whsp "*" whsp equal-expression)
equal-expression = not-equal-expression *(whsp "==" whsp not-equal-expression)
-not-equal-expression = equivalent-expression *(whsp "!=" whsp equivalent-expression)
-equivalent-expression = with-expression *(whsp equivalent whsp with-expression)
-
-with-expression = application-expression *(whsp1 with whsp1 with-clause)
-
-with-clause =
- any-label-or-some *(whsp "." whsp any-label-or-some) whsp "=" whsp application-expression
+not-equal-expression = application-expression *(whsp "!=" whsp application-expression)
; Import expressions need to be separated by some whitespace, otherwise there
diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs
index 1e1449c..e870db3 100644
--- a/dhall/src/syntax/text/parser.rs
+++ b/dhall/src/syntax/text/parser.rs
@@ -130,6 +130,7 @@ lazy_static::lazy_static! {
use Rule::*;
// In order of precedence
let operators = vec![
+ equivalent,
import_alt,
bool_or,
natural_plus,
@@ -142,7 +143,6 @@ lazy_static::lazy_static! {
natural_times,
bool_eq,
bool_ne,
- equivalent,
];
PrecClimber::new(
operators