本文整理汇总了C++中scanner_t::get_number方法的典型用法代码示例。如果您正苦于以下问题:C++ scanner_t::get_number方法的具体用法?C++ scanner_t::get_number怎么用?C++ scanner_t::get_number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scanner_t
的用法示例。
在下文中一共展示了scanner_t::get_number方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BracketTerm
void parser_t::BracketTerm() {
parsetree.push(NT_BracketTerm);
switch (scanner.next_token()) {
case T_openparen:
scanner.eat_token(T_openparen);
cerr_buffer.push_back("(");
Expression();
scanner.eat_token(T_closeparen);
cerr_buffer.push_back(")");
break;
case T_m:
scanner.eat_token(T_m);
scanner.eat_token(T_opensquare);
cerr_buffer.push_back("m[");
Expression();
scanner.eat_token(T_closesquare);
cerr_buffer.push_back("]");
break;
case T_num:
scanner.eat_token(T_num);
cerr_buffer.push_back(scanner.get_number());
break;
default:
syntax_error(NT_BracketTerm);
}
parsetree.pop();
}
示例2: Label
void parser_t::Label() {
parsetree.push(NT_Label);
scanner.eat_token(T_label);
scanner.eat_token(T_num);
scanner.eat_token(T_colon);
cerr_buffer.push_back("L" + scanner.get_number() + ":\n");
parsetree.pop();
}
示例3: Jump
void parser_t::Jump() {
parsetree.push(NT_Jump);
scanner.eat_token(T_goto);
scanner.eat_token(T_num);
cerr_buffer.push_back("goto L" + scanner.get_number() + ";\n");
if (scanner.next_token() == T_if) {
scanner.eat_token(T_if);
// Insert if statement before goto
string goto_str = cerr_buffer.back();
cerr_buffer.pop_back();
cerr_buffer.push_back("if (");
Expression();
cerr_buffer.push_back(") {\n");
cerr_buffer.push_back(goto_str);
cerr_buffer.push_back("}\n");
}
parsetree.pop();
}
示例4: Fact
int parser_t::Fact()
{
int v;
parsetree.push(NT_Fact);
switch (scanner.next_token())
{
case T_num:
v = scanner.get_number();
eat_token(T_num);
break;
case T_openparen:
eat_token(T_openparen);
v = Expr(v);
eat_token(T_closeparen);
break;
default:
syntax_error(NT_Fact);
break;
}
parsetree.pop();
return v;
}