ATermList get_imports(ATermList decls)
{
  ATerm decl, mod, spec;
  ATermList mods, new_decls;
  
  new_decls = ATmakeList0();
  while(!ATisEmpty(decls)) {
    decl = ATgetFirst(decls);
    decls = ATgetNext(decls);
    if(ATmatch(decl, "Imports([<list>])", &mods)) {
	while(!ATisEmpty(mods)) {
	    mod = ATgetFirst(mods);
	    mods = ATgetNext(mods);
	    if(ATindexOf(imported, mod, 0) == -1) 
	      {
		if(!silent)
		  ATfprintf(stderr, "        importing: %t\n", mod);
		imported = ATinsert(imported, mod);
		sprintf(file_name, "%s.r", t_string(mod));
		spec = parse_file(file_name);
		new_decls = ATconcat(spec_decls(spec), new_decls);
	    }
	    else
	      {
		if(!silent)
		  ATfprintf(stderr, "        importing: %t (done)\n", mod);
	      }
	}
    } else {
	new_decls = ATinsert(new_decls, decl);
    }
  }
  return new_decls;
}
Beispiel #2
0
ATermList procAbstraction(ATermList procArgs){
	ATerm procArg, newTerm, par, parSort, parName;
	ATermList newProcArgs = ATmakeList0();	
	ATermList pars = MCRLgetListOfPars();
	ATerm termSort;
		
	for (;!ATisEmpty(procArgs); 
			procArgs = ATgetNext(procArgs), pars = ATgetNext(pars)) { 
		procArg = ATgetFirst(procArgs);	
		par = ATgetFirst(pars);
		parSort = (ATerm) ATgetArgument((ATermAppl) par, 1);
		parName = (ATerm) ATgetArgument((ATermAppl) par, 0);
		newTerm = termAbstraction(procArg, parSort);	
		
		termSort = getTermSort(newTerm);
		

		if(isAbstracted(termSort) && !isAbstracted(parSort)){
			if(!isLifted(termSort)){
				newTerm = createSingTerm(newTerm, liftSort(termSort));
				termSort = liftSort(termSort);
			}
			newTerm = createGammaTerm(newTerm, termSort);
			if(-1 == ATindexOf(conflictingPars, parName , 0))
				conflictingPars = ATappend(conflictingPars, parName);
		}
					
		newProcArgs = ATappend(newProcArgs, newTerm);
	}
	return newProcArgs;	
}
Beispiel #3
0
ATbool contains_epsilon(ATermList set) {
  PT_Symbol epsilon = PT_makeSymbolEmpty();
  
  if(ATindexOf(set,(ATerm)epsilon,0) >= 0)
    return ATtrue;
  else
    return ATfalse;
}
Beispiel #4
0
int main(int argc, char *argv[]) {
    int i, j = 0;
    char **newargv = (char**) calloc(argc + 2, sizeof(char*));
    ATsetWarningHandler(WarningHandler);
    ATsetErrorHandler(ErrorHandler);
    if (!newargv) ATerror("Cannot allocate array argv");  
    newargv[j++] = argv[0]; newargv[j++] = "-no-extra-rules";
    ATinit(argc, argv, (ATerm*) &argc);
    ATprotect((ATerm*) &smds);
    ATprotect((ATerm*) &pars);
    ATprotect((ATerm*) &inits);
    ATprotect((ATerm*) &vars);
    ATprotect((ATerm*) &actnames);
    ATprotect((ATerm*) &actargs);
    vars = actnames = actargs = ATempty;
    for (i=1;i<argc;i++) {
    if (!strcmp(argv[i],"-help")) {
	help();
	exit(0);
	}
    if (!strcmp(argv[i],"-version")) {
	version();
	exit(0);
	}
   if (!strcmp(argv[i],"-pars")) {
	pars = ATempty;
        continue;
	}
   if (!strcmp(argv[i],"-npars")) {
	npars = ATtrue;
        continue;
	}
   if (!strcmp(argv[i],"-extra")) {
	extra = ATtrue;
        continue;
	}
    newargv[j++] = argv[i];
    }
    if (extra) {
         if (!MCRLinitRW(j, newargv)) exit(EXIT_FAILURE);
         RWdeclareVariables(MCRLgetListOfPars());
         }
    else
    {if (!MCRLinitSU(j, newargv)) exit(EXIT_FAILURE);}
    if (npars) {
        fprintf(stdout,"%d", MCRLgetNumberOfPars());
        exit(EXIT_SUCCESS);
        }
    smds = MCRLgetListOfSummands();
    if (pars) {
         pars = MCRLgetListOfPars();
         inits = MCRLgetListOfInitValues();
         }
    ATfprintf(stdout, "Number of process parameters: %d\n", 
          MCRLgetNumberOfPars());
    ATfprintf(stdout, "Number of summands: %d\n",ATgetLength(smds));
    for (;!ATisEmpty(smds);smds=ATgetNext(smds)) {
         ATerm smd = ATgetFirst(smds);
         ATerm actname = ATgetArgument((ATermAppl) smd, 1),
               actarg = ATgetArgument((ATermAppl) smd, 2);
         vars = ATconcat(vars, (ATermList) ATgetArgument((ATermAppl) smd, 0));
         if (ATindexOf(actnames , actname, 0) < 0 || 
               ATindexOf(actargs , actarg, 0)<0) {
                actnames = ATinsert(actnames, actname); 
                actargs = ATinsert(actargs, actarg);
                }
         if (extra) {
                if (!ATisEmpty(vars)) ATerror(
                "Flag -extra cannot be used, there are sum variables present");
                DisabledEdges(
                   (ATermList) ATgetArgument(
                      (ATermAppl)ATgetArgument((ATermAppl) smd, 3), 0));
                }
         }
    ATfprintf(stdout, "Number of sum variables: %d\n", ATgetLength(vars));
    ATfprintf(stdout, "Number of different action names: %d\n", 
               ATgetLength(actnames));
    if (pars) {
        ATfprintf(stdout, "Process parameters\n");
        for (i=1;!ATisEmpty(pars)&&!ATisEmpty(inits);
             pars=ATgetNext(pars), inits=ATgetNext(inits),i++) {
             ATerm par = ATgetFirst(pars);
             ATfprintf(stdout, "%t:\t%t\tinit[%d]=%t\n", MCRLprint(
                   ATgetArgument((ATermAppl)par, 0)),
                   MCRLprint(ATgetArgument((ATermAppl)par, 1)),
                   i, MCRLprint(ATgetFirst(inits))); 
             }
       }
    exit(EXIT_SUCCESS); 
    }