当前位置: 首页>>代码示例>>C++>>正文


C++ qi::on_success方法代码示例

本文整理汇总了C++中qi::on_success方法的典型用法代码示例。如果您正苦于以下问题:C++ qi::on_success方法的具体用法?C++ qi::on_success怎么用?C++ qi::on_success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qi的用法示例。


在下文中一共展示了qi::on_success方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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

示例2: 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::on_success方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。