Reputation: 4178
I have a couple of symbol tables on which I want to inhibit partial matching.
Reading across some questions, I figured it can be done using the distinct directive
.
However, adding distinct(char_("a-zAZ09_"))[no_case[my_symb_1]];
each time a symbol table is referenced in the grammar is reducing readability. So I tried to make a rule that accepts a symbol table and returns its matching value:
qi::rule<Iterator, Operation(const qi::symbols<char, Operation>&)> no_partial_match;
no_partial_match %= distinct(char_("a-zAZ09_"))[no_case[lazy(_r1)]];
And use it later in the grammar:
some_rule = no_partial_match(my_symb_1) >> int_;
but it fails with:
const boost::spirit::qi::symbols<char,Operation,boost::spirit::qi::tst<Char,T>,boost::spirit::qi::tst_pass_through>::adder
&boost::spirit::qi::symbols<Char,T,boost::spirit::qi::tst<Char,T>,boost::spirit::qi::tst_pass_through>::adder::operator
()(const Iterator &,const Iterator &,const T &) const': expects 3 arguments - 1 provided
How to achieve this?
(PS: I'm aware of the generic solution provided in the comments here, but I'm looking for a simpler approach for this specific symbol table signature and not a generic one.)
Upvotes: 0
Views: 116
Reputation: 4178
Got it, has to wrap the symbol table in phx::ref(...)
like this
some_rule = no_partial_match(phx::ref(my_symb_1)) >> int_;
Upvotes: 1