Beispiel #1
0
int main(int argc, char *argv[])
{
  FILE *f;
  int k;
  char *fname;
  
  if (argc < 2) fname="mm.txt";
  else fname=argv[1]; 
    
  tblNew(macros);
  if (!macros) merr("Unable to create table for macro");
  
  chsNew(body);
  if (!body) merr("Unable to create temporary buffer");
  
  f = fopen(fname,"r");
  if (!f) merr("Unable to open file");
  
  /* Load text into the buffer */
  chsCpyFile(text, f);
  
  fputs(text,stdout);
  fputs("\n-----------------\n",stdout);

  /* the |&B| recognizer will get a balanced parenthesis*/
  chsSubFun(text, 0,"&Km(<*a>)$(<+a>)(&B())&K(&N)",getmacro);

  tblForeach(macros,k) {
    printf("[%s] = \"%s\"\n",tblKeyS(macros,k),tblValS(macros,k)); 
  }
Beispiel #2
0
Archive
arFrString(String name)
{
	static Table	tbl = 0;
	Archive		ar;
	FileName	fn;

	arDEBUG(dbOut, "Looking for archive \"%s\"\n", name);
	
	if (tbl == 0)
		tbl = tblNew((TblHashFun) strAHash, (TblEqFun) strAEqual);

	if ((ar = (Archive) tblElt(tbl, (TblKey) name, (TblElt) 0)) != 0)
		return ar;

	if ((fn = fileRdFind(libSearchPath(), name, FTYPE_AR_INT)) != 0)
		ar = arRead(fn);
	else if (fileIsOpenable((fn = arFileNameFrPath(name)), "r")) {
		ar = arRead(fn);
	}
	else {
		comsgWarning(NULL, ALDOR_W_CantUseArchive, name);
		ar = 0;
	}

	tblSetElt(tbl, (TblKey) name, (TblElt) ar);
	return ar;
}
Beispiel #3
0
AbSub
absNew(Stab stab)
{
	AbSub	sigma;

	sigma	= (AbSub) stoAlloc((unsigned) OB_Other, sizeof(*sigma));

	sigma->stab	= stab;
	sigma->self	= false;
	sigma->lazy	= true;
	sigma->serialNo	= absSerialNo++;
	sigma->refc	= 1;
	sigma->l	= listNil(AbBind);
	sigma->results	= tblNew((TblHashFun) 0, (TblEqFun) 0);
	sigma->fv	= NULL;

	return sigma;
}
Beispiel #4
0
FreeVar
fvSingleton(Syme syme)
{
	static Table	tbl = 0;
	FreeVar		fv = 0;

	if (tbl == 0)
		tbl = tblNew((TblHashFun) 0, (TblEqFun) 0);

	assert(tbl);
	fv = (FreeVar) tblElt(tbl, syme, NULL);
	if (fv == 0) {
		fv = fvFrTheSymes(listCons(Syme)(syme, listNil(Syme)));
		tblSetElt(tbl, syme, fv);
	}

	assert(fv);
	return fv;
}