Dhall-lang: EBNF grammar does not acknowledge hex and octal literals

Created on 29 Jan 2019  路  4Comments  路  Source: dhall-lang/dhall-lang

The rules for natural-literal and integer-literal are as follows:

natural-raw = 1*DIGIT

integer-literal = ( "+" / "-" ) natural-raw whitespace

natural-literal = natural-raw whitespace

But dhall-haskell is happy to parse hex literals such as 0x1f or octal literals such as 0o17, for integers (with leading +/-) and naturals (without).

Should the standard grammar have rules for hex and octal literals? If so, would you accept a PR adding them?

(Related question: should this also apply to de Bruijn indices? dhall-haskell accepts \(x : Natural) -> \(x: Natural) -> x@0x1 but that subjectively feels icky, and I wonder if this is more by accident than design?)

Most helpful comment

Oh yeah, then I think the right thing to do here is to fix the Haskell implementation to match the current standard. The reason it deviates is because I was lazy and used a predefined parser for parsing integer literals, but I can fix that

All 4 comments

What's the use case you have in mind for hex or octal literals?

Also, technically this is not a concern of the standard, but another thing to consider here is that dhall format would likely not preserve hex literals even if they were standardized since I presume any proposal to do so would not change the internal representation in the syntax tree

I don't have a use case at all, I don't mind one way or the other. However, I read your year in review post and saw:

Last year I promised to upstream all features from the Haskell implementation into the language standard, since at the time a few import-related features were implementation-defined. This was a top priority because I didn鈥檛 want to treat other language bindings as second-class citizens.

This year we successfully standardized everything, meaning that there should no longer be any implementation-defined features.

so I assumed that differences between the haskell implementation and the standard, such as in this issue, were something you were working to remove. If I have misunderstood, please feel free to close the issue.

Oh yeah, then I think the right thing to do here is to fix the Haskell implementation to match the current standard. The reason it deviates is because I was lazy and used a predefined parser for parsing integer literals, but I can fix that

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philandstuff picture philandstuff  路  4Comments

Nadrieril picture Nadrieril  路  6Comments

f-f picture f-f  路  6Comments

saurabhnanda picture saurabhnanda  路  4Comments

singpolyma picture singpolyma  路  5Comments