本文整理汇总了C++中idParser::ExpectTokenType方法的典型用法代码示例。如果您正苦于以下问题:C++ idParser::ExpectTokenType方法的具体用法?C++ idParser::ExpectTokenType怎么用?C++ idParser::ExpectTokenType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idParser
的用法示例。
在下文中一共展示了idParser::ExpectTokenType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseConstantValue
/*
================
idTypeInfoGen::ParseConstantValue
================
*/
void idTypeInfoGen::ParseConstantValue( const char *scope, idParser &src, idStr &value ) {
idToken token;
idStr constantString;
int indent = 0;
while( src.ReadToken( &token ) ) {
if ( token == "(" ) {
indent++;
} else if ( token == ")" ) {
indent--;
} else if ( indent == 0 && ( token == ";" || token == "," || token == "}" ) ) {
src.UnreadToken( &token );
break;
} else if ( token.type == TT_NAME ) {
constantString = token;
while( src.CheckTokenString( "::" ) ) {
src.ExpectTokenType( TT_NAME, 0, &token );
constantString += "::" + token;
}
value += va( "%d", GetIntegerConstant( scope, constantString, src ) );
continue;
}
value += token;
}
}
示例2: ParseArraySize
/*
================
idTypeInfoGen::ParseArraySize
================
*/
int idTypeInfoGen::ParseArraySize( const char *scope, idParser &src ) {
idToken token;
idStr sizeString, constantString;
int size, totalSize;
if ( !src.CheckTokenString( "[" ) ) {
return 0;
}
totalSize = 1;
sizeString = "";
while( src.ReadToken( &token ) ) {
if ( token == "]" ) {
if ( sizeString.Length() ) {
size = EvaluateIntegerString( sizeString );
if ( size ) {
totalSize *= size;
}
sizeString = "";
}
if ( !src.CheckTokenString( "[" ) ) {
break;
}
} else if ( token.type == TT_NAME ) {
constantString = token;
while( src.CheckTokenString( "::" ) ) {
src.ExpectTokenType( TT_NAME, 0, &token );
constantString += "::" + token;
}
sizeString += va( "%d", GetIntegerConstant( scope, constantString, src ) );
} else {
sizeString += token;
}
}
return totalSize;
}
示例3: ParseScope
//.........这里部分代码省略.........
}
}
varType = "";
isConst = false;
isStatic = false;
} else if ( ( isStatic || isConst ) && src.CheckTokenString( "=" ) ) {
// constant
idConstantInfo *constantInfo = new idConstantInfo;
constantInfo->name = scope + token;
constantInfo->type = varType;
constantInfo->type.StripTrailing( ' ' );
ParseConstantValue( scope, src, constantInfo->value );
constants.Append( constantInfo );
} else if ( isStatic ) {
// static class variable
varType += token + " ";
} else {
// check for class variables
while( 1 ) {
int arraySize = ParseArraySize( scope, src );
if ( arraySize ) {
idClassVariableInfo var;
var.name = token;
var.type = varType;
var.type.StripTrailing( ' ' );
var.type += va( "[%d]", arraySize );
var.bits = 0;
typeInfo->variables.Append( var );
if ( !src.CheckTokenString( "," ) ) {
varType = "";
isConst = false;
isStatic = false;
break;
}
varType.StripTrailing( "* " );
} else {
int bits = 0;
if ( src.CheckTokenString( ":" ) ) {
idToken bitSize;
src.ExpectTokenType( TT_NUMBER, TT_INTEGER, &bitSize );
bits = bitSize.GetIntValue();
}
if ( src.CheckTokenString( "," ) ) {
idClassVariableInfo var;
var.name = token;
var.type = varType;
var.type.StripTrailing( ' ' );
var.bits = bits;
typeInfo->variables.Append( var );
varType.StripTrailing( "* " );
} else if ( src.CheckTokenString( ";" ) ) {
idClassVariableInfo var;
var.name = token;
var.type = varType;
var.type.StripTrailing( ' ' );
var.bits = bits;
typeInfo->variables.Append( var );
varType = "";
isConst = false;
isStatic = false;
break;
} else {
varType += token + " ";
break;
}
}
while( src.CheckTokenString( "*" ) ) {
varType += "* ";
}
if ( !src.ExpectTokenType( TT_NAME, 0, &token ) ) {
break;
}
}
}
} else {
varType += token + " ";
}
}
}
示例4: ParseTimeline
/*
================
sdDeclToolTip::ParseTimeline
================
*/
bool sdDeclToolTip::ParseTimeline( idParser& src ) {
idToken token;
src.SkipUntilString( "{", &token );
while ( true ) {
if( !src.ReadToken( &token ) ) {
return false;
}
if ( !token.Icmp( "onTime" ) ) {
src.ReadToken( &token );
int time;
if ( token.type == TT_NUMBER ) {
time = ( token.GetIntValue() / 100.0f ) * GetLength();
} else if ( token.type == TT_NAME && !token.Icmp( "end" ) ) {
time = TLTIME_END;
} else {
src.Error( "sdDeclToolTip::ParseTimeline number expected for 'onTime'" );
return false;
}
timelinePair_t event;
event.first = time;
if ( timeline.Num() > 0 ) {
timelinePair_t lastEvent = timeline.Back();
if ( lastEvent.first > time && time != TLTIME_END ) {
src.Error( "sdDeclToolTip::ParseTimeline time events must be in increasing order: '%i'", time );
return false;
}
}
src.ReadToken( &token );
if ( !token.Icmp( "guiEvent" ) ) {
event.second.eventType = TL_GUIEVENT;
if( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
src.Error( "sdDeclToolTip::ParseTimeline string expected after 'guiEvent'" );
return false;
}
event.second.arg1 = token;
} else if ( !token.Icmp( "pause" ) ) {
event.second.eventType = TL_PAUSE;
} else if ( !token.Icmp( "unpause" ) ) {
event.second.eventType = TL_UNPAUSE;
} else if ( !token.Icmp( "showInventory" ) ) {
event.second.eventType = TL_SHOWINVENTORY;
if( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
src.Error( "sdDeclToolTip::ParseTimeline string expected after 'guiEvent'" );
return false;
}
event.second.arg1 = token;
} else if ( !token.Icmp( "hideInventory" ) ) {
event.second.eventType = TL_HIDEINVENTORY;
} else if ( !token.Icmp( "waypointHighlight" ) ) {
event.second.eventType = TL_WAYPOINTHIGHLIGHT;
if( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
src.Error( "sdDeclToolTip::ParseTimeline string expected after 'guiEvent'" );
return false;
}
event.second.arg1 = token;
} else if ( !token.Icmp( "lookAtTask" ) ) {
event.second.eventType = TL_LOOKATTASK;
} else {
src.Error( "sdDeclToolTip::ParseTimeline unexpected timeline event '%s'", token.c_str() );
return false;
}
timeline.Append( event );
} else if ( !token.Icmp( "unpauseWeaponSlot" ) ) {
if( !src.ExpectTokenType( TT_NUMBER, 0, &token ) ) {
src.Error( "sdDeclToolTip::ParseTimeline number expected after 'unpauseWeaponSlot'" );
return false;
}
//.........这里部分代码省略.........