void init_acdata_dict()
{
  ATermList afuns, terms;

  _acdata_dict = (ATermList)ATreadFromBinaryString(_acdata_dict_baf, _acdata_dict_LEN);

  ATprotect((ATerm *)&_acdata_dict);

  afuns = (ATermList)ATelementAt(_acdata_dict, 0);


  terms = (ATermList)ATelementAt(_acdata_dict, 1);

}
示例#2
0
static ATerm ofp_getArgType(ATerm term, ATbool * isOptType)
{
   int i;
   ATerm kind, name;

   if (ATmatch(term, "[<term>,<term>]", &kind, &name)) {
      // MATCHED (kind, name)
   }
   else {
      *isOptType = ATfalse;
      return ATmake("None");
   }

   for (i = 0; i <  ATgetLength(gTypeTable); i++) {
      ATerm typeName, typeList;
      ATbool matched = ATfalse;
      ATerm name_type = ATelementAt(gTypeTable, i);
      if (ATmatch(name_type, "Type(<term>,<term>)", &typeName, &typeList)) {
         matched = ATtrue;
         *isOptType = ATfalse;
      }
      else if (ATmatch(name_type, "OptType(<term>,<term>)", &typeName, &typeList)) {
         matched = ATtrue;
         *isOptType = ATtrue;
      }
      if (matched && ATisEqual(name, typeName)) {
         return typeList;
      }
   }

   *isOptType = ATfalse;
   return ATmake("None");
}
示例#3
0
文件: absint.c 项目: jkeiren/muCRL
ATerm funcAbstraction(ATerm func, ATerm dstSort){ 
	ATermList argSorts;
	ATerm newTerm, newTermSort;
	ATerm arg, argSort, fSort, argSortAux;  
	ATbool  modified;
	int i, j;
	char *fName;
	AFun fun;
	
	argSorts = getFuncSortList(func);	
	fSort = getTermSort(func);
	
	fun = ATgetAFun(func); 
	fName = ATgetName(fun);
	
	if(reservedFunc(fun)) 
		return func;	

	do{
		modified = ATfalse;
		for(i=0; i< ATgetArity(ATgetAFun(func)); i++){
			arg = ATgetArgument((ATermAppl) func, i);
			argSort = ATelementAt(argSorts, i);
	 
			if(toAbstractArg(argSort, argSorts, fSort))
				argSort = liftSort(abstractSort(getUnLifted(argSort)));
			
			
			newTerm = termAbstraction(arg, argSort);
			newTermSort = getTermSort(newTerm); 
			
			
			if(newTerm != arg)
				modified = ATtrue;
			
			func = (ATerm) ATsetArgument((ATermAppl) func, newTerm, i);
			argSorts =  ATreplace(argSorts, newTermSort, i);
			
			if(toAbstractTarget(newTermSort, fSort))
				fSort = liftSort(abstractSort(getUnLifted(fSort)));
			
			if(toLiftTarget(newTermSort, fSort))
				fSort = liftSort(fSort);
				
			if(modified) break;
		}
	} while(modified);
		
	
	if(toAbstractSort(fSort) && abstractedSorts(argSorts))
		fSort = liftSort(abstractSort(getUnLifted(fSort)));

	func = createNewFuncTerm(func, argSorts, fSort);
	return func;
}
示例#4
0
void init_terms_dict()
{
  ATermList afuns, terms;

  _terms_dict = ATreadFromBinaryString(_terms_dict_baf, _terms_dict_LEN);

  ATprotect(&_terms_dict);

  afuns = (ATermList)ATelementAt((ATermList)_terms_dict, 0);


  terms = (ATermList)ATelementAt((ATermList)_terms_dict, 1);

  AnnotatedTrueAndFalse = ATgetFirst(terms);
  terms = ATgetNext(terms);
  DeclareA = ATgetFirst(terms);
  terms = ATgetNext(terms);
  DeclareAB = ATgetFirst(terms);
  terms = ATgetNext(terms);
  DeclareB = ATgetFirst(terms);
  terms = ATgetNext(terms);
  False = ATgetFirst(terms);
  terms = ATgetNext(terms);
  OtherTrueAndFalse = ATgetFirst(terms);
  terms = ATgetNext(terms);
  Ten = ATgetFirst(terms);
  terms = ATgetNext(terms);
  True = ATgetFirst(terms);
  terms = ATgetNext(terms);
  TrueAndFalse = ATgetFirst(terms);
  terms = ATgetNext(terms);
  Twenty = ATgetFirst(terms);
  terms = ATgetNext(terms);
  Two = ATgetFirst(terms);
  terms = ATgetNext(terms);
  dummy = ATgetFirst(terms);
  terms = ATgetNext(terms);
}
示例#5
0
ATermList filter_multiples(int n, ATermList numbers)
{
  int i, nr, len = ATgetLength(numbers);
  ATerm el;

  for(i=0; i<len; i++) {
    el = ATelementAt(numbers, i);
    nr = ATgetInt((ATermInt)el);
    if(nr % n == 0) {
      len--;
      numbers = ATremoveElementAt(numbers, i);
    }
  }

  return numbers;
}
示例#6
0
/**
 * Return a list of types associated with this name or None
 */
static ATerm ofp_getTypeList(ATerm name, ATbool * isOptType)
{
   int i;

   for (i = 0; i <  ATgetLength(gTypeTable); i++) {
      ATerm typeName, typeList;
      ATbool matched = ATfalse;
      ATerm name_type = ATelementAt(gTypeTable, i);
      if (ATmatch(name_type, "Type(<term>,<term>)", &typeName, &typeList)) {
         *isOptType = ATfalse;
         matched = ATtrue;
      }
      else if (ATmatch(name_type, "OptType(<term>,<term>)", &typeName, &typeList)) {
         *isOptType = ATtrue;
         matched = ATtrue;
      }
      if (matched && ATisEqual(name, typeName)) {
         return typeList;
      }
   }

   *isOptType = ATfalse;
   return ATmake("None");
}
示例#7
0
void init_Graph_dict()
{
  ATermList afuns, terms;

  _Graph_dict = ATreadFromBinaryString(_Graph_dict_baf, _Graph_dict_LEN);

  ATprotect(&_Graph_dict);

  afuns = (ATermList)ATelementAt((ATermList)_Graph_dict, 0);

  afun16 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun16);
  afuns = ATgetNext(afuns);
  afun15 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun15);
  afuns = ATgetNext(afuns);
  afun14 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun14);
  afuns = ATgetNext(afuns);
  afun13 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun13);
  afuns = ATgetNext(afuns);
  afun39 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun39);
  afuns = ATgetNext(afuns);
  afun38 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun38);
  afuns = ATgetNext(afuns);
  afun19 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun19);
  afuns = ATgetNext(afuns);
  afun37 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun37);
  afuns = ATgetNext(afuns);
  afun18 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun18);
  afuns = ATgetNext(afuns);
  afun36 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun36);
  afuns = ATgetNext(afuns);
  afun17 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun17);
  afuns = ATgetNext(afuns);
  afun35 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun35);
  afuns = ATgetNext(afuns);
  afun22 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun22);
  afuns = ATgetNext(afuns);
  afun40 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun40);
  afuns = ATgetNext(afuns);
  afun23 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun23);
  afuns = ATgetNext(afuns);
  afun41 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun41);
  afuns = ATgetNext(afuns);
  afun20 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun20);
  afuns = ATgetNext(afuns);
  afun21 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun21);
  afuns = ATgetNext(afuns);
  afun4 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun4);
  afuns = ATgetNext(afuns);
  afun5 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun5);
  afuns = ATgetNext(afuns);
  afun2 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun2);
  afuns = ATgetNext(afuns);
  afun3 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun3);
  afuns = ATgetNext(afuns);
  afun0 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun0);
  afuns = ATgetNext(afuns);
  afun1 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun1);
  afuns = ATgetNext(afuns);
  afun29 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun29);
  afuns = ATgetNext(afuns);
  afun28 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun28);
  afuns = ATgetNext(afuns);
  afun8 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun8);
  afuns = ATgetNext(afuns);
  afun25 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun25);
  afuns = ATgetNext(afuns);
  afun24 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun24);
  afuns = ATgetNext(afuns);
  afun9 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun9);
  afuns = ATgetNext(afuns);
  afun6 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun6);
  afuns = ATgetNext(afuns);
  afun27 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun27);
  afuns = ATgetNext(afuns);
  afun7 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun7);
  afuns = ATgetNext(afuns);
  afun26 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun26);
  afuns = ATgetNext(afuns);
  afun31 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun31);
  afuns = ATgetNext(afuns);
  afun32 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun32);
  afuns = ATgetNext(afuns);
  afun33 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun33);
  afuns = ATgetNext(afuns);
  afun34 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun34);
  afuns = ATgetNext(afuns);
  afun10 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun10);
  afuns = ATgetNext(afuns);
  afun11 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun11);
  afuns = ATgetNext(afuns);
  afun12 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun12);
  afuns = ATgetNext(afuns);
  afun30 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  ATprotectAFun(afun30);
  afuns = ATgetNext(afuns);

  terms = (ATermList)ATelementAt((ATermList)_Graph_dict, 1);

}
示例#8
0
static void generateSource(FILE *file, ATermList terms, ATermList afuns)
{
  int len, row, col, index;
  unsigned char *data;
  ATerm all;
  ATermList list, term_aliases, afun_aliases;
  ATermList term_values, afun_values;

  if (opt_gen_date) {
    time_t now = time(NULL);
    fprintf(file, "/*\n * Generated at %s", ctime(&now));
    fprintf(file, " */\n\n");
  }

  fprintf(file, "#include \"%s.h\"\n\n", file_prefix);

  /*{{{  unzip term and afun lists */

  term_aliases = ATempty;
  afun_aliases = ATempty;
  term_values  = ATempty;
  afun_values  = ATempty;

  list = afuns;
  while (!ATisEmpty(list)) {
    ATerm alias, value;
    ATerm pair = ATgetFirst(list);
    list = ATgetNext(list);
    if (!ATmatch(pair, "[<term>,<term>]", &alias, &value)) {
      ATfprintf(stderr, "malformed [alias,afun] pair: %t\n", pair);
      exit(1);
    }
    afun_aliases = ATinsert(afun_aliases, alias);
    afun_values  = ATinsert(afun_values, value);
  }

  afun_aliases = ATreverse(afun_aliases);
  afun_values  = ATreverse(afun_values);

  list = terms;
  while (!ATisEmpty(list)) {
    ATerm alias, value;
    ATerm pair = ATgetFirst(list);
    list = ATgetNext(list);
    if (!ATmatch(pair, "[<term>,<term>]", &alias, &value)) {
      ATfprintf(stderr, "malformed [alias,term] pair: %t\n", pair);
      exit(1);
    }
    term_aliases = ATinsert(term_aliases, alias);
    term_values  = ATinsert(term_values, value);
  }

  term_aliases = ATreverse(term_aliases);
  term_values  = ATreverse(term_values);

  /*}}}  */

  /*{{{  generate symbol declarations */

  list = afun_aliases;
  while (!ATisEmpty(list)) {
    ATerm alias = ATgetFirst(list);
    list = ATgetNext(list);

    checkAlias(alias);

    ATfprintf(file, "AFun %t;\n", alias);
  }

  fprintf(file, "\n");

  /*}}}  */
  /*{{{  generate term declarations */

  list = term_aliases;
  while (!ATisEmpty(list)) {
    ATerm alias = ATgetFirst(list);
    list = ATgetNext(list);

    checkAlias(alias);

    ATfprintf(file, "ATerm %t = NULL;\n", alias);
  }

  /*}}}  */
  /*{{{  generate BAF data */

  ATfprintf(file, "\n/*\n");

  list = afuns;
  while (!ATisEmpty(list)) {
    ATermList pair = (ATermList)ATgetFirst(list);
    list = ATgetNext(list);
    ATfprintf(file, " * %t = %t\n", ATelementAt(pair, 0), ATelementAt(pair, 1));
  }
  ATfprintf(file, " *\n");

  list = terms;
  while (!ATisEmpty(list)) {
    ATermList pair = (ATermList)ATgetFirst(list);
    list = ATgetNext(list);
    ATfprintf(file, " * %t = %t\n", ATelementAt(pair, 0), ATelementAt(pair, 1));
  }
  ATfprintf(file, " *\n");
  ATfprintf(file, " */\n");

  ATfprintf(file, "\nstatic ATerm _%s = NULL;\n\n", code_prefix);

  all = ATmake("[<term>,<term>]", afun_values, term_values);
  data = (unsigned char *)ATwriteToBinaryString(all, &len);

  ATfprintf(file, "#define _%s_LEN %d\n\n", code_prefix, len);
  ATfprintf(file, "static char _%s_baf[_%s_LEN] = {\n", code_prefix, code_prefix, len);

  index = 0;

  for (row=0; index<len; row++) {
    for (col=0; col<ROW_LENGTH && index<len; col++) {
      fprintf(file, "0x%02X", data[index++]);
      if (index < len) {
	fprintf(file, ",");
      }
    }
    fprintf(file, "\n");
  }

  ATfprintf(file, "};\n\n");

  /*}}}  */
  /*{{{  generate init function */

  ATfprintf(file, "void init_%s()\n", code_prefix);
  ATfprintf(file, "{\n");
  ATfprintf(file, "  ATermList afuns, terms;\n\n");

  ATfprintf(file, "  _%s = ATreadFromBinaryString(_%s_baf, _%s_LEN);\n", 
	    code_prefix, code_prefix, code_prefix);
  ATfprintf(file, "  assert(_%s);\n\n", code_prefix);
  ATfprintf(file, "  ATprotect(&_%s);\n\n", code_prefix);

  ATfprintf(file, "  afuns = (ATermList)ATelementAt((ATermList)_%s, 0);\n\n", code_prefix);

  list = afuns;
  while (!ATisEmpty(list)) {
    ATerm alias;
    ATermList pair = (ATermList)ATgetFirst(list);
    list = ATgetNext(list);
    alias = ATelementAt(pair, 0);
    ATfprintf(file, "  %t = ATgetAFun((ATermAppl)ATgetFirst(afuns));\n", alias);
    ATfprintf(file, "  afuns = ATgetNext(afuns);\n");
  }

  ATfprintf(file, "\n  terms = (ATermList)ATelementAt((ATermList)_%s, 1);\n\n", code_prefix);

  list = terms;
  index = 0;
  while (!ATisEmpty(list)) {
    ATerm alias;
    ATermList pair = (ATermList)ATgetFirst(list);
    list = ATgetNext(list);
    alias = ATelementAt(pair, 0);
    ATfprintf(file, "  %t = ATgetFirst(terms);\n", alias);
    ATfprintf(file, "  terms = ATgetNext(terms);\n");
  }

  ATfprintf(file, "}\n");

  /*}}}  */

}
示例#9
0
int SG_Batch (int argc, char **argv)
{
  ATerm      parse_tree;

  parse_tree = SGparseFileUsingTable(program_name, 
                                     parse_table_name, 
                                     start_symbol,
                                     input_file_name, 
                                     output_file_name);
  if (!SG_OUTPUT) {
    return 0;
  }

  if (!parse_tree) {
    ATwarning("%s: error in %s: unexpected error\n",
              program_name, input_file_name);
    return 2;
  }

  if (SGisParseError(parse_tree)) {
    ATermList errlist;
    ATerm     errcode;
    AFun      err;
    int      c, line, col;

    errlist = (ATermList) ATgetArgument((ATermAppl) parse_tree, 0);
    errcode = ATgetArgument((ATermAppl) parse_tree, 1);
    c    = ATgetInt((ATermInt) ATgetArgument(ATelementAt(errlist, 0), 0));
    line = ATgetInt((ATermInt) ATgetArgument(ATelementAt(errlist, 1), 0));
    col  = ATgetInt((ATermInt) ATgetArgument(ATelementAt(errlist, 2), 0));
    err  = ATgetAFun(errcode);

    if (err == SG_EOF_Error_AFun) {
      ATwarning("%s: error in %s, line %d, col %d: end of file unexpected\n",
                program_name, input_file_name, line, col);
    }
    else if (err == SG_Plain_Error_AFun) {
      if (isprint(c)) {
        ATwarning("%s: error in %s, line %d, col %d: character `%c' (\\x%2.2x)"
                  " unexpected\n",
                  program_name, input_file_name, line, col, c, c);
      }
      else {
        ATwarning("%s: error in %s, line %d, col %d: character \\x%2.2x"
                  " unexpected\n",
                  program_name, input_file_name, line, col, c);
      }
    } 
    else if (err == SG_Cycle_Error_AFun) {
      ATwarning("%s: error in %s, line %d, col %d: cycle detected, productions: %t\n",
                program_name, 
                input_file_name, 
                line, 
                col, 
                ATgetArgument(errcode, 0));
    }
    else if (err == SG_Amb_Error_AFun) {
      int ambiescount = ATgetInt((ATermInt) ATgetArgument(errcode,0));
      ATwarning("%s: error in %s, line %d, col %d: cannot represent %d ambiguit%s\n",
                program_name, 
                input_file_name, 
                line, 
                col, 
                ambiescount,
                (ambiescount > 1) ? "ies" : "y" );
    }
    else if (err == SG_Too_Many_Ambiguities_Error_AFun) {
      ATwarning("%s: error in %s, line %d, col %d: too many ambiguities\n",
                program_name, input_file_name, line, col);
    }
    else {
      ATwarning("%s: error in %s, line %d, col %d: unknown error\n",
                program_name, input_file_name, line, col);
    }
    return 1;
  }
  else if(!SGisParseTree(parse_tree)) {
    ATwarning("%s: error: neither parse tree nor parse error for %s\n",
              program_name, input_file_name);
    return 1;
  }

  IF_VERBOSE(
    int  nrambs;
    char *sort;

    nrambs = SGnrAmb(SG_NR_ASK);
    sort   = SGsort(SG_GET, NULL);
    ATwarning("%s: %s parsed %s as sort %s, with %d ambiguit%s\n",
              program_name, parse_table_name, input_file_name,
              sort ? sort : "[undetermined]",
              nrambs, (nrambs==1)?"y":"ies");
  );
示例#10
0
PT_Symbol PT_getSymbolsSymbolAt(PT_Symbols symbols, int index)
{
    return PT_makeSymbolFromTerm(
	 ATelementAt((ATermList)PT_makeTermFromSymbols(symbols), index));
}
示例#11
0
void init_AIL_dict()
{
  ATermList afuns, terms;

  _AIL_dict = (ATermList)ATreadFromBinaryString(_AIL_dict_baf, _AIL_dict_LEN);

  ATprotect((ATerm *)&_AIL_dict);

  afuns = (ATermList)ATelementAt(_AIL_dict, 0);

  AIL_afun0 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun1 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun2 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun3 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun4 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun5 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun6 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun7 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun8 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun9 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun10 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun11 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun12 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun13 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun14 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun15 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun16 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun17 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun18 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun19 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun20 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun21 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun22 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun23 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun24 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun25 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun26 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun27 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun28 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun29 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun30 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun31 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun32 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun33 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun34 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun35 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun36 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun37 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun38 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun39 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun40 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun41 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun42 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun43 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun44 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);
  AIL_afun45 = ATgetAFun((ATermAppl)ATgetFirst(afuns));
  afuns = ATgetNext(afuns);

  terms = (ATermList)ATelementAt(_AIL_dict, 1);

  AIL_patternStatementListMany = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternStatementListSingle = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternStatementListEmpty = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternProgramProgram = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternArgLabel = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternArgAterm = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternArgCode = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternArgNumber = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternStatementInstruction = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternStatementLabelDef = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternInstructionWithArg = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternInstructionWithoutArg = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternSignatureListMany = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternSignatureListSingle = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternSignatureListEmpty = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternDefinitionDefault = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternSignatureWithoutPattern = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternSignatureWithPattern = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternPatternCode = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternPatternLabel = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternPatternAterm = ATgetFirst(terms);
  terms = ATgetNext(terms);
  AIL_patternPatternInt = ATgetFirst(terms);
  terms = ATgetNext(terms);
}
示例#12
0
ATbool ofp_traverse_FunType(ATerm term, pOFP_Traverse FunType)
{
   int i;
   char * percent_s = "%s";
   char * comma = "";
   char * name = "None";
   ATermList args = (ATermList) ATmake("[]");

//#ifdef DEBUG_PRINT
   printf("\nFunType: %s\n", ATwriteToString(term));
//#endif

   OFP_Traverse FunType_args, FunType_result;
   if (ATmatch(term, "FunType(<term>,<term>)", &FunType_args.term, &FunType_result.term) ) {

   printf("---------args------- %s\n", ATwriteToString(FunType_args.term));
      if (ofp_traverse_FunType_result(FunType_result.term, &FunType_result)) {
         // MATCHED FunType_result
         name = (char*) FunType_result.post;
      } else return ATfalse;
      printf("---------name------- %s\n", name);

      ATermList FunType_args_tail = (ATermList) ATmake("<term>", FunType_args.term);
      while (! ATisEmpty(FunType_args_tail)) {
         OFP_Traverse FunType_arg;
         FunType_arg.term = ATgetFirst(FunType_args_tail);
         FunType_args_tail = ATgetNext(FunType_args_tail);

         if (ofp_traverse_FunType_arg(FunType_arg.term, &FunType_arg)) {
            // MATCHED FunType_arg
            args = ATappend(args, FunType_arg.term);
         } else return ATfalse;
      }

   }

   /** Output traversal function header information
    */
   printf("\n");
   printf("//========================================================================================\n");
   printf("// %s\n", name);
   printf("//----------------------------------------------------------------------------------------\n");
   printf("ATbool ofp_traverse_%s(ATerm term, pOFP_Traverse %s)\n", name, name);
   printf("{\n");
   printf("#ifdef DEBUG_PRINT\n");
   printf("   printf(\"%s: %s\\n\", ATwriteToString(term));\n", name, percent_s);
   printf("#endif\n\n");

   for (i = 0; i <  ATgetLength(args); i++) {
      ATerm arg = ATelementAt(args, i);
      ATbool list_type = ofp_isArgListKind(arg);
      if (list_type) ofp_build_node_traversal(arg, "_list", 1);
      else           ofp_build_node_traversal(arg, "_term", 1);
   }

   /** Declare input (args) to production 
    */
   comma = "";
   printf("   OFP_Traverse");
   for (i = 0; i <  ATgetLength(args); i++) {
      char * arg_name = "None";
      ATerm arg = ATelementAt(args, i);
      ATbool list_type = ofp_isArgListKind(arg);
      printf("%s %s", comma, ofp_getArgNameStr(arg, &arg_name));
      if (list_type) printf("_list");
      else           printf("_term");
      comma = ",";
   }
   printf(";\n");

   /** Traverse input (args) to production 
    */
   comma = "";
   // replace production name with the name given to the ATerm
   printf("   if (ATmatch(term, \"%s(", (char*) FunType->pre);
   for (i = 0; i <  ATgetLength(args); i++) {
      printf("%s<term>", comma);
      comma = ",";
   }
   printf(")\"");

   for (i = 0; i <  ATgetLength(args); i++) {
      char * arg_name = "None";
      ATerm arg = ATelementAt(args, i);
      ATbool list_type = ofp_isArgListKind(arg);

      printf(", &%s", ofp_getArgNameStr(arg, &arg_name));
      if (list_type) printf("_list");
      else           printf("_term");
      printf(".term");
   }
   printf(")) {\n\n");

   /** Call traversal for input (arg) to production 
    */
   for (i = 0; i <  ATgetLength(args); i++) {
      ATbool isOptType;
      ATerm arg = ATelementAt(args, i);
      ATerm type = ofp_getArgType(arg, &isOptType);
      ATerm kind = ofp_getArgKind(arg);
      ATerm name = ofp_getArgName(arg);

      if (ofp_isTypeNameList(type)) {
         int j;
         ATermList nameList = (ATermList) type;
         for (j = 0; j < ATgetLength(nameList); j++) {
            arg = ATmake("[<term>,<term>]", kind, ATelementAt(nameList, j));
            ofp_build_old_node_traversal(name, arg, kind);
         }
         // This is a production with or rules so one of the traversals must have
         // matched and returned ATtrue. So return ATfalse in case none matched.
         printf("      return ATfalse; /* for set of OR productions */\n");
      }
      else {
         ofp_build_old_node_traversal(ofp_getArgName(arg), arg, kind);
      }
   }

   printf("\n      return ATtrue;\n");
   printf("   }\n");
   printf("\n   return ATfalse;\n");
   printf("}\n");

   return ATtrue;
}