本文整理汇总了C++中Tokenizer::advance方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokenizer::advance方法的具体用法?C++ Tokenizer::advance怎么用?C++ Tokenizer::advance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer::advance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
示例2: if
SmartPointer<Entity> Parser::compareOp(Tokenizer &tokenizer) {
SmartPointer<Entity> entity = addOp(tokenizer);
while (true) {
if (tokenizer.getType() == TokenType::ID_TOKEN) {
Operator op;
string id = String::toUpper(tokenizer.getValue());
if (id == "EQ") op = Operator::EQ_OP;
else if (id == "NE") op = Operator::NE_OP;
else if (id == "GT") op = Operator::GT_OP;
else if (id == "GE") op = Operator::GE_OP;
else if (id == "LT") op = Operator::LT_OP;
else if (id == "LE") op = Operator::LE_OP;
if (op != Operator::NO_OP) {
tokenizer.advance();
entity = new BinaryOp(op, entity, addOp(tokenizer));
continue;
}
}
break;
}
return entity;
}
示例3: UnaryOp
SmartPointer<Entity> Parser::unaryOp(Tokenizer &tokenizer) {
Operator op;
switch(tokenizer.getType()) {
case TokenType::ADD_TOKEN: op = Operator::ADD_OP; break;
case TokenType::SUB_TOKEN: op = Operator::SUB_OP; break;
default: break;
}
if (op == Operator::NO_OP) THROW("Expected unary - or + operator");
tokenizer.advance();
return new UnaryOp(op, numberRefOrExpr(tokenizer));
}
示例4: mulOp
SmartPointer<Entity> Parser::addOp(Tokenizer &tokenizer) {
SmartPointer<Entity> entity = mulOp(tokenizer);
while (true) {
Operator op;
switch(tokenizer.getType()) {
case TokenType::ADD_TOKEN: op = Operator::ADD_OP; break;
case TokenType::SUB_TOKEN: op = Operator::SUB_OP; break;
default: break;
}
if (op != Operator::NO_OP) {
tokenizer.advance();
entity = new BinaryOp(op, entity, mulOp(tokenizer));
} else break;
}
return entity;
}
示例5: expOp
SmartPointer<Entity> Parser::mulOp(Tokenizer &tokenizer) {
SmartPointer<Entity> entity = expOp(tokenizer);
while (true) {
Operator op;
switch(tokenizer.getType()) {
case TokenType::MUL_TOKEN: op = Operator::MUL_OP; break;
case TokenType::DIV_TOKEN: op = Operator::DIV_OP; break;
case TokenType::ID_TOKEN:
if (String::toUpper(tokenizer.getValue()) == "MOD")
op = Operator::MOD_OP;
break;
default: break;
}
if (op != Operator::NO_OP) {
tokenizer.advance();
entity = new BinaryOp(op, entity, expOp(tokenizer));
} else break;
}
return entity;
}