Import conflict resoultion
kellywilson at nowhere.com
kellywilson at nowhere.com
Fri Jul 14 09:37:05 PDT 2006
Hey Kris and Jeremy,
Kris: You are correct that this construct will not have much of an effect on the
dmd frontend, as far a parsing goes (semantically, it shouldn't be a big issue
either, I believe). As far as the ":" or "as" keywords being \noise\, they are
actually TERMINALS in my grammar and thus can be "ignored" if there is anther
rule that matches the input without said terminals. ie:
nonterm(Decl*) ImportDeclaration {
-> IMPORT x:ImportNames SEMI
-> IMPORT x:ImportNames COLON Identifier SEMI
}
The rules above (the example is in my parser - using Elkhound syntax) show that
we can easily match an "ImportDeclaration" using either "import x.y;" or "import
x.y : something;"
The terminal ":" is a keyword that already exists in the lexer. The terminal
"as" would still be a keyword "in the traditional sense", if used, and would
need to be added to the lexer. It would not be a big deal to add to my lexer or
parser, however.
I assume what Jeremy means by the "context-free" thingy is actually a concern
with added ambiguities or conflicts. My parser doesn't have any extra
ambiguities when adding the ":" or "as" keyword to the ImportDeclaration rule of
the parser. There are no extra conflicts (shift/reduce or reduce/reduce for the
parser guys) added by this new rule, either.
If anyone has any other syntactic additions that they would like to test, I can
easily add them to my parser to check for conflicts/ambiguities. The semantics
will have to be checked by Walter in his frontend. If I find some time soon, I
will try to get my parser code into shape (and upgrade to version 0.162) for
release on dsource.org, so that others can test out new syntax ideas, as well.
Semantic checking may come when version 1.0 is available.
Thanks,
K.Wilson
P.S. Hey Jeremy...D is not without ambiguities in the (0.149) spec/version that
I worked off of. There are several ambiguities that the dmd frontend deals with
(and Walter has discussed before, I believe). I have about 4 ambiguities in my
grammar. I also have a lot of conflicts which are dealt with using default
conflict resolution schemes at the moment (semantic checking, when added, would
deal with some of these conflicts differently).
In article <e96khi$aql$1 at digitaldaemon.com>, kris says...
>
>Jeremy wrote:
>
>> Doesn't the "import a.b.c : a;" syntax break the context-free parsing thingy? I
>> don't know much about it, but couldn't the colon get confused with the colon in
>> "a = b ? 1 : 2;" stuff?
>>
>> - jeremy
>>
>>
>
>Unlikely. The ":" or "as" or whatever is simply /noise/ -- something
>that is primarily optional for the underlying parser. It does depend on
>the parser, but DMD is an RD variety so can handle it without issue. In
>other words, whatever goes in there is not really a keyword in the
>traditional sense?
More information about the Digitalmars-d
mailing list