Correct forum for discussing documentation issues?
Andre Artus
andre.artus at gmail.com
Sat Aug 3 07:58:44 PDT 2013
On Saturday, 3 August 2013 at 12:22:48 UTC, Peter Alexander wrote:
> On Saturday, 3 August 2013 at 11:22:42 UTC, Andre Artus wrote:
>> I'm not sure that I am explaining this properly as it seems
>> that at least 2 different people were under the impression I
>> was making a point quite different from the one I was trying
>> to make.
>
> I understand. It seems that there are two "ways" that a static
> import declaration can be produced in the grammar.
>
> I'm not sure if it counts as a bug, or just a redundant
> production (but then, where are the redundant productions for
> "public import" etc.?)
>
> I'm not an expert on formal grammar specifications, so I don't
> know if redundant productions are okay or not. I'm also never
> sure where you draw the line between parsing and semantic
> analysis (the grammar allows "override import", is that okay?).
> I'm guessing you would formally say that the grammar is
> ambiguous at the production level, but non-ambiguous after
> semantic analysis.
>
> So, I think you're right, but I don't know if it's a bug or not.
I poked around in the DMD parser's source (parse.{c|h}) which
doesn't seem too difficult to follow (I take it it's handwritten,
not generated). But until I step through it with a debugger or
create a trace log I'm not going to be confident.
As I read it the parser implements "static import" as shown in
the spec (which is easier with a handwritten parser).
It's not a huge problem; just that people trying to write an
input file for a parser generator may run into issues around
disambiguation which could be confusing if they don't understand
what is going on: the repetition (in the spec) is [I believe] a
reflection of an implementation detail, probably to speed up the
common path.
I did a search for D grammars online before ultimately embarking
on my own as I could not find one that could parse any
non-trivial D source. And I am yet to find one that parses the
imports in all it's possible manifestations.
More information about the Digitalmars-d
mailing list