本文整理汇总了C++中Lexer::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Lexer::begin方法的具体用法?C++ Lexer::begin怎么用?C++ Lexer::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
inline bool
tokenize_and_parse(Iterator& first, Iterator last, Lexer const& lex
, ParserExpr const& xpr, Attribute& attr)
{
// Report invalid expression error as early as possible.
// If you got an error_invalid_expression error message here,
// then the expression (expr) is not a valid spirit qi expression.
BOOST_SPIRIT_ASSERT_MATCH(qi::domain, ParserExpr);
typename Lexer::iterator_type iter = lex.begin(first, last);
return compile<qi::domain>(xpr).parse(
iter, lex.end(), unused, unused, attr);
}
示例2: main
int main() {
std::cout << "Boost version: " << BOOST_LIB_VERSION << std::endl;
std::string input = "33";
char const* inputIt = input.c_str();
char const* inputEnd = &input[input.size()];
Lexer<LexerType> tokens;
LexerType::iterator_type token = tokens.begin(inputIt, inputEnd);
LexerType::iterator_type end = tokens.end();
for (; token->is_valid() && token != end; ++token)
{
auto range = boost::get<IteratorRange>(token->value());
std::cout << ToString(static_cast<TokenType>(token->id())) << " (" << std::string(range.begin(), range.end()) << ')' << std::endl;
}
}
示例3: test_parser
bool test_parser(Char const* in, Parser const& p, Lexer& lex,
Skipper const& s, bool full_match = true)
{
// we don't care about the result of the "what" function.
// we only care that all parsers have it:
boost::spirit::qi::what(p);
std::string str (in);
std::string::iterator it_in = str.begin();
std::string::iterator end_in = str.end();
typedef typename Lexer::iterator_type iterator_type;
iterator_type iter = lex.begin(it_in, end_in);
iterator_type end = lex.end();
return boost::spirit::qi::phrase_parse(iter, end, p, s)
&& (!full_match || (iter == end));
}