本文整理汇总了C++中CTokenizer::AddParseFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CTokenizer::AddParseFile方法的具体用法?C++ CTokenizer::AddParseFile怎么用?C++ CTokenizer::AddParseFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTokenizer
的用法示例。
在下文中一共展示了CTokenizer::AddParseFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
#ifdef _WIN32
struct _finddata_t fileinfo;
bool error_pause = false;
#endif
char *filename, error_msg[MAX_STRING_LENGTH], newfilename[MAX_FILENAME_LENGTH];
int handle;
//Init the tokenizer and pass the symbols we require
Tokenizer.Create( 0 );
Tokenizer.SetSymbols( (keywordArray_t *) Interpreter.GetSymbols() );
Tokenizer.SetErrorProc( (void (__cdecl *)(const char *)) NULL_Error );
//Init the block streaming class
BlockStream.Init();
//No script arguments, print the banner
if (argc < 2)
{
printf("\n\nIBIze v%1.2f -- jweier\n", IBIZE_VERSION );
printf("ICARUS v%1.2f\n", ICARUS_VERSION );
printf("Copyright (c) 1999, Raven Software\n");
printf("------------------------------\n");
printf("\nIBIze [script1.txt] [script2.txt] [script3.txt] ...\n\n");
return 0;
}
int iErrorBlock = 0;
//Interpret all files passed on the command line
for (int i=1; i<argc; i++)
{
filename = (char *) argv[i];
//FIXME: There could be better ways to do this...
if ( filename[0] == '-' )
{
#ifdef _WIN32
if ( tolower(filename[1]) == 'e' )
error_pause = true;
//Can just use a wildcard in the commandline on non-windows
if ( tolower(filename[1]) == 'a' )
{
handle = _findfirst ( "*.txt", &fileinfo);
while ( handle != -1 )
{
if (Tokenizer.AddParseFile( (char*) &fileinfo.name ))
{
//Interpret the file
if ( (iErrorBlock=InterpretFile( (char *) &fileinfo.name )) !=0 )
{
// failed
//
BlockStream.Free();
if (error_pause)
getch();
}
}
if ( _findnext( handle, &fileinfo ) == -1 )
break;
}
_findclose (handle);
}
#endif
continue;
}
//Tokenize the file
if (Tokenizer.AddParseFile( filename ))
{
//Interpret the file
if ( (iErrorBlock=InterpretFile( filename )) !=0 )
{
// failed
//
BlockStream.Free();
#ifdef _WIN32
if (error_pause)
getch();
#endif
return iErrorBlock;
}
}
else
{
//Try adding on the SCR extension if it was left off
strcpy((char *) &newfilename, filename);
strcat((char *) &newfilename, SCRIPT_EXTENSION);
if (Tokenizer.AddParseFile( (char*) &newfilename ))
{
//.........这里部分代码省略.........
示例2: ReadASEHeader_Actual
//
// this actually reads XSI or GLA headers... historical mutation strikes again...
//
static void ReadASEHeader_Actual(LPCSTR psFilename, int &iStartFrame, int &iFrameCount, int &iFrameSpeed, bool bReadingGLA, bool bCanSkipXSIRead /* = false */)
{
// since the XSI loader is so damn slow and flakey I'm going to have to cache the info to avoid re-reading...
//
// do we have it in the cache?...
//
if (strstr(psFilename,".xsi") || strstr(psFilename,".XSI"))
{
ASECachedInfo_t::iterator iter = ASECachedInfo.find(psFilename);
if (iter != ASECachedInfo.end())
{
iStartFrame = 0;
iFrameCount = (*iter).second.first;
iFrameSpeed = (*iter).second.second;
return;
}
}
// is it a GLA file?...
//
if (bReadingGLA)
{
char sTemp[1024];
strcpy(sTemp,psFilename);
if (!(strstr(psFilename,".gla") || strstr(psFilename,".GLA")))
{
strcat(sTemp,".gla");
}
iStartFrame = 0;
iFrameCount = GLA_ReadHeader(sTemp);
iFrameSpeed = 20; // any old value for GLA file
return;
}
// it's not in the cache, but we may be able to avoid having to read it under some circumstances...
//
bool bXSIShouldBeRead = true;
if (gbCarWash_DoingScan)
{
bCanSkipXSIRead = false; // stop it asking the question
bXSIShouldBeRead= gbCarWash_YesToXSIScan;
}
if ( (strstr(psFilename,".xsi") || strstr(psFilename,".XSI"))
&& bCanSkipXSIRead
)
{
if (!gbSkipXSIRead && !gbSkipXSIRead_QuestionAsked)
{
gbSkipXSIRead_QuestionAsked = true;
gbSkipXSIRead = !GetYesNo(va("Model file: \"%s\"\n\n... is an XSI, and they can be damn slow to read in\n\nDo you want to scan all the XSIs?",psFilename));
}
bXSIShouldBeRead = !gbSkipXSIRead;
}
if (strstr(psFilename,".xsi") || strstr(psFilename,".XSI"))
{
if (bXSIShouldBeRead)
{
ReadXSIHeader(psFilename, iStartFrame, iFrameCount, iFrameSpeed);
if (iFrameCount!=0)
{
// cache it for future...
//
ASECachedInfo[psFilename] = FrameCountAndSpeed_t(iFrameCount,iFrameSpeed);
}
}
return;
}
// it must be an ASE file then instead....
//
CTokenizer* tokenizer = CTokenizer::Create();
tokenizer->AddParseFile(psFilename, ((CAssimilateApp*)AfxGetApp())->GetBufferSize());
tokenizer->SetSymbols(CSequence_s_Symbols);
tokenizer->SetKeywords(CSequence_s_Keywords);
CToken* curToken = tokenizer->GetToken();
while(curToken != NULL)
{
switch (curToken->GetType())
{
case TK_EOF:
curToken->Delete();
curToken = NULL;
break;
case TK_ASTERISK:
curToken->Delete();
curToken = tokenizer->GetToken();
switch(curToken->GetType())
{
//.........这里部分代码省略.........
示例3: Parse
void CASEFile::Parse()
{
if (m_file == NULL)
{
return;
}
CAlertErrHandler errhandler;
CTokenizer* tokenizer = CTokenizer::Create(TKF_USES_EOL | TKF_NUMERICIDENTIFIERSTART);
tokenizer->SetErrHandler(&errhandler);
tokenizer->SetKeywords(s_keywords);
tokenizer->SetSymbols(s_symbols);
tokenizer->AddParseFile(m_file, 16 * 1024);
int tokType = TK_UNDEFINED;
while(tokType != TK_EOF)
{
CToken* curToken = tokenizer->GetToken();
if (curToken->GetType() == TK_EOF)
{
curToken->Delete();
tokType = TK_EOF;
break;
}
if (curToken->GetType() == TK_EOL)
{
curToken->Delete();
continue;
}
if (curToken->GetType() != TK_ASE_ASTERISK)
{
tokenizer->Error(TKERR_UNEXPECTED_TOKEN);
curToken->Delete();
tokenizer->GetToEndOfLine()->Delete();
continue;
}
curToken->Delete();
curToken = tokenizer->GetToken();
tokType = curToken->GetType();
curToken->Delete();
switch(tokType)
{
case TK_EOF:
break;
case TK_GEOMOBJECT:
ParseGeomObject(tokenizer);
break;
case TK_SCENE:
ParseScene(tokenizer);
break;
case TK_MATERIAL_LIST:
ParseMaterialList(tokenizer);
break;
case TK_ASE_COMMENT:
ParseComment(tokenizer);
break;
case TK_3DSMAX_ASCIIEXPORT:
ParseAsciiExport(tokenizer);
break;
default:
tokenizer->Error(TKERR_UNEXPECTED_TOKEN);
tokenizer->GetToEndOfLine()->Delete();
break;
}
}
}