Hello Ellery,

On 06/13/2010 03:15 PM, BCS wrote:

Right now we have two semi-official definitions of the D grammar; the
docs (that are wrong) and the parser source (that is effectively
unreadable by most people). I would like to propose a solution to
this problem: eliminate one of them and derive it from the other.

In the past, Walter has expressed a dislike of parser generators. I
doubt you can get him to change his mind on that one, especially since
most parser generators won't be able to handle D anyways, and I doubt
any of them will be able to handle D efficiently (what are they called
- GLR parser generators? Don't know about these).

I was very careful to leave both options open in the way I phrased that ;).


As far as analysing parse.c goes, how much effort is it going to take
to figure out what


void parseSomething()
{

while(1)
switch(token.value){
case x:
parseThis();
continue;
case y:
parseThat();
break;
}
break;
}

}


Something ::= This* That;

The switch is just an optimization. As long as the code is regular enough, it can be analyzed. (I will grant that the resulting grammar might be ambiguous or LL(k) where k is higher than it needs to be)

should look like in a grammar?

Counterproposal: why don't we just fix the grammar?


That would be a start as well as a necessary step in getting a extractor working (to test the tools output against), but if the docs and the parser are maintained separately, the docs will be wrong sooner rather than later.

I know this will be hard to do but it can be done incrementally with
each step making improvements over the last.

The first thing to do is put all of the description of the grammar in
the docs into one place. If the literal text of each production is
replace with a macro reference then the definitions of these macros
can
be put into a single file and expanded everywhere.
The incremental improvement here is that having the grammar in one
place
by it's self will make it easier to check.

I would very much like to see the entire grammar in one place. I can't
tell you how obnoxious it is to search through the entire site to find
one production


A while back I took a pass at pulling the grammar from the HTML via sed so I could stuff in into a parser generator. That it worked is the only good thing I can say about the experience.

And as always, apologies for being a pessimist.

--
... <IXOYE><



Reply via email to