本文整理汇总了C++中scanner_t::scan_num方法的典型用法代码示例。如果您正苦于以下问题:C++ scanner_t::scan_num方法的具体用法?C++ scanner_t::scan_num怎么用?C++ scanner_t::scan_num使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scanner_t
的用法示例。
在下文中一共展示了scanner_t::scan_num方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Jump
// Jump -> "goto" number Jump_
void parser_t::Jump()
{
parsetree.push(NT_Jump);
eat_token(T_goto);
char* label_name = scanner.scan_num();
eat_token(T_num);
Jump_(label_name);
parsetree.pop();
}
示例2: Label
void parser_t::Label()
{
parsetree.push(NT_Label);
eat_token(T_label);
char* label_name = scanner.scan_num();
eat_token(T_num);
eat_token(T_colon);
fprintf(stderr, "\tlabel%s:", label_name);
parsetree.pop();
}
示例3: Expression
std::string parser_t::Expression()
{
std::string firstExpression("");
std::string result("");
std::ostringstream stream;
parsetree.push(NT_Expression);
switch (scanner.next_token()) {
case T_openparen:
eat_token(T_openparen);
firstExpression = Expression();
if (scanner.next_token() != T_closeparen) syntax_error(NT_Expression);
eat_token(T_closeparen);
stream << "(" << firstExpression << ")";
result = stream.str();
break;
case T_m:
eat_token(T_m);
if (scanner.next_token() != T_opensquare) syntax_error(NT_Expression);
eat_token(T_opensquare);
firstExpression = Expression();
if (scanner.next_token() != T_closesquare) syntax_error(NT_Expression);
eat_token(T_closesquare);
stream << "m[" << firstExpression << "]";
result = stream.str();
break;
case T_num:
result = scanner.scan_num();
eat_token(T_num);
break;
default:
syntax_error(NT_Expression);
break;
}
result = Expression_(result);
parsetree.pop();
return result;
}