[dox] Fixing the lexical rule for BinaryInteger

Andre Artus andre.artus at gmail.com
Fri Aug 16 11:52:46 PDT 2013


The documentation on the lexical rules for BinaryInteger 
(http://dlang.org/lex.html#BinaryInteger) has a few issues:

> BinaryInteger:
>    BinPrefix BinaryDigits

The nonterminal BinaryDigits, does not exist.


> BinaryDigitsUS:
>    BinaryDigitUS
>    BinaryDigitUS BinaryDigitsUS

The construction for BinaryDigitsUS currently allows for the 
following:

_(_)*, e.g. 0b_, 0b__, 0b___ etc.


Which is clearly not allowed by the compiler.


I have put up a change on GitHub [1], but there is a clear 
problem. The DMD compiler allows for any of the following 
(reduced cases):

a. 0b__1
b. 0b_1_
c. 0b1__

Whereas my change disallows the second case (b), but is in line 
with how the other integers are specified.

This is a specification problem (limitation of BNF), not an 
implementation problem. In plain English one would just say that 
the BinaryDigitsUS sequence should contain at least one 
BinaryDigit character.

I'm busy working on the HexadecimalInteger, which has related 
issues.

1. 
https://github.com/andre-artus/dlang.org/blob/LexBinaryDigit/lex.dd



More information about the Digitalmars-d mailing list