Exemplo n.º 1
0
/*
 * build an input token..
 * consider only those starting with _ or A-Za-z.
 */
static ndptr
inspect(int c, char *tp)
{
	char *name = tp;
	char *etp = tp+MAXTOK;
	ndptr p;

	*tp++ = c;

	while ((isalnum(c = gpbc()) || c == '_') && tp < etp)
		*tp++ = c;
	if (c != EOF)
		PUSHBACK(c);
	*tp = EOS;
	/* token is too long, it won't match anything, but it can still
	 * be output. */
	if (tp == ep) {
		outputstr(name);
		while (isalnum(c = gpbc()) || c == '_') {
			if (sp < 0)
				reallyputchar(c);
			else
				CHRSAVE(c);
		}
		*name = EOS;
		return NULL;
	}

	p = ohash_find(&macros, ohash_qlookupi(&macros, name, (const char **)&tp));
	if (p == NULL)
		return NULL;
	if (macro_getdef(p) == NULL)
		return NULL;
	return p;
}
Exemplo n.º 2
0
LDemonstrator*
LDemonstrator::POPAffines(void){
LDemonstrator* result=new LDemonstrator();

int nb_repeats=GetStack()->size();

for(int i=0; i<nb_repeats;++i) {
   AttachedClauses* current=POP();
   if(current->GetKnowledge()->GetNonAffineInequations()->size() ==0){
      result->PUSHBACK(current->GetKnowledge());
      }
   else   {
      PUSHBACK(current->GetKnowledge());
      }
   }
return result;
}
Exemplo n.º 3
0
/*
 * expand_macro - user-defined macro expansion
 */
void
expand_macro(const char *argv[], int argc)
{
	const char *t;
	const char *p;
	int n;
	int argno;

	t = argv[0];		       /* defn string as a whole */
	p = t;
	while (*p)
		p++;
	p--;			       /* last character of defn */
	while (p > t) {
		if (*(p - 1) != ARGFLAG)
			PUSHBACK(*p);
		else {
			switch (*p) {

			case '#':
				pbnum(argc - 2);
				break;
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				if ((argno = *p - '0') < argc - 1)
					pbstr(argv[argno + 1]);
				break;
			case '*':
				if (argc > 2) {
					for (n = argc - 1; n > 2; n--) {
						pbstr(argv[n]);
						pushback(COMMA);
					}
					pbstr(argv[2]);
				}
				break;
                        case '@':
				if (argc > 2) {
					for (n = argc - 1; n > 2; n--) {
						pbstr(rquote);
						pbstr(argv[n]);
						pbstr(lquote);
						pushback(COMMA);
					}
					pbstr(rquote);
					pbstr(argv[2]);
					pbstr(lquote);
				}
                                break;
			default:
				PUSHBACK(*p);
				PUSHBACK('$');
				break;
			}
			p--;
		}
		p--;
	}
	if (p == t)		       /* do last character */
		PUSHBACK(*p);
}
Exemplo n.º 4
0
void
LDemonstrator::Merge(LDemonstrator* __ld){
for(list<AttachedClauses*>::iterator it=__ld->GetStack()->begin(); it != __ld->GetStack()->end(); ++it)
   PUSHBACK((*it)->GetKnowledge());
return ;
}
Exemplo n.º 5
0
void
LDemonstrator::Inject(vector<LogicalClause*>* __unified){
for(vector<LogicalClause*>::iterator it=__unified->begin(); it != __unified->end(); ++it)
   PUSHBACK(*it);
return;
}
Exemplo n.º 6
0
bool
LDemonstrator::Inference(vector<string>* __param){
// cout<<"\nLDemonstrator::Inference(vector<string>* __param){ ....\n";
// 
if(GetStack()->size() == 0)
   return this;
bool end=false;

LDemonstrator* affine=POPAffines();
// Print();
int nb_repeats=GetStack()->size();
nb_repeats*=nb_repeats;
bool some_affine_constraints=false;
if(GetStack()->size() ==0)
   end=true;

while(!end){
//    cout<<"\nLDemonstrator::Inference==========STACK\n";
//    Print();
   AttachedClauses* header=POP();
/*   cout<<"\nLDemonstrator::Inference==========HEADER\n";
   header->Print();*/
   int __nb_unified;
   if(header->GetKnowledge()->GetVariables()->size()==0){
      PUSHBACK(header->GetKnowledge());
      __nb_unified=0;
      
      }
   else{

      AttachToAll(header->GetKnowledge());
      Try2UnifyAll(__param);
      vector<LogicalClause*>* unified=new vector<LogicalClause*>();
      *unified=RecoverUnified();
      __nb_unified=unified->size();
      DetachAll();
      Inject(unified);
      
      PUSHBACK(header->GetKnowledge());
      LDemonstrator* traduced_affine=POPAffines();
   
      if(traduced_affine->GetStack()->size() != 0){
         affine->Merge(traduced_affine);
//          cout<<"\nInference ........ ohhh pas mal fin anticipée ...!\n";
//          traduced_affine->Print();
//          cout<<"\naffine ....\n";
//          affine->Print();
//          cout<<"\nInference ........ ohhh pas mal fin anticipée ...FIN\n";
         some_affine_constraints=true;
         end=true;
         }
      
      }
   
   nb_repeats--;
      
   if(nb_repeats==0) end=true;
//    cout<<"\n nb repeats = "<<nb_repeats<<"  taille pile d'inferences ="<<GetStack()->size()<<"  nb unified == "<<__nb_unified;
//    Print();

   }


// CLEAR();
Merge(affine);

// cout<<"\nLDemonstrator::Inference=================FIN DE DEMO \n";
// Print();
// cout<<"\nLDemonstrator::Inference(vector<string>* __param){ ....END\n";
// cout<<"\n================================================================\n";
return some_affine_constraints;
}