Exemple #1
0
bool Contains( const TokenSet& setTokens1, const TokenSet& setTokens2 )
{
	if ( setTokens2.empty() )
		return setTokens1.empty();
	for ( TokenSet::const_iterator i = setTokens2.begin() ; i != setTokens2.end() ; ++i )
		if ( ! Contains( setTokens1, *i ) )
			return false;
	return true;
}
Exemple #2
0
bool Contains( const TokenSet& setTokens, int iToken )
{
	if ( setTokens.empty() )
		return false;
	switch ( iToken ) {
		case MULTIPLE :	case DIVIDE :	case DIVIDEINT : case PERCENT : case MODULO :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_MULTIPLICATIVE );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case NOT :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_UNARY );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case MINUS :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_UNARY );
				if ( i != setTokens.end() )
					return true;
				i = setTokens.find( CLASS_ADDITIVE );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case PLUS :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_ADDITIVE );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case LESS : case LESSEQUAL : case LESSGREATER : case EQUAL : case DOUBLEEQUAL : case NONEQUAL : case GREATER : case GREATEREQUAL :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_RELATIONAL );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case XOR :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_LOGICAL );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case AND : case SC_AND :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_LOGICAL_AND );
				if ( i != setTokens.end() )
					return true;
				i = setTokens.find( CLASS_LOGICAL );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case OR : case SC_OR :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_LOGICAL_OR );
				if ( i != setTokens.end() )
					return true;
				i = setTokens.find( CLASS_LOGICAL );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case IMPLIES : case SC_IMPLIES :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_LOGICAL_IMPLIES );
				if ( i != setTokens.end() )
					return true;
				i = setTokens.find( CLASS_LOGICAL );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case TRUEE: case FALSEE :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_BOOLEAN );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case DOT : case ARROWW :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_CALLKIND );
				if ( i != setTokens.end() )
					return true;
				break;
			}
		case PRE : case POST : case DEFATTRIBUTE : case DEFMETHOD :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_PREPOST );
				if ( i != setTokens.end() )
					return true;
			}
		case INV :
			{
				TokenSet::const_iterator i = setTokens.find( CLASS_STEREOTYPES );
				if ( i != setTokens.end() )
					return true;
				break;
			}
	}
	TokenSet::const_iterator i = setTokens.find( iToken );
	return i != setTokens.end();
}