summaryrefslogtreecommitdiff
path: root/dhall/src/syntax/text
diff options
context:
space:
mode:
authorNadrieril2020-04-11 15:41:21 +0100
committerNadrieril2020-06-25 15:12:09 +0100
commit72ad56209fe10e3120c19ca5b820ff267423ab1d (patch)
tree4728152ca9b5af25c293b3b16f921b5bcf32a1b8 /dhall/src/syntax/text
parent4c80de149200a86f7fc13c725160dafb35d0ac08 (diff)
spec: fix precedence of `===` and `with`
Diffstat (limited to 'dhall/src/syntax/text')
-rw-r--r--dhall/src/syntax/text/dhall.abnf22
-rw-r--r--dhall/src/syntax/text/parser.rs2
2 files changed, 15 insertions, 9 deletions
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