本文整理汇总了C++中BFFIterator::ParseToNext方法的典型用法代码示例。如果您正苦于以下问题:C++ BFFIterator::ParseToNext方法的具体用法?C++ BFFIterator::ParseToNext怎么用?C++ BFFIterator::ParseToNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFFIterator
的用法示例。
在下文中一共展示了BFFIterator::ParseToNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseIncludeDirective
// ParseIncludeDirective
//------------------------------------------------------------------------------
bool BFFParser::ParseIncludeDirective( BFFIterator & iter )
{
// Sanity check include depth to detect cyclic includes
if ( s_Depth >= 128 )
{
Error::Error_1035_ExcessiveDepthComplexity( iter );
return false;
}
// we expect a " quoted string
if ( *iter != '"' )
{
Error::Error_1031_UnexpectedCharFollowingDirectiveName( iter, AStackString<>( "include" ), '"' );
return false;
}
BFFIterator stringStart( iter );
stringStart++; // first actual character
// find end of string
if ( iter.ParseToNext( '"' ) == false )
{
Error::Error_1012_UnexpectedEndOfFile( iter );
return false;
}
// unescape and substitute variables
AStackString<> include;
if ( PerformVariableSubstitutions( stringStart, iter, include ) == false )
{
return false;
}
iter++; // skip closing quote before returning
FLOG_INFO( "Including: %s\n", include.Get() );
// open include
// 1) Try current directory
AStackString<> includeToUse;
if (PathUtils::IsFullPath(include) == false)
{
const char * lastSlash = iter.GetFileName().FindLast( NATIVE_SLASH );
lastSlash = lastSlash ? lastSlash : iter.GetFileName().FindLast( OTHER_SLASH );
lastSlash = lastSlash ? ( lastSlash + 1 ): iter.GetFileName().Get(); // file only, truncate to empty
includeToUse.Assign( iter.GetFileName().Get(), lastSlash );
}
includeToUse += include;
AStackString<> includeToUseClean;
NodeGraph::CleanPath( includeToUse, includeToUseClean );
FileStream f;
if ( f.Open( includeToUseClean.Get(), FileStream::READ_ONLY ) == false )
{
Error::Error_1032_UnableToOpenInclude( stringStart, includeToUseClean );
return false;
}
// check if include uses "once" pragma
if ( FBuild::Get().GetDependencyGraph().IsOneUseFile( includeToUseClean ) )
{
// already seen, and uses #once : don't include again
return true;
}
uint64_t includeTimeStamp = FileIO::GetFileLastWriteTime( includeToUseClean );
// read content of include
const uint32_t fileSize = (uint32_t)f.GetFileSize();
AutoPtr< char > mem( (char *)ALLOC( fileSize + 1 ) );
if ( f.Read( mem.Get(), fileSize ) != fileSize )
{
Error::Error_1033_ErrorReadingInclude( stringStart, include, Env::GetLastErr() );
return false;
}
mem.Get()[ fileSize ] = '\000'; // sentinel
BFFParser parser;
const bool pushStackFrame = false; // include is treated as if injected at this point
return parser.Parse( mem.Get(), fileSize, includeToUseClean.Get(), includeTimeStamp, pushStackFrame );
}
示例2: ParseVariableDeclaration
// ParseVariableDeclaration
//------------------------------------------------------------------------------
bool BFFParser::ParseVariableDeclaration( BFFIterator & iter, const AString & varName, BFFStackFrame * frame )
{
m_SeenAVariable = true;
// look for an appropriate operator
BFFIterator operatorIter( iter );
bool modification = false;
if ( *iter == BFF_VARIABLE_ASSIGNMENT )
{
// assignment
}
else if ( ( *iter == BFF_VARIABLE_CONCATENATION ) ||
( *iter == BFF_VARIABLE_SUBTRACTION ) )
{
// concatenation
modification = true;
}
else
{
Error::Error_1016_UnexepectedCharFollowingVariableName( iter );
return false;
}
// skip the assignment symbol and whitespace
iter++;
iter.SkipWhiteSpaceAndComments();
if ( iter.IsAtEnd() )
{
Error::Error_1012_UnexpectedEndOfFile( iter );
return false;
}
char openToken = *iter;
char closeToken = 0;
bool ok = false;
if ( ( openToken == '"' ) || ( openToken == '\'' ) )
{
closeToken = openToken;
ok = true;
}
else if ( openToken == BFF_SCOPE_OPEN )
{
closeToken = BFF_SCOPE_CLOSE;
ok = true;
}
else if ( openToken == BFF_STRUCT_OPEN )
{
closeToken = BFF_STRUCT_CLOSE;
ok = true;
}
else if ( ( openToken >= '0' ) && ( openToken <= '9' ) )
{
if ( modification )
{
Error::Error_1027_CannotModify( operatorIter, varName, BFFVariable::VAR_ANY, BFFVariable::VAR_INT );
return false;
}
// integer value?
BFFIterator startIntValue( iter );
while ( iter.IsAtEnd() == false )
{
iter++;
if ( ( *iter < '0' ) || ( *iter > '9' ) )
{
break; // end of integer
}
}
if ( startIntValue.GetDistTo( iter ) > 10 )
{
Error::Error_1018_IntegerValueCouldNotBeParsed( startIntValue );
return false;
}
AStackString<> intAsString( startIntValue.GetCurrent(), iter.GetCurrent() );
int i = 0;
if ( sscanf( intAsString.Get(), "%i", &i ) != 1 )
{
Error::Error_1018_IntegerValueCouldNotBeParsed( startIntValue );
return false;
}
return StoreVariableInt( varName, i, frame );
}
else if ( ( *iter == 't' ) || ( *iter == 'f' ) )
{
// might be 'true' or 'false'
BFFIterator startBoolValue( iter );
if ( iter.ParseToNext( 'e' ) == true )
{
iter++;
if ( ( startBoolValue.GetDistTo( iter ) <= 5 ) )
{
AStackString<8> value( startBoolValue.GetCurrent(), iter.GetCurrent() );
if ( value == "true" )
{
if ( modification )
{
Error::Error_1027_CannotModify( operatorIter, varName, BFFVariable::VAR_ANY, BFFVariable::VAR_BOOL );
return false;
//.........这里部分代码省略.........