static void writeSet(A2PWriter writer, A2PType expected, ATermList set){ A2PSetType setType = (A2PSetType) expected->theType; A2PType elementType = setType->elementType; ISIndexedSet sharedTypes = writer->typeSharingMap; int elementHash = hashType(elementType); int elementTypeId = ISget(sharedTypes, (void*) elementType, elementHash); int size = ATgetLength(set); ATermList next; if(elementTypeId == -1){ writeByteToBuffer(writer->buffer, PDB_SET_HEADER); doWriteType(writer, elementType); ISstore(sharedTypes, (void*) elementType, elementHash); }else{ writeByteToBuffer(writer->buffer, PDB_SET_HEADER | PDB_TYPE_SHARED_FLAG); printInteger(writer->buffer, elementTypeId); } printInteger(writer->buffer, size); next = set; while(!ATisEmpty(next)){ ATerm current = ATgetFirst(next); next = ATgetNext(next); doSerialize(writer, elementType, current); } }
static void writeRelation(A2PWriter writer, A2PType expected, ATermList relation){ A2PRelationType relationType = (A2PRelationType) expected->theType; A2PType tupleType = relationType->tupleType; ISIndexedSet sharedTypes = writer->typeSharingMap; int tupleHash = hashType(tupleType); int tupleTypeId = ISget(sharedTypes, (void*) tupleType, tupleHash); int size = ATgetLength(relation); ATermList next; if(tupleTypeId == -1){ writeByteToBuffer(writer->buffer, PDB_RELATION_HEADER); doWriteType(writer, tupleType); ISstore(sharedTypes, (void*) tupleType, tupleHash); }else{ writeByteToBuffer(writer->buffer, PDB_RELATION_HEADER | PDB_TYPE_SHARED_FLAG); printInteger(writer->buffer, tupleTypeId); } printInteger(writer->buffer, size); next = relation; while(!ATisEmpty(next)){ ATerm current = ATgetFirst(next); next = ATgetNext(next); doSerialize(writer, tupleType, current); } }
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"); }
ATbool ofp_traverse_OpDeclInj(ATerm term, pOFP_Traverse OpDeclInj) { ATerm alias, type, opt; int isOptType = 0; if (ATmatch(term, "OpDeclInj(<term>)", &OpDeclInj->term)) { #ifdef DEBUG_PRINT printf("\nofp_traverse_OpDeclInj: %s\n", ATwriteToString(OpDeclInj->term)); #endif if (ATmatch(OpDeclInj->term, "FunType(<term>,<term>)", &type, &alias)) { ATermList list; if (ATmatch(type, "<term>", &list)) { // not a simple alias if (ATgetLength(list) > 1) return ATfalse; } else return ATfalse; if (ATmatch(type, "[ConstType(SortNoArgs(<term>))]", &type)) { // MATCHED object type } else return ATfalse; if (ATmatch(alias, "ConstType(SortNoArgs(<term>))", &alias)) { // MATCHED object alias } else return ATfalse; } else return ATfalse; OpDeclInj->term = ATmake("Alias(<term>,<term>)", type, alias); return ATtrue; } return ATfalse; }
static void writeAnnotatedNode(A2PWriter writer, A2PType expected, ATermAppl node, ATermList annotations){ A2PNodeType t = (A2PNodeType) expected->theType; AFun fun = ATgetAFun(node); int arity = ATgetArity(fun); char *name = ATgetName(fun); int nrOfAnnotations = ATgetLength(annotations); int i; ATerm annotationLabel; ATerm annotationValue; unsigned int hash = hashString(name); int nodeNameId = ISstore(writer->nameSharingMap, (void*) name, hash); if(nodeNameId == -1){ int nameLength = dataArraySize(name); writeByteToBuffer(writer->buffer, PDB_ANNOTATED_NODE_HEADER); printInteger(writer->buffer, nameLength); writeDataToBuffer(writer->buffer, name, nameLength); }else{ writeByteToBuffer(writer->buffer, PDB_ANNOTATED_NODE_HEADER | PDB_NAME_SHARED_FLAG); printInteger(writer->buffer, nodeNameId); } printInteger(writer->buffer, arity); for(i = 0; i < arity; i++){ doSerialize(writer, A2PvalueType(), ATgetArgument(node, i)); } /* Annotations. */ if((nrOfAnnotations % 2) == 1){ fprintf(stderr, "Detected corrupt annotations (Unbalanced).\n"); exit(1); } printInteger(writer->buffer, nrOfAnnotations); do{ char *label; int labelLength; A2PType annotationType; annotationLabel = ATgetFirst(annotations); annotations = ATgetNext(annotations); annotationValue = ATgetFirst(annotations); annotations = ATgetNext(annotations); if(ATgetType(annotationLabel) != AT_APPL){ fprintf(stderr, "Detected corrupt annotation; label term is not a 'string'.\n"); exit(1); } label = ATgetName(ATgetAFun((ATermAppl) annotationLabel)); labelLength = dataArraySize(label); printInteger(writer->buffer, labelLength); writeDataToBuffer(writer->buffer, label, labelLength); annotationType = (A2PType) HTget(t->declaredAnnotations, (void*) label, hashString(label)); doSerialize(writer, annotationType, annotationValue); }while(!ATisEmpty(annotations)); }
static void writeAnnotatedConstructor(A2PWriter writer, A2PType expected, ATermAppl constructor, ATermList annotations){ A2PConstructorType t = (A2PConstructorType) expected->theType; ISIndexedSet sharedTypes = writer->typeSharingMap; int typeHash = hashType(expected); int constructorTypeId = ISget(sharedTypes, (void*) expected, typeHash); int arity = ATgetArity(ATgetAFun(constructor)); int nrOfAnnotations = ATgetLength(annotations); int i; ATerm annotationLabel; ATerm annotationValue; if(constructorTypeId == -1){ writeByteToBuffer(writer->buffer, PDB_ANNOTATED_CONSTRUCTOR_HEADER); doWriteType(writer, expected); ISstore(sharedTypes, (void*) expected, typeHash); }else{ writeByteToBuffer(writer->buffer, PDB_ANNOTATED_CONSTRUCTOR_HEADER | PDB_TYPE_SHARED_FLAG); printInteger(writer->buffer, constructorTypeId); } printInteger(writer->buffer, arity); for(i = 0; i < arity; i++){ doSerialize(writer, ((A2PTupleType) t->children->theType)->fieldTypes[i], ATgetArgument(constructor, i)); } /* Annotations. */ if((nrOfAnnotations % 2) == 1){ fprintf(stderr, "Detected corrupt annotations (Unbalanced).\n"); exit(1); } printInteger(writer->buffer, nrOfAnnotations); do{ char *label; int labelLength; A2PType annotationType; annotationLabel = ATgetFirst(annotations); annotations = ATgetNext(annotations); annotationValue = ATgetFirst(annotations); annotations = ATgetNext(annotations); if(ATgetType(annotationLabel) != AT_APPL){ fprintf(stderr, "Detected corrupt annotation; label term is not a 'string'.\n"); exit(1); } label = ATgetName(ATgetAFun((ATermAppl) annotationLabel)); labelLength = dataArraySize(label); printInteger(writer->buffer, labelLength); writeDataToBuffer(writer->buffer, label, labelLength); annotationType = (A2PType) HTget(t->declaredAnnotations, (void*) label, hashString(label)); doSerialize(writer, annotationType, annotationValue); }while(!ATisEmpty(annotations)); }
static ATbool ofp_isTypeNameList(ATerm type) { if (! ATmatch(type, "None")) { ATermList nameList = (ATermList) type; if (ATgetLength((ATermList) type) > 1) { return ATtrue; } } return ATfalse; }
void printResults(){ ATermList pars; ATermList vars; ATermList abstracted, lifted; ATerm par, parSort; ATerm var, varSort; abstracted = ATmakeList0(); lifted = ATmakeList0(); pars = ATtableKeys(par_tab); for(;!ATisEmpty(pars); pars = ATgetNext(pars)){ par = ATgetFirst(pars); parSort = ATtableGet(par_tab, par); if(isAbstracted(parSort)){ abstracted = ATinsert(abstracted, par); } else if (isLifted(parSort)){ lifted = ATinsert(lifted, par); } } fprintf(stderr, "%d Parameters Abstracted:\n", ATgetLength(abstracted)); pTerm((ATerm) abstracted); fprintf(stderr, "%d Parameters Lifted:\n", ATgetLength(lifted)); pTerm((ATerm) lifted); fprintf(stderr, "%d Conflicting Parameters:\n", ATgetLength(conflictingPars)); pTerm((ATerm) conflictingPars); abstracted = ATmakeList0(); vars = ATtableKeys(var_tab); for(;!ATisEmpty(vars); vars = ATgetNext(vars)){ var = ATgetFirst(vars); varSort = ATtableGet(var_tab, var); if(isAbstracted(varSort)){ abstracted = ATinsert(abstracted, var); } } fprintf(stderr, "%d Variables Abstracted:\n", ATgetLength(abstracted)); pTerm((ATerm) abstracted); }
int main(int argc, char *argv[]) { int i, j = 0; ATbool result = ATfalse; int absCounter; char **newargv = (char**) calloc(argc + 1, sizeof(char*)); parseCommandLine(argc, argv); if (!newargv) ATerror("Cannot allocate array argv"); newargv[j++] = argv[0]; ATinit(argc, argv, (ATerm*) &argc); ATsetWarningHandler(WarningHandler); ATsetErrorHandler(ErrorHandler); if (!MCRLinitRW(j, newargv)) exit(-1); fprintf(stderr, "Number of Summands (input): %d\n", ATgetLength(MCRLgetListOfSummands())); if(prevAbstraction()){ P("The Specification has been abstracted before."); exit(0); } initAbsInt(); abstractParsAndVars(); specAbstraction(); abstractSummands(); fprintf(stderr, "Number of Summands (output): %d\n", ATgetLength(MCRLgetListOfSummands())); printResults(); MCRLoutput(); if (!result) exit(EXIT_FAILURE); else exit(EXIT_SUCCESS); }
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; }
void *_mkterm() { char *f; ATermList ts; MatchFunFC("TCons", 2, &&mkterm_fail); Arg(0); if(ATisString(Ttop())) { f = t_string(Ttop()); Tpop(); Arg(1); Tdrop(); MatchFunFC("TCons", 2, &&mkterm_fail); Arg(0); ts = (ATermList) consnil_to_list_shallow(Ttop()); Tpop(); Tset((ATerm) ATmakeApplList(ATmakeSymbol(f, ATgetLength(ts), ATfalse), ts)); } else if(ATgetType(Ttop()) == AT_REAL)
static ATerm _ProveCondition(ATerm c) { /* Obliged that last branch must be "if (b, T, F)" Invariant will be used at each first argument of "if" */ ATerm result = c; ATermList ts = ATempty; while (ATgetAFun(c)==MCRLsym_ite && ATgetArgument((ATermAppl) c, 2) == MCRLterm_false) { ts = ATinsert(ts, ATgetArgument((ATermAppl) c, 0)); c = ATgetArgument((ATermAppl) c, 1); } if (ATisEmpty(ts)) return result; else { int n = ATgetLength (ts), i; DECLA(ATerm, l, n);DECLA(ATerm, r, n); DECLA(ATerm, s, n); ATerm I = MCRLgetInvariant(0); for (i=n-1;i>=0;i--, ts = ATgetNext(ts)) l[i] = ATgetFirst(ts); for (i=0;i<n;i++) { int j, p; for (p = 0, j=n-1;j>=0;j--) if (i!=j) { s[p] = (ATerm) ATmakeAppl3(MCRLsym_ite, l[j], p>0?s[p-1]:MCRLterm_true,MCRLterm_false); p++; } r[i] = p>0?s[p-1]:MCRLterm_true; } for (i=0;i<n;i++) { /* If proven (I and r) -> l then (c = l and r) will be replaced by r */ ATerm IandR = (ATerm) ATmakeAppl2(MCRLsym_and, I, r[i]), arrow = Prove((ATerm) ATmakeAppl3(MCRLsym_ite, IandR, l[i], MCRLterm_true)); /* ATwarning("QQQA %t", MCRLprint(arrow)); */ if (ATisEqual(arrow, MCRLterm_true)) { return r[i]; } } return result; } }
static void DisabledEdges(ATermList gs) { ATermList smds = MCRLgetListOfSummands(), pars = MCRLgetListOfPars(); int false_cnt = 0, true_cnt = 0, n = ATgetLength(smds); static int k = 1; SubstituteInPars(pars, gs); for (;!ATisEmpty(smds);smds=ATgetNext(smds)) { ATerm smd = ATgetFirst(smds), c = ATgetArgument((ATermAppl) smd,4), cw = NULL; if (!ATisEmpty((ATermList) ATgetArgument((ATermAppl) smd, 0))) ATerror("Flag -extra is used while sum variables occur"); cw = RWrewrite(c); if ( ATisEqual(cw, MCRLterm_false)) false_cnt++; if ( ATisEqual(cw, MCRLterm_true)) true_cnt++; } fprintf(stdout, "Summand %d N = %d disabled %d enabled %d\n", k++, n, false_cnt, true_cnt); }
void ofp_build_or_traversal(ATerm arg, char * src_suffix, int depth) { int i; ATbool isOptType; char * arg_name = ofp_getArgNameStr(arg, &arg_name); ATerm kind = ofp_getArgKind(arg); ATerm type = ofp_getArgType(arg, &isOptType); ATermList nameList = (ATermList) type; indent(depth); printf("OR traversal......... %s;\n", ATwriteToString(type)); for (i = 0; i < ATgetLength(nameList); i++) { printf("OR traversal.........kind=%s\n", ATwriteToString(kind)); // ATerm argi = ATmake("[<term>,<term>]", kind, ATelementAt(nameList, i)); // ofp_build_node_traversal(argi, "", depth); } // 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. indent(depth); printf("return ATfalse; /* for set of OR productions */\n"); }
ATbool ofp_traverse_FunType_arg(ATerm term, pOFP_Traverse FunType_arg) { ATbool isOptType; #ifdef DEBUG_PRINT printf("\nFunType_arg: %s\n", ATwriteToString(term)); #endif if (ATmatch(term, "ConstType(Sort(<str>,<term>))", &FunType_arg->pre, &FunType_arg->term)) { if (ATmatch(FunType_arg->term, "[SortNoArgs(<str>)]", &FunType_arg->post)) { // MATCHED FunType_arg_type ATerm type_name = ATmake("<str>", (char*)FunType_arg->post); ATerm type_list = ofp_getTypeList(type_name, &isOptType); if (isOptType) { FunType_arg->pre = "OptionOption"; } } else return ATfalse; } else if (ATmatch(term, "ConstType(SortNoArgs(<str>))", &FunType_arg->post)) { // MATCHED FunType_arg_type ATerm type_name = ATmake("<str>", (char*)FunType_arg->post); ATerm type_list = ofp_getTypeList(type_name, &isOptType); FunType_arg->pre = "None"; if (! ATmatch(type_list, "None")) { ATermList nameList = (ATermList) type_list; if (ATgetLength(nameList) > 1) { FunType_arg->pre = "Or"; } } } else { return ATfalse; } FunType_arg->term = ATmake("[<str>,<str>]", (char*)FunType_arg->pre, (char*)FunType_arg->post); return ATtrue; }
static void writeMap(A2PWriter writer, A2PType expected, ATermList map){ A2PMapType mapType = (A2PMapType) expected->theType; ISIndexedSet sharedTypes = writer->typeSharingMap; int mapHash = hashType(expected); int mapTypeId = ISget(sharedTypes, (void*) expected, mapHash); int size = ATgetLength(map); ATermList next; if(size % 2 == 1){ fprintf(stderr, "Number of elements in the map is unbalanced.\n"); exit(1); } if(mapTypeId == -1){ writeByteToBuffer(writer->buffer, PDB_MAP_HEADER); doWriteType(writer, expected); ISstore(sharedTypes, (void*) expected, mapHash); }else{ writeByteToBuffer(writer->buffer, PDB_MAP_HEADER | PDB_TYPE_SHARED_FLAG); printInteger(writer->buffer, mapTypeId); } printInteger(writer->buffer, size >> 1); next = map; while(!ATisEmpty(next)){ ATerm key = ATgetFirst(map); ATerm value; next = ATgetNext(map); value = ATgetFirst(map); next = ATgetNext(map); doSerialize(writer, mapType->keyType, key); doSerialize(writer, mapType->valueType, value); } }
/** * 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"); }
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); }
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; }
int PT_getSymbolsLength(PT_Symbols symbols) { return ATgetLength(PT_SymbolsToTerm(symbols)); }