Esempio n. 1
0
std::pair<bool, ResidualGraph::Token> ResidualGraph::pathSatisfiesTokenSpecs(const Path& p) const
{
	TokenSet collectedTokens;
	TokenSet forbiddenTokens;
	// walk in reverse order as we build the path back to front in findShortestPath()
	for(auto af = p.rbegin(); af != p.rend(); ++af)
	{
		Arc a = af->first;
		bool forward = af->second > 0;
		ResidualArcCandidate ac = undirectedArcToPair(a, forward);
		const TokenSet& arcForbiddenTokens = residualArcForbidsTokens_.at(ac);
		const TokenSet& providedTokens = residualArcProvidesTokens_.at(ac);

		// update collected tokens
		collectedTokens.insert(providedTokens.begin(), providedTokens.end());
		forbiddenTokens.insert(arcForbiddenTokens.begin(), arcForbiddenTokens.end());
	}

	// no forbidden token is allowed in collected
	for(Token t : collectedTokens)
	{
		if(forbiddenTokens.count(t) > 0)
			return std::make_pair(false, t);
	}

	return std::make_pair(true, 0);
}
Esempio n. 2
0
void InitializeTokenSets()
{
	if ( ! bTokenSetInitialized ) {
		First_name.insert( IDENTIFIER );

		First_typeName.insert( IDENTIFIER );

		First_colon.insert( COLON );

		First_inputend.insert( INPUTEND );

		First_inv.insert( INV );

		First_right_parenthesis.insert( RIGHT_PARENTHESIS );

		First_left_parenthesis.insert( LEFT_PARENTHESIS );

		First_prePost.insert( CLASS_PREPOST );

		First_in.insert( INN );

		First_equal.insert( EQUAL );

		First_then.insert( THEN );

		First_else.insert( ELSE );

		First_endif.insert( ENDIF );

		First_delimiter.insert( DELIMITER );

		First_right_bracket.insert( RIGHT_BRACKET );

		First_left_brace.insert( LEFT_BRACE );

		First_right_brace.insert( RIGHT_BRACE );

		First_literal.insert( STRING );
		First_literal.insert( REAL );
		First_literal.insert( INTEGER );
		First_literal.insert( POUND );
		First_literal.insert( CLASS_BOOLEAN );

		First_primaryExpression = First_literal;
		First_primaryExpression .insert( IDENTIFIER );
		First_primaryExpression .insert( LEFT_PARENTHESIS );
		First_primaryExpression .insert( IF );

		First_contextDeclarationHelper.insert( IDENTIFIER );

		First_formalParameter.insert( IDENTIFIER );

		First_formalParameterList = First_formalParameter;

		First_featureCallParameters.insert( LEFT_PARENTHESIS );

		First_featureCall.insert( IDENTIFIER );

		First_postfixExpression = Union( First_primaryExpression, First_featureCall );

		First_unaryExpression = First_postfixExpression;
		First_unaryExpression.insert( CLASS_UNARY );

		First_multiplicativeExpression = First_unaryExpression;

		First_additiveExpression = First_multiplicativeExpression;

		First_relationalExpression = First_additiveExpression;

		First_andExpression = First_relationalExpression;

		First_xorExpression = First_andExpression;

		First_orExpression = First_xorExpression;

		First_implicationExpression = First_orExpression;

		First_letExpression.insert( LET );

		First_expression = Union( First_letExpression, First_implicationExpression );

		First_featureCallParametersHelper = First_expression;
		First_featureCallParametersHelper.insert( IDENTIFIER );
		First_featureCallParametersHelper.insert( RIGHT_PARENTHESIS );

		First_actualParameterList = First_expression;

		First_expressionListOrRange = First_expression;

		First_qualifiers.insert( LEFT_BRACKET );


//<udmoclpat changes
		First_fileNode.insert( PAT_OPEN );

		First_handleNode.insert( PAT_SWITCH );

		First_printNode.insert( PAT_PRINT );

		First_textNode.insert( SEPARATOR );

		First_extendedExpression = Union( First_expression, First_fileNode );
		First_extendedExpression = Union( First_extendedExpression, First_handleNode );
		First_extendedExpression = Union( First_extendedExpression, First_printNode );

		First_enumeratedExpression = Union( First_expression, First_left_brace );
//udmoclpat changes>


		bTokenSetInitialized = true;

		Last_contextDeclarationHelper.insert( CLASS_STEREOTYPES );

		Last_literal.insert( STRING );
		Last_literal.insert( REAL );
		Last_literal.insert( INTEGER );
		Last_literal.insert( IDENTIFIER );
		Last_literal.insert( CLASS_BOOLEAN );

		Last_primaryExpression = Last_literal;
		Last_primaryExpression.insert( RIGHT_BRACE );
		Last_primaryExpression.insert( RIGHT_PARENTHESIS );
		Last_primaryExpression.insert( ENDIF );

		Last_featureCall.insert( IDENTIFIER );
		Last_featureCall.insert( RIGHT_PARENTHESIS );

		Last_implicationExpression = Union( Last_primaryExpression, Last_featureCall );

		Last_expression = Last_implicationExpression;

		Last_featureCallParametersHelper = Last_expression;
	}
}