On Monday, 8 April 2013 at 21:50:12 UTC, Christopher Bergqvist
wrote:
On Tuesday, 2 April 2013 at 19:00:21 UTC, Tobias Pankrath wrote:
I'm wondering if it's possibly to mechanically check that
what's in the grammar is how DMD behaves.
Take the grammar and (randomly) generate strings with it and
check if DMD does complain. You'd need a parse only don't
check semantics flag, though.
This will not check if the strings are parsed correctly by DMD
nor if invalid strings are rejected. But it would be a start.
An alternative idea for ensuring that documentation and
implementation are in sync might be to list the full grammar
definition as a data structure that can both be used as input
for the parser and as input for a tool that generates the
documentation. Theoretically possible, :) just look at
Philippe Sigaud's Pegged.
I know but the parser is currently hand written and I think
Walter will only accept an auto generated parser if it is as fast
as the current solution.
However in an old discussion someone said that the D grammar
isn't LALR(1) or LR(1), so I don't think that is possible with
current D parser generators. Do we have a pegged grammar for D?
Another think is that for documentation purposes you might want
to have an more readable but ambiguous grammar than your
generator of choice will accept.