本文整理汇总了C++中Token::IsEOF方法的典型用法代码示例。如果您正苦于以下问题:C++ Token::IsEOF方法的具体用法?C++ Token::IsEOF怎么用?C++ Token::IsEOF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::IsEOF方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
void IdLookupReader::Read(const char* p_filePath, CrossMap<unsigned, string>& p_table)
{
fstream file;
file.open(p_filePath, ios::in);
if (!file.is_open())
return;
string line;
string key;
string value;
Token* token = NULL;
unsigned lastId = 0;
while(getline(file, line))
{
if(line.empty())
continue;
line = FilterLine(line);
Toolbox::GetCharacterBuffer(line, m_buffer);
m_scanner->SetCodeBuffer(m_buffer);
m_scanner->Reset();
key.clear();
value.clear();
while((token = m_scanner->GetNextToken()) && !token->IsEOF())
{
if (g_TokenTypesMap[token->TypeId]->Name == "identifier")
{
value = token->Value->Lexeme;
}
else if(g_TokenTypesMap[token->TypeId]->Name == "number")
{
key = token->Value->Lexeme;
lastId = atoi(key.c_str());
}
}
if(key.empty())
++lastId;
std::string enumStr = EnumToSentence(value);
p_table.SetByFirst(lastId, enumStr);
}
file.close();
}
示例2: GetToken
Token Tokenizer::GetToken(int i)
{
int p = buffer_pos + i;
if (p < 0)
return Token();
while (int(token_buffer.size()) < p + 1) {
Token t;
ReadToken(t);
if (t.IsEOF())
return t;
token_buffer.push_back(t);
}
return token_buffer[p];
}
示例3: main
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
GLCCPreprocessor* preproc = NULL;
GLCCint errCode = GLCCError_Ok;
GLCCint tmpErrCode = GLCCError_Ok;
GLPPOptions opts;
extern const LexicalEntry* GetGlslTokens();
extern const char** GetGlslReservedTypes();
StateObject parserState(GetGlslReservedTypes());
Lexer myLex(GetGlslTokens(), "struct Foo {\n\tdmat2x2 bar[3];\n\tfloat baz;\n};", &parserState);
for (Token tok = myLex.Pop(); !tok.IsEOF(); tok = myLex.Pop()) {
std::cout << tok << std::endl;
}
if (argc < 2) {
errCode = GLCCError_MissingRequiredParameter;
goto exit;
}
if ((errCode = genPreprocessor(&preproc, &opts)) != GLCCError_Ok)
goto exit;
if ((errCode = preprocessFromFile(preproc, argv[1])) != GLCCError_Ok) {
const char* errText = getLastError(preproc);
if (errText) {
printf("Error reported during preprocessing: \"%s\"\n", errText);
}
goto cleanup;
}
cleanup:
tmpErrCode = deletePreprocessor(&preproc);
if (tmpErrCode != GLCCError_Ok) {
printf("Error while cleaning up: '%d', main still returning preprocess status.", tmpErrCode);
}
exit:
return errCode;
}