
Maurizio Vitale wrote:
Good day,
The following example conceptually builds on the previous one I've posted (but it is self contained). It requires boost::proto from CVS head, as Eric has fixed one or two bugs. Thanks, Eric!
No problem!
What it does is to define two user defined types, my_int wrapping ints, and my_uint wrapping unsigned ints.
It then defines two grammars, my_grammar which allows arbitrary mix of signed and unsigned quantities and my_segregated_grammar which doesn't allow those incestuous relations.
Furthemore, the example does allow to modify the normal C++ rule for when signed and unsigned are mixed together: define priority to be magnitude_c and you get the standard (and not particularly useful, imho, C/C++ rule). Define priority to be two_complement_c and you get the rule I really need for SystemC: if signed is combined with unsigned, signed win.
Pretty cool. <snip>
The code is public domain. If anybody see something bad in the code, let me know. I've noticed myself the lack of comments, no need to mention it :-)
Looks good to me. -- Eric Niebler Boost Consulting www.boost-consulting.com