Overlapping functionality: IFTI, templates, is-expressions
Russell Lewis
webmaster at villagersonline.com
Wed Mar 19 17:09:28 PDT 2008
BCS wrote:
> Russell Lewis wrote:
>
>> I don't know whether I *need* one...but it's a very fun exercise to
>> write one. I have your svn repository checked out on my machine...but
>> I haven't delved deeping into it, yet. From a cursory inspection, it
>> didn't seem like it fit my needs. But I may be wrong. :)
>
> What do you need/want? Outside not having () groups, crashing on Left
> recursive grammars and a funky syntax for action rules, I think is
> fairly complete. I'm actually starting to work on it again and might be
> able to work in something if you need it.
I don't really have logical reasoning here, so take what I'm about to
say as "the story of what Russ did" instead of "substantive criticism of
any details":
The thing that I stumbled on was that, if I understood you correctly,
your project is a port of the dmd front-end. What I'm looking for is a
parser for the D language which is explicitly not tied to dmd. Not
because dmd is bad (I use it all the time), but because I think that,
for the health of the community, I think we really need more than one
compiler. Ports of dmd don't count, IMHO.
The other thing I'm doing is that I'm experimenting with my new parser
architecture (infill delegates instead of building parse trees in the
first pass), so I don't expect that other parser libraries are likely to
be places to play with that. I posted a description of this parser
architecture in one of my (very few) posts to digitalmars.D.learn
BTW, my current (95% working, just had some corner cases that wouldn't
auto-detect the right specialized templates) parser library uses syntax
like this:
or!(':',
Parse_block, /* parses a nonterminal */
chain!("import", array!(IDENT, ','), ';'),
... many other alternativess ...)
(delegate void(... auto-generated arg types ...)
{
... process successful parse here ...
});
It's far from perfect, but it's fun. It includes the templates
chain!(...) (sequences)
optional!(...) (things that can be skipped)
array!(...) (repeated sequences, with or without dividers)
or!(...) (alternatives)
and they nest nicely.
:)
More information about the Digitalmars-d
mailing list