Пример #1
0
void
Grammar::process( void )
{
	RuleTable::get()->findPrecedences();

	/// Compute the lambda-nonterminals and the first-sets for every
    /// nonterminal
	findFirstSets();

	// Compute all LR(0) states.  Also record follow-set propagation
	// links so that the follow-set can be computed later
	findStates();

	// Tie up loose ends on the propagation links
	findLinks();

	// Compute the follow set of every reducible configuration
	findFollowSets();

	// Compute the action tables
	findActions();

	// Compress the action tables
	if ( isCompressActions() )
		compressTables();

	// Generate a report of the parser generated.  (the "y.output" file) */
	if ( ! isQuiet() )
		reportOutput();

	// Generate the source code for the parser
	outputFiles();
}
Пример #2
0
void
CragStackCombiner::combine(const std::vector<Crag>& crags, Crag& crag) {

	LOG_USER(cragstackcombinerlog)
			<< "combining CRAGs, "
			<< (_requireBbOverlap ? "" : " do not ")
			<< "require bounding box overlap"
			<< std::endl;

	std::map<Crag::Node, Crag::Node> prevNodeMap;
	std::map<Crag::Node, Crag::Node> nextNodeMap;

	for (unsigned int z = 1; z < crags.size(); z++) {

		LOG_USER(cragstackcombinerlog) << "linking CRAG " << (z-1) << " and " << z << std::endl;

		if (z == 1)
			prevNodeMap = copyNodes(crags[0], crag);
		else
			prevNodeMap = nextNodeMap;

		nextNodeMap = copyNodes(crags[z], crag);

		std::vector<std::pair<Crag::Node, Crag::Node>> links = findLinks(crags[z-1], crags[z]);

		for (const auto& pair : links)
			crag.addAdjacencyEdge(
					prevNodeMap[pair.first],
					nextNodeMap[pair.second]);
	}
}