本文整理汇总了C++中qi类的典型用法代码示例。如果您正苦于以下问题:C++ qi类的具体用法?C++ qi怎么用?C++ qi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了qi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:GISpecialist,项目名称:mapnik,代码行数:32,代码来源:dasharray_parser.hpp
示例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")
;
}
开发者ID:CCJY,项目名称:coliru,代码行数:9,代码来源:main.cpp
示例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;
}
开发者ID:nfomon,项目名称:shok,代码行数:53,代码来源:Compiler.cpp
示例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)]
)
;
}
开发者ID:LancelotGHX,项目名称:Simula,代码行数:13,代码来源:string_token_id.cpp
示例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))
]
;
}
开发者ID:kamrann,项目名称:workbase,代码行数:16,代码来源:repeat_remove_cmd_parser.cpp
示例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;
}
开发者ID:CCJY,项目名称:coliru,代码行数:33,代码来源:main.cpp
示例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;
}
开发者ID:jiayuehua,项目名称:hello-panda-project,代码行数:28,代码来源:parse_int_number.cpp
示例8:
best_cmd_parser< Iterator >::best_cmd_parser():
best_cmd_parser::base_type(start)
{
using qi::lit;
start =
lit("best")[phx::nothing]
;
}
开发者ID:kamrann,项目名称:workbase,代码行数:9,代码来源:best_cmd_parser.cpp
示例9:
chart_cmd_parser< Iterator >::chart_cmd_parser():
chart_cmd_parser::base_type(start)
{
using qi::lit;
start =
lit("chart")
[phx::nothing]
// >> enum_vals
;
}
开发者ID:kamrann,项目名称:workbase,代码行数:11,代码来源:chart_cmd_parser.cpp
示例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 {" );
}
开发者ID:DerOrfa,项目名称:isis,代码行数:13,代码来源:VistaSaParser.hpp
示例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{})
]
;
}
开发者ID:kamrann,项目名称:workbase,代码行数:13,代码来源:repeat_add_cmd_parser.cpp
示例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{})
]
;
}
开发者ID:kamrann,项目名称:workbase,代码行数:13,代码来源:debug_cmd_parser.cpp
示例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;
}
开发者ID:fadushin,项目名称:sandbox,代码行数:23,代码来源:num_list4.cpp
示例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)]];
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:14,代码来源:sexpr_parser.hpp
示例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 );
}
开发者ID:biot023,项目名称:spirittuts,代码行数:15,代码来源:num_list3.cpp
示例16: body
function<Iterator, Lexer>::function(
error_handler<typename Lexer::base_iterator_type, Iterator>& error_handler
, Lexer const& l)
: function::base_type(start), body(error_handler, l)
{
qi::_1_type _1;
qi::_2_type _2;
qi::_3_type _3;
qi::_4_type _4;
qi::_val_type _val;
using qi::on_error;
using qi::on_success;
using qi::fail;
using boost::phoenix::function;
typedef client::error_handler<typename Lexer::base_iterator_type, Iterator>
error_handler_type;
typedef function<error_handler_type> error_handler_function;
typedef function<client::annotation<Iterator> > annotation_function;
identifier = body.expr.identifier;
argument_list = -(identifier % ',');
start = (l.token("void") | l.token("int"))
> identifier
> '(' > argument_list > ')'
> (';' | '{' > body > '}')
;
// Debugging and error handling and reporting support.
BOOST_SPIRIT_DEBUG_NODES(
(identifier)
(argument_list)
(start)
);
// Error handling: on error in start, call error_handler.
on_error<fail>(start,
error_handler_function(error_handler)(
"Error! Expecting ", _4, _3));
// Annotation: on success in start, call annotation.
on_success(identifier,
annotation_function(error_handler.iters)(_val, _1));
}
开发者ID:LancelotGHX,项目名称:Simula,代码行数:47,代码来源:function_def.hpp
示例17: parse_IC_line
optional< p_value_test_case >
parse_IC_line( Iterator first, Iterator last )
{
using qi::double_;
using qi::_1;
using qi::uint_;
using qi::phrase_parse;
using ascii::space;
using boost::phoenix::ref;
optional< p_value_test_case > result;
/// Will look like "N=2; IC=1.57184,1.57184,1.57184,1.22985,1.22985,1.57184,1.57184,1.22985"
size_t N;
if( phrase_parse( first, last, "N=" >> uint_ >> "; IC=", space, N ) ) {
result.reset( p_value_test_case( N ) );
if( ! phrase_parse( first, last, double_ % ",", space, result->ICs ) ) {
result = optional< p_value_test_case >(); // reset
}
}
return result;
}
开发者ID:JohnReid,项目名称:STEME,代码行数:23,代码来源:parse.cpp
示例18: main
int
main()
{
using spirit_test::test_attr;
namespace qi = boost::spirit::qi;
using qi::attr;
using qi::double_;
{
double d = 0.0;
BOOST_TEST(test_attr("", attr(1.0), d) && d == 1.0);
double d1 = 1.0;
BOOST_TEST(test_attr("", attr(d1), d) && d == 1.0);
std::pair<double, double> p;
BOOST_TEST(test_attr("1.0", double_ >> attr(1.0), p) &&
p.first == 1.0 && p.second == 1.0);
char c = '\0';
BOOST_TEST(test_attr("", attr('a'), c) && c == 'a');
std::string str;
BOOST_TEST(test_attr("", attr("test"), str) && str == "test");
}
{ // testing lazy constructs
using boost::phoenix::val;
using boost::phoenix::ref;
double d = 0.0;
BOOST_TEST(test_attr("", attr(val(1.0)), d) && d == 1.0);
double d1 = 2.0;
BOOST_TEST(test_attr("", attr(ref(d1)), d) && d == 2.0);
}
{
std::string s;
BOOST_TEST(test_attr("s", "s" >> qi::attr(std::string("123")), s) &&
s == "123");
}
return boost::report_errors();
}
开发者ID:LancelotGHX,项目名称:Simula,代码行数:45,代码来源:attr.cpp
示例19: parse_numbers
bool parse_numbers(Iterator first, Iterator last, std::vector<double>& v)
{
using qi::double_;
using qi::phrase_parse;
using qi::_1;
using ascii::space;
using phoenix::push_back;
using phoenix::ref;
bool r = phrase_parse(first, last,
// Begin grammar
(
double_[push_back(ref(v), _1)] % ','
)
,
// End grammar
space);
if (first != last) // fail if we did not get a full match
return false;
return r;
}
开发者ID:Ruinland,项目名称:boost-doc-zh,代码行数:24,代码来源:num_list3.cpp
示例20: expr
statement<Iterator, Lexer>::statement(
error_handler<typename Lexer::base_iterator_type, Iterator>& error_handler
, Lexer const& l)
: statement::base_type(statement_list), expr(error_handler, l)
{
qi::_1_type _1;
qi::_2_type _2;
qi::_3_type _3;
qi::_4_type _4;
qi::_val_type _val;
qi::tokenid_mask_type tokenid_mask;
using qi::on_error;
using qi::on_success;
using qi::fail;
using boost::phoenix::function;
typedef client::error_handler<typename Lexer::base_iterator_type, Iterator>
error_handler_type;
typedef function<error_handler_type> error_handler_function;
typedef function<client::annotation<Iterator> > annotation_function;
statement_list =
+statement_
;
statement_ =
variable_declaration
| assignment
| compound_statement
| if_statement
| while_statement
| return_statement
| expr
| ';'
;
variable_declaration =
l("int")
> expr.identifier
> -(l("=") > expr)
> ';'
;
assignment =
expr.identifier
> tokenid_mask(token_ids::op_assign)
> expr
> ';'
;
if_statement =
l("if")
> '('
> expr
> ')'
> statement_
>
-(
l("else")
> statement_
)
;
while_statement =
l("while")
> '('
> expr
> ')'
> statement_
;
compound_statement =
'{' >> -statement_list >> '}'
;
return_statement =
l("return")
> -expr
> ';'
;
// Debugging and error handling and reporting support.
BOOST_SPIRIT_DEBUG_NODES(
(statement_list)
(statement_)
(variable_declaration)
(assignment)
(if_statement)
(while_statement)
(compound_statement)
(return_statement)
);
// Error handling: on error in statement_list, call error_handler.
on_error<fail>(statement_list,
error_handler_function(error_handler)(
"Error! Expecting ", _4, _3));
//.........这里部分代码省略.........
开发者ID:LancelotGHX,项目名称:Simula,代码行数:101,代码来源:statement_def.hpp
注:本文中的qi类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论