Anyone interested in a Spirit for D?
Walter Bright
newshound at digitalmars.com
Wed Oct 18 14:12:41 PDT 2006
Bill Baxter wrote:
> But given Don's experiments with compile-time text parsing in D, it's
> conceivable that in D the above parser could just be created with:
>
> r = make_parser("real_number (',' real_number)*");
>
> I.e. use the EBNF version directly in a string literal that gets parsed
> at compile time.
> That would be pretty cool.
Yes, it would be. But there's a catastrophic problem with it. Spirit
enables code snippets to be attached to terminals by overloading the []
operator. If the EBNF was all in a string literal, this would be impossible.
> Though, you know, even thinking about Boost::Spirit, I have to wonder if
> it really is necessary. From the intro it says that it's primary use is
> "extremely small micro-parsers", not a full blown language processor.
> But if that's the target then the runtime overhead of translating the
> EBNF description to a parser would be pretty trivial. So I guess the
> real benefit of a compile-time parser-generator is that your grammar can
> be _verified_ at compile-time.
I disagree. I think the real benefit is avoiding reliance on an add-on
tool. Such tools are a nuisance; making archival, maintenance, etc., clumsy.
> At any rate the Spirit documentation seems to be rife with juicy
> comments of the form "yes it looks funky, but we're stuck with C++
> here". So it's a good place to get ideas for how to make things better.
Yup.
More information about the Digitalmars-d
mailing list