Underscore not allowed after first decimal digit
waldemarhorwat opened this issue · 10 comments
The numeric separator grammar currently allows 12_34 but not 1_234. I doubt that's the intent; please fix it.
Yep, certainly not the intent. Will look more carefully in a bit. Otherwise, @rwaldron fyi.
@waldemarhorwat here's the current grammar
DecimalDigits ::
DecimalDigit
DecimalDigits DecimalDigit
DecimalDigits NumericLiteralSeparator DecimalDigit
DecimalDigits expands into DecimalDigit. Am I misunderstanding something?
It's not immediately clear to me either how 1_234
wouldn't parse.
Yes, you're misunderstanding the grammar you wrote in this proposal. Try to parse 1_234
as a NumericLiteral with that grammar. It expands to the DecimalLiteral production, which expands into a DecimalIntegerLiteral production (with the optional ExponentPart omitted), which you defined as follows:
DecimalIntegerLiteral ::
0
NonZeroDigit DecimalDigits opt
As I illustrated in the example, this grammar does not allow an underscore to occur between the first digit and the subsequent digits.
which you defined as follows:
DecimalIntegerLiteral ::
0
NonZeroDigit DecimalDigits opt
We didn't define that at all, that grammar is copied directly from the current spec, to provide context, with our additions appearing with a green highlight. Anyway, I see the issue now, and I'll work on revising the grammar.
We didn't define that at all, that grammar is copied directly from the current spec, to provide context, with our additions appearing with a green highlight.
It's part of the grammar you're proposing. Hair-splitting like that is not productive.
@rwaldron @waldemarhorwat fwiw the latest production seems OK with me. Would def fix the issue.
Yes, that works.
Thanks @waldemarhorwat!