2016-03-14 27 views
0

我有幾個符號表,我想禁止部分匹配。將符號表傳遞爲繼承屬性以提升精神規則

通過閱讀一些問題,我認爲可以使用distinct directive來完成。

但是,每次在語法中引用符號表時都會添加distinct(char_("a-zAZ09_"))[no_case[my_symb_1]];,這是降低可讀性的原因。所以,我試圖讓接受一個符號表,並返回其匹配值的規則:

qi::rule<Iterator, Operation(const qi::symbols<char, Operation>&)> no_partial_match; 

no_partial_match %= distinct(char_("a-zAZ09_"))[no_case[lazy(_r1)]]; 

後來在語法使用它:

some_rule = no_partial_match(my_symb_1) >> int_; 

,但它失敗:

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 

如何做到這一點?

PS:我知道在評論here提供通用的解決方案,但我正在尋找這個特定的符號表簽名更簡單的方法,而不是一個通用的一個

回答

1

了它能夠包裝符號表中phx::ref(...)

這樣

some_rule = no_partial_match(phx::ref(my_symb_1)) >> int_;