D Grammar in BNF Text Form?
Tom Browder via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jun 7 04:41:31 PDT 2014
On Fri, Jun 6, 2014 at 6:24 PM, Brian Schott via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Friday, 6 June 2014 at 23:08:41 UTC, Tom Browder via Digitalmars-d wrote:
>>
>> What about the lexer and parser info on the D lang site in the
>> language reference. Is it current?
>
> https://issues.dlang.org/show_bug.cgi?id=10233
>
> Language changes in D have traditionally started out as compiler changes,
> and then some time later a change is made to the grammar specification.
> Sometimes this process doesn't happen properly and other times it just
> doesn't happen.
>
> I've been trying to keep better track of this so that the specification
> doesn't get too out-of-date.
So the description in grammar.html is the official grammar
specification for the stable dmd compiler. Is there a plain text
version somewhere? If not, it seems to me that one should be created
[I volunteer to do that] and then that should be the definitive source
for the grammar spec (with a program to generate the web page [I
volunteer to do that, too]).
The lexer/grammar text format looks in pretty good shape to
automatically transform into other, slightly different versions for
input into such systems as flex/bison or Regex::Grammars.
Nick Sabalausky earlier said that a GLR parser should be able to
handle D. GNU Bison is supposed to be able to do that and do it
speedily.
I can't say definitively, but Regex::Grammars may also work (it has >
1 lookahead) but would obviously be slower. If it could be made to
work with D, it would be of great utility because it generates very
usable data structures from a successful parse.
Again, my interest is in creating D bindings for a large C library and
to do it auto-magically, and this discussion is very enlightening and
gives me some confidence that it is feasible.
Thanks.
Best regards,
-Tom
More information about the Digitalmars-d
mailing list