std::ostream& theory::display_flat_app(std::ostream & out, app * n) const { func_decl * d = n->get_decl(); if (n->get_num_args() == 0) { out << d->get_name(); display_parameters(out, d->get_num_parameters(), d->get_parameters()); } else if (n->get_family_id() == get_family_id()) { out << "(" << d->get_name(); display_parameters(out, d->get_num_parameters(), d->get_parameters()); ptr_buffer<app> todo; todo.push_back(n); while (!todo.empty()) { n = todo.back(); todo.pop_back(); unsigned num = n->get_num_args(); for (unsigned i = 0; i < num; i++) { app * arg = to_app(n->get_arg(i)); if (d->is_associative() && arg->get_decl() == d) { todo.push_back(arg); } else { out << " "; display_app(out, arg); } } } out << ")"; } else { out << "#" << n->get_id(); } return out; }
/** \brief Display enode definitions #n := (f #i_1 ... #i_n), where #i_k is the root of the k-th argument of the enode #n. */ void context::display_normalized_enodes(std::ostream & out) const { out << "normalized enodes:\n"; ptr_vector<enode>::const_iterator it = m_enodes.begin(); ptr_vector<enode>::const_iterator end = m_enodes.end(); for (; it != end; ++it) { enode * n = *it; out << "#"; out.width(5); out << std::left << n->get_owner_id() << " #"; out.width(5); out << n->get_root()->get_owner_id() << " := " << std::right; unsigned num = n->get_owner()->get_num_args(); if (num > 0) out << "("; out << n->get_decl()->get_name(); if (!n->get_decl()->private_parameters()) display_parameters(out, n->get_decl()->get_num_parameters(), n->get_decl()->get_parameters()); for (unsigned i = 0; i < num; i++) { expr * arg = n->get_owner()->get_arg(i); if (e_internalized(arg)) { enode * n = get_enode(arg)->get_root(); out << " #" << n->get_owner_id(); } else { out << " #" << arg->get_id(); } } if (num > 0) out << ")"; if (is_relevant(n)) out << "\t*"; out << "\n"; } }
std::ostream& theory::display_app(std::ostream & out, app * n) const { func_decl * d = n->get_decl(); if (n->get_num_args() == 0) { out << d->get_name(); display_parameters(out, d->get_num_parameters(), d->get_parameters()); } else if (n->get_family_id() == get_family_id()) { out << "(" << d->get_name(); display_parameters(out, d->get_num_parameters(), d->get_parameters()); unsigned num = n->get_num_args(); for (unsigned i = 0; i < num; i++) { out << " "; display_app(out, to_app(n->get_arg(i))); } out << ")"; } else { out << "#" << n->get_id(); } return out; }
void parseParameters(int argc,char *argv[],int *ptr,char sptr[MAX_PLIST][MAX_STRLEN], int *np,char name[MAX_PSR][MAX_NAMELEN],int *iname, int *haveName,char *filterStr,char *customStr,int *nohead,int *tbForm,int *noNumber, char *dbFile,char *mergeCat,paramtype *defParam,int *ephem,char *boundary, int *allmerge,int *webflag,char *plotx,char *ploty,int *plotx_log,int *ploty_log, int *bib_info,int *listRef,int *listallRef,int *listparticularRef,char *listIndRef, int *checkCat,int *fsize,int *nocand,int *nointerim) { register unsigned int i,j; char *strptr; char bound1[1000]; char bound2[1000]; pcat_expert = 0; strcpy(bound1,""); strcpy(bound2,""); *iname = 0; /* Number of pulsar names given on the command line */ /* Convert to upper case */ for (i=1;i<argc;i++) { if (strcasecmp(argv[i-1],"-db_file")!=0 && strcasecmp(argv[i-1],"-psr")!=0 && strcasecmp(argv[i-1],"-merge")!=0 && strcasecmp(argv[i-1],"-group")!=0 && strcasecmp(argv[i-1],"-web")!=0) /* Don't put filenames in upper case */ upperCase(argv[i]); } for (i=1;i<argc;i++) { if (strcmp(argv[i],"-S")==0) /* Define sort parameter */ pcat_sort=getParam(argv[++i],NULL); else if (strcmp(argv[i],"-H")==0) /* Help */ help(); else if (strcmp(argv[i],"-V")==0) /* Version of catalogue */ version(dbFile); else if (strcmp(argv[i],"-LISTREF")==0) /* List reference */ *listRef=1; else if (strcmp(argv[i],"-NOCAND")==0) /* No candidates */ *nocand=1; else if (strcmp(argv[i],"-NOINTERIM")==0) /* No interim */ *nointerim=1; else if (strcmp(argv[i],"-BBL")==0) /* List reference */ *listRef=2; else if (strcmp(argv[i],"-ALLBIBS")==0) /* List reference */ *listRef=3; else if (strcmp(argv[i],"-ALLREF")==0) /* List all references */ *listallRef=1; else if (strcmp(argv[i],"-BIB")==0) /* Provide bibliographic reference */ { *listparticularRef=1; strcpy(listIndRef,argv[++i]); } else if (strcmp(argv[i],"-BOUNDARY")==0) /* Boundary string */ strcpy(boundary,argv[++i]); else if (strcmp(argv[i],"-BOUND_COORD")==0) /* Old boundary method */ strcpy(bound1,argv[++i]); else if (strcmp(argv[i],"-BOUND_RADIUS")==0) /* Old boundary method */ strcpy(bound2,argv[++i]); else if (strcmp(argv[i],"-CHECK")==0) /* Check catalogue */ *checkCat=1; else if (strcmp(argv[i],"-ALL")==0) /* Merge with PSRCAT_RUNDIR environment variable */ *allmerge=1; else if (strcmp(argv[i],"-E")==0) /* TEMPO ephemeris */ *ephem = 1; else if (strcmp(argv[i],"-E2")==0) /* Full ephemeris */ *ephem = 2; else if (strcmp(argv[i],"-E3")==0) /* Select ephemeris */ *ephem = 3; else if (strcmp(argv[i],"-E4")==0) /* Select ephemeris */ *ephem = 4; else if (strcmp(argv[i],"-FSIZE")==0) /* Select ephemeris */ sscanf(argv[++i],"%d",fsize); else if (strcmp(argv[i],"-EXPERT")==0) /* expert mode */ pcat_expert = 1; else if (strcmp(argv[i],"-DESCEND")==0) /* Sort in descending order */ pcat_descend=1; else if (strcmp(argv[i],"-DB_FILE")==0) /* Catalogue file */ strcpy(dbFile,argv[++i]); else if (strcmp(argv[i],"-PLOTX")==0) /* expression for plotting on x-axis */ {strcpy(plotx,argv[++i]);*nohead=1;} else if (strcmp(argv[i],"-PLOTY")==0) /* ploty */ {strcpy(ploty,argv[++i]);*nohead=1;} else if (strcmp(argv[i],"-LOGX")==0) /* Take log10 of x-axis */ *plotx_log = 1; else if (strcmp(argv[i],"-LOGY")==0) /* Take log10 of y-axis */ *ploty_log = 1; else if (strcmp(argv[i],"-MERGE")==0) /* Merge catalogues */ strcat(mergeCat,argv[++i]); else if (strcmp(argv[i],"-BIBLIOGRAPHY")==0) *bib_info=1; else if (strcmp(argv[i],"-NONUMBER")==0) /* No numbering */ *noNumber=1; else if (strcmp(argv[i],"-O")==0) /* Tabular format */ { i++; if (strcmp(argv[i],"LONG")==0) *tbForm=0; if (strcmp(argv[i],"PUBLISH")==0) *tbForm=1; if (strcmp(argv[i],"SHORT")==0) *tbForm=2; if (strcmp(argv[i],"SHORT_NO_ERROR")==0) *tbForm=2; if (strcmp(argv[i],"SHORT_ERROR")==0) *tbForm=3; if (strcmp(argv[i],"LONG_ERROR")==0) *tbForm=4; if (strcmp(argv[i],"NONE")==0) *tbForm=5; } else if (strcmp(argv[i],"-C1")==0) /* Custom parameter 1 */ strcat(pcat_custom1,argv[++i]); else if (strcmp(argv[i],"-C2")==0) /* Custom parameter 2 */ strcat(pcat_custom2,argv[++i]); else if (strcmp(argv[i],"-C3")==0) /* Custom parameter 3 */ strcat(pcat_custom3,argv[++i]); else if (strcmp(argv[i],"-C4")==0) /* Custom parameter 4 */ strcat(pcat_custom4,argv[++i]); else if (strcmp(argv[i],"-NULL")==0) /* Null value string */ strcpy(NO_VAL,argv[++i]); else if (strcmp(argv[i],"-WEB")==0) /* Web flag */ { char web_address[MAX_STRLEN*3]; *webflag=1; /* Add to counter */ strcpy(web_address,"echo \""); strcat(web_address,argv[i+1]); i++; strcat(web_address,"\" >>"); strcat(web_address,COUNTER_FILE); system(web_address); } else if (strcmp(argv[i],"-P")==0) /* Describe parameters */ { if (i+1==argc) display_parameters("*",defParam); /* List all parameters */ else display_parameters(argv[i+1],defParam); /* Get selected parameter list */ } else if (strcmp(argv[i],"-C")==0) /* Define parameters */ { customStr = argv[i]; *np = 0; for (j=0;j<MAX_PLIST;j++) { if (j==0) strptr = strtok(argv[i+1]," \t\n"); else strptr = strtok(NULL," \t\n"); if (strptr==NULL) break; if (strcmp(strptr,"JNAME")==0) {strcpy(sptr[*np],"PSRJ"); strcpy(strptr,"PSRJ");} else if (strcmp(strptr,"BNAME")==0) {strcpy(sptr[*np],"PSRB"); strcpy(strptr,"PSRB");} else strcpy(sptr[*np],strptr); ptr[(*np)++] = getParam(strptr,NULL); if (ptr[(*np)-1]==-1) { printf("Parameter >%s< not known. Use psrcat -p to get a list of parameters\n",strptr); exit(1); } } i++; } else if (strcmp(argv[i],"-L")==0) /* Logical expression for filtering pulsars */ strcat(filterStr,argv[++i]); else if (strcmp(argv[i],"-NOHEAD")==0) *nohead=1; else if (strcmp(argv[i],"-VERBOSE")==0) verbose=1; else if (strcmp(argv[i],"-X")==0) /* Simplify some settings */ { *nohead=1; *noNumber=1; *tbForm=4; } else if (strcmp(argv[i],"-PSR")==0) /* Read pulsar names from a file */ { FILE *fin; char temp[1000]; i++; if (!(fin = fopen(argv[i],"r"))) { printf("Unable to open pulsar file %s\n",argv[i]); exit(1); } while (!feof(fin)) { if (fscanf(fin,"%s",temp)==1) { haveName[*iname]=0; if (temp[0] == '0' || temp[0]=='1' || temp[0] =='2') sprintf(name[(*iname)++],"?%s",temp); else sprintf(name[(*iname)++],"%s",temp); } } fclose(fin); } else if (argv[i][0] == '0' || argv[i][0] == '1' || argv[i][0] == '2') /* Pulsar name */ {haveName[*iname] = 0; sprintf(name[(*iname)++],"?%s",argv[i]);} else if (argv[i][0] == 'B' || argv[i][0] == 'J') /* Pulsar name */ {haveName[*iname] = 0; sprintf(name[(*iname)++],"%s",argv[i]);} else { printf("Unknown parameter >%s<. Use -h to get list of parameters.\n",argv[i]); exit(1); } } if (strlen(bound1)>0 && strlen(bound2)>0) { strcpy(boundary,bound1); strcat(boundary," "); strcat(boundary,bound2); } }