Comments (6)
Hmm, dhall-rust also fails to parse this (with a slightly weird error message):
dhall-rust error message
Err(
Error(
Dhall(
Error {
kind: Parse(
Error {
variant: ParsingError {
positives: [
empty_record_literal,
non_empty_record_type_or_literal,
],
negatives: [],
},
location: Pos(
2,
),
line_col: Pos(
(
1,
3,
),
),
path: None,
line: "{ if : Text }",
continued_line: None,
},
),
},
),
),
)
Maybe the standard disallows keyword keys? (EDIT: I think that the standard allows keyword keys, it allows )any-label
(or Some
) and not non-reserved-label
from dhallj.
Thanks for the report!
The current behavior is definitely intentional. From dhall.abnf
:
; A simple label cannot be one of the reserved keywords
; listed in the `keyword` rule.
; A PEG parser could use negative lookahead to
; enforce this, e.g. as follows:
; simple-label =
; keyword 1*simple-label-next-char
; / !keyword (simple-label-first-char *simple-label-next-char)
simple-label-first-char = ALPHA / "_"
simple-label-next-char = ALPHANUM / "-" / "/" / "_"
simple-label = simple-label-first-char *simple-label-next-char
And:
keyword =
if / then / else
...
The prohibition on keywords in simple-label
is different from the non-reserved-label
constraint, which is about built-ins (for example DhallJ will parse { True: Text }
with no complaints, since True
is a built-in but not a keyword).
So right now you'd have to use a quoted label for if
:
scala> val Right(expr) = """{ `if` : Text }""".parseExpr
expr: org.dhallj.core.Expr = {`if` : Text}
If the spec is wrong or I'm misreading it I'm happy to make this change. @Gabriel439, do you happen to know whether we should consider the Haskell implementation correct on this?
from dhallj.
Ah yes, I missed that constraint, it should be rejected (or the standard should be changed).
from dhallj.
@travisbrown: From my reading of the standard the Haskell implementation is not compliant. It's easy to fix, though, and I created a ticket to track this work: dhall-lang/dhall-haskell#1750
from dhallj.
@Gabriel439 Thanks! @amesgen Mind if I close this for now?
from dhallj.
Yes, thanks for the very quick responses!
from dhallj.
Related Issues (20)
- Investigate whether Paths.get is safe across platforms
- Incorrect home page in Maven repository HOT 2
- Leverage Truffle? HOT 1
- Unions don't seem to be typechecked correctly HOT 2
- Are there any Java examples for reading dhall files? HOT 1
- root directory for imports HOT 7
- cannot parse string literals with a # HOT 4
- YAML export escapes newlines HOT 2
- Fix DontCacheIfHash test
- Fix with precedence
- Parse quoted URLs correctly HOT 2
- Investigate CirceConverterSuite round-trip test failures HOT 1
- Run type-inference/success/prelude acceptance test HOT 2
- Document identifier index limit
- YAML export escapes quotes HOT 3
- Set up JavaScript build HOT 8
- Import resolution against consul/etcd
- Fill in gaps in single-quoted literal support
- dhall-scala dependency is broken: dhall-ast not found HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dhallj.