예제 #1
0
void
Bchart::
add_reg_item(Item * itm )
{
    if(printDebug() > 250) cerr << "add_reg_item " << *itm << endl;
    put_in_reg(itm);
    add_starter_edges(itm); 
//
// Look at the art for this item (i.e., it has the same Term and start). For
// each of the dotted rules which hope to have this item following the 'dot', 
// extend the rule.  
//
    
  for(int right = 0 ; right < 2 ; right++)
    {
      int pos = right ? itm->start() : itm->finish();
      //cerr<< "Look for " << *itm << " " << pos << " " << right << endl;
      Edges::iterator edgeIter = waitingEdges[right][pos].begin();
      for( ; edgeIter != waitingEdges[right][pos].end() ; edgeIter++ )
	{
	  Edge* edge = *edgeIter;
	  extend_rule(edge, itm, right);
	}
    }
}
예제 #2
0
void
Bchart::
already_there_extention(int i, int start, int right, Edge* edge)
{
  assert(i >= 0 && i < MAXSENTLEN && start >= 0 && start < MAXSENTLEN);
  Items::iterator regsiter = regs[i][start].begin();
  for( ; regsiter != regs[i][start].end() ; regsiter++)
    {
      Item* item = *regsiter;
      extend_rule( edge, item, right );  
    }
}
예제 #3
0
파일: expand.cpp 프로젝트: igel-kun/sudoku
int main(int argc, char** argv){
	gen_rule extend_rule(extend);	
	bool applicable;

	gen_sudoku s(9);
	cin >> s;
	applicable = s.applyrule(&extend_rule);
	if(applicable) {
		cout << s;
		return 1;
	} else return 0;
}
예제 #4
0
//also need to make lhs of edge a term*, and give edge a start member.
void
Bchart::
add_starter_edges(Item* itm)
{
  if(printDebug() > 140)
    cerr << "add_starter_edges " << *itm << endl;
  ConstTerm* poslhs;
  int ht = itm->term()->toInt();
  int i;
  for(i = 0 ; ; i++)
    {
      int rt = posStarts(ht,i);
      if(rt < 0) break;
      poslhs = Term::fromInt(rt);
      Edge*  nedge = new Edge(poslhs);//???;
      extend_rule(nedge, itm, 0);  //adding head is like extending left;
    }
}
예제 #5
0
void
Bchart::
add_edge(Edge* edge, int right)
{
  if(printDebug() > 250)
    wcerr << "add_edge " << *edge << endl;

  int     loc = right ? edge->loc() : edge->start() ;
  int     i;

  extend_rule(edge, stops[loc], right); 
  // Iterate over i = the length of the constituent -1.;
  // looking for a reg item of length i and starting position start;
  if(right)
    for( i = 0 ; i < wrd_count_ - loc ; i++ )
      already_there_extention(i, loc, right, edge);
  else
    for( i = 0 ; i < loc ; i++)
      already_there_extention(loc - i -1, i, right, edge);

  assert(loc >= 0 && loc < MAXSENTLEN);
  waitingEdges[right][loc].push_back( edge ); 
}