本文整理汇总了C++中Tokenizer::hasMore方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokenizer::hasMore方法的具体用法?C++ Tokenizer::hasMore怎么用?C++ Tokenizer::hasMore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer::hasMore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseOne
bool Parser::parseOne(Tokenizer &tokenizer, Processor &processor) {
try {
if (!tokenizer.hasMore()) return false;
processor(block(tokenizer));
return true;
} catch (const Exception &e) {
THROWCS("Exception @" << tokenizer.getLocation(), e);
}
}
示例2: scope
SmartPointer<Block> Parser::block(Tokenizer &tokenizer) {
ParseScope scope(tokenizer.getScanner());
// Deleted
bool deleted = false;
if (tokenizer.consume(TokenType::DIV_TOKEN)) deleted = true;
// Line number
int line = -1;
if (tokenizer.isID("N")) {
tokenizer.advance();
Token num = tokenizer.match(TokenType::NUMBER_TOKEN);
line = String::parseU32(num.getValue());
}
// Children
std::vector<SmartPointer<Entity> > children;
// O-Code
if (tokenizer.isID("O")) children.push_back(ocode(tokenizer));
while (tokenizer.hasMore()) {
switch (tokenizer.getType()) {
case TokenType::EOL_TOKEN: break; // End of block
case TokenType::COMMENT_TOKEN:
case TokenType::PAREN_COMMENT_TOKEN:
children.push_back(comment(tokenizer));
break;
case TokenType::POUND_TOKEN:
children.push_back(assign(tokenizer));
break;
default:
if (!tokenizer.isType(TokenType::ID_TOKEN))
THROWS("Expected word or assignment, found " << tokenizer.getType());
children.push_back(word(tokenizer));
break;
}
if (tokenizer.getType() == TokenType::EOL_TOKEN) {
tokenizer.advance();
break;
}
}
return scope.set(new Block(deleted, line, children));
}