Wild Life  2.29
 All Data Structures Files Functions Variables Typedefs Macros
Macros | Functions | Variables
print.c File Reference

Go to the source code of this file.

Macros

#define COMMA_PREC   ((commasym->op_data)?(commasym->op_data->precedence):0)
 
#define COLON_PREC   ((colonsym->op_data)?(colonsym->op_data->precedence):0)
 

Functions

void pretty_psi_term (ptr_psi_term, long, long)
 
void pretty_attr (ptr_node, long)
 
void pretty_tag_or_psi_term (ptr_psi_term, long, long)
 
void init_print ()
 
char * heap_nice_name ()
 
GENERIC unique_name ()
 
long str_to_int (char *s)
 
void print_bin (long b)
 
void print_code (FILE *s, ptr_int_list c)
 
void go_through (ptr_psi_term)
 
void print_operator_kind (FILE *s, long kind)
 
void check_pointer (ptr_psi_term p)
 
void go_through_tree (ptr_node t)
 
void insert_variables (ptr_node vars, long force)
 
void forbid_variables (ptr_node n)
 
void prettyf_inner (char *s, long q, char c)
 
long starts_nonlower (char *s)
 
long has_non_alpha (char *s)
 
long all_symbol (char *s)
 
long is_integer (char *s)
 
long no_quote (char *s)
 
void prettyf (char *s)
 
void prettyf_quoted_string (char *s)
 
void prettyf_quote (char *s)
 
void end_tab ()
 
void mark_tab (ptr_tab_brk t)
 
void new_tab (ptr_tab_brk *t)
 
long strpos (long pos, char *str)
 
void work_out_length ()
 
long count_features (ptr_node t)
 
long check_legal_cons (ptr_psi_term t, ptr_definition t_type)
 
void pretty_list (ptr_psi_term t, long depth)
 
long check_opargs (ptr_node n)
 
long opcheck (ptr_psi_term t, long *prec, long *type)
 
long pretty_psi_with_ops (ptr_psi_term t, long sprec, long depth)
 
void do_pretty_attr (ptr_node t, ptr_tab_brk tab, long *cnt, long two, long depth)
 
long two_or_more (ptr_node t)
 
void pretty_output ()
 
void pretty_variables (ptr_node n, ptr_tab_brk tab)
 
long print_variables (long printflag)
 
void write_attributes (ptr_node n, ptr_tab_brk tab)
 
void main_pred_write (ptr_node)
 
void listing_pred_write (ptr_node n, long fflag)
 
void pred_write (ptr_node n)
 
void main_display_psi_term (ptr_psi_term)
 
void display_psi_stdout (ptr_psi_term t)
 
void display_psi_stderr (ptr_psi_term t)
 
void display_psi_stream (ptr_psi_term t)
 
void display_psi (FILE *s, ptr_psi_term t)
 
void display_couple (ptr_psi_term u, char *s, ptr_psi_term v)
 
void print_resid_message (ptr_psi_term t, ptr_resid_list r)
 

Variables

long print_depth =PRINT_DEPTH
 
long indent =FALSE
 
long const_quote =TRUE
 
long write_resids =FALSE
 
long write_canon =FALSE
 
long write_stderr =FALSE
 
long write_corefs =TRUE
 
long page_width =PAGE_WIDTH
 
long display_persistent =FALSE
 
char * no_name ="pointer"
 
char * name ="symbol"
 
char * buffer
 
char seg_format [PRINT_POWER+4]
 
item pretty_things [PRETTY_SIZE]
 
static long listing_flag
 
static long func_flag
 

Macro Definition Documentation

#define COLON_PREC   ((colonsym->op_data)?(colonsym->op_data->precedence):0)

Definition at line 42 of file print.c.

#define COMMA_PREC   ((commasym->op_data)?(commasym->op_data->precedence):0)

Definition at line 41 of file print.c.

Function Documentation

long all_symbol ( char *  s)

Definition at line 397 of file print.c.

References FALSE, SYMBOL, and TRUE.

399 {
400  while (*s) {
401  if (!SYMBOL(*s)) return FALSE;
402  s++;
403  }
404  return TRUE;
405 }
#define SYMBOL(C)
Definition: def_macro.h:52
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
long check_legal_cons ( ptr_psi_term  t,
ptr_definition  t_type 
)

Definition at line 642 of file print.c.

References count_features(), FEATCMP, find(), one, and two.

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 }
#define FEATCMP
Definition: def_const.h:257
char * two
Definition: def_glob.h:251
char * one
Definition: def_glob.h:250
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
long check_opargs ( ptr_node  n)

Definition at line 815 of file print.c.

References featcmp().

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 }
ptr_node left
Definition: def_struct.h:183
char * key
Definition: def_struct.h:182
long featcmp(char *str1, char *str2)
Definition: trees.c:89
ptr_node right
Definition: def_struct.h:184
void check_pointer ( ptr_psi_term  p)

Definition at line 214 of file print.c.

References wl_node::data, deref_ptr, find(), go_through(), heap_insert(), INTCMP, no_name, NULL, and pointer_names.

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 }
#define INTCMP
Definition: def_const.h:256
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:276
ptr_node pointer_names
Definition: def_glob.h:29
#define deref_ptr(P)
Definition: def_macro.h:95
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
unsigned long * GENERIC
Definition: def_struct.h:17
long count_features ( ptr_node  t)

Definition at line 619 of file print.c.

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 }
ptr_node left
Definition: def_struct.h:183
ptr_node right
Definition: def_struct.h:184
void display_couple ( ptr_psi_term  u,
char *  s,
ptr_psi_term  v 
)

Definition at line 1516 of file print.c.

References buffer, check_pointer(), const_quote, end_tab(), FALSE, gen_sym_counter, heap_pointer, indent, indx, insert_variables(), listing_flag, mark_tab(), MAX_PRECEDENCE, new_tab(), NULL, output_stream, pointer_names, pretty_output(), pretty_tag_or_psi_term(), pretty_things, prettyf(), printed_pointers, TRUE, var_tree, work_out_length(), write_canon, and write_resids.

1520 {
1521  GENERIC old_heap_pointer;
1522  ptr_tab_brk new;
1523 
1524  output_stream=stdout;
1526  old_heap_pointer=heap_pointer;
1527 
1530  gen_sym_counter=0;
1531  check_pointer(u);
1532  check_pointer(v);
1534 
1535  indent=FALSE;
1536  const_quote=TRUE;
1539  *buffer=0;
1541  new_tab(&new);
1542  mark_tab(new);
1544  prettyf(s);
1546  end_tab();
1547 
1548  if (indent) {
1549  work_out_length();
1550  pretty_output();
1551  }
1552 
1553  heap_pointer=old_heap_pointer;
1554 }
ptr_node printed_pointers
Definition: def_glob.h:28
#define NULL
Definition: def_const.h:203
ptr_node var_tree
Definition: def_glob.h:26
ptr_node pointer_names
Definition: def_glob.h:29
#define TRUE
Definition: def_const.h:127
ptr_item indx
Definition: def_glob.h:329
#define FALSE
Definition: def_const.h:128
GENERIC heap_pointer
Definition: def_glob.h:12
#define MAX_PRECEDENCE
Definition: def_const.h:103
long gen_sym_counter
Definition: def_glob.h:30
FILE * output_stream
Definition: def_glob.h:41
unsigned long * GENERIC
Definition: def_struct.h:17
void display_psi ( FILE *  s,
ptr_psi_term  t 
)

Definition at line 1460 of file print.c.

References main_display_psi_term(), and outfile.

1463 {
1464  outfile=s;
1466 }
FILE * outfile
Definition: def_glob.h:333
void display_psi_stderr ( ptr_psi_term  t)

Definition at line 1438 of file print.c.

References main_display_psi_term(), and outfile.

1440 {
1441  outfile=stderr;
1443 }
FILE * outfile
Definition: def_glob.h:333
void display_psi_stdout ( ptr_psi_term  t)

Definition at line 1427 of file print.c.

References main_display_psi_term(), and outfile.

1429 {
1430  outfile=stdout;
1432 }
FILE * outfile
Definition: def_glob.h:333
void display_psi_stream ( ptr_psi_term  t)

Definition at line 1449 of file print.c.

References main_display_psi_term(), outfile, and output_stream.

1451 {
1454 }
FILE * outfile
Definition: def_glob.h:333
FILE * output_stream
Definition: def_glob.h:41
void do_pretty_attr ( ptr_node  t,
ptr_tab_brk  tab,
long *  cnt,
long  two,
long  depth 
)

Definition at line 1109 of file print.c.

References COMMA_PREC, display_modules, extract_module_from_name(), mark_tab(), wl_module::module_name, pretty_tag_or_psi_term(), prettyf(), prettyf_quote(), str_to_int(), and strip_module_name().

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  }
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)); */
1155 
1156  if (t->right) {
1157  prettyf(",");
1158  do_pretty_attr(t->right,tab,cnt,two,depth);
1159  }
1160  }
1161 }
char * two
Definition: def_glob.h:251
char * strip_module_name(char *str)
Definition: modules.c:139
GENERIC data
Definition: def_struct.h:185
long display_modules
Definition: def_glob.h:164
ptr_node left
Definition: def_struct.h:183
char * key
Definition: def_struct.h:182
ptr_module extract_module_from_name(char *str)
Definition: modules.c:111
char * module_name
Definition: def_struct.h:75
ptr_node right
Definition: def_struct.h:184
void end_tab ( )

Definition at line 497 of file print.c.

References buffer, heap_alloc(), indent, indx, and wl_item::str.

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 }
char * str
Definition: def_struct.h:311
ptr_item indx
Definition: def_glob.h:329
GENERIC heap_alloc(long s)
Definition: memory.c:1518
void forbid_variables ( ptr_node  n)

Definition at line 309 of file print.c.

References deref_ptr, heap_insert(), INTCMP, wl_node::key, and printed_pointers.

311 {
312  ptr_psi_term v;
313 
314  if(n) {
316  v=(ptr_psi_term )n->data;
317  deref_ptr(v);
318  (void)heap_insert(INTCMP,(char *)v,&printed_pointers,(GENERIC)n->key);
320  }
321 }
ptr_node printed_pointers
Definition: def_glob.h:28
#define INTCMP
Definition: def_const.h:256
GENERIC data
Definition: def_struct.h:185
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:276
ptr_node left
Definition: def_struct.h:183
#define deref_ptr(P)
Definition: def_macro.h:95
char * key
Definition: def_struct.h:182
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node right
Definition: def_struct.h:184
void go_through ( ptr_psi_term  t)

Definition at line 258 of file print.c.

References go_through_tree().

260 {
261  // ptr_list l;
262 
263  if (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 }
ptr_node attr_list
Definition: def_struct.h:171
void go_through_tree ( ptr_node  t)

Definition at line 236 of file print.c.

References check_pointer().

238 {
239  if (t) {
240  if (t->left) {
241  go_through_tree(t->left);
242  }
244  if (t->right) {
246  }
247  }
248 
249 }
GENERIC data
Definition: def_struct.h:185
ptr_node left
Definition: def_struct.h:183
ptr_node right
Definition: def_struct.h:184
long has_non_alpha ( char *  s)

Definition at line 386 of file print.c.

References FALSE, ISALPHA, and TRUE.

388 {
389  while (*s) {
390  if (!ISALPHA(*s)) return TRUE;
391  s++;
392  }
393  return FALSE;
394 }
#define ISALPHA(C)
Definition: def_macro.h:43
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
char* heap_nice_name ( )

Definition at line 55 of file print.c.

References gen_sym_counter, heap_copy_string(), perr(), and STRLEN.

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 }
void perr(char *str)
Definition: error.c:659
char * heap_copy_string(char *s)
Definition: trees.c:147
long gen_sym_counter
Definition: def_glob.h:30
#define STRLEN
Definition: def_const.h:86
void init_print ( )

Definition at line 48 of file print.c.

References PRINT_POWER, and seg_format.

49 {
50  (void)snprintf(seg_format,PRINT_POWER+4,"%%0%ldd",PRINT_POWER);
51 }
#define PRINT_POWER
Definition: def_const.h:96
void insert_variables ( ptr_node  vars,
long  force 
)

Definition at line 281 of file print.c.

References wl_node::data, deref_ptr, find(), INTCMP, and pointer_names.

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 }
#define INTCMP
Definition: def_const.h:256
GENERIC data
Definition: def_struct.h:185
ptr_node pointer_names
Definition: def_glob.h:29
ptr_node left
Definition: def_struct.h:183
#define deref_ptr(P)
Definition: def_macro.h:95
char * key
Definition: def_struct.h:182
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node right
Definition: def_struct.h:184
long is_integer ( char *  s)

Definition at line 408 of file print.c.

References DIGIT, FALSE, and TRUE.

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 }
#define DIGIT(C)
Definition: def_macro.h:37
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
void listing_pred_write ( ptr_node  n,
long  fflag 
)

Definition at line 1341 of file print.c.

References const_quote, FALSE, func_flag, indent, listing_flag, main_pred_write(), outfile, output_stream, print_depth, PRINT_DEPTH, TRUE, write_canon, write_corefs, write_resids, and write_stderr.

1344 {
1345  long old_print_depth;
1346 
1348  func_flag=fflag;
1349  indent=TRUE;
1350  const_quote=TRUE;
1356  old_print_depth=print_depth;
1358  main_pred_write(n);
1359  print_depth=old_print_depth;
1360  (void)fflush(outfile);
1361 }
FILE * outfile
Definition: def_glob.h:333
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define PRINT_DEPTH
Definition: def_const.h:92
FILE * output_stream
Definition: def_glob.h:41
void main_display_psi_term ( ptr_psi_term  t)

Definition at line 1470 of file print.c.

References buffer, const_quote, deref_ptr, end_tab(), FALSE, gen_sym_counter, go_through(), heap_pointer, indent, indx, insert_variables(), listing_flag, mark_tab(), MAX_PRECEDENCE, new_tab(), NULL, pointer_names, pretty_output(), pretty_tag_or_psi_term(), pretty_things, printed_pointers, TRUE, var_tree, work_out_length(), write_canon, and write_resids.

1472 {
1473  GENERIC old_heap_pointer;
1474  ptr_tab_brk new;
1475 
1477  if(t) {
1478 
1479  deref_ptr(t);
1480 
1481  old_heap_pointer=heap_pointer;
1484  gen_sym_counter=0;
1485  go_through(t);
1487 
1488  indent=FALSE;
1489  const_quote=TRUE;
1492  *buffer=0;
1494 
1495  new_tab(&new);
1496  mark_tab(new);
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 }
ptr_node printed_pointers
Definition: def_glob.h:28
#define NULL
Definition: def_const.h:203
ptr_node var_tree
Definition: def_glob.h:26
ptr_node pointer_names
Definition: def_glob.h:29
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
ptr_item indx
Definition: def_glob.h:329
#define FALSE
Definition: def_const.h:128
GENERIC heap_pointer
Definition: def_glob.h:12
#define MAX_PRECEDENCE
Definition: def_const.h:103
long gen_sym_counter
Definition: def_glob.h:30
unsigned long * GENERIC
Definition: def_struct.h:17
void main_pred_write ( ptr_node  n)

Definition at line 1375 of file print.c.

References buffer, check_pointer(), end_tab(), FALSE, gen_sym_counter, go_through_tree(), heap_pointer, indent, indx, insert_variables(), mark_tab(), MAX_PRECEDENCE, new_tab(), NULL, pointer_names, pretty_output(), pretty_tag_or_psi_term(), pretty_things, printed_pointers, var_tree, work_out_length(), write_attributes(), and write_corefs.

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;
1387  gen_sym_counter=0;
1388  if (write_corefs)
1389  go_through_tree(n);
1390  else
1393 
1394  *buffer=0;
1395 
1397  new_tab(&new);
1398 
1399  if (write_corefs) {
1400  write_attributes(n,new);
1401  }
1402  else {
1403  mark_tab(new);
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 
1417  }
1418 }
ptr_node printed_pointers
Definition: def_glob.h:28
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
ptr_node var_tree
Definition: def_glob.h:26
ptr_node pointer_names
Definition: def_glob.h:29
ptr_node left
Definition: def_struct.h:183
ptr_item indx
Definition: def_glob.h:329
#define FALSE
Definition: def_const.h:128
GENERIC heap_pointer
Definition: def_glob.h:12
#define MAX_PRECEDENCE
Definition: def_const.h:103
long gen_sym_counter
Definition: def_glob.h:30
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node right
Definition: def_struct.h:184
void mark_tab ( ptr_tab_brk  t)

Definition at line 513 of file print.c.

References end_tab(), indx, and wl_item::tab.

515 {
516  end_tab();
517  indx->tab=t;
518 }
ptr_tab_brk tab
Definition: def_struct.h:312
ptr_item indx
Definition: def_glob.h:329
void new_tab ( ptr_tab_brk t)

Definition at line 525 of file print.c.

References FALSE, and HEAP_ALLOC.

527 {
528  (*t)=HEAP_ALLOC(tab_brk);
529  (*t)->broken=FALSE;
530  (*t)->printed=FALSE;
531  (*t)->column=0;
532 }
#define FALSE
Definition: def_const.h:128
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
long no_quote ( char *  s)

Definition at line 423 of file print.c.

References all_symbol(), FALSE, ISALPHA, LOWER, SINGLE, and TRUE.

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 }
#define ISALPHA(C)
Definition: def_macro.h:43
#define LOWER(C)
Definition: def_macro.h:41
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define SINGLE(C)
Definition: def_macro.h:47
long opcheck ( ptr_psi_term  t,
long *  prec,
long *  type 
)

Definition at line 834 of file print.c.

References check_opargs(), fx, fy, INFIX, wl_operator_data::next, NOTOP, NULL, POSTFIX, wl_operator_data::precedence, PREFIX, xf, xfx, xfy, yf, and yfx.

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 }
#define yfx
Definition: def_const.h:268
#define xfx
Definition: def_const.h:265
#define POSTFIX
Definition: def_const.h:340
ptr_operator_data next
Definition: def_struct.h:49
#define fx
Definition: def_const.h:262
#define NULL
Definition: def_const.h:203
#define xfy
Definition: def_const.h:267
#define PREFIX
Definition: def_const.h:339
#define xf
Definition: def_const.h:261
#define INFIX
Definition: def_const.h:338
#define yf
Definition: def_const.h:263
#define NOTOP
Definition: def_const.h:337
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
ptr_operator_data op_data
Definition: def_struct.h:139
#define fy
Definition: def_const.h:264
void pred_write ( ptr_node  n)

Definition at line 1365 of file print.c.

References FALSE, listing_flag, main_pred_write(), outfile, output_stream, and write_stderr.

1367 {
1369  /* write_stderr=FALSE; */
1371  main_pred_write(n);
1372  (void)fflush(outfile);
1373 }
FILE * outfile
Definition: def_glob.h:333
#define FALSE
Definition: def_const.h:128
FILE * output_stream
Definition: def_glob.h:41
void pretty_attr ( ptr_node  t,
long  depth 
)

Definition at line 1180 of file print.c.

References do_pretty_attr(), new_tab(), prettyf(), and two_or_more().

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 }
void pretty_list ( ptr_psi_term  t,
long  depth 
)

Definition at line 661 of file print.c.

References alist, wl_psi_term::attr_list, check_legal_cons(), COMMA_PREC, wl_node::data, deref_ptr, disj_nil, disjunction, DOTDOT, equal_types, FALSE, find(), get_two_args(), INTCMP, wl_definition::keyword, mark_tab(), MAX_PRECEDENCE, new_tab(), nil, overlap_type(), pointer_names, pretty_symbol(), pretty_tag_or_psi_term(), prettyf(), print_depth, TRUE, and wl_psi_term::type.

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)
722 
723  /* Determine how to print the CDR */
724  n=find(INTCMP,(char *)cdr,pointer_names);
725 
726  if(n && n->data) {
727  prettyf("|");
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("|");
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 }
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
#define INTCMP
Definition: def_const.h:256
void pretty_symbol(ptr_keyword k)
Definition: modules.c:446
ptr_keyword keyword
Definition: def_struct.h:124
GENERIC data
Definition: def_struct.h:185
#define DOTDOT
Definition: def_const.h:335
long overlap_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1486
ptr_node pointer_names
Definition: def_glob.h:29
ptr_definition disj_nil
Definition: def_glob.h:85
#define deref_ptr(P)
Definition: def_macro.h:95
ptr_definition alist
Definition: def_glob.h:94
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_definition disjunction
Definition: def_glob.h:84
#define equal_types(A, B)
Definition: def_macro.h:106
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
#define MAX_PRECEDENCE
Definition: def_const.h:103
ptr_definition nil
Definition: def_glob.h:97
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
void pretty_output ( )

Definition at line 1200 of file print.c.

References wl_tab_brk::broken, wl_tab_brk::column, indx, outfile, wl_tab_brk::printed, wl_item::str, wl_item::tab, and TRUE.

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 }
long printed
Definition: def_struct.h:307
long column
Definition: def_struct.h:305
ptr_tab_brk tab
Definition: def_struct.h:312
char * str
Definition: def_struct.h:311
FILE * outfile
Definition: def_glob.h:333
long broken
Definition: def_struct.h:306
#define TRUE
Definition: def_const.h:127
ptr_item indx
Definition: def_glob.h:329
void pretty_psi_term ( ptr_psi_term  t,
long  sprec,
long  depth 
)

Definition at line 972 of file print.c.

References wl_goal::aaaa_1, alist, check_legal_cons(), cut, deref_ptr, disj_nil, disjunction, display_persistent, DOTDOT, eof, equal_types, FALSE, wl_residuation::goal, heap_pointer, integer, wl_definition::keyword, wl_residuation::next, nil, wl_goal::pending, pretty_attr(), pretty_list(), pretty_psi_with_ops(), pretty_quote_symbol(), pretty_symbol(), prettyf(), prettyf_quoted_string(), print_depth, PRINT_POWER, PRINT_SPLIT, quoted_string, REAL, real, seg_format, stream, STRLEN, sub_type(), sys_bytedata, WL_MAXINT, and write_canon.

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 &&
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)) {
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 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
ptr_residuation resid
Definition: def_struct.h:173
ptr_goal goal
Definition: def_struct.h:156
ptr_definition stream
Definition: def_glob.h:103
ptr_residuation next
Definition: def_struct.h:157
void pretty_symbol(ptr_keyword k)
Definition: modules.c:446
ptr_keyword keyword
Definition: def_struct.h:124
#define DOTDOT
Definition: def_const.h:335
#define REAL
Definition: def_const.h:72
long sub_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1544
void pretty_quote_symbol(ptr_keyword k)
Definition: modules.c:464
ptr_definition disj_nil
Definition: def_glob.h:85
ptr_definition real
Definition: def_glob.h:102
#define deref_ptr(P)
Definition: def_macro.h:95
ptr_definition alist
Definition: def_glob.h:94
ptr_definition eof
Definition: def_glob.h:86
#define PRINT_POWER
Definition: def_const.h:96
ptr_definition integer
Definition: def_glob.h:93
#define FALSE
Definition: def_const.h:128
ptr_definition quoted_string
Definition: def_glob.h:101
GENERIC value_3
Definition: def_struct.h:170
ptr_definition disjunction
Definition: def_glob.h:84
GENERIC heap_pointer
Definition: def_glob.h:12
#define equal_types(A, B)
Definition: def_macro.h:106
ptr_definition sys_bytedata
Definition: def_glob.h:336
#define PRINT_SPLIT
Definition: def_const.h:95
#define WL_MAXINT
Definition: def_const.h:76
ptr_definition cut
Definition: def_glob.h:83
ptr_definition nil
Definition: def_glob.h:97
#define STRLEN
Definition: def_const.h:86
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
ptr_definition pending
Definition: def_struct.h:228
long pretty_psi_with_ops ( ptr_psi_term  t,
long  sprec,
long  depth 
)

Definition at line 866 of file print.c.

References deref_ptr, FALSE, func_flag, fx, fy, get_two_args(), INFIX, listing_flag, MAX_PRECEDENCE, opcheck(), POSTFIX, PREFIX, pretty_quote_symbol(), pretty_tag_or_psi_term(), prettyf(), TRUE, write_canon, xf, xfx, xfy, yf, and yfx.

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("(");
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("(");
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("(");
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("(");
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 }
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
#define yfx
Definition: def_const.h:268
#define xfx
Definition: def_const.h:265
#define POSTFIX
Definition: def_const.h:340
#define fx
Definition: def_const.h:262
ptr_keyword keyword
Definition: def_struct.h:124
#define xfy
Definition: def_const.h:267
char * symbol
Definition: def_struct.h:91
void pretty_quote_symbol(ptr_keyword k)
Definition: modules.c:464
#define PREFIX
Definition: def_const.h:339
#define deref_ptr(P)
Definition: def_macro.h:95
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define xf
Definition: def_const.h:261
#define yf
Definition: def_const.h:263
#define INFIX
Definition: def_const.h:338
#define MAX_PRECEDENCE
Definition: def_const.h:103
ptr_definition type
Definition: def_struct.h:165
ptr_node attr_list
Definition: def_struct.h:171
#define fy
Definition: def_const.h:264
void pretty_tag_or_psi_term ( ptr_psi_term  p,
long  sprec,
long  depth 
)

Definition at line 761 of file print.c.

References COLON_PREC, wl_node::data, deref_ptr, DOTDOT, FALSE, find(), heap_insert(), INTCMP, is_top, no_name, NULL, pointer_names, pretty_psi_term(), prettyf(), printed_pointers, and unique_name().

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 }
ptr_node printed_pointers
Definition: def_glob.h:28
#define is_top(T)
Definition: def_macro.h:108
#define INTCMP
Definition: def_const.h:256
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
#define DOTDOT
Definition: def_const.h:335
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:276
ptr_node pointer_names
Definition: def_glob.h:29
#define deref_ptr(P)
Definition: def_macro.h:95
#define FALSE
Definition: def_const.h:128
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
unsigned long * GENERIC
Definition: def_struct.h:17
void pretty_variables ( ptr_node  n,
ptr_tab_brk  tab 
)

Definition at line 1221 of file print.c.

References wl_node::data, deref_ptr, eqsym, find(), INTCMP, mark_tab(), MAX_PRECEDENCE, wl_definition::op_data, opcheck(), wl_operator_data::precedence, pretty_psi_term(), prettyf(), and printed_pointers.

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("(");
1250  if (tprec>=eqprec) prettyf(")");
1251  }
1252  else
1254  }
1255 
1256  if(n->right) {
1257  prettyf(", ");
1258  pretty_variables(n->right,tab);
1259  }
1260 }
ptr_node printed_pointers
Definition: def_glob.h:28
#define INTCMP
Definition: def_const.h:256
GENERIC data
Definition: def_struct.h:185
ptr_node left
Definition: def_struct.h:183
#define deref_ptr(P)
Definition: def_macro.h:95
ptr_definition eqsym
Definition: def_glob.h:87
char * key
Definition: def_struct.h:182
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
#define MAX_PRECEDENCE
Definition: def_const.h:103
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
ptr_operator_data op_data
Definition: def_struct.h:139
ptr_node right
Definition: def_struct.h:184
void prettyf ( char *  s)

Definition at line 447 of file print.c.

References FALSE, and prettyf_inner().

449 {
450  prettyf_inner(s,FALSE,'\'');
451 }
#define FALSE
Definition: def_const.h:128
void prettyf_inner ( char *  s,
long  q,
char  c 
)

Definition at line 349 of file print.c.

References buffer, indent, and outfile.

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 }
FILE * outfile
Definition: def_glob.h:333
void prettyf_quote ( char *  s)

Definition at line 474 of file print.c.

References const_quote, no_quote(), and prettyf_inner().

476 {
477  prettyf_inner(s, const_quote && !no_quote(s), '\'');
478 }
void prettyf_quoted_string ( char *  s)

Definition at line 454 of file print.c.

References const_quote, and prettyf_inner().

456 {
457  prettyf_inner((char *)s,const_quote,'"');
458 }
void print_bin ( long  b)

Definition at line 130 of file print.c.

References INT_SIZE, and outfile.

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 }
#define INT_SIZE
Definition: def_const.h:144
FILE * outfile
Definition: def_glob.h:333
void print_code ( FILE *  s,
ptr_int_list  c 
)

Definition at line 147 of file print.c.

References wl_int_list::next, NOT_CODED, outfile, print_bin(), and wl_int_list::value_1.

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 }
#define NOT_CODED
Definition: def_const.h:134
FILE * outfile
Definition: def_glob.h:333
GENERIC value_1
Definition: def_struct.h:54
ptr_int_list next
Definition: def_struct.h:55
void print_operator_kind ( FILE *  s,
long  kind 
)

Definition at line 173 of file print.c.

References fx, fy, xf, xfx, xfy, yf, and yfx.

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 }
#define yfx
Definition: def_const.h:268
#define xfx
Definition: def_const.h:265
#define fx
Definition: def_const.h:262
#define xfy
Definition: def_const.h:267
#define xf
Definition: def_const.h:261
#define yf
Definition: def_const.h:263
#define fy
Definition: def_const.h:264
void print_resid_message ( ptr_psi_term  t,
ptr_resid_list  r 
)

Definition at line 1562 of file print.c.

References buffer, check_pointer(), const_quote, end_tab(), FALSE, gen_sym_counter, heap_pointer, indent, indx, insert_variables(), listing_flag, mark_tab(), MAX_PRECEDENCE, new_tab(), wl_resid_list::next, NULL, outfile, pointer_names, pretty_tag_or_psi_term(), pretty_things, prettyf(), printed_pointers, TRUE, wl_resid_list::var, var_tree, write_canon, and write_resids.

1565 {
1566  GENERIC old_heap_pointer;
1567  ptr_tab_brk new;
1568  ptr_resid_list r2; /* 21.9 */
1569 
1570  outfile=stdout;
1572  old_heap_pointer=heap_pointer;
1573 
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 
1587 
1588  indent=FALSE;
1589  const_quote=TRUE;
1592  *buffer=0;
1594  new_tab(&new);
1595  mark_tab(new);
1596 
1597  prettyf("residuating ");
1599  prettyf(" on variable(s) {");
1600 
1601  r2=r;
1602  while(r2) {
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 }
ptr_node printed_pointers
Definition: def_glob.h:28
ptr_resid_list next
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:203
ptr_node var_tree
Definition: def_glob.h:26
FILE * outfile
Definition: def_glob.h:333
ptr_node pointer_names
Definition: def_glob.h:29
#define TRUE
Definition: def_const.h:127
ptr_item indx
Definition: def_glob.h:329
#define FALSE
Definition: def_const.h:128
ptr_psi_term var
Definition: def_struct.h:60
GENERIC heap_pointer
Definition: def_glob.h:12
#define MAX_PRECEDENCE
Definition: def_const.h:103
long gen_sym_counter
Definition: def_glob.h:30
unsigned long * GENERIC
Definition: def_struct.h:17
long print_variables ( long  printflag)

Definition at line 1272 of file print.c.

References buffer, const_quote, end_tab(), FALSE, forbid_variables(), gen_sym_counter, go_through_tree(), heap_pointer, indent, indx, insert_variables(), listing_flag, mark_tab(), new_tab(), NULL, outfile, output_stream, pointer_names, pretty_output(), pretty_things, pretty_variables(), prettyf(), printed_pointers, TRUE, var_tree, work_out_length(), write_canon, and write_resids.

1275 {
1276  ptr_tab_brk new;
1277  GENERIC old_heap_pointer;
1278  if (!printflag) return FALSE; /* 21.1 */
1279 
1282  old_heap_pointer=heap_pointer;
1283 
1286  gen_sym_counter=0;
1290 
1291  indent=TRUE;
1292  const_quote=TRUE;
1295  *buffer=0;
1297 
1298  if (var_tree) {
1299  new_tab(&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 }
ptr_node printed_pointers
Definition: def_glob.h:28
#define NULL
Definition: def_const.h:203
ptr_node var_tree
Definition: def_glob.h:26
FILE * outfile
Definition: def_glob.h:333
ptr_node pointer_names
Definition: def_glob.h:29
#define TRUE
Definition: def_const.h:127
ptr_item indx
Definition: def_glob.h:329
#define FALSE
Definition: def_const.h:128
GENERIC heap_pointer
Definition: def_glob.h:12
long gen_sym_counter
Definition: def_glob.h:30
FILE * output_stream
Definition: def_glob.h:41
unsigned long * GENERIC
Definition: def_struct.h:17
long starts_nonlower ( char *  s)

Definition at line 379 of file print.c.

References LOWER.

381 {
382  return (*s && !LOWER(s[0]));
383 }
#define LOWER(C)
Definition: def_macro.h:41
long str_to_int ( char *  s)

Definition at line 103 of file print.c.

References DIGIT.

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 }
#define DIGIT(C)
Definition: def_macro.h:37
long strpos ( long  pos,
char *  str 
)

Definition at line 540 of file print.c.

543 {
544  while (*str) {
545  if (str[0]=='\n') pos=0; else pos++;
546  str++;
547  }
548  return pos;
549 }
long two_or_more ( ptr_node  t)

Definition at line 1165 of file print.c.

References FALSE, and TRUE.

1167 {
1168  if (t) {
1169  if (t->left || t->right) return TRUE; else return FALSE;
1170  }
1171  else
1172  return FALSE;
1173 }
ptr_node left
Definition: def_struct.h:183
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_node right
Definition: def_struct.h:184
GENERIC unique_name ( )

Definition at line 87 of file print.c.

References find(), heap_nice_name(), STRCMP, and var_tree.

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 }
ptr_node var_tree
Definition: def_glob.h:26
#define STRCMP
Definition: def_const.h:255
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
unsigned long * GENERIC
Definition: def_struct.h:17
void work_out_length ( )

Definition at line 557 of file print.c.

References wl_tab_brk::broken, wl_tab_brk::column, FALSE, indx, NULL, page_width, wl_tab_brk::printed, wl_item::str, strpos(), wl_item::tab, and TRUE.

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 }
long printed
Definition: def_struct.h:307
long column
Definition: def_struct.h:305
ptr_tab_brk tab
Definition: def_struct.h:312
char * str
Definition: def_struct.h:311
#define NULL
Definition: def_const.h:203
long broken
Definition: def_struct.h:306
#define TRUE
Definition: def_const.h:127
ptr_item indx
Definition: def_glob.h:329
#define FALSE
Definition: def_const.h:128
void write_attributes ( ptr_node  n,
ptr_tab_brk  tab 
)

Definition at line 1321 of file print.c.

References mark_tab(), MAX_PRECEDENCE, and pretty_tag_or_psi_term().

1324 {
1325  if(n) {
1326  write_attributes(n->left,tab);
1327  mark_tab(tab);
1329  write_attributes(n->right,tab);
1330  }
1331 }
GENERIC data
Definition: def_struct.h:185
ptr_node left
Definition: def_struct.h:183
#define MAX_PRECEDENCE
Definition: def_const.h:103
ptr_node right
Definition: def_struct.h:184

Variable Documentation

char* buffer

Definition at line 22 of file print.c.

long const_quote =TRUE

Definition at line 10 of file print.c.

long display_persistent =FALSE

Definition at line 18 of file print.c.

long func_flag
static

Definition at line 32 of file print.c.

long indent =FALSE

Definition at line 9 of file print.c.

long listing_flag
static

Definition at line 28 of file print.c.

char* name ="symbol"

Definition at line 21 of file print.c.

char* no_name ="pointer"

Definition at line 20 of file print.c.

long page_width =PAGE_WIDTH

Definition at line 16 of file print.c.

item pretty_things[PRETTY_SIZE]

Definition at line 25 of file print.c.

long print_depth =PRINT_DEPTH

Definition at line 8 of file print.c.

char seg_format[PRINT_POWER+4]

Definition at line 23 of file print.c.

long write_canon =FALSE

Definition at line 12 of file print.c.

long write_corefs =TRUE

Definition at line 14 of file print.c.

long write_resids =FALSE

Definition at line 11 of file print.c.

long write_stderr =FALSE

Definition at line 13 of file print.c.