GithubHelp home page GithubHelp logo

Comments (6)

amesgen avatar amesgen commented on July 27, 2024

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.

travisbrown avatar travisbrown commented on July 27, 2024

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.

amesgen avatar amesgen commented on July 27, 2024

Ah yes, I missed that constraint, it should be rejected (or the standard should be changed).

from dhallj.

Gabriella439 avatar Gabriella439 commented on July 27, 2024

@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.

travisbrown avatar travisbrown commented on July 27, 2024

@Gabriel439 Thanks! @amesgen Mind if I close this for now?

from dhallj.

amesgen avatar amesgen commented on July 27, 2024

Yes, thanks for the very quick responses!

from dhallj.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.