I'm stuck on some problem that may en dup silly.
I have a DSL defined by the following grammar :
struct dimen_grammar : bp::or_<
//////////////////////////////////////////////////////////////////////////
// Terminals are dimensional values or integral values
//////////////////////////////////////////////////////////////////////////
bp::or_< bp::terminal< dimensionsbp::_,bp::_ >
, integer_grammar
>
//////////////////////////////////////////////////////////////////////////
// dimen can be added together or scaled by an integer
// or shifted left or right by an integer
//////////////////////////////////////////////////////////////////////////
,bp::or_< bp::plus
,bp::multiplies
,bp::multiplies
,bp::shift_left
,bp::shift_right
>
> {};
I've defined a proper callable_context that take care of my special
terminals and built
a terminal class. At this point, everythign works perfect : i can build
expressions and evaluate them.
Now I add a grammar with semantic action that helps me computes an
aspect of those expression :
struct dimen_size : bp::or_<
//////////////////////////////////////////////////////////////////////////
// dimensionnal values terminal contains its own size value
//////////////////////////////////////////////////////////////////////////
bp::when< bp::terminal< dimensionsbp::_,bp::_ >
, dimension_of< bp::_value>()
>
//////////////////////////////////////////////////////////////////////////
// integral values has a size of 1
//////////////////////////////////////////////////////////////////////////
, bp::when()>
//////////////////////////////////////////////////////////////////////////
// size(d1+d2) = max(size(d1),size(d2))
//////////////////////////////////////////////////////////////////////////
, bp::when< bp::plus
, bm::max()
>
//////////////////////////////////////////////////////////////////////////
// size(d1*i) = size(d1)
//////////////////////////////////////////////////////////////////////////
, bp::when< bp::multiplies
, dimen_size(bp::_left)
>
//////////////////////////////////////////////////////////////////////////
// size(i*d2) = size(d2)
//////////////////////////////////////////////////////////////////////////
, bp::when< bp::multiplies
, dimen_size(bp::_right)
>
//////////////////////////////////////////////////////////////////////////
// size(d1<
, dimen_size(bp::_left)
>
//////////////////////////////////////////////////////////////////////////
// size(d1>>i) = size(d1)
//////////////////////////////////////////////////////////////////////////
, bp::when< bp::shift_right
, dimen_size(bp::_left)
>
//////////////////////////////////////////////////////////////////////////
// Other returns 0
//////////////////////////////////////////////////////////////////////////
, bp::when()>
> {};
This works. If I remove the bp::when()>, it fails
to compile when I try to use a hand-overloaded operator<< for
displaying expression values on standard output.
So, is there anything I missed (like deactivating operator<< in the
grammar somehow ?) ?
Other question :
When defining custom tag to build new function, why does the make_expr
tempalte doesn't do check on its argument
to see if it's match the grammar of the domain it's bound to use ? Seems
I'm forced to add additional layer of SFINAE to prevent those
function to get called on w/e types.
Thanks in advance for help
--
___________________________________________
Joel Falcou - Assistant Professor
PARALL Team - LRI - Universite Paris Sud XI
Tel : (+33)1 69 15 66 35