00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "espresso.h"
00016
00017 static bool line_length_error;
00018 static int lineno;
00019
00020 void skip_line(fpin, fpout, echo)
00021 register FILE *fpin, *fpout;
00022 register bool echo;
00023 {
00024 register int ch;
00025 while ((ch=getc(fpin)) != EOF && ch != '\n')
00026 if (echo)
00027 putc(ch, fpout);
00028 if (echo)
00029 putc('\n', fpout);
00030 lineno++;
00031 }
00032
00033 char *get_word(fp, word)
00034 register FILE *fp;
00035 register char *word;
00036 {
00037 register int ch, i = 0;
00038 while ((ch = getc(fp)) != EOF && isspace(ch))
00039 ;
00040 word[i++] = ch;
00041 while ((ch = getc(fp)) != EOF && ! isspace(ch))
00042 word[i++] = ch;
00043 word[i++] = '\0';
00044 return word;
00045 }
00046
00047
00048
00049
00050 void read_cube(fp, PLA)
00051 register FILE *fp;
00052 pPLA PLA;
00053 {
00054 register int var, i;
00055 pcube cf = cube.temp[0], cr = cube.temp[1], cd = cube.temp[2];
00056 bool savef = FALSE, saved = FALSE, saver = FALSE;
00057 char token[256];
00058 int varx, first, last, offset;
00059
00060 set_clear(cf, cube.size);
00061
00062
00063 for(var = 0; var < cube.num_binary_vars; var++)
00064 switch(getc(fp)) {
00065 case EOF:
00066 goto bad_char;
00067 case '\n':
00068 if (! line_length_error)
00069 (void) fprintf(stderr, "product term(s) %s\n",
00070 "span more than one line (warning only)");
00071 line_length_error = TRUE;
00072 lineno++;
00073 var--;
00074 break;
00075 case ' ': case '|': case '\t':
00076 var--;
00077 break;
00078 case '2': case '-':
00079 set_insert(cf, var*2+1);
00080 case '0':
00081 set_insert(cf, var*2);
00082 break;
00083 case '1':
00084 set_insert(cf, var*2+1);
00085 break;
00086 case '?':
00087 break;
00088 default:
00089 goto bad_char;
00090 }
00091
00092
00093
00094 for(var = cube.num_binary_vars; var < cube.num_vars-1; var++)
00095
00096
00097 if (cube.part_size[var] < 0) {
00098 (void) fscanf(fp, "%s", token);
00099 if (equal(token, "-") || equal(token, "ANY")) {
00100 if (kiss && var == cube.num_vars - 2) {
00101
00102 } else {
00103
00104 set_or(cf, cf, cube.var_mask[var]);
00105 }
00106 } else if (equal(token, "~")) {
00107 ;
00108
00109 } else {
00110 if (kiss && var == cube.num_vars - 2)
00111 varx = var - 1, offset = ABS(cube.part_size[var-1]);
00112 else
00113 varx = var, offset = 0;
00114
00115 first = cube.first_part[varx];
00116 last = cube.last_part[varx];
00117 for(i = first; i <= last; i++)
00118 if (PLA->label[i] == (char *) NULL) {
00119 PLA->label[i] = util_strsav(token);
00120 set_insert(cf, i+offset);
00121 break;
00122 } else if (equal(PLA->label[i], token)) {
00123 set_insert(cf, i+offset);
00124 break;
00125 }
00126 if (i > last) {
00127 (void) fprintf(stderr,
00128 "declared size of variable %d (counting from variable 0) is too small\n", var);
00129 exit(-1);
00130 }
00131 }
00132
00133 } else for(i = cube.first_part[var]; i <= cube.last_part[var]; i++)
00134 switch (getc(fp)) {
00135 case EOF:
00136 goto bad_char;
00137 case '\n':
00138 if (! line_length_error)
00139 (void) fprintf(stderr, "product term(s) %s\n",
00140 "span more than one line (warning only)");
00141 line_length_error = TRUE;
00142 lineno++;
00143 i--;
00144 break;
00145 case ' ': case '|': case '\t':
00146 i--;
00147 break;
00148 case '1':
00149 set_insert(cf, i);
00150 case '0':
00151 break;
00152 default:
00153 goto bad_char;
00154 }
00155
00156
00157 if (kiss) {
00158 saver = savef = TRUE;
00159 (void) set_xor(cr, cf, cube.var_mask[cube.num_vars - 2]);
00160 } else
00161 set_copy(cr, cf);
00162 set_copy(cd, cf);
00163 for(i = cube.first_part[var]; i <= cube.last_part[var]; i++)
00164 switch (getc(fp)) {
00165 case EOF:
00166 goto bad_char;
00167 case '\n':
00168 if (! line_length_error)
00169 (void) fprintf(stderr, "product term(s) %s\n",
00170 "span more than one line (warning only)");
00171 line_length_error = TRUE;
00172 lineno++;
00173 i--;
00174 break;
00175 case ' ': case '|': case '\t':
00176 i--;
00177 break;
00178 case '4': case '1':
00179 if (PLA->pla_type & F_type)
00180 set_insert(cf, i), savef = TRUE;
00181 break;
00182 case '3': case '0':
00183 if (PLA->pla_type & R_type)
00184 set_insert(cr, i), saver = TRUE;
00185 break;
00186 case '2': case '-':
00187 if (PLA->pla_type & D_type)
00188 set_insert(cd, i), saved = TRUE;
00189 case '~':
00190 break;
00191 default:
00192 goto bad_char;
00193 }
00194 if (savef) PLA->F = sf_addset(PLA->F, cf);
00195 if (saved) PLA->D = sf_addset(PLA->D, cd);
00196 if (saver) PLA->R = sf_addset(PLA->R, cr);
00197 return;
00198
00199 bad_char:
00200 (void) fprintf(stderr, "(warning): input line #%d ignored\n", lineno);
00201 skip_line(fp, stdout, TRUE);
00202 return;
00203 }
00204 void parse_pla(fp, PLA)
00205 IN FILE *fp;
00206 INOUT pPLA PLA;
00207 {
00208 int i, var, ch, np, last;
00209 char word[256];
00210
00211 lineno = 1;
00212 line_length_error = FALSE;
00213
00214 loop:
00215 switch(ch = getc(fp)) {
00216 case EOF:
00217 return;
00218
00219 case '\n':
00220 lineno++;
00221
00222 case ' ': case '\t': case '\f': case '\r':
00223 break;
00224
00225 case '#':
00226 (void) ungetc(ch, fp);
00227 skip_line(fp, stdout, echo_comments);
00228 break;
00229
00230 case '.':
00231
00232 if (equal(get_word(fp, word), "i")) {
00233 if (cube.fullset != NULL) {
00234 (void) fprintf(stderr, "extra .i ignored\n");
00235 skip_line(fp, stdout, FALSE);
00236 } else {
00237 if (fscanf(fp, "%d", &cube.num_binary_vars) != 1)
00238 fatal("error reading .i");
00239 cube.num_vars = cube.num_binary_vars + 1;
00240 cube.part_size = ALLOC(int, cube.num_vars);
00241 }
00242
00243
00244 } else if (equal(word, "o")) {
00245 if (cube.fullset != NULL) {
00246 (void) fprintf(stderr, "extra .o ignored\n");
00247 skip_line(fp, stdout, FALSE);
00248 } else {
00249 if (cube.part_size == NULL)
00250 fatal(".o cannot appear before .i");
00251 if (fscanf(fp, "%d", &(cube.part_size[cube.num_vars-1]))!=1)
00252 fatal("error reading .o");
00253 cube_setup();
00254 PLA_labels(PLA);
00255 }
00256
00257
00258 } else if (equal(word, "mv")) {
00259 if (cube.fullset != NULL) {
00260 (void) fprintf(stderr, "extra .mv ignored\n");
00261 skip_line(fp, stdout, FALSE);
00262 } else {
00263 if (cube.part_size != NULL)
00264 fatal("cannot mix .i and .mv");
00265 if (fscanf(fp,"%d %d",
00266 &cube.num_vars,&cube.num_binary_vars) != 2)
00267 fatal("error reading .mv");
00268 if (cube.num_binary_vars < 0)
00269 fatal("num_binary_vars (second field of .mv) cannot be negative");
00270 if (cube.num_vars < cube.num_binary_vars)
00271 fatal(
00272 "num_vars (1st field of .mv) must exceed num_binary_vars (2nd field of .mv)");
00273 cube.part_size = ALLOC(int, cube.num_vars);
00274 for(var=cube.num_binary_vars; var < cube.num_vars; var++)
00275 if (fscanf(fp, "%d", &(cube.part_size[var])) != 1)
00276 fatal("error reading .mv");
00277 cube_setup();
00278 PLA_labels(PLA);
00279 }
00280
00281
00282 } else if (equal(word, "p"))
00283 (void) fscanf(fp, "%d", &np);
00284
00285 else if (equal(word, "e") || equal(word,"end")) {
00286 if (cube.fullset == NULL) {
00287
00288 } else if (PLA->F == NULL) {
00289 PLA->F = new_cover(10);
00290 PLA->D = new_cover(10);
00291 PLA->R = new_cover(10);
00292 }
00293 return;
00294 }
00295
00296 else if (equal(word, "kiss"))
00297 kiss = TRUE;
00298
00299
00300 else if (equal(word, "type")) {
00301 (void) get_word(fp, word);
00302 for(i = 0; pla_types[i].key != 0; i++)
00303 if (equal(pla_types[i].key + 1, word)) {
00304 PLA->pla_type = pla_types[i].value;
00305 break;
00306 }
00307 if (pla_types[i].key == 0)
00308 fatal("unknown type in .type command");
00309
00310
00311 } else if (equal(word, "ilb")) {
00312 if (cube.fullset == NULL)
00313 fatal("PLA size must be declared before .ilb or .ob");
00314 if (PLA->label == NULL)
00315 PLA_labels(PLA);
00316 for(var = 0; var < cube.num_binary_vars; var++) {
00317 (void) get_word(fp, word);
00318 i = cube.first_part[var];
00319 PLA->label[i+1] = util_strsav(word);
00320 PLA->label[i] = ALLOC(char, strlen(word) + 6);
00321 (void) sprintf(PLA->label[i], "%s.bar", word);
00322 }
00323 } else if (equal(word, "ob")) {
00324 if (cube.fullset == NULL)
00325 fatal("PLA size must be declared before .ilb or .ob");
00326 if (PLA->label == NULL)
00327 PLA_labels(PLA);
00328 var = cube.num_vars - 1;
00329 for(i = cube.first_part[var]; i <= cube.last_part[var]; i++) {
00330 (void) get_word(fp, word);
00331 PLA->label[i] = util_strsav(word);
00332 }
00333
00334 } else if (equal(word, "label")) {
00335 if (cube.fullset == NULL)
00336 fatal("PLA size must be declared before .label");
00337 if (PLA->label == NULL)
00338 PLA_labels(PLA);
00339 if (fscanf(fp, "var=%d", &var) != 1)
00340 fatal("Error reading labels");
00341 for(i = cube.first_part[var]; i <= cube.last_part[var]; i++) {
00342 (void) get_word(fp, word);
00343 PLA->label[i] = util_strsav(word);
00344 }
00345
00346 } else if (equal(word, "symbolic")) {
00347 symbolic_t *newlist, *p1;
00348 if (read_symbolic(fp, PLA, word, &newlist)) {
00349 if (PLA->symbolic == NIL(symbolic_t)) {
00350 PLA->symbolic = newlist;
00351 } else {
00352 for(p1=PLA->symbolic;p1->next!=NIL(symbolic_t);
00353 p1=p1->next){
00354 }
00355 p1->next = newlist;
00356 }
00357 } else {
00358 fatal("error reading .symbolic");
00359 }
00360
00361 } else if (equal(word, "symbolic-output")) {
00362 symbolic_t *newlist, *p1;
00363 if (read_symbolic(fp, PLA, word, &newlist)) {
00364 if (PLA->symbolic_output == NIL(symbolic_t)) {
00365 PLA->symbolic_output = newlist;
00366 } else {
00367 for(p1=PLA->symbolic_output;p1->next!=NIL(symbolic_t);
00368 p1=p1->next){
00369 }
00370 p1->next = newlist;
00371 }
00372 } else {
00373 fatal("error reading .symbolic-output");
00374 }
00375
00376
00377 } else if (equal(word, "phase")) {
00378 if (cube.fullset == NULL)
00379 fatal("PLA size must be declared before .phase");
00380 if (PLA->phase != NULL) {
00381 (void) fprintf(stderr, "extra .phase ignored\n");
00382 skip_line(fp, stdout, FALSE);
00383 } else {
00384 do ch = getc(fp); while (ch == ' ' || ch == '\t');
00385 (void) ungetc(ch, fp);
00386 PLA->phase = set_save(cube.fullset);
00387 last = cube.last_part[cube.num_vars - 1];
00388 for(i=cube.first_part[cube.num_vars - 1]; i <= last; i++)
00389 if ((ch = getc(fp)) == '0')
00390 set_remove(PLA->phase, i);
00391 else if (ch != '1')
00392 fatal("only 0 or 1 allowed in phase description");
00393 }
00394
00395
00396 } else if (equal(word, "pair")) {
00397 int j;
00398 if (PLA->pair != NULL) {
00399 (void) fprintf(stderr, "extra .pair ignored\n");
00400 } else {
00401 ppair pair;
00402 PLA->pair = pair = ALLOC(pair_t, 1);
00403 if (fscanf(fp, "%d", &(pair->cnt)) != 1)
00404 fatal("syntax error in .pair");
00405 pair->var1 = ALLOC(int, pair->cnt);
00406 pair->var2 = ALLOC(int, pair->cnt);
00407 for(i = 0; i < pair->cnt; i++) {
00408 (void) get_word(fp, word);
00409 if (word[0] == '(') (void) strcpy(word, word+1);
00410 if (label_index(PLA, word, &var, &j)) {
00411 pair->var1[i] = var+1;
00412 } else {
00413 fatal("syntax error in .pair");
00414 }
00415
00416 (void) get_word(fp, word);
00417 if (word[strlen(word)-1] == ')') {
00418 word[strlen(word)-1]='\0';
00419 }
00420 if (label_index(PLA, word, &var, &j)) {
00421 pair->var2[i] = var+1;
00422 } else {
00423 fatal("syntax error in .pair");
00424 }
00425 }
00426 }
00427
00428 } else {
00429 if (echo_unknown_commands)
00430 printf("%c%s ", ch, word);
00431 skip_line(fp, stdout, echo_unknown_commands);
00432 }
00433 break;
00434 default:
00435 (void) ungetc(ch, fp);
00436 if (cube.fullset == NULL) {
00437
00438 if (echo_comments)
00439 putchar('#');
00440 skip_line(fp, stdout, echo_comments);
00441 break;
00442 }
00443 if (PLA->F == NULL) {
00444 PLA->F = new_cover(10);
00445 PLA->D = new_cover(10);
00446 PLA->R = new_cover(10);
00447 }
00448 read_cube(fp, PLA);
00449 }
00450 goto loop;
00451 }
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489 int read_pla(fp, needs_dcset, needs_offset, pla_type, PLA_return)
00490 IN FILE *fp;
00491 IN bool needs_dcset, needs_offset;
00492 IN int pla_type;
00493 OUT pPLA *PLA_return;
00494 {
00495 pPLA PLA;
00496 int i, second, third;
00497 long time;
00498 cost_t cost;
00499
00500
00501 PLA = *PLA_return = new_PLA();
00502 PLA->pla_type = pla_type;
00503
00504
00505 time = ptime();
00506 parse_pla(fp, PLA);
00507
00508
00509 if (PLA->F == NULL) {
00510 return EOF;
00511 }
00512
00513
00514 for(i = 0; i < cube.num_vars; i++) {
00515 cube.part_size[i] = ABS(cube.part_size[i]);
00516 }
00517 if (kiss) {
00518 third = cube.num_vars - 3;
00519 second = cube.num_vars - 2;
00520 if (cube.part_size[third] != cube.part_size[second]) {
00521 (void) fprintf(stderr," with .kiss option, third to last and second\n");
00522 (void) fprintf(stderr, "to last variables must be the same size.\n");
00523 return EOF;
00524 }
00525 for(i = 0; i < cube.part_size[second]; i++) {
00526 PLA->label[i + cube.first_part[second]] =
00527 util_strsav(PLA->label[i + cube.first_part[third]]);
00528 }
00529 cube.part_size[second] += cube.part_size[cube.num_vars-1];
00530 cube.num_vars--;
00531 setdown_cube();
00532 cube_setup();
00533 }
00534
00535 if (trace) {
00536 totals(time, READ_TIME, PLA->F, &cost);
00537 }
00538
00539
00540 time = ptime();
00541 if (pos || PLA->phase != NULL || PLA->symbolic_output != NIL(symbolic_t)) {
00542 needs_offset = TRUE;
00543 }
00544 if (needs_offset && (PLA->pla_type==F_type || PLA->pla_type==FD_type)) {
00545 free_cover(PLA->R);
00546 PLA->R = complement(cube2list(PLA->F, PLA->D));
00547 } else if (needs_dcset && PLA->pla_type == FR_type) {
00548 pcover X;
00549 free_cover(PLA->D);
00550
00551 X = d1merge(sf_join(PLA->F, PLA->R), cube.num_vars - 1);
00552 PLA->D = complement(cube1list(X));
00553 free_cover(X);
00554 } else if (PLA->pla_type == R_type || PLA->pla_type == DR_type) {
00555 free_cover(PLA->F);
00556 PLA->F = complement(cube2list(PLA->D, PLA->R));
00557 }
00558
00559 if (trace) {
00560 totals(time, COMPL_TIME, PLA->R, &cost);
00561 }
00562
00563
00564 if (pos) {
00565 pcover onset = PLA->F;
00566 PLA->F = PLA->R;
00567 PLA->R = onset;
00568 PLA->phase = new_cube();
00569 set_diff(PLA->phase, cube.fullset, cube.var_mask[cube.num_vars-1]);
00570 } else if (PLA->phase != NULL) {
00571 (void) set_phase(PLA);
00572 }
00573
00574
00575 if (PLA->pair != (ppair) NULL) {
00576 set_pair(PLA);
00577 }
00578
00579 if (PLA->symbolic != NIL(symbolic_t)) {
00580 EXEC(map_symbolic(PLA), "MAP-INPUT ", PLA->F);
00581 }
00582 if (PLA->symbolic_output != NIL(symbolic_t)) {
00583 EXEC(map_output_symbolic(PLA), "MAP-OUTPUT ", PLA->F);
00584 if (needs_offset) {
00585 free_cover(PLA->R);
00586 EXECUTE(PLA->R=complement(cube2list(PLA->F,PLA->D)), COMPL_TIME, PLA->R, cost);
00587 }
00588 }
00589
00590 return 1;
00591 }
00592
00593 void PLA_summary(PLA)
00594 pPLA PLA;
00595 {
00596 int var, i;
00597 symbolic_list_t *p2;
00598 symbolic_t *p1;
00599
00600 printf("# PLA is %s", PLA->filename);
00601 if (cube.num_binary_vars == cube.num_vars - 1)
00602 printf(" with %d inputs and %d outputs\n",
00603 cube.num_binary_vars, cube.part_size[cube.num_vars - 1]);
00604 else {
00605 printf(" with %d variables (%d binary, mv sizes",
00606 cube.num_vars, cube.num_binary_vars);
00607 for(var = cube.num_binary_vars; var < cube.num_vars; var++)
00608 printf(" %d", cube.part_size[var]);
00609 printf(")\n");
00610 }
00611 printf("# ON-set cost is %s\n", print_cost(PLA->F));
00612 printf("# OFF-set cost is %s\n", print_cost(PLA->R));
00613 printf("# DC-set cost is %s\n", print_cost(PLA->D));
00614 if (PLA->phase != NULL)
00615 printf("# phase is %s\n", pc1(PLA->phase));
00616 if (PLA->pair != NULL) {
00617 printf("# two-bit decoders:");
00618 for(i = 0; i < PLA->pair->cnt; i++)
00619 printf(" (%d %d)", PLA->pair->var1[i], PLA->pair->var2[i]);
00620 printf("\n");
00621 }
00622 if (PLA->symbolic != NIL(symbolic_t)) {
00623 for(p1 = PLA->symbolic; p1 != NIL(symbolic_t); p1 = p1->next) {
00624 printf("# symbolic: ");
00625 for(p2=p1->symbolic_list; p2!=NIL(symbolic_list_t); p2=p2->next) {
00626 printf(" %d", p2->variable);
00627 }
00628 printf("\n");
00629 }
00630 }
00631 if (PLA->symbolic_output != NIL(symbolic_t)) {
00632 for(p1 = PLA->symbolic_output; p1 != NIL(symbolic_t); p1 = p1->next) {
00633 printf("# output symbolic: ");
00634 for(p2=p1->symbolic_list; p2!=NIL(symbolic_list_t); p2=p2->next) {
00635 printf(" %d", p2->pos);
00636 }
00637 printf("\n");
00638 }
00639 }
00640 (void) fflush(stdout);
00641 }
00642
00643
00644 pPLA new_PLA()
00645 {
00646 pPLA PLA;
00647
00648 PLA = ALLOC(PLA_t, 1);
00649 PLA->F = PLA->D = PLA->R = (pcover) NULL;
00650 PLA->phase = (pcube) NULL;
00651 PLA->pair = (ppair) NULL;
00652 PLA->label = (char **) NULL;
00653 PLA->filename = (char *) NULL;
00654 PLA->pla_type = 0;
00655 PLA->symbolic = NIL(symbolic_t);
00656 PLA->symbolic_output = NIL(symbolic_t);
00657 return PLA;
00658 }
00659
00660
00661 PLA_labels(PLA)
00662 pPLA PLA;
00663 {
00664 int i;
00665
00666 PLA->label = ALLOC(char *, cube.size);
00667 for(i = 0; i < cube.size; i++)
00668 PLA->label[i] = (char *) NULL;
00669 }
00670
00671
00672 void free_PLA(PLA)
00673 pPLA PLA;
00674 {
00675 symbolic_list_t *p2, *p2next;
00676 symbolic_t *p1, *p1next;
00677 int i;
00678
00679 if (PLA->F != (pcover) NULL)
00680 free_cover(PLA->F);
00681 if (PLA->R != (pcover) NULL)
00682 free_cover(PLA->R);
00683 if (PLA->D != (pcover) NULL)
00684 free_cover(PLA->D);
00685 if (PLA->phase != (pcube) NULL)
00686 free_cube(PLA->phase);
00687 if (PLA->pair != (ppair) NULL) {
00688 FREE(PLA->pair->var1);
00689 FREE(PLA->pair->var2);
00690 FREE(PLA->pair);
00691 }
00692 if (PLA->label != NULL) {
00693 for(i = 0; i < cube.size; i++)
00694 if (PLA->label[i] != NULL)
00695 FREE(PLA->label[i]);
00696 FREE(PLA->label);
00697 }
00698 if (PLA->filename != NULL) {
00699 FREE(PLA->filename);
00700 }
00701 for(p1 = PLA->symbolic; p1 != NIL(symbolic_t); p1 = p1next) {
00702 for(p2 = p1->symbolic_list; p2 != NIL(symbolic_list_t); p2 = p2next) {
00703 p2next = p2->next;
00704 FREE(p2);
00705 }
00706 p1next = p1->next;
00707 FREE(p1);
00708 }
00709 PLA->symbolic = NIL(symbolic_t);
00710 for(p1 = PLA->symbolic_output; p1 != NIL(symbolic_t); p1 = p1next) {
00711 for(p2 = p1->symbolic_list; p2 != NIL(symbolic_list_t); p2 = p2next) {
00712 p2next = p2->next;
00713 FREE(p2);
00714 }
00715 p1next = p1->next;
00716 FREE(p1);
00717 }
00718 PLA->symbolic_output = NIL(symbolic_t);
00719 FREE(PLA);
00720 }
00721
00722
00723 int read_symbolic(fp, PLA, word, retval)
00724 FILE *fp;
00725 pPLA PLA;
00726 char *word;
00727 symbolic_t **retval;
00728 {
00729 symbolic_list_t *listp, *prev_listp;
00730 symbolic_label_t *labelp, *prev_labelp;
00731 symbolic_t *newlist;
00732 int i, var;
00733
00734 newlist = ALLOC(symbolic_t, 1);
00735 newlist->next = NIL(symbolic_t);
00736 newlist->symbolic_list = NIL(symbolic_list_t);
00737 newlist->symbolic_list_length = 0;
00738 newlist->symbolic_label = NIL(symbolic_label_t);
00739 newlist->symbolic_label_length = 0;
00740 prev_listp = NIL(symbolic_list_t);
00741 prev_labelp = NIL(symbolic_label_t);
00742
00743 for(;;) {
00744 (void) get_word(fp, word);
00745 if (equal(word, ";"))
00746 break;
00747 if (label_index(PLA, word, &var, &i)) {
00748 listp = ALLOC(symbolic_list_t, 1);
00749 listp->variable = var;
00750 listp->pos = i;
00751 listp->next = NIL(symbolic_list_t);
00752 if (prev_listp == NIL(symbolic_list_t)) {
00753 newlist->symbolic_list = listp;
00754 } else {
00755 prev_listp->next = listp;
00756 }
00757 prev_listp = listp;
00758 newlist->symbolic_list_length++;
00759 } else {
00760 return FALSE;
00761 }
00762 }
00763
00764 for(;;) {
00765 (void) get_word(fp, word);
00766 if (equal(word, ";"))
00767 break;
00768 labelp = ALLOC(symbolic_label_t, 1);
00769 labelp->label = util_strsav(word);
00770 labelp->next = NIL(symbolic_label_t);
00771 if (prev_labelp == NIL(symbolic_label_t)) {
00772 newlist->symbolic_label = labelp;
00773 } else {
00774 prev_labelp->next = labelp;
00775 }
00776 prev_labelp = labelp;
00777 newlist->symbolic_label_length++;
00778 }
00779
00780 *retval = newlist;
00781 return TRUE;
00782 }
00783
00784
00785 int label_index(PLA, word, varp, ip)
00786 pPLA PLA;
00787 char *word;
00788 int *varp;
00789 int *ip;
00790 {
00791 int var, i;
00792
00793 if (PLA->label == NIL(char *) || PLA->label[0] == NIL(char)) {
00794 if (sscanf(word, "%d", varp) == 1) {
00795 *ip = *varp;
00796 return TRUE;
00797 }
00798 } else {
00799 for(var = 0; var < cube.num_vars; var++) {
00800 for(i = 0; i < cube.part_size[var]; i++) {
00801 if (equal(PLA->label[cube.first_part[var]+i], word)) {
00802 *varp = var;
00803 *ip = i;
00804 return TRUE;
00805 }
00806 }
00807 }
00808 }
00809 return FALSE;
00810 }