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

print More...

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

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 seg_format [PRINT_POWER+4]
 
item pretty_things [PRETTY_SIZE]
 
static long listing_flag
 
static long func_flag
 

Detailed Description

print

Definition in file print.c.

Macro Definition Documentation

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

Definition at line 40 of file print.c.

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

Definition at line 39 of file print.c.

Function Documentation

long all_symbol ( char *  s)

all_symbol

Parameters
s- char *s

Return TRUE iff s contains only SYMBOL characters.

Definition at line 434 of file print.c.

References FALSE, SYMBOL, and TRUE.

435 {
436  while (*s) {
437  if (!SYMBOL(*s)) return FALSE;
438  s++;
439  }
440  return TRUE;
441 }
#define SYMBOL(C)
Definition: def_macro.h:57
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long check_legal_cons ( ptr_psi_term  t,
ptr_definition  t_type 
)

check_legal_cons

Parameters
t- ptr_psi_term t
t_type- ptr_definition t_type

CHECK_LEGAL_CONS(t,t_type) Check that T is of type T_TYPE, that it has exactly the attributes '1' and '2' and that the 2nd is either nil or also long check_legal_cons(t,t_type)

Definition at line 713 of file print.c.

References wl_psi_term::attr_list, count_features(), FEATCMP, find(), one, two, and wl_psi_term::type.

714 {
715  return (t->type==t_type &&
716  count_features(t->attr_list)==2 &&
717  find(FEATCMP,one,t->attr_list) &&
718  find(FEATCMP,two,t->attr_list));
719 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * two
Definition: def_glob.h:892
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long check_opargs ( ptr_node  n)

check_opargs

Parameters
n- ptr_node n

Routines to handle printing of operators. The main routine is pretty_psi_with_ops, which is called in pretty_psi_term.

Check arguments of a potential operator. Returns existence of arguments 1 and 2 in low two bits of result. If only argument "1" exists, returns 1. If only arguments "1" and "2" exist, returns 3. Existence of any other arguments causes third bit to be set as well.

Definition at line 887 of file print.c.

References featcmp(), wl_node::key, wl_node::left, and wl_node::right.

888 {
889  if (n) {
890  long f=check_opargs(n->left) | check_opargs(n->right);
891  if (!featcmp(n->key,"1")) return 1 | f;
892  if (!featcmp(n->key,"2")) return 2 | f;
893  return 4 | f;
894  }
895  else
896  return 0;
897 }
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
ptr_node right
Definition: def_struct.h:200
void check_pointer ( ptr_psi_term  p)

check_pointer

Parameters
p- ptr_psi_term p

CHECK_POINTER(p) Count the number of times address P has been encountered in the current psi-term being printed. If it is more than once then a tag will have to be used. If P has not already been seen, then explore the psi_term it points to.

Definition at line 233 of file print.c.

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

234 {
235  ptr_node n;
236 
237  if (p) {
238  deref_ptr(p);
239  n=find(INTCMP,(char *)p,pointer_names);
240  if (n==NULL) {
241  (void)heap_insert(INTCMP,(char *)p,&pointer_names,(GENERIC)NULL);
242  go_through(p);
243  }
244  else
245  n->data=(GENERIC)no_name;
246  }
247 }
#define INTCMP
indicates to use intcmp for comparison (in trees.c)
Definition: def_const.h:971
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
heap_insert
Definition: trees.c:320
ptr_node pointer_names
Definition: def_glob.h:1008
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
long count_features ( ptr_node  t)

count_features

Parameters
t- ptr_node t

COUNT_FEATURES(t) Return the number of features of a tree.

Definition at line 690 of file print.c.

References wl_node::left, and wl_node::right.

691 {
692  long c=0;
693  if(t) {
694  if(t->left)
695  c+=count_features(t->left);
696  c++;
697  if(t->right)
698  c+=count_features(t->right);
699  }
700  return c;
701 }
ptr_node left
Definition: def_struct.h:199
ptr_node right
Definition: def_struct.h:200
void display_couple ( ptr_psi_term  u,
char *  s,
ptr_psi_term  v 
)

display_couple

Parameters
u- ptr_psi_term u
s- char *s
v- ptr_psi_term v

DISPLAY_COUPLE(u,s,v) Print a couple of psi-terms (u,v) with the correct co-referencing. Print string S in between.

Definition at line 1643 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.

1644 {
1645  GENERIC old_heap_pointer;
1646  ptr_tab_brk new;
1647 
1648  output_stream=stdout;
1650  old_heap_pointer=heap_pointer;
1651 
1654  gen_sym_counter=0;
1655  check_pointer(u);
1656  check_pointer(v);
1658 
1659  indent=FALSE;
1660  const_quote=TRUE;
1663  *buffer=0;
1665  new_tab(&new);
1666  mark_tab(new);
1668  prettyf(s);
1670  end_tab();
1671 
1672  if (indent) {
1673  work_out_length();
1674  pretty_output();
1675  }
1676 
1677  heap_pointer=old_heap_pointer;
1678 }
ptr_node printed_pointers
Definition: def_glob.h:1007
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
ptr_node pointer_names
Definition: def_glob.h:1008
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * buffer
buffer used only in print.c - there is local with same name in xpred.c
Definition: def_glob.h:781
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_item indx
Definition: def_glob.h:970
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
long gen_sym_counter
Definition: def_glob.h:1009
FILE * output_stream
Definition: def_glob.h:1017
void display_psi ( FILE *  s,
ptr_psi_term  t 
)

display_psi

Parameters
s- FILE *s
t- ptr_psi_term t

DISPLAY_PSI(stream,t) Print the psi_term T to the given stream.

Definition at line 1579 of file print.c.

References main_display_psi_term(), and outfile.

1580 {
1581  outfile=s;
1583 }
FILE * outfile
Definition: def_glob.h:974
void display_psi_stderr ( ptr_psi_term  t)

display_psi_stderr

Parameters
t- ptr_psi_term t

DISPLAY_PSI_STDERR(t) Print the psi_term T to stderr as simply as possible (no indenting).

Definition at line 1550 of file print.c.

References main_display_psi_term(), and outfile.

1551 {
1552  outfile=stderr;
1554 }
FILE * outfile
Definition: def_glob.h:974
void display_psi_stdout ( ptr_psi_term  t)

display_psi_stdout

Parameters
t- ptr_psi_term t

DISPLAY_PSI_STDOUT(t) Print the psi_term T to stdout as simply as possible (no indenting).

Definition at line 1536 of file print.c.

References main_display_psi_term(), and outfile.

1537 {
1538  outfile=stdout;
1540 }
FILE * outfile
Definition: def_glob.h:974
void display_psi_stream ( ptr_psi_term  t)

display_psi_stream

Parameters
t- ptr_psi_term t

DISPLAY_PSI_STREAM(t) Print the psi_term T to output_stream as simply as possible (no indenting).

Definition at line 1564 of file print.c.

References main_display_psi_term(), outfile, and output_stream.

1565 {
1568 }
FILE * outfile
Definition: def_glob.h:974
FILE * output_stream
Definition: def_glob.h:1017
void do_pretty_attr ( ptr_node  t,
ptr_tab_brk  tab,
long *  cnt,
long  two,
long  depth 
)

do_pretty_attr

Parameters
t- ptr_node t
tab- ptr_tab_brk tab
cnt- long *cnt
two- long two
depth- long depth

DO_PRETTY_ATTR(t,tab,cnt,two,depth) Pretty print the attribute tree T at position TAB.

CNT is what the value of the first integer label should be, so that "p(1=>a,2=>b)" is printed "p(a,b)" but "p(2=>a,3=>b)" is printed as "p(2 => a,3 => b)".

Definition at line 1199 of file print.c.

References COMMA_PREC, wl_node::data, display_modules, extract_module_from_name(), wl_node::key, wl_node::left, mark_tab(), wl_module::module_name, pretty_tag_or_psi_term(), prettyf(), prettyf_quote(), wl_node::right, str_to_int(), and strip_module_name().

1200 {
1201  long v;
1202  char s[4];
1203  ptr_module module;
1204 
1205  if (t) {
1206  if (t->left) {
1207  do_pretty_attr(t->left,tab,cnt,two,depth);
1208  prettyf(",");
1209  }
1210 
1211  /* Don't start each argument on a new line, */
1212  /* unless printing a function body: */
1213  mark_tab(tab);
1214 
1215  v=str_to_int(t->key);
1216  if (v<0) {
1217  if(display_modules) { /* RM: Jan 21 1993 */
1218  module=extract_module_from_name(t->key);
1219  if(module) {
1220  prettyf(module->module_name);
1221  prettyf("#");
1222  }
1223  }
1225 
1226  prettyf(" => ");
1227  }
1228  else if (v== *cnt)
1229  (*cnt)++ ;
1230  else {
1231  (void)snprintf(s,4,"%ld",v);
1232  prettyf(s); /* 6.10 */
1233  prettyf(" => ");
1234  }
1235 
1236  /* pretty_tag_or_psi_term(t->data,(two?COMMA_PREC:MAX_PRECEDENCE+1)); */
1238 
1239  if (t->right) {
1240  prettyf(",");
1241  do_pretty_attr(t->right,tab,cnt,two,depth);
1242  }
1243  }
1244 }
char * two
Definition: def_glob.h:892
long display_modules
whether to display modules with symbols
Definition: def_glob.h:741
char * strip_module_name(char *str)
strip_module_name
Definition: modules.c:144
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
ptr_module extract_module_from_name(char *str)
extract_module_from_name
Definition: modules.c:116
char * module_name
Definition: def_struct.h:106
ptr_node right
Definition: def_struct.h:200
void end_tab ( )

end_tab

END_TAB() Mark the end of an item. Copy the item's string into global space and point to the next item.

Definition at line 554 of file print.c.

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

555 {
556  if (indent) {
557  indx->str=(char *)heap_alloc(strlen(buffer)+1);
558  strcpy(indx->str,buffer);
559  indx++;
560  *buffer=0;
561  }
562 }
char * str
Definition: def_struct.h:315
char * buffer
buffer used only in print.c - there is local with same name in xpred.c
Definition: def_glob.h:781
ptr_item indx
Definition: def_glob.h:970
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void forbid_variables ( ptr_node  n)

FORBID_VARIABLES This inserts the value of the dereferenced variables into the PRINTED_POINTERS tree, so that they will never be printed as NAME:value inside a psi-term. Each variable is printed as NAME = VALUE by the PRINT_VARIABLES routine.

Definition at line 334 of file print.c.

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

335 {
336  ptr_psi_term v;
337 
338  if(n) {
340  v=(ptr_psi_term )n->data;
341  deref_ptr(v);
342  (void)heap_insert(INTCMP,(char *)v,&printed_pointers,(GENERIC)n->key);
344  }
345 }
ptr_node printed_pointers
Definition: def_glob.h:1007
#define INTCMP
indicates to use intcmp for comparison (in trees.c)
Definition: def_const.h:971
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
heap_insert
Definition: trees.c:320
ptr_node left
Definition: def_struct.h:199
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
char * key
Definition: def_struct.h:198
ptr_node right
Definition: def_struct.h:200
void go_through ( ptr_psi_term  t)

go_through

Parameters
t- ptr_psi_term t

GO_THROUGH(t) This routine goes through all the sub_terms of psi_term T to determine which pointers need to have names given to them for printing because they are referred to elsewhere. T is a dereferenced psi_term.

Definition at line 282 of file print.c.

References wl_psi_term::attr_list, and go_through_tree().

283 {
284  if (t->attr_list)
286 
287  /*
288  if(r=t->resid)
289  while(r) {
290  if(r->goal->pending)
291  go_through(r->goal->aaaa_1);
292  r=r->next;
293  } */
294 }
ptr_node attr_list
Definition: def_struct.h:187
void go_through_tree ( ptr_node  t)

go_through_tree

Parameters
t- ptr_node t

GO_THROUGH_TREE(t) Explore all the pointers in the attribute tree T. Pointers that occur more than once will need a tag.

Definition at line 258 of file print.c.

References check_pointer(), wl_node::data, wl_node::left, and wl_node::right.

259 {
260  if (t) {
261  if (t->left) {
262  go_through_tree(t->left);
263  }
265  if (t->right) {
267  }
268  }
269 
270 }
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
ptr_node right
Definition: def_struct.h:200
long has_non_alpha ( char *  s)

has_non_alpha

Parameters
s- char *s

Return TRUE iff s contains a character that is not alphanumeric.

Definition at line 418 of file print.c.

References FALSE, ISALPHA, and TRUE.

419 {
420  while (*s) {
421  if (!ISALPHA(*s)) return TRUE;
422  s++;
423  }
424  return FALSE;
425 }
#define ISALPHA(C)
Definition: def_macro.h:48
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
char* heap_nice_name ( )

heap_nice_name

Generate a nice-looking new variable name.

Definition at line 63 of file print.c.

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

64 {
65  string tmp1,tmp2;
66  char g,len; // ,leading_a;
67 
68  g= ++gen_sym_counter;
69  len=2;
70  strcpy(tmp2,"");
71  do {
72  g--;
73  /* Prefix one character to tmp2: */
74  (void)snprintf(tmp1,2,"%c",g%26+'A');
75  strcat(tmp1,tmp2);
76  strcpy(tmp2,tmp1);
77  g=g/26;
78  len++;
79  } while (g>0 && len<STRLEN);
80  if (len>=STRLEN)
81  perr("Variable name too long -- the universe has ceased to exist.");
82 
83  strcpy(tmp1,"_");
84  strcat(tmp1,tmp2);
85 
86  return heap_copy_string(tmp1);
87 }
void perr(char *str)
perr
Definition: error.c:763
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
long gen_sym_counter
Definition: def_glob.h:1009
#define STRLEN
Maximum size of file names and input tokens (which includes input strings) (Note: calculated tokens c...
Definition: def_const.h:162
void init_print ( )

init_print

Initialize size of single segment of split printing. Wild_Life integers are represented as REALS, and therefore can have higher precision than the machine integers. They will be printed in segments.

Definition at line 52 of file print.c.

References PRINT_POWER, and seg_format.

53 {
54  (void)snprintf(seg_format,PRINT_POWER+4,"%%0%ldd",PRINT_POWER);
55 }
#define PRINT_POWER
Power of ten to split printing (REALs are often more precise than ints.
Definition: def_const.h:190
void insert_variables ( ptr_node  vars,
long  force 
)

insert_variables

Parameters
vars- ptr_node vars
force- long force

INSERT_VARIABLES(vars,force) This routine gives the name of the query variable to the corresponding pointer in the POINTER_NAMES. If FORCE is TRUE then variables will be printed as TAGS, even if not referred to elsewhere.

Definition at line 308 of file print.c.

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

309 {
310  ptr_psi_term p;
311  ptr_node n;
312 
313  if(vars) {
314  insert_variables(vars->right,force);
315  p=(ptr_psi_term )vars->data;
316  deref_ptr(p);
317  n=find(INTCMP,(char *)p,pointer_names);
318  if (n)
319  if (n->data || force)
320  n->data=(GENERIC)vars->key;
321  insert_variables(vars->left,force);
322  }
323 }
#define INTCMP
indicates to use intcmp for comparison (in trees.c)
Definition: def_const.h:971
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
ptr_node pointer_names
Definition: def_glob.h:1008
ptr_node left
Definition: def_struct.h:199
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
char * key
Definition: def_struct.h:198
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_node right
Definition: def_struct.h:200
long is_integer ( char *  s)

is_integer

Parameters
s- char *s

Return TRUE if s represents an integer.

Definition at line 450 of file print.c.

References DIGIT, FALSE, and TRUE.

451 {
452  if (!*s) return FALSE;
453  if (*s=='-') s++;
454  while (*s) {
455  if (!DIGIT(*s)) return FALSE;
456  s++;
457  }
458  return TRUE;
459 }
#define DIGIT(C)
Definition: def_macro.h:42
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
void listing_pred_write ( ptr_node  n,
long  fflag 
)

listing_pred_write

Parameters
n- ptr_node n
fflag- long fflag

For the listing built-in

Definition at line 1438 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.

1439 {
1440  long old_print_depth;
1441 
1443  func_flag=fflag;
1444  indent=TRUE;
1445  const_quote=TRUE;
1451  old_print_depth=print_depth;
1453  main_pred_write(n);
1454  print_depth=old_print_depth;
1455  (void)fflush(outfile);
1456 }
FILE * outfile
Definition: def_glob.h:974
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define PRINT_DEPTH
Initial depth limit for printing.
Definition: def_const.h:176
FILE * output_stream
Definition: def_glob.h:1017
void main_display_psi_term ( ptr_psi_term  t)

main_display_psi_term

Parameters
t- ptr_psi_term t

Main loop for previous two entry points

Definition at line 1593 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.

1594 {
1595  GENERIC old_heap_pointer;
1596  ptr_tab_brk new;
1597 
1599  if(t) {
1600 
1601  deref_ptr(t);
1602 
1603  old_heap_pointer=heap_pointer;
1606  gen_sym_counter=0;
1607  go_through(t);
1609 
1610  indent=FALSE;
1611  const_quote=TRUE;
1614  *buffer=0;
1616 
1617  new_tab(&new);
1618  mark_tab(new);
1620  end_tab();
1621  if (indent) {
1622  work_out_length();
1623  pretty_output();
1624  }
1625 
1626  heap_pointer=old_heap_pointer;
1627  }
1628  else
1629  printf("*null psi_term*");
1630 }
ptr_node printed_pointers
Definition: def_glob.h:1007
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
ptr_node pointer_names
Definition: def_glob.h:1008
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * buffer
buffer used only in print.c - there is local with same name in xpred.c
Definition: def_glob.h:781
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_item indx
Definition: def_glob.h:970
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
long gen_sym_counter
Definition: def_glob.h:1009
void main_pred_write ( ptr_node  n)

main_pred_write

Parameters
n- ptr_node n

Definition at line 1484 of file print.c.

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

1485 {
1486  if (n) {
1487  GENERIC old_heap_pointer;
1488  ptr_tab_brk new;
1489 
1490  if (!write_corefs) main_pred_write(n->left);
1491 
1492  old_heap_pointer=heap_pointer;
1495  gen_sym_counter=0;
1496  if (write_corefs)
1497  go_through_tree(n);
1498  else
1501 
1502  *buffer=0;
1503 
1505  new_tab(&new);
1506 
1507  if (write_corefs) {
1508  write_attributes(n,new);
1509  }
1510  else {
1511  mark_tab(new);
1513  }
1514 
1515  end_tab();
1516 
1517  if (indent) {
1518  work_out_length();
1519  pretty_output();
1520  }
1521 
1522  heap_pointer=old_heap_pointer;
1523 
1525  }
1526 }
ptr_node printed_pointers
Definition: def_glob.h:1007
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
ptr_node pointer_names
Definition: def_glob.h:1008
ptr_node left
Definition: def_struct.h:199
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * buffer
buffer used only in print.c - there is local with same name in xpred.c
Definition: def_glob.h:781
ptr_item indx
Definition: def_glob.h:970
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
long gen_sym_counter
Definition: def_glob.h:1009
ptr_node right
Definition: def_struct.h:200
void mark_tab ( ptr_tab_brk  t)

mark_tab

Parameters
t- ptr_tab_brk t

MARK_TAB(t) Mark a tabbing position T. Make the current item point to tabbing position T.

Definition at line 573 of file print.c.

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

574 {
575  end_tab();
576  indx->tab=t;
577 }
ptr_tab_brk tab
Definition: def_struct.h:316
ptr_item indx
Definition: def_glob.h:970
void new_tab ( ptr_tab_brk t)

new_tab

Parameters
t- ptr_tab_brk *t

NEW_TAB(t) Create a new tabulation mark T.

Definition at line 587 of file print.c.

References FALSE, and HEAP_ALLOC.

588 {
589  (*t)=HEAP_ALLOC(tab_brk);
590  (*t)->broken=FALSE;
591  (*t)->printed=FALSE;
592  (*t)->column=0;
593 }
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
long no_quote ( char *  s)

no_quote

Parameters
s- char *s

Return TRUE if s does not have to be quoted, i.e., s starts with '_' or a lowercase symbol and contains all digits, letters, and '_'.

Definition at line 470 of file print.c.

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

471 {
472  if (!s[0]) return FALSE;
473 
474  if (s[0]=='%') return FALSE;
475  if (SINGLE(s[0]) && s[1]==0) return TRUE;
476  if (s[0]=='_' && s[1]==0) return FALSE;
477  if (all_symbol(s)) return TRUE;
478 
479  if (!LOWER(s[0])) return FALSE;
480  s++;
481  while (*s) {
482  if (!ISALPHA(*s)) return FALSE;
483  s++;
484  }
485  return TRUE;
486 }
#define ISALPHA(C)
Definition: def_macro.h:48
#define LOWER(C)
Definition: def_macro.h:46
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define SINGLE(C)
Definition: def_macro.h:52
long opcheck ( ptr_psi_term  t,
long *  prec,
long *  type 
)

opcheck

Parameters
t- ptr_psi_term t
prec- long *prec
type- long *type)

Get information about an operator. If t is an operator with the correct arguments, return one of {INFIX, PREFIX, POSTFIX} and also its precedence and type. If t is not an operator, or it has wrong arguments, return NOTOP and prec=0.

Definition at line 913 of file print.c.

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

914 {
915  long op;
916  long result=NOTOP;
917  long numarg=check_opargs(t->attr_list);
918  ptr_operator_data opdat=t->type->op_data;
919 
920  *prec=0;
921  if (numarg!=1 && numarg!=3) return NOTOP;
922  while (opdat) {
923  op=opdat->type;
924  if (numarg==1) {
925  if (op==xf || op==yf) { result=POSTFIX; break; }
926  if (op==fx || op==fy) { result=PREFIX; break; }
927  }
928  if (numarg==3)
929  if (op==xfx || op==xfy || op==yfx) { result=INFIX; break; }
930  opdat=opdat->next;
931  }
932  if (opdat==NULL) return NOTOP;
933  *prec=opdat->precedence;
934  *type=op;
935  return result;
936 }
#define yfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1037
#define xfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1021
#define POSTFIX
used in pretty printing in print.c
Definition: def_const.h:1374
ptr_operator_data next
Definition: def_struct.h:76
#define fx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1000
#define NULL
Definition: def_const.h:533
#define xfy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1030
#define PREFIX
used in pretty printing in print.c
Definition: def_const.h:1367
#define xf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:993
#define INFIX
used in pretty printing in print.c
Definition: def_const.h:1360
#define yf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1007
#define NOTOP
used in pretty printing in print.c
Definition: def_const.h:1353
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_operator_data op_data
Definition: def_struct.h:158
#define fy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1014
void pred_write ( ptr_node  n)

pred_write

Parameters
n- ptr_node n

PRED_WRITE(n) N is an attribute tree to be printed in one lump. This is called by WRITE.

For all write builtins I.e: write, writeq, pretty_write, pretty_writeq, write_err, writeq_err.

Definition at line 1469 of file print.c.

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

1470 {
1472  /* write_stderr=FALSE; */
1474  main_pred_write(n);
1475  (void)fflush(outfile);
1476 }
FILE * outfile
Definition: def_glob.h:974
#define FALSE
Standard boolean.
Definition: def_const.h:275
FILE * output_stream
Definition: def_glob.h:1017
void pretty_attr ( ptr_node  t,
long  depth 
)

pretty_attr

Parameters
t- ptr_node t
depth- long depth

PRETTY_ATTR(t,depth) Pretty print the attributes. This calls DO_PRETTY_ATTR which does the real work.

Definition at line 1273 of file print.c.

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

1274 {
1275  ptr_tab_brk new;
1276  long cnt=1;
1277 
1278  prettyf("(");
1279  new_tab(&new);
1280 
1281  do_pretty_attr(t,new,&cnt,two_or_more(t),depth);
1282 
1283  prettyf(")");
1284 }
void pretty_list ( ptr_psi_term  t,
long  depth 
)

pretty_list

Parameters
t- ptr_psi_term t
depth- long depth

PRETTY_LIST(t,depth) Pretty print a list. On entry we know that T is a legal CONS pair, so we can immediately print the opening bracket etc...

Definition at line 734 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.

735 {
736  ptr_tab_brk new;
737  ptr_definition t_type;
738  ptr_psi_term car,cdr;
739  ptr_node n;
740  char sep[4],end[3];
741  long list_depth; /* 20.8 */
742  long done=FALSE; /* RM: Dec 11 1992 */
743 
744  strcpy(sep,"ab");
745  strcpy(end,"cd");
746  t_type=t->type;
747 
748  if (overlap_type(t_type,alist)) {
749  if (!equal_types(t_type,alist)) {
750  pretty_symbol(t_type->keyword); /* RM: Jan 13 1993 */
751  prettyf(DOTDOT);
752  }
753  prettyf("[");
754  strcpy(sep,",");
755  strcpy(end,"]");
756  }
757 
758  /*
759  else if (equal_types(t_type,conjunction)) {
760  prettyf("(");
761  strcpy(sep,DOTDOT);
762  strcpy(end,")");
763  }
764  */
765 
766  else if (equal_types(t_type,disjunction)) {
767  prettyf("{");
768  strcpy(sep,";");
769  strcpy(end,"}");
770  }
771 
772 
773  /* RM: Dec 11 1992 New code for printing lists */
774 
775  new_tab(&new);
776  list_depth=0; /* 20.8 */
777  while(!done) {
778  mark_tab(new);
779  if(list_depth==print_depth)
780  prettyf("...");
781 
782  get_two_args(t->attr_list,&car,&cdr);
783  deref_ptr(car);
784  deref_ptr(cdr);
785 
786 
787  if(list_depth<print_depth)
789 
790  /* Determine how to print the CDR */
791  n=find(INTCMP,(char *)cdr,pointer_names);
792 
793  if(n && n->data) {
794  prettyf("|");
796  done=TRUE;
797  }
798  else
799  if(( /* RM: Feb 1 1993 */
800  (cdr->type==nil && overlap_type(t_type,alist)) ||
801  (cdr->type==disj_nil && t_type==disjunction)
802  )
803  && !cdr->attr_list)
804  done=TRUE;
805  else
806  if(!check_legal_cons(cdr,t_type)) {
807  prettyf("|");
809  done=TRUE;
810  }
811  else {
812  if(list_depth<print_depth)
813  prettyf(sep);
814  t=cdr;
815  }
816 
817  list_depth++;
818  }
819 
820  prettyf(end);
821 }
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define INTCMP
indicates to use intcmp for comparison (in trees.c)
Definition: def_const.h:971
void pretty_symbol(ptr_keyword k)
pretty_symbol
Definition: modules.c:452
ptr_keyword keyword
Definition: def_struct.h:147
GENERIC data
Definition: def_struct.h:201
#define DOTDOT
used in pretty printing in print.c
Definition: def_const.h:1346
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
ptr_node pointer_names
Definition: def_glob.h:1008
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition nil
symbol in bi module
Definition: def_glob.h:340
ptr_definition disj_nil
symbol in syntax module
Definition: def_glob.h:256
#define equal_types(A, B)
Definition: def_macro.h:111
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
void pretty_output ( )

pretty_output

PRETTY_OUTPUT() Final output of all these pretty things which have been built up.

Definition at line 1293 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.

1294 {
1295  ptr_item i;
1296  long j;
1297 
1298  for(i=pretty_things+1;(unsigned long)i<(unsigned long)indx;i++) {
1299  if(i->tab->broken && i->tab->printed) {
1300  fprintf(outfile,"\n");
1301  for(j=0;j<i->tab->column;j++)
1302  fprintf(outfile," ");
1303  }
1304  fprintf(outfile,"%s",i->str);
1305  i->tab->printed=TRUE;
1306  }
1307 }
long printed
Definition: def_struct.h:312
long column
Definition: def_struct.h:310
ptr_tab_brk tab
Definition: def_struct.h:316
char * str
Definition: def_struct.h:315
FILE * outfile
Definition: def_glob.h:974
long broken
Definition: def_struct.h:311
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_item indx
Definition: def_glob.h:970
void pretty_psi_term ( ptr_psi_term  t,
long  sprec,
long  depth 
)

pretty_psi_term

Parameters
t- ptr_psi_term t
sprec- long sprec
depth- long depth

PRETTY_PSI_TERM(t,sprec,depth) Pretty print a psi_term T with sugar for lists.

Definition at line 1058 of file print.c.

References wl_goal::aaaa_1, alist, wl_psi_term::attr_list, 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, wl_psi_term::resid, seg_format, stream, STRLEN, sub_type(), sys_bytedata, wl_psi_term::type, wl_psi_term::value_3, WL_MAXINT, and write_canon.

1059 {
1060  char buf[STRLEN]; /* Big enough for a long number */
1061  ptr_residuation r;
1062  long argswritten;
1063  // double fmod();
1064 
1065  if (t) {
1066  deref_ptr(t); /* PVR */
1067 
1068  /* if (trace) printf("<%ld>",t->status); For brunobug.lf PVR 14.2.94 */
1069 
1070  /* RM: Feb 12 1993 */
1071  if(display_persistent &&
1072  (GENERIC)t>heap_pointer)
1073  prettyf(" $");
1074 
1075  if((t->type==alist || t->type==disjunction) && check_legal_cons(t,t->type))
1076  pretty_list(t,depth+1); /* RM: Dec 11 1992 */
1077  else
1078  if(t->type==nil && !t->attr_list)
1079  prettyf("[]");
1080  else
1081  if(t->type==disj_nil && !t->attr_list) /* RM: Feb 1 1993 */
1082  prettyf("{}");
1083  else {
1084  argswritten=FALSE;
1085  if (t->value_3) {
1086 #ifdef CLIFE
1087  if(t->type->type==block) { /* RM 20 Jan 1993 */
1088  pretty_block(t); /* AA 21 Jan 1993 */
1089  }
1090  else
1091 #endif /* CLIFE */
1092  if (sub_type(t->type,integer)) {
1093  /* Print integers in chunks up to the full precision of the REAL */
1094  long seg,neg,i;
1095  REAL val;
1096  char segbuf[100][PRINT_POWER+3];
1097 
1098  val = *(REAL *)t->value_3;
1099  neg = (val<0.0);
1100  if (neg) val = -val;
1101  if (val>WL_MAXINT) goto PrintReal;
1102  seg=0;
1103  while (val>=(double)PRINT_SPLIT) {
1104  double tmp;
1105  tmp=(REAL)fmod((double)val,(double)PRINT_SPLIT);
1106  (void)snprintf(segbuf[seg],100,seg_format,(unsigned long)tmp);
1107  val=floor(val/(double)PRINT_SPLIT);
1108  seg++;
1109  }
1110  (void)snprintf(segbuf[seg],100,"%s%ld",(neg?"-":""),(unsigned long)val);
1111  for (i=seg; i>=0; i--) prettyf(segbuf[i]);
1112  if (!equal_types(t->type,integer)) {
1113  prettyf(DOTDOT);
1114  pretty_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1115  }
1116  }
1117  else if (sub_type(t->type,real)) {
1118  PrintReal:
1119  (void)snprintf(buf,STRLEN,"%lg",*(REAL *)t->value_3);
1120  prettyf(buf);
1121  if (!equal_types(t->type,real) &&
1122  !equal_types(t->type,integer)) {
1123  prettyf(DOTDOT);
1124  pretty_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1125  }
1126  }
1127  else if (sub_type(t->type,quoted_string)) {
1128  prettyf_quoted_string((char *)t->value_3);
1129  if(!equal_types(t->type,quoted_string)) {
1130  prettyf(DOTDOT);
1131  pretty_quote_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1132  }
1133  }
1134  /* DENYS: BYTEDATA */
1135  else if (sub_type(t->type,sys_bytedata)) {
1137  }
1138  else if (equal_types(t->type,stream)) {
1139  (void)snprintf(buf,STRLEN,"stream(%ld)",(long)t->value_3);
1140  prettyf(buf);
1141  }
1142  else if (equal_types(t->type,eof))
1143  pretty_quote_symbol(eof->keyword); /* RM: Jan 13 1993 */
1144  else if (equal_types(t->type,cut))
1145  pretty_quote_symbol(cut->keyword); /* RM: Jan 13 1993 */
1146  else {
1147  prettyf("*** bad object '");
1148  pretty_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1149  prettyf("'***");
1150  }
1151  }
1152  else {
1153  if (depth<print_depth) /* 20.8 */
1154  argswritten=pretty_psi_with_ops(t,sprec,depth+1);
1155  /* RM: Jan 13 1993 */
1156  if (!argswritten) pretty_quote_symbol(t->type->keyword);
1157  }
1158 
1159  /* write_canon -- PVR 24.2.94 */
1160  if (!argswritten && t->attr_list &&
1161  (depth<print_depth || write_canon)) /* 20.8 */
1162  pretty_attr(t->attr_list,depth+1);
1163 
1164  if (depth>=print_depth && !write_canon && t->attr_list) /* 20.8 */
1165  prettyf("(...)");
1166  }
1167  if ((r=t->resid))
1168  while (r) {
1169  if (r->goal->pending) {
1170  if (FALSE /* write_resids 11.8 */) {
1171  prettyf("\\");
1172  pretty_psi_term(r->goal->aaaa_1,0,depth);
1173  }
1174  else
1175  prettyf("~");
1176  }
1177  r=r->next;
1178  }
1179  }
1180 }
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
ptr_residuation resid
Definition: def_struct.h:189
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_goal goal
Definition: def_struct.h:172
ptr_residuation next
Definition: def_struct.h:173
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
void pretty_symbol(ptr_keyword k)
pretty_symbol
Definition: modules.c:452
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
ptr_keyword keyword
Definition: def_struct.h:147
#define DOTDOT
used in pretty printing in print.c
Definition: def_const.h:1346
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
void pretty_quote_symbol(ptr_keyword k)
pretty_quote_symbol
Definition: modules.c:470
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define PRINT_POWER
Power of ten to split printing (REALs are often more precise than ints.
Definition: def_const.h:190
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition nil
symbol in bi module
Definition: def_glob.h:340
GENERIC value_3
Definition: def_struct.h:186
ptr_definition disj_nil
symbol in syntax module
Definition: def_glob.h:256
#define equal_types(A, B)
Definition: def_macro.h:111
#define PRINT_SPLIT
Size at which to split printing (REALs are often more precise than ints.
Definition: def_const.h:183
#define WL_MAXINT
Maximum exactly representable integer (2^53-1 for double IEEE format)
Definition: def_const.h:140
#define STRLEN
Maximum size of file names and input tokens (which includes input strings) (Note: calculated tokens c...
Definition: def_const.h:162
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition pending
Definition: def_struct.h:243
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long pretty_psi_with_ops ( ptr_psi_term  t,
long  sprec,
long  depth 
)

pretty_psi_with_ops

Parameters
t- ptr_psi_term t
sprec- long sprec
depth- long depth

Write an expression with its operators. Return TRUE iff the arguments of t are written here (i.e. t was indeed a valid operator, and is therefore taken care of here).

Definition at line 949 of file print.c.

References wl_psi_term::attr_list, deref_ptr, FALSE, func_flag, fx, fy, get_two_args(), INFIX, wl_definition::keyword, listing_flag, MAX_PRECEDENCE, opcheck(), POSTFIX, PREFIX, pretty_quote_symbol(), pretty_tag_or_psi_term(), prettyf(), wl_keyword::symbol, TRUE, wl_psi_term::type, write_canon, xf, xfx, xfy, yf, and yfx.

950 {
951  // ptr_tab_brk new;
952  ptr_psi_term arg1, arg2;
953  long ttype, a1type, a2type;
954  long tprec, a1prec, a2prec;
955  long tkind, a1kind, a2kind;
956  long p1, p2, argswritten;
957  long sp; /* surrounding parentheses */
958 
959  if (write_canon) return FALSE; /* PVR 24.2.94 */
960 
961  argswritten=TRUE;
962  tkind=opcheck(t, &tprec, &ttype);
963  sp=(tkind==INFIX||tkind==PREFIX||tkind==POSTFIX) && tprec>=sprec;
964  if (sp) prettyf("(");
965  if (tkind==INFIX) {
966  get_two_args(t->attr_list, &arg1, &arg2);
967  deref_ptr(arg1); /* 16.9 */
968  deref_ptr(arg2); /* 16.9 */
969  a1kind = opcheck(arg1, &a1prec, &a1type);
970  a2kind = opcheck(arg2, &a2prec, &a2type);
971 
972  /* The p1 and p2 flags tell whether to put parens around t's args */
973  /* Calculate p1 flag: */
974  if (a1prec>tprec) p1=TRUE;
975  else if (a1prec<tprec) p1=FALSE;
976  else /* equal priority */
977  if (ttype==xfy || ttype==xfx) p1=TRUE;
978  else /* yfx */
979  if (a1type==yfx || a1type==fx || a1type==fy) p1=FALSE;
980  else p1=TRUE;
981 
982  /* Calculate p2 flag: */
983  if (a2prec>tprec) p2=TRUE;
984  else if (a2prec<tprec) p2=FALSE;
985  else /* equal priority */
986  if (ttype==yfx || ttype==xfx) p2=TRUE;
987  else /* xfy */
988  if (a2type==xfy || a2type==xf || a2type==yf) p2=FALSE;
989  else p2=TRUE;
990 
991  /* Write the expression */
992  if (p1) prettyf("(");
994  if (p1) prettyf(")");
995  if (!p1 && strcmp(t->type->keyword->symbol,",")) {
996  prettyf(" ");
997  }
998  pretty_quote_symbol(t->type->keyword); /* RM: Jan 13 1993 */
999  if (listing_flag && !func_flag &&
1000  (!strcmp(t->type->keyword->symbol,",") ||
1001  !strcmp(t->type->keyword->symbol,":-"))) {
1002  prettyf("\n ");
1003  }
1004  else {
1005  if (!p2 && strcmp(t->type->keyword->symbol,".")) prettyf(" ");
1006  }
1007  if (p2) prettyf("(");
1008  pretty_tag_or_psi_term(arg2,MAX_PRECEDENCE+1,depth);
1009  if (p2) prettyf(")");
1010  }
1011  else if (tkind==PREFIX) {
1012  get_two_args(t->attr_list, &arg1, &arg2); /* arg2 does not exist */
1013  a1kind = opcheck(arg1, &a1prec, &a1type);
1014 
1015  /* Calculate p1 flag: */
1016  if (a1type==fx || a1type==fy) p1=FALSE;
1017  else p1=(tprec<=a1prec);
1018 
1019  pretty_quote_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1020  if (!p1) prettyf(" ");
1021  if (p1) prettyf("(");
1022  pretty_tag_or_psi_term(arg1,MAX_PRECEDENCE+1,depth);
1023  if (p1) prettyf(")");
1024  }
1025  else if (tkind==POSTFIX) {
1026  get_two_args(t->attr_list, &arg1, &arg2); /* arg2 does not exist */
1027  a1kind = opcheck(arg1, &a1prec, &a1type);
1028 
1029  /* Calculate p1 flag: */
1030  if (a1type==xf || a1type==yf) p1=FALSE;
1031  else p1=(tprec<=a1prec);
1032 
1033  if (p1) prettyf("(");
1034  pretty_tag_or_psi_term(arg1,MAX_PRECEDENCE+1,depth);
1035  if (p1) prettyf(")");
1036  if (!p1) prettyf(" ");
1037  pretty_quote_symbol(t->type->keyword); /* RM: Jan 13 1993 */
1038  }
1039  else {
1040  argswritten=FALSE;
1041  }
1042  if (sp) prettyf(")");
1043  return argswritten;
1044 }
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define yfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1037
#define xfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1021
#define POSTFIX
used in pretty printing in print.c
Definition: def_const.h:1374
#define fx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1000
ptr_keyword keyword
Definition: def_struct.h:147
#define xfy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1030
char * symbol
Definition: def_struct.h:118
void pretty_quote_symbol(ptr_keyword k)
pretty_quote_symbol
Definition: modules.c:470
#define PREFIX
used in pretty printing in print.c
Definition: def_const.h:1367
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define xf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:993
#define yf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1007
#define INFIX
used in pretty printing in print.c
Definition: def_const.h:1360
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
#define fy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1014
void pretty_tag_or_psi_term ( ptr_psi_term  p,
long  sprec,
long  depth 
)

pretty_tag_or_psi_term

Parameters
p- ptr_psi_term p
sprec- long sprec
depth- long depth

PRETTY_TAG_OR_PSI_TERM(p,depth) Print a psi-term, but first precede it with the appropriate TAG. Don't reprint the same psi-term twice.

Definition at line 834 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().

835 {
836  ptr_node n,n2;
837 
838  if (p==NULL) {
839  prettyf("<VOID>");
840  return;
841  }
842  if (FALSE /*depth>=print_depth*/) { /* 20.8 */
843  prettyf("...");
844  return;
845  }
846  deref_ptr(p);
847 
848  n=find(INTCMP,(char *)p,pointer_names);
849 
850  if (n && n->data) {
851  if (n->data==(GENERIC)no_name) {
852  n->data=(GENERIC)unique_name();
853  /* sprintf(name,"_%ld%c",++gen_sym_counter,0); */
854  /* n->data=(GENERIC)heap_copy_string(name); */
855  }
856  n2=find(INTCMP,(char *)p,printed_pointers);
857  if(n2==NULL) {
858  prettyf((char *)n->data);
859  (void)heap_insert(INTCMP,(char *)p,&printed_pointers,(GENERIC)n->data);
860  if (!is_top(p)) {
861  prettyf(DOTDOT);
862  pretty_psi_term(p,COLON_PREC,depth);
863  }
864  }
865  else
866  prettyf((char *)n2->data);
867  }
868  else
869  pretty_psi_term(p,sprec,depth);
870 }
ptr_node printed_pointers
Definition: def_glob.h:1007
#define is_top(T)
Definition: def_macro.h:113
#define INTCMP
indicates to use intcmp for comparison (in trees.c)
Definition: def_const.h:971
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
#define DOTDOT
used in pretty printing in print.c
Definition: def_const.h:1346
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
heap_insert
Definition: trees.c:320
ptr_node pointer_names
Definition: def_glob.h:1008
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
void pretty_variables ( ptr_node  n,
ptr_tab_brk  tab 
)

pretty_variables

Parameters
n- ptr_node n
tab- ptr_tab_brk tab

PRETTY_VARIABLES(n,tab) Pretty print the variables at position TAB.

Definition at line 1318 of file print.c.

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

1319 {
1320  ptr_psi_term tok;
1321  ptr_node n2;
1322 
1323  if(n->left) {
1324  pretty_variables(n->left,tab);
1325  prettyf(", ");
1326  }
1327 
1328  mark_tab(tab);
1329  prettyf(n->key);
1330  prettyf(" = ");
1331 
1332  tok=(ptr_psi_term )n->data;
1333  deref_ptr(tok);
1334  n2=find(INTCMP,(char *)tok,printed_pointers);
1335  if(strcmp((char *)n2->data,n->key)<0)
1336  /* Reference to previously printed variable */
1337  prettyf((char *)n2->data);
1338  else {
1339  if (eqsym->op_data) {
1340  long tkind, tprec, ttype, eqprec;
1341  eqprec=eqsym->op_data->precedence;
1342  tkind=opcheck(tok, &tprec, &ttype);
1343  if (tprec>=eqprec) prettyf("(");
1345  if (tprec>=eqprec) prettyf(")");
1346  }
1347  else
1349  }
1350 
1351  if(n->right) {
1352  prettyf(", ");
1353  pretty_variables(n->right,tab);
1354  }
1355 }
ptr_node printed_pointers
Definition: def_glob.h:1007
ptr_definition eqsym
symbol in syntax module
Definition: def_glob.h:270
#define INTCMP
indicates to use intcmp for comparison (in trees.c)
Definition: def_const.h:971
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
#define deref_ptr(P)
Definition: def_macro.h:100
char * key
Definition: def_struct.h:198
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
ptr_operator_data op_data
Definition: def_struct.h:158
ptr_node right
Definition: def_struct.h:200
void prettyf ( char *  s)

prettyf

Parameters
s- char *s

PRETTYF(s) This prints the string S into the BUFFER.

Definition at line 496 of file print.c.

References FALSE, and prettyf_inner().

497 {
498  prettyf_inner(s,FALSE,'\'');
499 }
#define FALSE
Standard boolean.
Definition: def_const.h:275
void prettyf_inner ( char *  s,
long  q,
char  c 
)

prettyf_inner

Parameters
s- char *s
q- long q
c- char c the quote character

PRINTING ROUTINES.

These routines allow the correct printing in minimal form of a set of possibly cyclic psi-terms with coreferences from one to another.

First the term to be printed is explored to locate any cyclic terms or coreferences. Then is printed into memory where is it formatted to fit within PAGE_WIDTH of the output page. Then it is effectively printed to the output stream.

Printing into memory involves the use of an array containing a TAB position on which to align things then a string to print. The routine WORK_OUT_LENGTH tries (by trial and error) to print the psi_term into PAGE_WIDTH columns by inserting line feeds whereever possible

Does the work of prettyf and prettyf_quote The q argument is a flag telling whether to quote or not.

Definition at line 374 of file print.c.

References buffer, indent, and outfile.

375 {
376  char *sb=buffer;
377 
378  if (indent) {
379  while (*sb) sb++;
380  if (q) { *sb = c; sb++; }
381  while (*s) {
382  if (q && *s==c) { *sb = *s; sb++; }
383  *sb = *s; sb++; s++;
384  }
385  if (q) { *sb = c; sb++; }
386  *sb=0;
387  }
388  else {
389  if (q) (void)putc(c,outfile);
390  while (*s) {
391  if (q && *s==c) { (void)putc(*s,outfile); }
392  (void)putc(*s,outfile);
393  s++;
394  }
395  if (q) (void)putc(c,outfile);
396  }
397 }
FILE * outfile
Definition: def_glob.h:974
char * buffer
buffer used only in print.c - there is local with same name in xpred.c
Definition: def_glob.h:781
void prettyf_quote ( char *  s)

prettyf_quote

Parameters
s- char *s

PRETTYF_QUOTE(s) This prints the string S into the buffer. S is surrounded by quotes if: (1) const_quote==TRUE, and (2) S does not represent an integer, and (2) S contains a non-alphanumeric character or starts with a non-lowercase character, and (3) if S is longer than one character, it is not true that S has only non-SINGLE SYMBOL characters (in that case, S does not need quotes),and (4) if S has only one character, it is a single space or underscore. When S is surrounded by quotes, a quote inside S is printed as two quotes.

Definition at line 529 of file print.c.

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

530 {
531  prettyf_inner(s, const_quote && !no_quote(s), '\'');
532 }
void prettyf_quoted_string ( char *  s)

prettyf_quoted_string

Parameters
s- char *s

Definition at line 507 of file print.c.

References const_quote, and prettyf_inner().

508 {
509  prettyf_inner((char *)s,const_quote,'"');
510 }
void print_bin ( long  b)

print_bin

Parameters
b- long b

PRINT_BIN(b) Print the integer B under binary format (currently 26 is printed **-*-). This is used to print the binary codes used in type encryption.

Definition at line 147 of file print.c.

References INT_SIZE, and outfile.

148 {
149  long p;
150 
151  for (p=INT_SIZE;p--;p>0)
152  {
153  fprintf(outfile,(b&1?"X":" "));
154  b = b>>1;
155  }
156 }
#define INT_SIZE
How many types can be encoded on one integer in the transitive closure encoding.
Definition: def_const.h:317
FILE * outfile
Definition: def_glob.h:974
void print_code ( FILE *  s,
ptr_int_list  c 
)

print_code

Parameters
s- FILE *s
c- ptr_int_list c

PRINT_CODE(s,c) Print a binary code C to a stream s (as used in type encoding).

Definition at line 167 of file print.c.

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

168 {
169  outfile=s;
170 
171  if (c==NOT_CODED)
172  fprintf(outfile," (not coded) ");
173  else {
174  fprintf(outfile," [");
175  while (c) {
176  print_bin((long)c->value_1);
177  c=c->next;
178  }
179  fprintf(outfile,"]");
180  }
181 }
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
FILE * outfile
Definition: def_glob.h:974
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
void print_operator_kind ( FILE *  s,
long  kind 
)

print_operator_kind

Parameters
s- FILE *s
kind- long kind

PRINT_OPERATOR_KIND(s,kind) Print the kind of an operator.

Definition at line 192 of file print.c.

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

193 {
194  switch (kind) {
195  case xf:
196  fprintf(s,"xf");
197  break;
198  case fx:
199  fprintf(s,"fx");
200  break;
201  case yf:
202  fprintf(s,"yf");
203  break;
204  case fy:
205  fprintf(s,"fy");
206  break;
207  case xfx:
208  fprintf(s,"xfx");
209  break;
210  case xfy:
211  fprintf(s,"xfy");
212  break;
213  case yfx:
214  fprintf(s,"yfx");
215  break;
216  default:
217  fprintf(s,"illegal");
218  break;
219  }
220 }
#define yfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1037
#define xfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1021
#define fx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1000
#define xfy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1030
#define xf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:993
#define yf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1007
#define fy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1014
void print_resid_message ( ptr_psi_term  t,
ptr_resid_list  r 
)

print_resid_message

Parameters
t- ptr_psi_term t
r- ptr_resid_list r

PRINT_RESID_MESSAGE This is called in trace mode to print the residuated goal along with the RV set.

Definition at line 1690 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.

1691 {
1692  GENERIC old_heap_pointer;
1693  ptr_tab_brk new;
1694  ptr_resid_list r2; /* 21.9 */
1695 
1696  outfile=stdout;
1698  old_heap_pointer=heap_pointer;
1699 
1702  gen_sym_counter=0;
1703 
1704  check_pointer(t);
1705 
1706  r2=r;
1707  while(r2) {
1708  check_pointer(r2->var);
1709  r2=r2->next;
1710  }
1711 
1713 
1714  indent=FALSE;
1715  const_quote=TRUE;
1718  *buffer=0;
1720  new_tab(&new);
1721  mark_tab(new);
1722 
1723  prettyf("residuating ");
1725  prettyf(" on variable(s) {");
1726 
1727  r2=r;
1728  while(r2) {
1730  r2=r2->next;
1731  if(r2)
1732  prettyf(",");
1733  }
1734 
1735  prettyf("}\n");
1736  end_tab();
1737 
1738  heap_pointer=old_heap_pointer;
1739 }
ptr_node printed_pointers
Definition: def_glob.h:1007
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
ptr_resid_list next
Definition: def_struct.h:97
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
FILE * outfile
Definition: def_glob.h:974
ptr_node pointer_names
Definition: def_glob.h:1008
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * buffer
buffer used only in print.c - there is local with same name in xpred.c
Definition: def_glob.h:781
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_item indx
Definition: def_glob.h:970
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term var
Definition: def_struct.h:95
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
long gen_sym_counter
Definition: def_glob.h:1009
long print_variables ( long  printflag)

print_variables

Parameters
printflag- long printflag

PRINT_VARIABLES This prints all the query variables. Symbols generated to print one variable are coherent with those used in other variables. Returns TRUE iff the set of query variables is nonempty.

Definition at line 1368 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.

1369 {
1370  ptr_tab_brk new;
1371  GENERIC old_heap_pointer;
1372  if (!printflag) return FALSE; /* 21.1 */
1373 
1376  old_heap_pointer=heap_pointer;
1377 
1380  gen_sym_counter=0;
1384 
1385  indent=TRUE;
1386  const_quote=TRUE;
1389  *buffer=0;
1391 
1392  if (var_tree) {
1393  new_tab(&new);
1395  prettyf(".");
1396  mark_tab(new);
1397  prettyf("\n");
1398  end_tab();
1399 
1400  if (indent) {
1401  work_out_length();
1402  pretty_output();
1403  }
1404  }
1405  heap_pointer=old_heap_pointer;
1406  return (var_tree!=NULL);
1407 }
ptr_node printed_pointers
Definition: def_glob.h:1007
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
FILE * outfile
Definition: def_glob.h:974
ptr_node pointer_names
Definition: def_glob.h:1008
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * buffer
buffer used only in print.c - there is local with same name in xpred.c
Definition: def_glob.h:781
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_item indx
Definition: def_glob.h:970
#define FALSE
Standard boolean.
Definition: def_const.h:275
long gen_sym_counter
Definition: def_glob.h:1009
FILE * output_stream
Definition: def_glob.h:1017
long starts_nonlower ( char *  s)

starts_nonlower

Parameters
s- char *s

Return TRUE iff s starts with a non-lowercase character.

Definition at line 406 of file print.c.

References LOWER.

407 {
408  return (*s && !LOWER(s[0]));
409 }
#define LOWER(C)
Definition: def_macro.h:46
long str_to_int ( char *  s)

str_to_int

Parameters
s- char *s

STR_TO_INT(s) Converts the string S into a positive integer. Returns -1 if s is not an integer.

Definition at line 118 of file print.c.

References DIGIT.

119 {
120  long v=0;
121  char c;
122 
123  c=(*s);
124  if (c==0)
125  v= -1;
126  else {
127  while (DIGIT(c)) {
128  v=v*10+(c-'0');
129  s++;
130  c=(*s);
131  }
132  if (c!=0) v= -1;
133  }
134 
135  return v;
136 }
#define DIGIT(C)
Definition: def_macro.h:42
long strpos ( long  pos,
char *  str 
)

strpos

Parameters
pos- long pos
str- char *str

Utility to correctly handle '
' inside strings being printed: What is the column after printing str, when the starting position is pos? Same as strlen, except that the length count starts with pos and
resets it.

Definition at line 608 of file print.c.

609 {
610  while (*str) {
611  if (str[0]=='\n') pos=0; else pos++;
612  str++;
613  }
614  return pos;
615 }
long two_or_more ( ptr_node  t)

two_or_more

Parameters
t- ptr_node t

Return true if number of attributes is greater than 1

Definition at line 1254 of file print.c.

References FALSE, wl_node::left, wl_node::right, and TRUE.

1255 {
1256  if (t) {
1257  if (t->left || t->right) return TRUE; else return FALSE;
1258  }
1259  else
1260  return FALSE;
1261 }
ptr_node left
Definition: def_struct.h:199
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_node right
Definition: def_struct.h:200
GENERIC unique_name ( )

unique_name

Make sure that the new variable name does not exist in the var_tree. (This situation should be rare.) Time to print a term is proportional to product of var_tree size and number of tags in the term. This may become large in pathological cases.

Definition at line 99 of file print.c.

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

100 {
101  GENERIC name_loc;
102 
103  do name_loc=(GENERIC)heap_nice_name();
104  while (find(STRCMP,(char *)name_loc,var_tree));
105 
106  return name_loc;
107 }
ptr_node var_tree
Definition: def_glob.h:1005
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define STRCMP
indicates to use strcmp for comparison (c function)
Definition: def_const.h:963
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
void work_out_length ( )

work_out_length

WORK_OUT_LENGTH() Calculate the number of blanks before each tabulation. Insert line feeds until it all fits into PAGE_WIDTH columns. This is done by a trial and error mechanism.

Definition at line 626 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.

627 {
628  ptr_item i;
629  long done=FALSE;
630  long pos;
631  ptr_tab_brk worst,root;
632  long w;
633 
634  while(!done) {
635 
636  pos=0;
637  done=TRUE;
638 
639  w= -1;
640  worst=NULL;
641  root=NULL;
642 
643  for(i=pretty_things+1;(unsigned long)i<(unsigned long)indx;i++) {
644 
645  if(i->tab->broken && i->tab->printed) {
646  pos=i->tab->column;
647  root=NULL;
648  }
649 
650  if(!i->tab->printed) i->tab->column=pos;
651 
652  if(!(i->tab->broken))
653  if(!root || (root && (root->column)>=(i->tab->column)))
654  root=i->tab;
655 
656  /* pos=pos+strlen(i->str); */
657  pos=strpos(pos,i->str);
658  i->tab->printed=TRUE;
659 
660  if(pos>page_width)
661  done=FALSE;
662 
663  if(pos>w) {
664  w=pos;
665  worst=root;
666  }
667  }
668 
669  for(i=pretty_things+1;(unsigned long)i<(unsigned long)indx;i++)
670  i->tab->printed=FALSE;
671 
672  if(!done)
673  if(worst)
674  worst->broken=TRUE;
675  else
676  done=TRUE;
677  }
678 }
long printed
Definition: def_struct.h:312
long column
Definition: def_struct.h:310
ptr_tab_brk tab
Definition: def_struct.h:316
char * str
Definition: def_struct.h:315
#define NULL
Definition: def_const.h:533
long broken
Definition: def_struct.h:311
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_item indx
Definition: def_glob.h:970
#define FALSE
Standard boolean.
Definition: def_const.h:275
void write_attributes ( ptr_node  n,
ptr_tab_brk  tab 
)

write_attributes

Parameters
n- ptr_node n
tab- ptr_tab_brk tab

WRITE_ATTRIBUTES(n) Used by all versions of the built-in predicate write, and by the built-in predicate listing.

Definition at line 1419 of file print.c.

References wl_node::data, wl_node::left, mark_tab(), MAX_PRECEDENCE, pretty_tag_or_psi_term(), and wl_node::right.

1420 {
1421  if(n) {
1422  write_attributes(n->left,tab);
1423  mark_tab(tab);
1425  write_attributes(n->right,tab);
1426  }
1427 }
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
ptr_node right
Definition: def_struct.h:200

Variable Documentation

long const_quote =TRUE

Definition at line 14 of file print.c.

long display_persistent =FALSE

Definition at line 22 of file print.c.

long func_flag
static

Definition at line 36 of file print.c.

long indent =FALSE

Definition at line 13 of file print.c.

long listing_flag
static

Definition at line 32 of file print.c.

char* name ="symbol"

Definition at line 25 of file print.c.

char* no_name ="pointer"

Definition at line 24 of file print.c.

long page_width =PAGE_WIDTH

Definition at line 20 of file print.c.

item pretty_things[PRETTY_SIZE]

Definition at line 29 of file print.c.

long print_depth =PRINT_DEPTH

Definition at line 12 of file print.c.

char seg_format[PRINT_POWER+4]

Definition at line 27 of file print.c.

long write_canon =FALSE

Definition at line 16 of file print.c.

long write_corefs =TRUE

Definition at line 18 of file print.c.

long write_resids =FALSE

Definition at line 15 of file print.c.

long write_stderr =FALSE

Definition at line 17 of file print.c.