本文整理汇总了C++中scanner_t::get_num方法的典型用法代码示例。如果您正苦于以下问题:C++ scanner_t::get_num方法的具体用法?C++ scanner_t::get_num怎么用?C++ scanner_t::get_num使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scanner_t
的用法示例。
在下文中一共展示了scanner_t::get_num方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Jump
void parser_t::Jump(){
int temp;
parsetree.push(NT_Jump);
eat_token(T_goto);
//cerr<<"goto ";
scanner.next_token();
temp = scanner.get_num();
eat_token(T_num);
scanner.next_token();
if(scanner.next_token()== T_if){
eat_token(T_if);
// cerr<<"if( ";
//scanner.next_token();
Expression();
cerr<<" );\n";
cerr<<"goto L";
cerr<<temp;
cerr<<"; \n";
}
else{
cerr<<"goto L";
cerr<<temp;
cerr<<"; \n";
}
parsetree.pop();
}
示例2: FactorP
void parser_t::FactorP(){
int temp = scanner.get_num();
parsetree.push(NT_FactorP);
switch(scanner.next_token()){
case T_power:
eat_token(T_power);
Exp();
FactorP();
break;
case T_eof:
parsetree.drawepsilon();
break;
default:
parsetree.drawepsilon();
// syntax_error(NT_ExpressionP);
break;
}
parsetree.pop();
}
示例3: Factor
void parser_t::Factor(){
token_type token;
parsetree.push(NT_Factor);
code_printf("intPow(");
switch(token = scanner.next_token()){
case T_openparen:
eat_token(T_openparen);
code_printf("(");
Expression();
code_printf(")");
eat_token(T_closeparen);
break;
case T_m:
code_printf("m[");
eat_token(T_m);
eat_token(T_opensquare);
Expression();
eat_token(T_closesquare);
code_printf("]");
break;
case T_num:
code_printf("%d",scanner.get_num());
eat_token(T_num);
break;
default:
syntax_error(NT_Factor);
/*
fprintf(stderr, "%d Invalid factor: %s\n", scanner.get_line(), token_to_string(token));
assert(0);
*/
}
Power();
parsetree.pop();
}
示例4: Jump
void parser_t::Jump(){
int number;
parsetree.push(NT_Jump);
eat_token(T_goto);
eat_token(T_num);
number = scanner.get_num();
JumpIf();
code_printf("goto my_label%d",number);
parsetree.pop();
}
示例5: Label
void parser_t::Label(){
parsetree.push(NT_Label);
eat_token(T_label);
eat_token(T_num);
eat_token(T_colon);
code_printf("my_label%d:\n", scanner.get_num());
parsetree.pop();
}
示例6: Label
void parser_t::Label(){
parsetree.push(NT_Jump);
eat_token(T_label);
cerr<<"L";
eat_token(T_num);
cerr<<scanner.get_num();
cerr<<":\n";
eat_token(T_colon);
parsetree.pop();
}
示例7: Exp
void parser_t::Exp(){
parsetree.push(NT_Exp);
switch (scanner.next_token()){
case T_openparen:
eat_token(T_openparen);
cerr<<" ( ";
Expression();
//scanner.next_token();
eat_token(T_closeparen);
cerr<< " ) ";
break;
case T_m:
eat_token(T_m);
cerr<<"m";
scanner.next_token();
eat_token(T_opensquare);
cerr<<"[ ";
Expression();
//scanner.next_token();
eat_token(T_closesquare);
cerr<<" ]";
break;
case T_num:
eat_token(T_num);
cerr<<scanner.get_num();
break;
case T_eof:
parsetree.drawepsilon();
break;
default:
syntax_error(NT_Exp);
break;
}
parsetree.pop();
}