本文整理汇总了C++中qi类的典型用法代码示例。如果您正苦于以下问题:C++ qi类的具体用法?C++ qi怎么用?C++ qi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了qi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_dasharray
bool parse_dasharray(Iterator first, Iterator last, std::vector<double>& dasharray)
{
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using qi::lit;
using qi::char_;
#if BOOST_VERSION > 104200
using qi::no_skip;
#else
using qi::lexeme;
#endif
using phoenix::push_back;
// SVG
// dasharray ::= (length | percentage) (comma-wsp dasharray)?
// no support for 'percentage' as viewport is unknown at load_map
//
bool r = phrase_parse(first, last,
(double_[push_back(phoenix::ref(dasharray), _1)] %
#if BOOST_VERSION > 104200
no_skip[char_(", ")]
#else
lexeme[char_(", ")]
#endif
| lit("none")),
qi::ascii::space);
if (first != last)
{
return false;
}
return r;
}
示例2: Event_Bool_No_Param
Event_Bool_No_Param ()
: Event_Bool_No_Param::base_type(start)
{
using qi::lit;
start =
lit("STATE_TIMEOUT") | lit("RAMPING_COMPLETED") | lit("PASSIVE_MEAS_COMPLETED")
;
}
示例3: in_begin
bool Compiler::execute() {
using phoenix::ref;
using qi::lit;
using qi::no_skip;
// iterate over stream input
typedef std::istreambuf_iterator<char> base_iterator_type;
base_iterator_type in_begin(m_input);
// convert input iterator to forward iterator, usable by spirit parser
typedef spirit::multi_pass<base_iterator_type> forward_iterator_type;
forward_iterator_type fwd_begin = spirit::make_default_multi_pass(in_begin);
forward_iterator_type fwd_end;
// Initialize global scope
Scope globalScope;
StdLib::Init(globalScope);
// Parsers
ExpParser<forward_iterator_type> exp_;
CmdParser<forward_iterator_type> cmd_(exp_);
CodeParser<forward_iterator_type> code_(exp_);
typedef qi::rule<forward_iterator_type, std::string(), ascii::space_type> StringRule;
typedef qi::rule<forward_iterator_type, ascii::space_type> VoidRule;
StringRule cmdline_ =
lit('[')
> (cmd_(ref(globalScope)) | code_(ref(globalScope)))
> lit(']')
;
VoidRule program_ = +(
cmdline_[ref(m_output) << qi::_1]
> -no_skip[ lit("\n")[ref(m_output) << endl] ]
);
//BOOST_SPIRIT_DEBUG_NODE(cmdline_);
//BOOST_SPIRIT_DEBUG_NODE(program_);
bool r = qi::phrase_parse(
fwd_begin, fwd_end,
program_,
ascii::space
);
if (!r || fwd_begin != fwd_end) {
return false;
}
// Cleanup the global scope :)
m_output << globalScope.bytecode() << endl;
return r;
}
示例4: word_count_grammar
word_count_grammar(TokenDef const&)
: word_count_grammar::base_type(start)
, w(0), c(0), a(0)
{
using boost::phoenix::ref;
using qi::token;
start = *( token(IDWORD) [++ref(w)]
| token(IDCHAR) [++ref(c)]
| token(IDANY) [++ref(a)]
)
;
}
示例5: lit
repeat_remove_cmd_parser< Iterator >::repeat_remove_cmd_parser():
repeat_remove_cmd_parser::base_type(start)
{
using qi::lit;
using qi::uint_;
using qi::_val;
using qi::_1;
start =
(lit("remove") | lit("rm") | lit("r")) >>
uint_
[
_val = phx::construct< repeat_remove_cmd >(_1 - phx::val(1u))
]
;
}
示例6: main
int main()
{
namespace spirit = boost::spirit;
namespace qi = spirit::qi;
namespace phoenix = boost::phoenix;
namespace ascii = spirit::ascii;
using qi::rule;
using qi::int_;
using qi::_1;
using qi::_val;
using qi::phrase_parse;
using boost::shared_ptr;
using boost::make_shared;
shared_ptr<int> x = make_shared<int>(123);
std::cout << *x << std::endl;
rule<
std::string::const_iterator
, shared_ptr<int>()
, ascii::space_type
> int_rule_ = int_[_val = new int(_1)];
shared_ptr<int> subject_;
std::string text_ = "12345";
auto result_ = phrase_parse(text_.cbegin(), text_.cend(), int_rule_, ascii::space, subject_);
std::cout << (result_ ? "passed" : "failed") << *subject_ << std::endl;
}
示例7: parse_int_number_main
int parse_int_number_main()
{
namespace qi = boost::spirit::qi;
using qi::parse;
using qi::phrase_parse;
using qi::int_;
using qi::double_;
using qi::ascii::space;
using qi::_1;
using boost::phoenix::ref;
using boost::phoenix::push_back;
char * a = "(12e2,12223)";
char * a_end = a+strlen(a) ;
char * b = "(1233)";
char * b_end = b+strlen(b);
char * c = "1 , 2,3,4,5,6,7,8,10,13";
char * c_end = b+strlen(b) ;
int n = 0;
std::vector<int> iv;
phrase_parse(c,c_end, int_%',', space, iv);
std::ostream_iterator <int> oi(std::cout, ",");
boost::copy(iv,oi);
std::cout<<"\n";
return 0;
}
示例8:
best_cmd_parser< Iterator >::best_cmd_parser():
best_cmd_parser::base_type(start)
{
using qi::lit;
start =
lit("best")[phx::nothing]
;
}
示例9:
chart_cmd_parser< Iterator >::chart_cmd_parser():
chart_cmd_parser::base_type(start)
{
using qi::lit;
start =
lit("chart")
[phx::nothing]
// >> enum_vals
;
}
示例10: vista_header_grammer
vista_header_grammer() : vista_header_grammer::base_type ( vista_header ) {
using qi::lit;
using qi::lexeme;
using ascii::char_;
using ascii::string;
using namespace qi::labels;
using phoenix::at_c;
using phoenix::push_back;
start_tag = lit ( "V-data 2 {" );
}
示例11:
repeat_add_cmd_parser< Iterator >::repeat_add_cmd_parser():
repeat_add_cmd_parser::base_type(start)
{
using qi::lit;
using qi::_val;
start =
lit("add")
[
_val = phx::val(repeat_add_cmd{})
]
;
}
示例12:
debug_cmd_parser< Iterator >::debug_cmd_parser():
debug_cmd_parser::base_type(start)
{
using qi::lit;
using qi::_val;
start =
lit("dbg")
[
_val = phx::val(debug_cmd{})
]
;
}
示例13: parse_numbers
bool parse_numbers(Iterator first, Iterator last, std::vector<double>& v)
{
using qi::char_;
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using ascii::space;
const char c = ';';
bool r = phrase_parse(first, last,
// Begin grammar
(
double_ % char_(',')
)
,
// End grammar
space, v);
if (first != last) // fail if we did not get a full match
return false;
return r;
}
示例14: tagger
tagger(F f_ = F()) : tagger::base_type(start), f(f_)
{
using qi::omit;
using qi::raw;
using qi::eps;
using qi::lit;
using qi::_1;
using qi::_r1;
using qi::_r2;
start = omit[raw[lit(_r2)] [f(_r1, _1)]];
epsilon = omit[raw[eps] [f(_r1, _1)]];
}
示例15: parse_numbers
bool parse_numbers( Iterator first, Iterator last, vector<double> &v )
{
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using ascii::space;
using phoenix::push_back;
bool r( phrase_parse( first, last,
(
double_[ push_back( phoenix::ref( v ), _1 ) ] % ','
),
space ) );
return ( first == last ? r : false );
}