summaryrefslogtreecommitdiff
path: root/dhall_parser
diff options
context:
space:
mode:
authorNadrieril2019-03-24 14:05:16 +0100
committerNadrieril2019-03-24 14:05:16 +0100
commit6c1a739687f706cf6630c55f8d53c92aacaf6e3d (patch)
tree9fd95a35fe35cd532cd869f4c6f0db6585482225 /dhall_parser
parentdc8497a1b659bff4e261a0d7f05f56d21c6d2448 (diff)
Disallow builtins as bound variables
Diffstat (limited to '')
-rw-r--r--dhall_parser/src/dhall.abnf12
1 files changed, 7 insertions, 5 deletions
diff --git a/dhall_parser/src/dhall.abnf b/dhall_parser/src/dhall.abnf
index d27554c..02edc84 100644
--- a/dhall_parser/src/dhall.abnf
+++ b/dhall_parser/src/dhall.abnf
@@ -168,11 +168,13 @@ quoted-label = 1*quoted-label-char
; NOTE: Dhall does not support Unicode labels, mainly to minimize the potential
; for code obfuscation
-; A label cannot not be any of the reserved identifiers for builtins (unless quoted).
+label = ("`" quoted-label "`" / simple-label)
+
+; An unreserved-label cannot not be any of the reserved identifiers for builtins (unless quoted).
; Their list can be found in semantics.md. This is not enforced by the grammar but
; should be checked by implementations. The only place where this restriction applies
; is bound variables.
-label = ("`" quoted-label "`" / simple-label)
+unreserved-label = label
; An any-label is allowed to be one of the reserved identifiers.
any-label = label
@@ -541,7 +543,7 @@ expression =
/ annotated-expression
; "\(x : a) -> b"
-lambda-expression = lambda whitespace "(" whitespace label whitespace ":" nonempty-whitespace expression ")" whitespace arrow whitespace expression
+lambda-expression = lambda whitespace "(" whitespace unreserved-label whitespace ":" nonempty-whitespace expression ")" whitespace arrow whitespace expression
; "if a then b else c"
ifthenelse-expression = if nonempty-whitespace expression then nonempty-whitespace expression else nonempty-whitespace expression
@@ -550,10 +552,10 @@ ifthenelse-expression = if nonempty-whitespace expression then nonempty-whitespa
; "let x = e1 in e2"
; "let x = e1 let y = e2 in e3"
let-expression = 1*let-binding in nonempty-whitespace expression
-let-binding = let nonempty-whitespace label whitespace [ ":" nonempty-whitespace expression ] "=" whitespace expression
+let-binding = let nonempty-whitespace unreserved-label whitespace [ ":" nonempty-whitespace expression ] "=" whitespace expression
; "forall (x : a) -> b"
-forall-expression = forall whitespace "(" whitespace label whitespace ":" nonempty-whitespace expression ")" whitespace arrow whitespace expression
+forall-expression = forall whitespace "(" whitespace unreserved-label whitespace ":" nonempty-whitespace expression ")" whitespace arrow whitespace expression
; "a -> b"
arrow-expression = operator-expression arrow whitespace expression