44 #ifdef CEXMC_USE_CUSTOM_FILTER
49 namespace CexmcCustomFilter
51 void Compiler::operator()( ParseResult & parseResult, Action
value )
54 parseResult.action =
value;
58 void Compiler::operator()( ParseResult & parseResult, Subtree &
value )
61 parseResult.expression =
value;
65 void Compiler::operator()( Subtree & ast, Node & node )
const
69 ast = boost::get< Subtree >( node );
71 catch (
const boost::bad_get & )
73 ast.type = Operator( Top );
74 ast.children.push_back( node );
79 void Compiler::operator()( Node &
self, Node &
left, Node &
right,
80 Operator
value )
const
82 Subtree & ast( boost::get< Subtree >(
self ) );
84 ast.children.push_back( left );
87 Subtree * astRight( boost::get< Subtree >( &right ) );
91 ast.children.push_back( right );
95 bool haveSamePriorities(
false );
96 Operator * rightOp( boost::get< Operator >( &astRight->type ) );
99 haveSamePriorities = value.priority == rightOp->priority;
101 if ( value.hasRLAssoc || ! haveSamePriorities )
103 ast.children.push_back( right );
107 Subtree * astDeepestRight( astRight );
115 Subtree * candidate = boost::get< Subtree >(
116 &astDeepestRight->children[ 0 ] );
120 if ( candidate->children.size() < 2 )
123 bool haveSamePriorities_(
false );
124 Operator * candidateOp( boost::get< Operator >(
125 &candidate->type ) );
128 haveSamePriorities_ = value.priority == candidateOp->priority;
132 if ( ! haveSamePriorities_ )
135 astDeepestRight = candidate;
139 astResult.children.push_back( ast.children[ 0 ] );
140 astResult.children.push_back( astDeepestRight->children[ 0 ] );
141 astResult.type =
value;
142 astDeepestRight->children[ 0 ] = astResult;
147 void Compiler::operator()( Node &
self, Node & child, Operator value )
150 Subtree & ast( boost::get< Subtree >(
self ) );
151 ast.children.push_back( child );
156 void Compiler::operator()( Node &
self, Node & primary )
const
160 Subtree * ast( boost::get< Subtree >( &
self ) );
165 Operator * op( boost::get< Operator >( &ast->type ) );
172 void Compiler::operator()( Node &
self, Node & child,
173 std::string & value )
const
175 Subtree & ast( boost::get< Subtree >(
self ) );
177 ast.children.push_back( child );
182 void Compiler::operator()( Leaf &
self, std::string &
name )
const
184 Variable &
variable( boost::get< Variable >(
self ) );
189 void Compiler::operator()( Leaf &
self,
int value,
size_t index )
const
191 Variable &
variable( boost::get< Variable >(
self ) );