Wild Life: print.c Source File

Wild Life 2.29

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
print.c
Go to the documentation of this file.
1 /* Copyright 1991 Digital Equipment Corporation.
2 ** All Rights Reserved.
3 *****************************************************************/
4 /* $Id: print.c,v 1.4 1995/01/14 00:27:20 duchier Exp $ */
5
6 #include "defs.h"
7
8 long print_depth=PRINT_DEPTH;
9 long indent=FALSE;
10 long const_quote=TRUE;
11 long write_resids=FALSE;
12 long write_canon=FALSE;
13 long write_stderr=FALSE;
14 long write_corefs=TRUE;
15
16 long page_width=PAGE_WIDTH;
17
18 long display_persistent=FALSE;
19
20 char *no_name="pointer";
21 char *name="symbol";
22 char *buffer;
23 char seg_format[PRINT_POWER+4];
24
25 item pretty_things[PRETTY_SIZE];
26
27 /* Used to distinguish listings from other writes */
28 static long listing_flag;
29
30 /* Used to list function bodies in a nice way */
31 /* Only valid if listing_flag==TRUE */
32 static long func_flag;
33
34
35 void pretty_psi_term(ptr_psi_term,long,long);
36 // void pretty_attr(ptr_node,ptr_tab_brk,long *,long,long);
37 void pretty_attr(ptr_node,long);
38 void pretty_tag_or_psi_term(ptr_psi_term,long,long);
39
40 /* Precedence of the comma and colon operators (or 0 if none exists) */
41 #define COMMA_PREC ((commasym->op_data)?(commasym->op_data->precedence):0)
42 #define COLON_PREC ((colonsym->op_data)?(colonsym->op_data->precedence):0)
43
44
45 /* Initialize size of single segment of split printing. Wild_Life */
46 /* integers are represented as REALS, and therefore can have higher */
47 /* precision than the machine integers. They will be printed in segments. */
48 void init_print()
49 {
50 (void)snprintf(seg_format,PRINT_POWER+4,"%%0%ldd",PRINT_POWER);
51 }
52
53
54 /* Generate a nice-looking new variable name. */
55 char * heap_nice_name()
56 {
57 string tmp1,tmp2;
58 char g,len; // ,leading_a;
59
60 g= ++gen_sym_counter;
61 len=2;
62 strcpy(tmp2,"");
63 do {
64 g--;
65 /* Prefix one character to tmp2: */
66 (void)snprintf(tmp1,2,"%c",g%26+'A');
67 strcat(tmp1,tmp2);
68 strcpy(tmp2,tmp1);
69 g=g/26;
70 len++;
71 } while (g>0 && len<STRLEN);
72 if (len>=STRLEN)
73 perr("Variable name too long -- the universe has ceased to exist.");
74
75 strcpy(tmp1,"_");
76 strcat(tmp1,tmp2);
77
78 return heap_copy_string(tmp1);
79 }
80
81
82 /* Make sure that the new variable name does not exist in the var_tree. */
83 /* (This situation should be rare.) */
84 /* Time to print a term is proportional to product of var_tree size and */
85 /* number of tags in the term. This may become large in pathological */
86 /* cases. */
87 GENERIC unique_name()
88 {
89 GENERIC name_loc;
90
91 do name_loc=(GENERIC)heap_nice_name();
92 while (find(STRCMP,(char *)name_loc,var_tree));
93
94 return name_loc;
95 }
96
97
98
99 /******** STR_TO_INT(s)
100 Converts the string S into a positive integer.
101 Returns -1 if s is not an integer.
102 */
103 long str_to_int(s)
104 char *s;
105 {
106 long v=0;
107 char c;
108
109 c=(*s);
110 if (c==0)
111 v= -1;
112 else {
113 while (DIGIT(c)) {
114 v=v*10+(c-'0');
115 s++;
116 c=(*s);
117 }
118 if (c!=0) v= -1;
119 }
120
121 return v;
122 }
123
124
125
126 /******** PRINT_BIN(b)
127 Print the integer B under binary format (currently 26 is printed **-*-).
128 This is used to print the binary codes used in type encryption.
129 */
130 void print_bin(b)
131 long b;
132 {
133 long p;
134
135 for (p=INT_SIZE;p--;p>0)
136 {
137 fprintf(outfile,(b&1?"X":" "));
138 b = b>>1;
139 }
140 }
141
142
143
144 /******** PRINT_CODE(s,c)
145 Print a binary code C to a stream s (as used in type encoding).
146 */
147 void print_code(s,c)
148 FILE *s;
149 ptr_int_list c;
150 {
151 outfile=s;
152
153 if (c==NOT_CODED)
154 fprintf(outfile," (not coded) ");
155 else {
156 fprintf(outfile," [");
157 while (c) {
158 print_bin((long)c->value_1);
159 c=c->next;
160 }
161 fprintf(outfile,"]");
162 }
163 }
164
165
166 void go_through(ptr_psi_term);
167
168
169
170 /******** PRINT_OPERATOR_KIND(s,kind)
171 Print the kind of an operator.
172 */
173 void print_operator_kind(s,kind)
174 FILE *s;
175 long kind;
176 {
177 switch (kind) {
178 case xf:
179 fprintf(s,"xf");
180 break;
181 case fx:
182 fprintf(s,"fx");
183 break;
184 case yf:
185 fprintf(s,"yf");
186 break;
187 case fy:
188 fprintf(s,"fy");
189 break;
190 case xfx:
191 fprintf(s,"xfx");
192 break;
193 case xfy:
194 fprintf(s,"xfy");
195 break;
196 case yfx:
197 fprintf(s,"yfx");
198 break;
199 default:
200 fprintf(s,"illegal");
201 break;
202 }
203 }
204
205
206
207 /******** CHECK_POINTER(p)
208 Count the number of times address P has been encountered in the current
209 psi-term being printed. If it is more than once then a tag will have to
210 be used.
211 If P has not already been seen, then explore the psi_term it points to.
212 */
213
214 void check_pointer(p)
215 ptr_psi_term p;
216 {
217 ptr_node n;
218
219 if (p) {
220 deref_ptr(p);
221 n=find(INTCMP,(char *)p,pointer_names);
222 if (n==NULL) {
223 (void)heap_insert(INTCMP,(char *)p,&pointer_names,(GENERIC)NULL);
224 go_through(p);
225 }
226 else
227 n->data=(GENERIC)no_name;
228 }
229 }
230
231
232 /******** GO_THROUGH_TREE(t)
233 Explore all the pointers in the attribute tree T.
234 Pointers that occur more than once will need a tag.
235 */
236 void go_through_tree(t)
237 ptr_node t;
238 {
239 if (t) {
240 if (t->left) {
241 go_through_tree(t->left);
242 }
243 check_pointer((ptr_psi_term)t->data);
244 if (t->right) {
245 go_through_tree(t->right);
246 }
247 }
248
249 }
250
251
252
253 /******** GO_THROUGH(t)
254 This routine goes through all the sub_terms of psi_term T to determine which
255 pointers need to have names given to them for printing because they are
256 referred to elsewhere. T is a dereferenced psi_term.
257 */
258 void go_through(t)
259 ptr_psi_term t;
260 {
261 // ptr_list l;
262
263 if (t->attr_list)
264 go_through_tree(t->attr_list);
265
266 /*
267 if(r=t->resid)
268 while(r) {
269 if(r->goal->pending)
270 go_through(r->goal->aaaa_1);
271 r=r->next;
272 } */
273 }
274
275 /******** INSERT_VARIABLES(vars,force)
276 This routine gives the name of the query variable to the corresponding
277 pointer in the POINTER_NAMES.
278 If FORCE is TRUE then variables will be printed as TAGS, even if not
279 referred to elsewhere.
280 */
281 void insert_variables(vars,force)
282 ptr_node vars;
283 long force;
284 {
285 ptr_psi_term p;
286 ptr_node n;
287
288 if(vars) {
289 insert_variables(vars->right,force);
290 p=(ptr_psi_term )vars->data;
291 deref_ptr(p);
292 n=find(INTCMP,(char *)p,pointer_names);
293 if (n)
294 if (n->data || force)
295 n->data=(GENERIC)vars->key;
296 insert_variables(vars->left,force);
297 }
298 }
299
300
301
302
303 /******** FORBID_VARIABLES
304 This inserts the value of the dereferenced variables into the
305 PRINTED_POINTERS tree, so that they will never be printed as
306 NAME:value inside a psi-term.
307 Each variable is printed as NAME = VALUE by the PRINT_VARIABLES routine.
308 */
309 void forbid_variables(n)
310 ptr_node n;
311 {
312 ptr_psi_term v;
313
314 if(n) {
315 forbid_variables(n->right);
316 v=(ptr_psi_term )n->data;
317 deref_ptr(v);
318 (void)heap_insert(INTCMP,(char *)v,&printed_pointers,(GENERIC)n->key);
319 forbid_variables(n->left);
320 }
321 }
322
323
324
325
326 /******************************************************************************
327 PRINTING ROUTINES.
328
329 These routines allow the correct printing in minimal form of a set of
330 possibly cyclic psi-terms with coreferences from one to another.
331
332 First the term to be printed is explored to locate any cyclic terms or
333 coreferences. Then is printed into memory where is it formatted to fit
334 within PAGE_WIDTH of the output page. Then it is effectively printed to the
335 output stream.
336
337 *****************************************************************************/
338
339
340
341 /* Printing into memory involves the use of an array containing a TAB
342 position on which to align things then a string to print. The routine
343 WORK_OUT_LENGTH tries (by trial and error) to print the psi_term into
344 PAGE_WIDTH columns by inserting line feeds whereever possible */
345
346
347 /* Does the work of prettyf and prettyf_quote */
348 /* The q argument is a flag telling whether to quote or not. */
349 void prettyf_inner(s,q,c)
350 char *s;
351 long q;
352 char c; /* the quote character */
353 {
354 char *sb=buffer;
355
356 if (indent) {
357 while (*sb) sb++;
358 if (q) { *sb = c; sb++; }
359 while (*s) {
360 if (q && *s==c) { *sb = *s; sb++; }
361 *sb = *s; sb++; s++;
362 }
363 if (q) { *sb = c; sb++; }
364 *sb=0;
365 }
366 else {
367 if (q) (void)putc(c,outfile);
368 while (*s) {
369 if (q && *s==c) { (void)putc(*s,outfile); }
370 (void)putc(*s,outfile);
371 s++;
372 }
373 if (q) (void)putc(c,outfile);
374 }
375 }
376
377
378 /* Return TRUE iff s starts with a non-lowercase character. */
379 long starts_nonlower(s)
380 char *s;
381 {
382 return (*s && !LOWER(s[0]));
383 }
384
385 /* Return TRUE iff s contains a character that is not alphanumeric. */
386 long has_non_alpha(s)
387 char *s;
388 {
389 while (*s) {
390 if (!ISALPHA(*s)) return TRUE;
391 s++;
392 }
393 return FALSE;
394 }
395
396 /* Return TRUE iff s contains only SYMBOL characters. */
397 long all_symbol(s)
398 char *s;
399 {
400 while (*s) {
401 if (!SYMBOL(*s)) return FALSE;
402 s++;
403 }
404 return TRUE;
405 }
406
407 /* Return TRUE if s represents an integer. */
408 long is_integer(s)
409 char *s;
410 {
411 if (!*s) return FALSE;
412 if (*s=='-') s++;
413 while (*s) {
414 if (!DIGIT(*s)) return FALSE;
415 s++;
416 }
417 return TRUE;
418 }
419
420 /* Return TRUE if s does not have to be quoted, i.e., */
421 /* s starts with '_' or a lowercase symbol and contains */
422 /* all digits, letters, and '_'. */
423 long no_quote(s)
424 char *s;
425 {
426 if (!s[0]) return FALSE;
427
428 if (s[0]=='%') return FALSE;
429 if (SINGLE(s[0]) && s[1]==0) return TRUE;
430 if (s[0]=='_' && s[1]==0) return FALSE;
431 if (all_symbol(s)) return TRUE;
432
433 if (!LOWER(s[0])) return FALSE;
434 s++;
435 while (*s) {
436 if (!ISALPHA(*s)) return FALSE;
437 s++;
438 }
439 return TRUE;
440 }
441
442
443
444 /******** PRETTYF(s)
445 This prints the string S into the BUFFER.
446 */
447 void prettyf(s)
448 char *s;
449 {
450 prettyf_inner(s,FALSE,'\'');
451 }
452
453
454 void prettyf_quoted_string(s)
455 char *s;
456 {
457 prettyf_inner((char *)s,const_quote,'"');
458 }
459
460
461
462 /****** PRETTYF_QUOTE(s)
463 This prints the string S into the buffer.
464 S is surrounded by quotes if:
465 (1) const_quote==TRUE, and
466 (2) S does not represent an integer, and
467 (2) S contains a non-alphanumeric character
468 or starts with a non-lowercase character, and
469 (3) if S is longer than one character, it is not true that S has only
470 non-SINGLE SYMBOL characters (in that case, S does not need quotes),and
471 (4) if S has only one character, it is a single space or underscore.
472 When S is surrounded by quotes, a quote inside S is printed as two quotes.
473 */
474 void prettyf_quote(s)
475 char *s;
476 {
477 prettyf_inner(s, const_quote && !no_quote(s), '\'');
478 }
479 /*
480 !is_integer(s) &&
481 (starts_nonlower(s) || has_non_alpha(s)) &&
482 ((int)strlen(s)>1
483 ? !all_symbol(s):
484 ((int)strlen(s)==1
485 ? (s[0]==' ' || s[0]=='_' || UPPER(s[0]) || DIGIT(s[0]))
486 : TRUE
487 )
488 ),
489 '\'');
490 */
491
492
493 /******** END_TAB()
494 Mark the end of an item.
495 Copy the item's string into global space and point to the next item.
496 */
497 void end_tab()
498 {
499 if (indent) {
500 indx->str=(char *)heap_alloc(strlen(buffer)+1);
501 strcpy(indx->str,buffer);
502 indx++;
503 *buffer=0;
504 }
505 }
506
507
508
509 /******** MARK_TAB(t)
510 Mark a tabbing position T.
511 Make the current item point to tabbing position T.
512 */
513 void mark_tab(t)
514 ptr_tab_brk t;
515 {
516 end_tab();
517 indx->tab=t;
518 }
519
520
521
522 /******** NEW_TAB(t)
523 Create a new tabulation mark T.
524 */
525 void new_tab(t)
526 ptr_tab_brk *t;
527 {
528 (*t)=HEAP_ALLOC(tab_brk);
529 (*t)->broken=FALSE;
530 (*t)->printed=FALSE;
531 (*t)->column=0;
532 }
533
534
535 /* Utility to correctly handle '\n' inside strings being printed: */
536 /* What is the column after printing str, when the starting position */
537 /* is pos? */
538 /* Same as strlen, except that the length count starts with pos and */
539 /* \n resets it. */
540 long strpos(pos, str)
541 long pos;
542 char *str;
543 {
544 while (*str) {
545 if (str[0]=='\n') pos=0; else pos++;
546 str++;
547 }
548 return pos;
549 }
550
551
552 /******** WORK_OUT_LENGTH()
553 Calculate the number of blanks before each tabulation.
554 Insert line feeds until it all fits into PAGE_WIDTH columns.
555 This is done by a trial and error mechanism.
556 */
557 void work_out_length()
558 {
559 ptr_item i;
560 long done=FALSE;
561 long pos;
562 ptr_tab_brk worst,root;
563 long w;
564
565 while(!done) {
566
567 pos=0;
568 done=TRUE;
569
570 w= -1;
571 worst=NULL;
572 root=NULL;
573
574 for(i=pretty_things+1;(unsigned long)i<(unsigned long)indx;i++) {
575
576 if(i->tab->broken && i->tab->printed) {
577 pos=i->tab->column;
578 root=NULL;
579 }
580
581 if(!i->tab->printed) i->tab->column=pos;
582
583 if(!(i->tab->broken))
584 if(!root || (root && (root->column)>=(i->tab->column)))
585 root=i->tab;
586
587 /* pos=pos+strlen(i->str); */
588 pos=strpos(pos,i->str);
589 i->tab->printed=TRUE;
590
591 if(pos>page_width)
592 done=FALSE;
593
594 if(pos>w) {
595 w=pos;
596 worst=root;
597 }
598 }
599
600 for(i=pretty_things+1;(unsigned long)i<(unsigned long)indx;i++)
601 i->tab->printed=FALSE;
602
603 if(!done)
604 if(worst)
605 worst->broken=TRUE;
606 else
607 done=TRUE;
608 }
609 }
610
611
612
613 /*** RM: Dec 11 1992 (START) ***/
614
615 /******** COUNT_FEATURES(t)
616 Return the number of features of a tree.
617 */
618
619 long count_features(t)
620
621 ptr_node t;
622 {
623 long c=0;
624 if(t) {
625 if(t->left)
626 c+=count_features(t->left);
627 c++;
628 if(t->right)
629 c+=count_features(t->right);
630 }
631 return c;
632 }
633
634
635
636 /******** CHECK_LEGAL_CONS(t,t_type)
637
638 Check that T is of type T_TYPE, that it has exactly the attributes '1' and
639 '2' and that the 2nd is either nil or also long check_legal_cons(t,t_type)
640 */
641
642 long check_legal_cons(t,t_type)
643 ptr_psi_term t;
644 ptr_definition t_type;
645
646 {
647 return (t->type==t_type &&
648 count_features(t->attr_list)==2 &&
649 find(FEATCMP,one,t->attr_list) &&
650 find(FEATCMP,two,t->attr_list));
651 }
652
653 /*** RM: Dec 11 1992 (END) ***/
654
655
656 /******** PRETTY_LIST(t,depth)
657 Pretty print a list.
658 On entry we know that T is a legal CONS pair, so we can immediately print
659 the opening bracket etc...
660 */
661 void pretty_list(t,depth)
662 ptr_psi_term t;
663 long depth;
664 {
665 ptr_tab_brk new;
666 // ptr_list l;
667 ptr_definition t_type;
668 ptr_psi_term car,cdr;
669 ptr_node n; // ,n2;
670 // char *tag=NULL;
671 // char colon[2],sep[4],end[3];
672 char sep[4],end[3];
673 long list_depth; /* 20.8 */
674 long done=FALSE; /* RM: Dec 11 1992 */
675
676
677 strcpy(sep,"ab");
678 strcpy(end,"cd");
679 t_type=t->type;
680
681 if (overlap_type(t_type,alist)) {
682 if (!equal_types(t_type,alist)) {
683 pretty_symbol(t_type->keyword); /* RM: Jan 13 1993 */
684 prettyf(DOTDOT);
685 }
686 prettyf("[");
687 strcpy(sep,",");
688 strcpy(end,"]");
689 }
690
691 /*
692 else if (equal_types(t_type,conjunction)) {
693 prettyf("(");
694 strcpy(sep,DOTDOT);
695 strcpy(end,")");
696 }
697 */
698
699 else if (equal_types(t_type,disjunction)) {
700 prettyf("{");
701 strcpy(sep,";");
702 strcpy(end,"}");
703 }
704
705
706 /* RM: Dec 11 1992 New code for printing lists */
707
708 new_tab(&new);
709 list_depth=0; /* 20.8 */
710 while(!done) {
711 mark_tab(new);
712 if(list_depth==print_depth)
713 prettyf("...");
714
715 get_two_args(t->attr_list,&car,&cdr);
716 deref_ptr(car);
717 deref_ptr(cdr);
718
719
720 if(list_depth<print_depth)
721 pretty_tag_or_psi_term(car,COMMA_PREC,depth);
722
723 /* Determine how to print the CDR */
724 n=find(INTCMP,(char *)cdr,pointer_names);
725
726 if(n && n->data) {
727 prettyf("|");
728 pretty_tag_or_psi_term(cdr,MAX_PRECEDENCE+1,depth);
729 done=TRUE;
730 }
731 else
732 if(( /* RM: Feb 1 1993 */
733 (cdr->type==nil && overlap_type(t_type,alist)) ||
734 (cdr->type==disj_nil && t_type==disjunction)
735 )
736 && !cdr->attr_list)
737 done=TRUE;
738 else
739 if(!check_legal_cons(cdr,t_type)) {
740 prettyf("|");
741 pretty_tag_or_psi_term(cdr,MAX_PRECEDENCE+1,depth);
742 done=TRUE;
743 }
744 else {
745 if(list_depth<print_depth)
746 prettyf(sep);
747 t=cdr;
748 }
749
750 list_depth++;
751 }
752
753 prettyf(end);
754 }
755
756
757 /******** PRETTY_TAG_OR_PSI_TERM(p,depth)
758 Print a psi-term, but first precede it with the appropriate TAG. Don't
759 reprint the same psi-term twice.
760 */
761 void pretty_tag_or_psi_term(p, sprec, depth)
762 ptr_psi_term p;
763 long sprec;
764 long depth;
765 {
766 ptr_node n,n2;
767
768 if (p==NULL) {
769 prettyf("<VOID>");
770 return;
771 }
772 if (FALSE /*depth>=print_depth*/) { /* 20.8 */
773 prettyf("...");
774 return;
775 }
776 deref_ptr(p);
777
778 n=find(INTCMP,(char *)p,pointer_names);
779
780 if (n && n->data) {
781 if (n->data==(GENERIC)no_name) {
782 n->data=(GENERIC)unique_name();
783 /* sprintf(name,"_%ld%c",++gen_sym_counter,0); */
784 /* n->data=(GENERIC)heap_copy_string(name); */
785 }
786 n2=find(INTCMP,(char *)p,printed_pointers);
787 if(n2==NULL) {
788 prettyf((char *)n->data);
789 (void)heap_insert(INTCMP,(char *)p,&printed_pointers,(GENERIC)n->data);
790 if (!is_top(p)) {
791 prettyf(DOTDOT);
792 pretty_psi_term(p,COLON_PREC,depth);
793 }
794 }
795 else
796 prettyf((char *)n2->data);
797 }
798 else
799 pretty_psi_term(p,sprec,depth);
800 }
801
802
803
804 /****************************************************************************/
805 /* Routines to handle printing of operators. */
806 /* The main routine is pretty_psi_with_ops, which is called in */
807 /* pretty_psi_term. */
808
809
810 /* Check arguments of a potential operator. */
811 /* Returns existence of arguments 1 and 2 in low two bits of result. */
812 /* If only argument "1" exists, returns 1. */
813 /* If only arguments "1" and "2" exist, returns 3. */
814 /* Existence of any other arguments causes third bit to be set as well. */
815 long check_opargs(n)
816 ptr_node n;
817 {
818 if (n) {
819 long f=check_opargs(n->left) | check_opargs(n->right);
820 if (!featcmp(n->key,"1")) return 1 | f;
821 if (!featcmp(n->key,"2")) return 2 | f;
822 return 4 | f;
823 }
824 else
825 return 0;
826 }
827
828
829 /* Get information about an operator. */
830 /* If t is an operator with the correct arguments, return one of */
831 /* {INFIX, PREFIX, POSTFIX} and also its precedence and type. */
832 /* If t is not an operator, or it has wrong arguments, return NOTOP */
833 /* and prec=0. */
834 long opcheck(t, prec, type)
835 ptr_psi_term t;
836 long *prec;
837 long *type;
838 {
839 long op;
840 long result=NOTOP;
841 long numarg=check_opargs(t->attr_list);
842 ptr_operator_data opdat=t->type->op_data;
843
844 *prec=0;
845 if (numarg!=1 && numarg!=3) return NOTOP;
846 while (opdat) {
847 op=opdat->type;
848 if (numarg==1) {
849 if (op==xf || op==yf) { result=POSTFIX; break; }
850 if (op==fx || op==fy) { result=PREFIX; break; }
851 }
852 if (numarg==3)
853 if (op==xfx || op==xfy || op==yfx) { result=INFIX; break; }
854 opdat=opdat->next;
855 }
856 if (opdat==NULL) return NOTOP;
857 *prec=opdat->precedence;
858 *type=op;
859 return result;
860 }
861
862
863 /* Write an expression with its operators. */
864 /* Return TRUE iff the arguments of t are written here (i.e. t was indeed */
865 /* a valid operator, and is therefore taken care of here). */
866 long pretty_psi_with_ops(t,sprec,depth)
867 ptr_psi_term t;
868 long sprec;
869 long depth;
870 {
871 // ptr_tab_brk new;
872 ptr_psi_term arg1, arg2;
873 long ttype, a1type, a2type;
874 long tprec, a1prec, a2prec;
875 long tkind, a1kind, a2kind;
876 long p1, p2, argswritten;
877 long sp; /* surrounding parentheses */
878
879 if (write_canon) return FALSE; /* PVR 24.2.94 */
880
881 argswritten=TRUE;
882 tkind=opcheck(t, &tprec, &ttype);
883 sp=(tkind==INFIX||tkind==PREFIX||tkind==POSTFIX) && tprec>=sprec;
884 if (sp) prettyf("(");
885 if (tkind==INFIX) {
886 get_two_args(t->attr_list, &arg1, &arg2);
887 deref_ptr(arg1); /* 16.9 */
888 deref_ptr(arg2); /* 16.9 */
889 a1kind = opcheck(arg1, &a1prec, &a1type);
890 a2kind = opcheck(arg2, &a2prec, &a2type);
891
892 /* The p1 and p2 flags tell whether to put parens around t's args */
893 /* Calculate p1 flag: */
894 if (a1prec>tprec) p1=TRUE;
895 else if (a1prec<tprec) p1=FALSE;
896 else /* equal priority */
897 if (ttype==xfy || ttype==xfx) p1=TRUE;
898 else /* yfx */
899 if (a1type==yfx || a1type==fx || a1type==fy) p1=FALSE;
900 else p1=TRUE;
901
902 /* Calculate p2 flag: */
903 if (a2prec>tprec) p2=TRUE;
904 else if (a2prec<tprec) p2=FALSE;
905 else /* equal priority */
906 if (ttype==yfx || ttype==xfx) p2=TRUE;
907 else /* xfy */
908 if (a2type==xfy || a2type==xf || a2type==yf) p2=FALSE;
909 else p2=TRUE;
910
911 /* Write the expression */
912 if (p1) prettyf("(");
913 pretty_tag_or_psi_term(arg1,MAX_PRECEDENCE+1,depth);
914 if (p1) prettyf(")");
915 if (!p1 && strcmp(t->type->keyword->symbol,",")) {
916 prettyf(" ");
917 }
918 pretty_quote_symbol(t->type->keyword); /* RM: Jan 13 1993 */
919 if (listing_flag && !func_flag &&
920 (!strcmp(t->type->keyword->symbol,",") ||
921 !strcmp(t->type->keyword->symbol,":-"))) {
922 prettyf("\n ");
923 }
924 else {
925 if (!p2 && strcmp(t->type->keyword->symbol,".")) prettyf(" ");
926 }
927 if (p2) prettyf("(");
928 pretty_tag_or_psi_term(arg2,MAX_PRECEDENCE+1,depth);
929 if (p2) prettyf(")");
930 }
931 else if (tkind==PREFIX) {
932 get_two_args(t->attr_list, &arg1, &arg2); /* arg2 does not exist */
933 a1kind = opcheck(arg1, &a1prec, &a1type);
934
935 /* Calculate p1 flag: */
936 if (a1type==fx || a1type==fy) p1=FALSE;
937 else p1=(tprec<=a1prec);
938
939 pretty_quote_symbol(t->type->keyword); /* RM: Jan 13 1993 */
940 if (!p1) prettyf(" ");
941 if (p1) prettyf("(");
942 pretty_tag_or_psi_term(arg1,MAX_PRECEDENCE+1,depth);
943 if (p1) prettyf(")");
944 }
945 else if (tkind==POSTFIX) {
946 get_two_args(t->attr_list, &arg1, &arg2); /* arg2 does not exist */
947 a1kind = opcheck(arg1, &a1prec, &a1type);
948
949 /* Calculate p1 flag: */
950 if (a1type==xf || a1type==yf) p1=FALSE;
951 else p1=(tprec<=a1prec);
952
953 if (p1) prettyf("(");
954 pretty_tag_or_psi_term(arg1,MAX_PRECEDENCE+1,depth);
955 if (p1) prettyf(")");
956 if (!p1) prettyf(" ");
957 pretty_quote_symbol(t->type->keyword); /* RM: Jan 13 1993 */
958 }
959 else {
960 argswritten=FALSE;
961 }
962 if (sp) prettyf(")");
963 return argswritten;
964 }
965
966 /****************************************************************************/
967
968
969 /******** PRETTY_PSI_TERM(t,sprec,depth)
970 Pretty print a psi_term T with sugar for lists.
971 */
972 void pretty_psi_term(t,sprec,depth)
973 ptr_psi_term t;
974 long sprec;
975 long depth;
976 {
977 char buf[STRLEN]; /* Big enough for a long number */
978 ptr_residuation r;
979 long argswritten;
980 // double fmod();
981
982 if (t) {
983 deref_ptr(t); /* PVR */
984
985 /* if (trace) printf("<%ld>",t->status); For brunobug.lf PVR 14.2.94 */
986
987 /* RM: Feb 12 1993 */
988 if(display_persistent &&
989 (GENERIC)t>heap_pointer)
990 prettyf(" $");
991
992 if((t->type==alist || t->type==disjunction) && check_legal_cons(t,t->type))
993 pretty_list(t,depth+1); /* RM: Dec 11 1992 */
994 else
995 if(t->type==nil && !t->attr_list)
996 prettyf("[]");
997 else
998 if(t->type==disj_nil && !t->attr_list) /* RM: Feb 1 1993 */
999 prettyf("{}");
1000 else {
1001 argswritten=FALSE;
1002 if (t->value_3) {
1003 #ifdef CLIFE
1004 if(t->type->type==block) { /* RM 20 Jan 1993 */
1005 pretty_block(t); /* AA 21 Jan 1993 */
1006 }
1007 else
1008 #endif /* CLIFE */
1009 if (sub_type(t->type,integer)) {
1010 /* Print integers in chunks up to the full precision of the REAL */
1011 long seg,neg,i;
1012 REAL val;
1013 char segbuf[100][PRINT_POWER+3];
1014
1015 val = *(REAL *)t->value_3;
1016 neg = (val<0.0);
1017 if (neg) val = -val;
1018 if (val>WL_MAXINT) goto PrintReal;
1019 seg=0;
1020 while (val>=(double)PRINT_SPLIT) {
1021 double tmp;
1022 tmp=(REAL)fmod((double)val,(double)PRINT_SPLIT);
1023 (void)snprintf(segbuf[seg],100,seg_format,(unsigned long)tmp);
1024 val=floor(val/(double)PRINT_SPLIT);
1025 seg++;
1026 }
1027 (void)snprintf(segbuf[seg],100,"%s%ld",(neg?"-":""),(unsigned long)val);
1028 for (i=seg; i>=0; i--) prettyf(segbuf[i]);
1029 if (!equal_types(t->type,integer)) {
1030 prettyf(DOTDOT);
1031 pretty_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1032 }
1033 }
1034 else if (sub_type(t->type,real)) {
1035 PrintReal:
1036 (void)snprintf(buf,STRLEN,"%lg",*(REAL *)t->value_3);
1037 prettyf(buf);
1038 if (!equal_types(t->type,real) &&
1039 !equal_types(t->type,integer)) {
1040 prettyf(DOTDOT);
1041 pretty_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1042 }
1043 }
1044 else if (sub_type(t->type,quoted_string)) {
1045 prettyf_quoted_string((char *)t->value_3);
1046 if(!equal_types(t->type,quoted_string)) {
1047 prettyf(DOTDOT);
1048 pretty_quote_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1049 }
1050 }
1051 /* DENYS: BYTEDATA */
1052 else if (sub_type(t->type,sys_bytedata)) {
1053 pretty_quote_symbol(t->type->keyword);
1054 }
1055 else if (equal_types(t->type,stream)) {
1056 (void)snprintf(buf,STRLEN,"stream(%ld)",(long)t->value_3);
1057 prettyf(buf);
1058 }
1059 else if (equal_types(t->type,eof))
1060 pretty_quote_symbol(eof->keyword); /* RM: Jan 13 1993 */
1061 else if (equal_types(t->type,cut))
1062 pretty_quote_symbol(cut->keyword); /* RM: Jan 13 1993 */
1063 else {
1064 prettyf("*** bad object '");
1065 pretty_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1066 prettyf("'***");
1067 }
1068 }
1069 else {
1070 if (depth<print_depth) /* 20.8 */
1071 argswritten=pretty_psi_with_ops(t,sprec,depth+1);
1072 /* RM: Jan 13 1993 */
1073 if (!argswritten) pretty_quote_symbol(t->type->keyword);
1074 }
1075
1076 /* write_canon -- PVR 24.2.94 */
1077 if (!argswritten && t->attr_list &&
1078 (depth<print_depth || write_canon)) /* 20.8 */
1079 pretty_attr(t->attr_list,depth+1);
1080
1081 if (depth>=print_depth && !write_canon && t->attr_list) /* 20.8 */
1082 prettyf("(...)");
1083 }
1084 if ((r=t->resid))
1085 while (r) {
1086 if (r->goal->pending) {
1087 if (FALSE /* write_resids 11.8 */) {
1088 prettyf("\\");
1089 pretty_psi_term(r->goal->aaaa_1,0,depth);
1090 }
1091 else
1092 prettyf("~");
1093 }
1094 r=r->next;
1095 }
1096 }
1097 }
1098
1099
1100
1101 /******** DO_PRETTY_ATTR(t,tab,cnt,depth)
1102 Pretty print the attribute tree T at position TAB.
1103
1104 CNT is what the value of the first integer label should be, so that
1105 "p(1=>a,2=>b)" is printed "p(a,b)"
1106 but
1107 "p(2=>a,3=>b)" is printed as "p(2 => a,3 => b)".
1108 */
1109 void do_pretty_attr(t,tab,cnt,two,depth)
1110 ptr_node t;
1111 ptr_tab_brk tab;
1112 long *cnt;
1113 long two;
1114 long depth;
1115 {
1116 long v;
1117 /* char *s="nnn"; 18.5 */
1118 char s[4];
1119 ptr_module module;
1120
1121
1122 if (t) {
1123 if (t->left) {
1124 do_pretty_attr(t->left,tab,cnt,two,depth);
1125 prettyf(",");
1126 }
1127
1128 /* Don't start each argument on a new line, */
1129 /* unless printing a function body: */
1130 mark_tab(tab);
1131
1132 v=str_to_int(t->key);
1133 if (v<0) {
1134 if(display_modules) { /* RM: Jan 21 1993 */
1135 module=extract_module_from_name(t->key);
1136 if(module) {
1137 prettyf(module->module_name);
1138 prettyf("#");
1139 }
1140 }
1141 prettyf_quote(strip_module_name(t->key));
1142
1143 prettyf(" => ");
1144 }
1145 else if (v== *cnt)
1146 (*cnt)++ ;
1147 else {
1148 (void)snprintf(s,4,"%ld",v);
1149 prettyf(s); /* 6.10 */
1150 prettyf(" => ");
1151 }
1152
1153 /* pretty_tag_or_psi_term(t->data,(two?COMMA_PREC:MAX_PRECEDENCE+1)); */
1154 pretty_tag_or_psi_term((ptr_psi_term)t->data,COMMA_PREC,depth);
1155
1156 if (t->right) {
1157 prettyf(",");
1158 do_pretty_attr(t->right,tab,cnt,two,depth);
1159 }
1160 }
1161 }
1162
1163
1164 /* Return true if number of attributes is greater than 1 */
1165 long two_or_more(t)
1166 ptr_node t;
1167 {
1168 if (t) {
1169 if (t->left || t->right) return TRUE; else return FALSE;
1170 }
1171 else
1172 return FALSE;
1173 }
1174
1175
1176 /******** PRETTY_ATTR(t,depth)
1177 Pretty print the attributes. This calls DO_PRETTY_ATTR which does the real
1178 work.
1179 */
1180 void pretty_attr(t,depth)
1181 ptr_node t;
1182 long depth;
1183 {
1184 ptr_tab_brk new;
1185 long cnt=1;
1186
1187 prettyf("(");
1188 new_tab(&new);
1189
1190 do_pretty_attr(t,new,&cnt,two_or_more(t),depth);
1191
1192 prettyf(")");
1193 }
1194
1195
1196
1197 /******** PRETTY_OUTPUT()
1198 Final output of all these pretty things which have been built up.
1199 */
1200 void pretty_output()
1201 {
1202 ptr_item i;
1203 long j;
1204
1205 for(i=pretty_things+1;(unsigned long)i<(unsigned long)indx;i++) {
1206 if(i->tab->broken && i->tab->printed) {
1207 fprintf(outfile,"\n");
1208 for(j=0;j<i->tab->column;j++)
1209 fprintf(outfile," ");
1210 }
1211 fprintf(outfile,"%s",i->str);
1212 i->tab->printed=TRUE;
1213 }
1214 }
1215
1216
1217
1218 /******** PRETTY_VARIABLES(n,tab)
1219 Pretty print the variables at position TAB.
1220 */
1221 void pretty_variables(n,tab)
1222 ptr_node n;
1223 ptr_tab_brk tab;
1224 {
1225 ptr_psi_term tok;
1226 ptr_node n2;
1227
1228 if(n->left) {
1229 pretty_variables(n->left,tab);
1230 prettyf(", ");
1231 }
1232
1233 mark_tab(tab);
1234 prettyf(n->key);
1235 prettyf(" = ");
1236
1237 tok=(ptr_psi_term )n->data;
1238 deref_ptr(tok);
1239 n2=find(INTCMP,(char *)tok,printed_pointers);
1240 if(strcmp((char *)n2->data,n->key)<0)
1241 /* Reference to previously printed variable */
1242 prettyf((char *)n2->data);
1243 else {
1244 if (eqsym->op_data) {
1245 long tkind, tprec, ttype, eqprec;
1246 eqprec=eqsym->op_data->precedence;
1247 tkind=opcheck(tok, &tprec, &ttype);
1248 if (tprec>=eqprec) prettyf("(");
1249 pretty_psi_term(tok,MAX_PRECEDENCE+1,0);
1250 if (tprec>=eqprec) prettyf(")");
1251 }
1252 else
1253 pretty_psi_term(tok,MAX_PRECEDENCE+1,0);
1254 }
1255
1256 if(n->right) {
1257 prettyf(", ");
1258 pretty_variables(n->right,tab);
1259 }
1260 }
1261
1262
1263
1264
1265 /******** PRINT_VARIABLES
1266 This prints all the query variables.
1267 Symbols generated to print one variable are coherent with those used in
1268 other variables.
1269 Returns TRUE iff the set of query variables is nonempty.
1270 */
1271
1272 long print_variables(printflag)
1273
1274 long printflag;
1275 {
1276 ptr_tab_brk new;
1277 GENERIC old_heap_pointer;
1278 if (!printflag) return FALSE; /* 21.1 */
1279
1280 outfile=output_stream;
1281 listing_flag=FALSE;
1282 old_heap_pointer=heap_pointer;
1283
1284 pointer_names=NULL;
1285 printed_pointers=NULL;
1286 gen_sym_counter=0;
1287 go_through_tree(var_tree);
1288 insert_variables(var_tree,TRUE);
1289 forbid_variables(var_tree);
1290
1291 indent=TRUE;
1292 const_quote=TRUE;
1293 write_resids=TRUE;
1294 write_canon=FALSE;
1295 *buffer=0;
1296 indx=pretty_things;
1297
1298 if (var_tree) {
1299 new_tab(&new);
1300 pretty_variables(var_tree,new);
1301 prettyf(".");
1302 mark_tab(new);
1303 prettyf("\n");
1304 end_tab();
1305
1306 if (indent) {
1307 work_out_length();
1308 pretty_output();
1309 }
1310 }
1311 heap_pointer=old_heap_pointer;
1312 return (var_tree!=NULL);
1313 }
1314
1315
1316
1317 /******** WRITE_ATTRIBUTES(n)
1318 Used by all versions of the built-in predicate write,
1319 and by the built-in predicate listing.
1320 */
1321 void write_attributes(n,tab)
1322 ptr_node n;
1323 ptr_tab_brk tab;
1324 {
1325 if(n) {
1326 write_attributes(n->left,tab);
1327 mark_tab(tab);
1328 pretty_tag_or_psi_term((ptr_psi_term)n->data,MAX_PRECEDENCE+1,0);
1329 write_attributes(n->right,tab);
1330 }
1331 }
1332
1333
1334 /******** PRED_WRITE(n)
1335 N is an attribute tree to be printed in one lump. This is called by WRITE.
1336 */
1337
1338 void main_pred_write(ptr_node);
1339
1340 /* For the listing built-in */
1341 void listing_pred_write(n,fflag)
1342 ptr_node n;
1343 long fflag;
1344 {
1345 long old_print_depth;
1346
1347 listing_flag=TRUE;
1348 func_flag=fflag;
1349 indent=TRUE;
1350 const_quote=TRUE;
1351 write_corefs=TRUE;
1352 write_stderr=FALSE;
1353 write_resids=FALSE;
1354 write_canon=FALSE;
1355 outfile=output_stream;
1356 old_print_depth=print_depth;
1357 print_depth=PRINT_DEPTH;
1358 main_pred_write(n);
1359 print_depth=old_print_depth;
1360 (void)fflush(outfile);
1361 }
1362
1363 /* For all write builtins */
1364 /* I.e: write, writeq, pretty_write, pretty_writeq, write_err, writeq_err. */
1365 void pred_write(n)
1366 ptr_node n;
1367 {
1368 listing_flag=FALSE;
1369 /* write_stderr=FALSE; */
1370 outfile=(write_stderr?stderr:output_stream);
1371 main_pred_write(n);
1372 (void)fflush(outfile);
1373 }
1374
1375 void main_pred_write(n)
1376 ptr_node n;
1377 {
1378 if (n) {
1379 GENERIC old_heap_pointer;
1380 ptr_tab_brk new;
1381
1382 if (!write_corefs) main_pred_write(n->left);
1383
1384 old_heap_pointer=heap_pointer;
1385 pointer_names=NULL;
1386 printed_pointers=NULL;
1387 gen_sym_counter=0;
1388 if (write_corefs)
1389 go_through_tree(n);
1390 else
1391 check_pointer((ptr_psi_term)n->data);
1392 insert_variables(var_tree,FALSE);
1393
1394 *buffer=0;
1395
1396 indx=pretty_things;
1397 new_tab(&new);
1398
1399 if (write_corefs) {
1400 write_attributes(n,new);
1401 }
1402 else {
1403 mark_tab(new);
1404 pretty_tag_or_psi_term((ptr_psi_term)n->data,MAX_PRECEDENCE+1,0);
1405 }
1406
1407 end_tab();
1408
1409 if (indent) {
1410 work_out_length();
1411 pretty_output();
1412 }
1413
1414 heap_pointer=old_heap_pointer;
1415
1416 if (!write_corefs) main_pred_write(n->right);
1417 }
1418 }
1419
1420
1421 void main_display_psi_term(ptr_psi_term); /* Forward declaration */
1422
1423
1424 /******** DISPLAY_PSI_STDOUT(t)
1425 Print the psi_term T to stdout as simply as possible (no indenting).
1426 */
1427 void display_psi_stdout(t)
1428 ptr_psi_term t;
1429 {
1430 outfile=stdout;
1431 main_display_psi_term(t);
1432 }
1433
1434
1435 /******** DISPLAY_PSI_STDERR(t)
1436 Print the psi_term T to stderr as simply as possible (no indenting).
1437 */
1438 void display_psi_stderr(t)
1439 ptr_psi_term t;
1440 {
1441 outfile=stderr;
1442 main_display_psi_term(t);
1443 }
1444
1445
1446 /******** DISPLAY_PSI_STREAM(t)
1447 Print the psi_term T to output_stream as simply as possible (no indenting).
1448 */
1449 void display_psi_stream(t)
1450 ptr_psi_term t;
1451 {
1452 outfile=output_stream;
1453 main_display_psi_term(t);
1454 }
1455
1456
1457 /******** DISPLAY_PSI(stream,t)
1458 Print the psi_term T to the given stream.
1459 */
1460 void display_psi(s,t)
1461 FILE *s;
1462 ptr_psi_term t;
1463 {
1464 outfile=s;
1465 main_display_psi_term(t);
1466 }
1467
1468
1469 /* Main loop for previous two entry points */
1470 void main_display_psi_term(t)
1471 ptr_psi_term t;
1472 {
1473 GENERIC old_heap_pointer;
1474 ptr_tab_brk new;
1475
1476 listing_flag=FALSE;
1477 if(t) {
1478
1479 deref_ptr(t);
1480
1481 old_heap_pointer=heap_pointer;
1482 pointer_names=NULL;
1483 printed_pointers=NULL;
1484 gen_sym_counter=0;
1485 go_through(t);
1486 insert_variables(var_tree,FALSE);
1487
1488 indent=FALSE;
1489 const_quote=TRUE;
1490 write_resids=FALSE;
1491 write_canon=FALSE;
1492 *buffer=0;
1493 indx=pretty_things;
1494
1495 new_tab(&new);
1496 mark_tab(new);
1497 pretty_tag_or_psi_term(t,MAX_PRECEDENCE+1,0);
1498 end_tab();
1499 if (indent) {
1500 work_out_length();
1501 pretty_output();
1502 }
1503
1504 heap_pointer=old_heap_pointer;
1505 }
1506 else
1507 printf("*null psi_term*");
1508 }
1509
1510
1511
1512 /******** DISPLAY_COUPLE(u,s,v)
1513 Print a couple of psi-terms (u,v) with the correct co-referencing. Print
1514 string S in between.
1515 */
1516 void display_couple(u,s,v)
1517 ptr_psi_term u;
1518 char *s;
1519 ptr_psi_term v;
1520 {
1521 GENERIC old_heap_pointer;
1522 ptr_tab_brk new;
1523
1524 output_stream=stdout;
1525 listing_flag=FALSE;
1526 old_heap_pointer=heap_pointer;
1527
1528 pointer_names=NULL;
1529 printed_pointers=NULL;
1530 gen_sym_counter=0;
1531 check_pointer(u);
1532 check_pointer(v);
1533 insert_variables(var_tree,TRUE);
1534
1535 indent=FALSE;
1536 const_quote=TRUE;
1537 write_resids=FALSE;
1538 write_canon=FALSE;
1539 *buffer=0;
1540 indx=pretty_things;
1541 new_tab(&new);
1542 mark_tab(new);
1543 pretty_tag_or_psi_term(u,MAX_PRECEDENCE+1,0);
1544 prettyf(s);
1545 pretty_tag_or_psi_term(v,MAX_PRECEDENCE+1,0);
1546 end_tab();
1547
1548 if (indent) {
1549 work_out_length();
1550 pretty_output();
1551 }
1552
1553 heap_pointer=old_heap_pointer;
1554 }
1555
1556
1557
1558 /******** PRINT_RESID_MESSAGE
1559 This is called in trace mode to print the residuated goal along with the
1560 RV set.
1561 */
1562 void print_resid_message(t,r)
1563 ptr_psi_term t;
1564 ptr_resid_list r; /* 21.9 */
1565 {
1566 GENERIC old_heap_pointer;
1567 ptr_tab_brk new;
1568 ptr_resid_list r2; /* 21.9 */
1569
1570 outfile=stdout;
1571 listing_flag=FALSE;
1572 old_heap_pointer=heap_pointer;
1573
1574 pointer_names=NULL;
1575 printed_pointers=NULL;
1576 gen_sym_counter=0;
1577
1578 check_pointer(t);
1579
1580 r2=r;
1581 while(r2) {
1582 check_pointer(r2->var);
1583 r2=r2->next;
1584 }
1585
1586 insert_variables(var_tree,TRUE);
1587
1588 indent=FALSE;
1589 const_quote=TRUE;
1590 write_resids=FALSE;
1591 write_canon=FALSE;
1592 *buffer=0;
1593 indx=pretty_things;
1594 new_tab(&new);
1595 mark_tab(new);
1596
1597 prettyf("residuating ");
1598 pretty_tag_or_psi_term(t,MAX_PRECEDENCE+1,0);
1599 prettyf(" on variable(s) {");
1600
1601 r2=r;
1602 while(r2) {
1603 pretty_tag_or_psi_term(r2->var,MAX_PRECEDENCE+1,0);
1604 r2=r2->next;
1605 if(r2)
1606 prettyf(",");
1607 }
1608
1609 prettyf("}\n");
1610 end_tab();
1611
1612 heap_pointer=old_heap_pointer;
1613 }
wl_goal::aaaa_1
ptr_psi_term aaaa_1
Definition: def_struct.h:224
printed_pointers
ptr_node printed_pointers
Definition: def_glob.h:28
prettyf_quoted_string
void prettyf_quoted_string(char *s)
Definition: print.c:454
main_display_psi_term
void main_display_psi_term(ptr_psi_term)
Definition: print.c:1470
pretty_things
item pretty_things[PRETTY_SIZE]
Definition: print.c:25
get_two_args
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
wl_operator_data::precedence
long precedence
Definition: def_struct.h:48
is_top
#define is_top(T)
Definition: def_macro.h:108
unique_name
GENERIC unique_name()
Definition: print.c:87
prettyf
void prettyf(char *s)
Definition: print.c:447
prettyf_inner
void prettyf_inner(char *s, long q, char c)
Definition: print.c:349
two_or_more
long two_or_more(ptr_node t)
Definition: print.c:1165
yfx
#define yfx
Definition: def_const.h:268
FEATCMP
#define FEATCMP
Definition: def_const.h:257
perr
void perr(char *str)
Definition: error.c:659
wl_item
Definition: def_struct.h:310
wl_tab_brk::printed
long printed
Definition: def_struct.h:307
opcheck
long opcheck(ptr_psi_term t, long *prec, long *type)
Definition: print.c:834
xfx
#define xfx
Definition: def_const.h:265
wl_operator_data
Definition: def_struct.h:46
go_through_tree
void go_through_tree(ptr_node t)
Definition: print.c:236
wl_residuation::goal
ptr_goal goal
Definition: def_struct.h:156
stream
ptr_definition stream
Definition: def_glob.h:103
INTCMP
#define INTCMP
Definition: def_const.h:256
wl_residuation::next
ptr_residuation next
Definition: def_struct.h:157
POSTFIX
#define POSTFIX
Definition: def_const.h:340
NOT_CODED
#define NOT_CODED
Definition: def_const.h:134
two
char * two
Definition: def_glob.h:251
listing_pred_write
void listing_pred_write(ptr_node n, long fflag)
Definition: print.c:1341
work_out_length
void work_out_length()
Definition: print.c:557
wl_operator_data::next
ptr_operator_data next
Definition: def_struct.h:49
wl_module
Definition: def_struct.h:74
wl_tab_brk::column
long column
Definition: def_struct.h:305
main_pred_write
void main_pred_write(ptr_node)
Definition: print.c:1375
fx
#define fx
Definition: def_const.h:262
pretty_symbol
void pretty_symbol(ptr_keyword k)
Definition: modules.c:446
defs.h
wl_psi_term
Definition: def_struct.h:161
COLON_PREC
#define COLON_PREC
Definition: print.c:42
forbid_variables
void forbid_variables(ptr_node n)
Definition: print.c:309
strip_module_name
char * strip_module_name(char *str)
Definition: modules.c:139
INT_SIZE
#define INT_SIZE
Definition: def_const.h:144
check_legal_cons
long check_legal_cons(ptr_psi_term t, ptr_definition t_type)
Definition: print.c:642
strpos
long strpos(long pos, char *str)
Definition: print.c:540
pretty_psi_term
void pretty_psi_term(ptr_psi_term, long, long)
Definition: print.c:972
DIGIT
#define DIGIT(C)
Definition: def_macro.h:37
wl_resid_list::next
ptr_resid_list next
Definition: def_struct.h:62
wl_item::tab
ptr_tab_brk tab
Definition: def_struct.h:312
wl_residuation
Definition: def_struct.h:152
wl_definition::keyword
ptr_keyword keyword
Definition: def_struct.h:124
ISALPHA
#define ISALPHA(C)
Definition: def_macro.h:43
wl_item::str
char * str
Definition: def_struct.h:311
write_stderr
long write_stderr
Definition: print.c:13
wl_node::data
GENERIC data
Definition: def_struct.h:185
NULL
#define NULL
Definition: def_const.h:203
var_tree
ptr_node var_tree
Definition: def_glob.h:26
display_couple
void display_couple(ptr_psi_term u, char *s, ptr_psi_term v)
Definition: print.c:1516
is_integer
long is_integer(char *s)
Definition: print.c:408
display_modules
long display_modules
Definition: def_glob.h:164
xfy
#define xfy
Definition: def_const.h:267
starts_nonlower
long starts_nonlower(char *s)
Definition: print.c:379
DOTDOT
#define DOTDOT
Definition: def_const.h:335
prettyf_quote
void prettyf_quote(char *s)
Definition: print.c:474
overlap_type
long overlap_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1486
REAL
#define REAL
Definition: def_const.h:72
print_depth
long print_depth
Definition: print.c:8
mark_tab
void mark_tab(ptr_tab_brk t)
Definition: print.c:513
outfile
FILE * outfile
Definition: def_glob.h:333
LOWER
#define LOWER(C)
Definition: def_macro.h:41
SYMBOL
#define SYMBOL(C)
Definition: def_macro.h:52
heap_insert
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:276
print_bin
void print_bin(long b)
Definition: print.c:130
pointer_names
ptr_node pointer_names
Definition: def_glob.h:29
write_attributes
void write_attributes(ptr_node n, ptr_tab_brk tab)
Definition: print.c:1321
PAGE_WIDTH
#define PAGE_WIDTH
Definition: def_const.h:89
buffer
char * buffer
Definition: print.c:22
sub_type
long sub_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1544
wl_int_list
Definition: def_struct.h:53
has_non_alpha
long has_non_alpha(char *s)
Definition: print.c:386
pretty_list
void pretty_list(ptr_psi_term t, long depth)
Definition: print.c:661
pretty_quote_symbol
void pretty_quote_symbol(ptr_keyword k)
Definition: modules.c:464
PREFIX
#define PREFIX
Definition: def_const.h:339
display_psi_stdout
void display_psi_stdout(ptr_psi_term t)
Definition: print.c:1427
heap_copy_string
char * heap_copy_string(char *s)
Definition: trees.c:147
disj_nil
ptr_definition disj_nil
Definition: def_glob.h:85
display_persistent
long display_persistent
Definition: print.c:18
real
ptr_definition real
Definition: def_glob.h:102
new_tab
void new_tab(ptr_tab_brk *t)
Definition: print.c:525
write_corefs
long write_corefs
Definition: print.c:14
deref_ptr
#define deref_ptr(P)
Definition: def_macro.h:95
alist
ptr_definition alist
Definition: def_glob.h:94
wl_tab_brk
Definition: def_struct.h:304
eqsym
ptr_definition eqsym
Definition: def_glob.h:87
name
char * name
Definition: print.c:21
wl_node::key
char * key
Definition: def_struct.h:182
eof
ptr_definition eof
Definition: def_glob.h:86
wl_tab_brk::broken
long broken
Definition: def_struct.h:306
TRUE
#define TRUE
Definition: def_const.h:127
pretty_psi_with_ops
long pretty_psi_with_ops(ptr_psi_term t, long sprec, long depth)
Definition: print.c:866
indx
ptr_item indx
Definition: def_glob.h:329
STRCMP
#define STRCMP
Definition: def_const.h:255
PRINT_POWER
#define PRINT_POWER
Definition: def_const.h:96
pretty_variables
void pretty_variables(ptr_node n, ptr_tab_brk tab)
Definition: print.c:1221
integer
ptr_definition integer
Definition: def_glob.h:93
str_to_int
long str_to_int(char *s)
Definition: print.c:103
FALSE
#define FALSE
Definition: def_const.h:128
wl_resid_list
Definition: def_struct.h:59
no_name
char * no_name
Definition: print.c:20
pred_write
void pred_write(ptr_node n)
Definition: print.c:1365
print_resid_message
void print_resid_message(ptr_psi_term t, ptr_resid_list r)
Definition: print.c:1562
display_psi_stderr
void display_psi_stderr(ptr_psi_term t)
Definition: print.c:1438
quoted_string
ptr_definition quoted_string
Definition: def_glob.h:101
extract_module_from_name
ptr_module extract_module_from_name(char *str)
Definition: modules.c:111
pretty_attr
void pretty_attr(ptr_node, long)
Definition: print.c:1180
check_pointer
void check_pointer(ptr_psi_term p)
Definition: print.c:214
wl_resid_list::var
ptr_psi_term var
Definition: def_struct.h:60
seg_format
char seg_format[PRINT_POWER+4]
Definition: print.c:23
wl_module::module_name
char * module_name
Definition: def_struct.h:75
disjunction
ptr_definition disjunction
Definition: def_glob.h:84
heap_pointer
GENERIC heap_pointer
Definition: def_glob.h:12
one
char * one
Definition: def_glob.h:250
equal_types
#define equal_types(A, B)
Definition: def_macro.h:106
print_code
void print_code(FILE *s, ptr_int_list c)
Definition: print.c:147
xf
#define xf
Definition: def_const.h:261
display_psi_stream
void display_psi_stream(ptr_psi_term t)
Definition: print.c:1449
find
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
heap_nice_name
char * heap_nice_name()
Definition: print.c:55
PRINT_DEPTH
#define PRINT_DEPTH
Definition: def_const.h:92
featcmp
long featcmp(char *str1, char *str2)
Definition: trees.c:89
init_print
void init_print()
Definition: print.c:48
INFIX
#define INFIX
Definition: def_const.h:338
yf
#define yf
Definition: def_const.h:263
check_opargs
long check_opargs(ptr_node n)
Definition: print.c:815
wl_definition
Definition: def_struct.h:121
go_through
void go_through(ptr_psi_term)
Definition: print.c:258
PRETTY_SIZE
#define PRETTY_SIZE
Definition: def_const.h:79
MAX_PRECEDENCE
#define MAX_PRECEDENCE
Definition: def_const.h:103
no_quote
long no_quote(char *s)
Definition: print.c:423
sys_bytedata
ptr_definition sys_bytedata
Definition: def_glob.h:336
gen_sym_counter
long gen_sym_counter
Definition: def_glob.h:30
do_pretty_attr
void do_pretty_attr(ptr_node t, ptr_tab_brk tab, long *cnt, long two, long depth)
Definition: print.c:1109
PRINT_SPLIT
#define PRINT_SPLIT
Definition: def_const.h:95
all_symbol
long all_symbol(char *s)
Definition: print.c:397
WL_MAXINT
#define WL_MAXINT
Definition: def_const.h:76
ptr_psi_term
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
display_psi
void display_psi(FILE *s, ptr_psi_term t)
Definition: print.c:1460
pretty_tag_or_psi_term
void pretty_tag_or_psi_term(ptr_psi_term, long, long)
Definition: print.c:761
NOTOP
#define NOTOP
Definition: def_const.h:337
cut
ptr_definition cut
Definition: def_glob.h:83
SINGLE
#define SINGLE(C)
Definition: def_macro.h:47
write_canon
long write_canon
Definition: print.c:12
func_flag
static long func_flag
Definition: print.c:32
output_stream
FILE * output_stream
Definition: def_glob.h:41
const_quote
long const_quote
Definition: print.c:10
nil
ptr_definition nil
Definition: def_glob.h:97
STRLEN
#define STRLEN
Definition: def_const.h:86
insert_variables
void insert_variables(ptr_node vars, long force)
Definition: print.c:281
write_resids
long write_resids
Definition: print.c:11
listing_flag
static long listing_flag
Definition: print.c:28
wl_node
Definition: def_struct.h:181
end_tab
void end_tab()
Definition: print.c:497
wl_psi_term::type
ptr_definition type
Definition: def_struct.h:165
wl_int_list::value_1
GENERIC value_1
Definition: def_struct.h:54
GENERIC
unsigned long * GENERIC
Definition: def_struct.h:17
pretty_output
void pretty_output()
Definition: print.c:1200
HEAP_ALLOC
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
wl_psi_term::attr_list
ptr_node attr_list
Definition: def_struct.h:171
wl_goal::pending
ptr_definition pending
Definition: def_struct.h:228
print_variables
long print_variables(long printflag)
Definition: print.c:1272
indent
long indent
Definition: print.c:9
wl_definition::op_data
ptr_operator_data op_data
Definition: def_struct.h:139
print_operator_kind
void print_operator_kind(FILE *s, long kind)
Definition: print.c:173
heap_alloc
GENERIC heap_alloc(long s)
Definition: memory.c:1518
count_features
long count_features(ptr_node t)
Definition: print.c:619
COMMA_PREC
#define COMMA_PREC
Definition: print.c:41
fy
#define fy
Definition: def_const.h:264
page_width
long page_width
Definition: print.c:16
wl_int_list::next
ptr_int_list next
Definition: def_struct.h:55