本文整理汇总了C++中Token::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ Token::Print方法的具体用法?C++ Token::Print怎么用?C++ Token::Print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::Print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestScanner
void TestScanner()
{
TestBegin("Scanner");
Scanner s;
Token tok;
s.From(
" \t\n"
" \ta.b = 1;\n"
" > < == <= >= != =~ && || . , : ; [ ] ( ) { } = + += -= *\r\n"
"123 0123 0xafbDDdd00\r"
"01233999 00. 1E9 1E-9 1e+9 1.1e900\n"
"\'fasdfa/#@[email protected]@@\\n\'\n"
"\"fjalksdfjal#@[email protected]#[email protected]#\\n\"\n"
"_abcd\r"
);
while( s.NextToken(&tok) && tok.Rep() != TOK_eof ){
tok.Print();
std::putchar('\n');
}
TestEnd();
}
示例2: GetNext
Token* Tokenizer::GetNext() {
Token* T = NULL;
// First check to see if there is an UnGetToken. If there is, use it.
if (UnGetToken != NULL) {
T = UnGetToken;
UnGetToken = NULL;
return T;
}
// Otherwise, crank up the scanner and get a new token.
// Get rid of any whitespace
SkipWhiteSpace();
// test for end of file
if (buffer.isEOF()) {
T = new Token(EOFSYM);
} else {
// Save the starting position of the symbol in a variable,
// so that nicer error messages can be produced.
TokenColumn = buffer.CurColumn();
// Check kind of current character
// Note that _'s are now allowed in identifiers.
if (isalpha(CurrentCh) || '_' == CurrentCh) {
// grab identifier or reserved word
T = GetIdent();
} else if ( '"' == CurrentCh) {
T = GetQuotedIdent();
} else if (isdigit(CurrentCh) || '-' == CurrentCh || '.' == CurrentCh) {
T = GetScalar();
} else {
//
// Check for other tokens
//
T = GetPunct();
}
}
if (T == NULL) {
throw ParserFatalException("didn't get a token");
}
if (_printTokens) {
std::cout << "Token read: ";
T->Print();
std::cout << std::endl;
}
return T;
}