Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow trailing delimiters #956

Merged
merged 4 commits into from Jun 25, 2020
Merged

Conversation

Nadrieril
Copy link
Member

Fixes #512.
I discovered that the grammar allowed { , = } for an empty record literal. I'm not sure if we want to keep that.

Copy link
Contributor

@Gabriella439 Gabriella439 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be fine with removing support for {, = } but I don't have strong opinions either way. That was an oversight from my attempt to standardize leading commas and not something I carefully thought through

@Profpatsch
Copy link
Member

Profpatsch commented Apr 15, 2020

Doesn’t allowing a trailing delimiter require backtracking all the way in parsers? I implemented that for the nix parser some time ago, but we scrapped it because of that.

@Gabriella439
Copy link
Contributor

Gabriella439 commented Apr 15, 2020

@Profpatsch: I believe it's still doable without full backtracking. Using commas as an example, after parsing any given comma-separated element you parse one of:

    try ("," *> "})
<|> "}"
<|> ("," *> parseElement *> parseRest)

... which limits backtracking to a limited number of characters

@Nadrieril
Copy link
Member Author

Isn't that lookahead rather than backtracking then ? I don't remember that being a performance sink

@Nadrieril
Copy link
Member Author

Does anyone object to this then ?

Copy link
Collaborator

@philandstuff philandstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have tests for the case of having both a leading and a trailing delimiter? eg [ , 3 , ] is valid according to the new ABNF.

@Gabriella439
Copy link
Contributor

@Nadrieril: I still think this proposal is a good idea

@Gabriella439
Copy link
Contributor

I think this is ready to be merged

@Nadrieril
Copy link
Member Author

Yeah sorry I haven't had the bandwidth for dhall recently, and I wanted to add the tests that @philandstuff suggested

@Nadrieril Nadrieril merged commit 0c899ab into dhall-lang:master Jun 25, 2020
@Nadrieril Nadrieril deleted the trailing-delims branch June 25, 2020 17:45
Gabriella439 added a commit to dhall-lang/dhall-haskell that referenced this pull request Jun 26, 2020
mergify bot pushed a commit to dhall-lang/dhall-haskell that referenced this pull request Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow trailing delimiters
6 participants