Subject: Re: [proto] : How to use complex grammars in a domain/extension
From: Eric Niebler (eric_at_[hidden])
Date: 2010-09-21 09:51:10
(proto lists members, see this thread for the rest of the discussion,
which has been happening on -users:
On 9/21/2010 9:19 AM, Roland Bock wrote:
> On 09/21/2010 11:55 AM, Thomas Heller wrote:
>> Solved the mistery. here is the code, explanation comes afterward:
>> So, everything works as expected!
> wow, this was driving me crazy, thanks for solving and explaining in all
> the detail! :-)
> I am still not sure if this isn't a conceptual problem, though:
> The "equation" grammar is perfectly OK. But without or-ing it with the
> "addition" grammar, the extension does not allow ANY valid expression to
> be created. I wonder if that is a bug or a feature?
It's a feature. Imagine this grammar:
, proto::nary_expr<proto::_, proto::vararg<IntsOnlyPlease> >
And a integer terminal "i" in a domain that obeys this grammar. Now,
what should this do:
i + "hello!";
You want it to fail because if it doesn't, you would create an
expression that doesn't conform to the domain's grammar. Right? Proto
accomplishes this by enforcing that all operands must conform to the
domain's grammar *and* the resulting expression must also conform.
Otherwise, the operator is disabled.
Anything else would be fundamentally broken.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Proto list run by eric at boostpro.com