Re: [proto] Externalizing grammar pattern matching

2010-11-23 Thread Eric Niebler
On 11/23/2010 2:18 PM, joel falcou wrote:
> On 23/11/10 17:20, Eric Niebler wrote:
>> On 11/23/2010 10:19 AM, Joel Falcou wrote:
>>> So, question is: is there a way to have an extensible list of
>>> when  that can be extended "from the outside", something
>>> like a proto::switch_ but with patterns instead of tag ?
>> No. The best you can do is document how to define a new Proto algorithm
>> from an old one:
>>
>>struct Old : proto::or_<  ...>  {};
>>
>>struct New : proto::or_<  my_stuff, Old>  {};
>>
>> Now everywhere in your library that you have the Old algorithm
>> hard-coded, you need to make it a template parameter so that your stuff
>> can be used with an extended algorithm.
> Can't the new extrnal_transform be of any help ?

No. You're not adding transforms. You're adding grammar rules. The
external transforms and proto::switch_ are extensible because they have
unique types off of which to key: rules and tags. There is no unique
type off of which to key in order to add new grammar rules. Phoenix uses
custom tag types with switch_. That's, or my above suggestion, are your
best bets.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com
___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


Re: [proto] Externalizing grammar pattern matching

2010-11-23 Thread joel falcou

On 23/11/10 17:20, Eric Niebler wrote:

On 11/23/2010 10:19 AM, Joel Falcou wrote:

So, question is: is there a way to have an extensible list of
when  that can be extended "from the outside", something
like a proto::switch_ but with patterns instead of tag ?

No. The best you can do is document how to define a new Proto algorithm
from an old one:

   struct Old : proto::or_<  ...>  {};

   struct New : proto::or_<  my_stuff, Old>  {};

Now everywhere in your library that you have the Old algorithm
hard-coded, you need to make it a template parameter so that your stuff
can be used with an extended algorithm.

Can't the new extrnal_transform be of any help ?

___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


Re: [proto] Externalizing grammar pattern matching

2010-11-23 Thread Eric Niebler
On 11/23/2010 10:19 AM, Joel Falcou wrote:
> So, question is: is there a way to have an extensible list of
> when that can be extended "from the outside", something
> like a proto::switch_ but with patterns instead of tag ?

No. The best you can do is document how to define a new Proto algorithm
from an old one:

  struct Old : proto::or_< ... > {};

  struct New : proto::or_< my_stuff, Old > {};

Now everywhere in your library that you have the Old algorithm
hard-coded, you need to make it a template parameter so that your stuff
can be used with an extended algorithm.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com
___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


[proto] Externalizing grammar pattern matching

2010-11-23 Thread Joel Falcou

Here is some classical pattern matching using proto::or_

https://gist.github.com/711891

This is pretty canonical I guess (unless my proto-fu is rusting).
As stated in the comments, my main concern is that adding new 
pattern->value rules need to edit or_<>. Also classical.


For a long time it didn't bothered me until I needed to ship some code
doing this AND wanting to be extended by random contributors to add new 
patterns.


I brainstormed and conjured something like:

https://gist.github.com/711895

(hold your horses on the crappiness of my MPL, it's a quick'n'dirty demo 
code trying to get around the fact that mpl::pair, for whatever silly 
reason, IS NOT a MPL RandomAccessSequence :| )


So it's slightly better. Now I dont have to touch the or_<>, just the
mpl::vector. Close but no cigare.

After some other hours, I found a way to make a MPL map look-a-like 
where the insertion is external:


https://gist.github.com/711906

Alas, i can't find a way to put a decent mpl::iterator over this so both 
puzzles pieces fits.



So, question is: is there a way to have an extensible list of 
when that can be extended "from the outside", something

like a proto::switch_ but with patterns instead of tag ?

My daydream being something akin to :

https://gist.github.com/711914

So, now, I'll be grateful if you can answer this by some "you moron, use 
X" :D

___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto