BNF questions and comments
Ary Manzana
ary at esperanto.org.ar
Fri Sep 7 05:55:40 PDT 2007
What you say is very true. That's why I dropped the ANTLR implementation
of the parser for Descent and ported DMD's front-end.
Kirk McDonald wrote:
> BCS wrote:
>> under LinkageType what (from a lexical standpoint) are C, C++, D, etc?
>>
>
> An identifier, an identifier and the ++ operator, and an identifier,
> respectively. This implies that "extern(C ++)" is legal. As with many
> things, the spec simply does not say anything about this.
>
>> ===
>> under Conditional Compilation:
>>
>> ConditionalDeclaration:
>> Condition : Declarations
>>
>> Condition:
>> StaticIfCondition
>>
>> StaticIfCondition:
>> static if ( AssignExpression )
>>
>> allowing this:
>>
>> static if(0==0) : int i;
>>
>> Is this supposed to work? If so what for?
>>
>
> Condition also has the VersionCondition and the DebugCondition in it. It
> is analogous to saying "private:". The block created in this way holds
> until the end of the enclosing block.
>
>> ===
>> The format of the bnf section is not consistent. Off hand:
>> -many productions are missing the :
>> -in most cases operators are unquote but in a few they are
>> -opt is used in a few cases but general omitted in favor of other choices
>> -grouping is used in 1 or 2 cases but again is generally not used.
>> -in two(?) places the "empty" production is used.
>>
>> this all comes from extracting the grammar from the docs. I would like
>> to be able to automate this but having these discrepancies requires
>> that I do it by hand.
>>
>
> I once wrote a D parser in Python, by hand, using the pyparsing library,
> so I'm fairly familiar with the spec's grammar's shortcomings. Nevermind
> about the resulting parser, it was basically useless. But the /process/
> of creating the parser was quite informative. Suffice to say that, yes,
> the spec has quite a lot of holes.
>
> The ultimate guide to the grammar is the DMD front-end source code,
> parse.h and parse.c. (Not to mention lexer.h and lexer.c.) If you
> compare the source to the grammar, it is obvious that the grammar was
> created after the fact. In the cases you've listed -- many of which I
> also listed on the newsgroup, back when I made my parser -- it is
> obvious that it was not created with an overly sharp eye to detail. (If
> you look around for that old thread of mine, I even had lists of what
> the grammar should look like for the missing cases, and where the unused
> cases should appear.)
>
> I mentioned this to Walter at one point at the conference. He knew the
> grammar had issues, but it's simply not a high priority for him.
> However, I suspect that if someone sent him a diff with the various
> documentation fixes, that he might use it.
>
More information about the Digitalmars-d-learn
mailing list