本文整理汇总了C++中BFFIterator::SkipWhiteSpaceAndComments方法的典型用法代码示例。如果您正苦于以下问题:C++ BFFIterator::SkipWhiteSpaceAndComments方法的具体用法?C++ BFFIterator::SkipWhiteSpaceAndComments怎么用?C++ BFFIterator::SkipWhiteSpaceAndComments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFFIterator
的用法示例。
在下文中一共展示了BFFIterator::SkipWhiteSpaceAndComments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseNamedVariableDeclaration
// ParseNamedVariableDeclaration
//------------------------------------------------------------------------------
bool BFFParser::ParseNamedVariableDeclaration( BFFIterator & iter )
{
// skip over the declaration symbol
ASSERT( *iter == BFF_DECLARE_VAR_INTERNAL );
m_LastVarNameStart = iter; // include type token in var name
iter++;
// make sure we haven't hit the end of the file
if ( iter.IsAtEnd() )
{
Error::Error_1012_UnexpectedEndOfFile( iter );
return false;
}
// make sure immediately after the symbol starts a variable name
if ( iter.IsAtValidVariableNameCharacter() == false )
{
Error::Error_1013_UnexpectedCharInVariableName( iter, nullptr );
return false;
}
// find the end of the variable name
iter.SkipVariableName();
if ( iter.IsAtEnd() )
{
Error::Error_1012_UnexpectedEndOfFile( iter );
return false;
}
m_LastVarNameEnd = iter;
// sanity check it is a sensible length
size_t varNameLen = m_LastVarNameStart.GetDistTo( m_LastVarNameEnd );
if ( varNameLen > MAX_VARIABLE_NAME_LENGTH )
{
Error::Error_1014_VariableNameIsTooLong( iter, (uint32_t)varNameLen, (uint32_t)MAX_VARIABLE_NAME_LENGTH );
return false;
}
// find the start of the assignment
iter.SkipWhiteSpaceAndComments();
if ( iter.IsAtEnd() )
{
Error::Error_1012_UnexpectedEndOfFile( iter );
return false;
}
return ParseVariableDeclaration( iter, m_LastVarNameStart, m_LastVarNameEnd );
}
示例2: ParseNamedVariableDeclaration
// ParseNamedVariableDeclaration
//------------------------------------------------------------------------------
bool BFFParser::ParseNamedVariableDeclaration( BFFIterator & iter )
{
const BFFIterator varNameStart( iter );
bool parentScope = false;
if ( ParseVariableName( iter, m_LastVarName, parentScope ) == false )
{
return false; // ParseVariableName() would have display an error
}
// find the start of the assignment
iter.SkipWhiteSpaceAndComments();
if ( iter.IsAtEnd() )
{
Error::Error_1012_UnexpectedEndOfFile( iter );
return false;
}
// check if points to a previous declaration in a parent scope
const BFFVariable * parentVar = nullptr;
m_LastVarFrame = ( parentScope )
? BFFStackFrame::GetParentDeclaration( m_LastVarName, nullptr, parentVar )
: nullptr;
if ( parentScope )
{
// check if a parent definition exists
if ( nullptr == m_LastVarFrame )
{
Error::Error_1009_UnknownVariable( varNameStart, nullptr );
return false;
}
ASSERT( nullptr != parentVar );
// check if the parent definition is frozen
if ( parentVar->Frozen() )
{
Error::Error_1060_CantModifyFrozenVar( varNameStart, nullptr, parentVar );
return false;
}
}
return ParseVariableDeclaration( iter, m_LastVarName, m_LastVarFrame );
}
示例3: ParseFunction
// ParseFunction
//------------------------------------------------------------------------------
bool BFFParser::ParseFunction( BFFIterator & iter )
{
ASSERT( iter.IsAtValidFunctionNameCharacter() );
// for variables to be used by this function
BFFStackFrame stackFrame;
BFFIterator functionNameStart( iter );
iter.SkipFunctionName();
if ( iter.IsAtEnd() )
{
Error::Error_1012_UnexpectedEndOfFile( iter );
return false;
}
// check length
if ( functionNameStart.GetDistTo( iter ) > MAX_FUNCTION_NAME_LENGTH )
{
// if it's too long, then it can't be a valid function
Error::Error_1015_UnknownFunction( functionNameStart );
return false;
}
// store function name
AStackString<MAX_FUNCTION_NAME_LENGTH> functionName( functionNameStart.GetCurrent(), iter.GetCurrent() );
const Function * func = Function::Find( functionName );
if ( func == nullptr )
{
Error::Error_1015_UnknownFunction( functionNameStart );
return false;
}
iter.SkipWhiteSpace();
if ( func->IsUnique() && func->GetSeen() )
{
Error::Error_1020_FunctionCanOnlyBeInvokedOnce( functionNameStart, func );
return false;
}
func->SetSeen();
FLOG_INFO( "Function call '%s'", functionName.Get() );
// header, or body?
bool hasHeader = false;
BFFIterator functionArgsStartToken( iter );
BFFIterator functionArgsStopToken( iter );
if ( *iter == BFF_FUNCTION_ARGS_OPEN )
{
// can this function accept a header?
if ( func->AcceptsHeader() == false )
{
Error::Error_1021_UnexpectedHeaderForFunction( iter, func );
return false;
}
// args
if ( iter.ParseToMatchingBrace( BFF_FUNCTION_ARGS_OPEN, BFF_FUNCTION_ARGS_CLOSE ) == false )
{
Error::Error_1022_MissingFunctionHeaderCloseToken( functionArgsStartToken, func );
return false;
}
functionArgsStopToken = iter;
hasHeader = true;
iter++; // skip over closing token
iter.SkipWhiteSpaceAndComments();
}
if ( func->NeedsHeader() && ( hasHeader == false ) )
{
Error::Error_1023_FunctionRequiresAHeader( iter, func );
return false;
}
// some functions have no body
bool hasBody = false;
BFFIterator functionBodyStartToken( iter );
BFFIterator functionBodyStopToken( iter );
if ( func->NeedsBody() )
{
// find body
if ( *iter != BFF_SCOPE_OPEN )
{
Error::Error_1024_FunctionRequiresABody( functionNameStart, func );
return false;
}
if ( iter.ParseToMatchingBrace( BFF_SCOPE_OPEN, BFF_SCOPE_CLOSE ) == false )
{
Error::Error_1025_MissingScopeCloseToken( functionBodyStartToken, func );
return false;
}
functionBodyStopToken = iter;
iter++;
hasBody = true;
}
//.........这里部分代码省略.........
示例4: 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;
//.........这里部分代码省略.........