Wild Life  2.30
 All Data Structures Files Functions Variables Typedefs Macros
Functions
def_proto.h File Reference

prototypes More...

Go to the source code of this file.

Functions

void insert_math_builtins ()
 insert math builtins into table More...
 
long c_trace ()
 trace More...
 
long c_tprove ()
 c_tprove More...
 
long c_quiet ()
 c_quiet More...
 
void setUnitList (GENERIC x)
 setUnitList(GENERIC x) More...
 
ptr_psi_term unitListValue ()
 make psi term from unitListElement More...
 
GENERIC unitListNext ()
 set unitListElement to NULL & return NULL More...
 
ptr_psi_term intListValue (ptr_int_list p)
 ptr_psi_term intListValue More...
 
GENERIC intListNext (ptr_int_list p)
 intListNext More...
 
ptr_psi_term quotedStackCopy (psi_term p)
 
ptr_psi_term residListGoalQuote (ptr_residuation p)
 residListGoalQuote More...
 
GENERIC residListNext (ptr_residuation p)
 residListNext More...
 
ptr_psi_term makePsiTerm (ptr_definition x)
 ptr_psi_term makePsiTerm More...
 
ptr_psi_term makePsiList (GENERIC head, ptr_psi_term(*valueFunc)(), GENERIC(*nextFunc)())
 makePsiList More...
 
ptr_goal makeGoal (ptr_psi_term p)
 makeGoal More...
 
void insert_system_builtins ()
 insert_system_builtins More...
 
long c_isa_subsort ()
 long c_isa_subsort More...
 
long isValue (ptr_psi_term p)
 isValue(p) More...
 
long c_glb ()
 long c_glb More...
 
long c_lub ()
 long c_lub More...
 
void insert_type_builtins ()
 void insert_type_builtins More...
 
int isSubTypeValue (ptr_psi_term arg1, ptr_psi_term arg2)
 isSubTypeValue More...
 
ptr_psi_term stack_nil ()
 stack_nil More...
 
ptr_psi_term stack_cons (ptr_psi_term head, ptr_psi_term tail)
 stack_cons More...
 
ptr_psi_term stack_pair (ptr_psi_term left, ptr_psi_term right)
 stack_pair More...
 
ptr_psi_term stack_int (long n)
 stack_int More...
 
ptr_psi_term stack_string (char *s)
 stack_string More...
 
ptr_psi_term stack_bytes (char *s, int n)
 stack_bytes More...
 
long psi_to_string (ptr_psi_term t, char **fn)
 psi_to_string More...
 
ptr_psi_term make_feature_list (ptr_node tree, ptr_psi_term tail, ptr_module module, int val)
 make_feature_list More...
 
long check_real (ptr_psi_term t, REAL *v, long *n)
 check_real More...
 
long get_real_value (ptr_psi_term t, REAL *v, long *n)
 get_real_value More...
 
void unify_bool_result (ptr_psi_term t, long v)
 unify_bool_result More...
 
long unify_real_result (ptr_psi_term t, REAL v)
 unify_real_result More...
 
long only_arg1 (ptr_psi_term t, ptr_psi_term *arg1)
 only_arg1 More...
 
long file_exists (char *s)
 file_exists More...
 
long c_halt ()
 c_halt More...
 
void exit_life (long nl_flag)
 exit_life More...
 
long c_abort ()
 c_abort More...
 
long abort_life (int nlflag)
 abort_life More...
 
long pred_clause (ptr_psi_term t, long r, ptr_psi_term g)
 pred_clause More...
 
void global_error_check (ptr_node n, int *error, int *eval2)
 global_error_check More...
 
void global_tree (ptr_node n)
 global_tree More...
 
void global_one (ptr_psi_term t)
 global_one More...
 
void persistent_error_check (ptr_node n, int *error)
 persistent_error_check More...
 
void persistent_tree (ptr_node n)
 persistent_tree More...
 
void persistent_one (ptr_psi_term t)
 persistent_one More...
 
long hidden_type (ptr_definition t)
 hidden_type More...
 
ptr_psi_term collect_symbols (long sel)
 collect_symbols More...
 
ptr_node one_attr ()
 one_attr More...
 
ptr_psi_term new_psi_term (long numargs, ptr_definition typ, ptr_psi_term **a1, ptr_psi_term **a2)
 new_psi_term More...
 
long has_rules (ptr_pair_list r)
 has_rules More...
 
long is_built_in (ptr_pair_list r)
 is_built_in More...
 
void list_special (ptr_psi_term t)
 list_special More...
 
void new_built_in (ptr_module m, char *s, def_type t, long(*r)())
 new_built_in More...
 
long declare_operator (ptr_psi_term t)
 declare_operator More...
 
char * str_conc (char *s1, char *s2)
 str_conc More...
 
char * sub_str (char *s, long p, long n)
 sub_str More...
 
long append_files (char *s1, char *s2)
 append_files More...
 
long c_concatenate ()
 c_concatenate More...
 
long c_string_length ()
 c_string_length More...
 
long c_sub_string ()
 c_sub_string More...
 
long c_append_file ()
 c_append_file More...
 
long c_random ()
 c_random More...
 
long c_initrandom ()
 c_initrandom More...
 
long c_deref_length ()
 c_deref_length More...
 
long c_args ()
 c_args More...
 
void init_built_in_types ()
 init_built_in_types More...
 
void init_copy ()
 init_copy More...
 
void clear_copy ()
 clear_copy More...
 
void insert_translation (ptr_psi_term a, ptr_psi_term b, long info)
 insert_translation More...
 
ptr_psi_term translate (ptr_psi_term a, long **infoptr)
 translate More...
 
ptr_psi_term exact_copy (ptr_psi_term t, long heap_flag)
 exact_copy More...
 
ptr_psi_term quote_copy (ptr_psi_term t, long heap_flag)
 quote_copy More...
 
ptr_psi_term eval_copy (ptr_psi_term t, long heap_flag)
 eval_copy More...
 
ptr_psi_term inc_heap_copy (ptr_psi_term t)
 inc_heap_copy More...
 
ptr_psi_term copy (ptr_psi_term t, long copy_flag, long heap_flag)
 copy More...
 
ptr_node distinct_tree (ptr_node t)
 distinct_tree More...
 
ptr_psi_term distinct_copy (ptr_psi_term t)
 distinct_copy More...
 
void mark_quote_c (ptr_psi_term t, long heap_flag)
 mark_quote_c More...
 
void mark_quote_tree_c (ptr_node n, long heap_flag)
 mark_quote_tree_c More...
 
void mark_eval (ptr_psi_term t)
 mark_eval More...
 
void mark_nonstrict (ptr_psi_term t)
 mark_nonstrict More...
 
void mark_quote_new2 (ptr_psi_term t)
 mark_quote_new2 More...
 
void mark_eval_new (ptr_psi_term t)
 mark_eval_new More...
 
void mark_eval_tree_new (ptr_node n)
 mark_eval_tree_new More...
 
void mark_quote_new (ptr_psi_term t)
 mark_quote_new More...
 
void mark_quote_tree_new (ptr_node n)
 mark_quote_tree_new More...
 
void mark_quote (ptr_psi_term t)
 mark_quote More...
 
void mark_quote_tree (ptr_node t)
 mark_quote_tree More...
 
void bk_mark_quote (ptr_psi_term t)
 bk_mark_quote More...
 
void bk_mark_quote_tree (ptr_node t)
 bk_mark_quote_tree More...
 
void stack_info (FILE *outfile)
 stack_info More...
 
void outputline (char *format,...)
 void outputline(char *format,...) More...
 
void traceline (char *format,...)
 traceline More...
 
void infoline (char *format,...)
 infoline More...
 
void warningline (char *format,...)
 warningline More...
 
void Errorline (char *format,...)
 Errorline. More...
 
void Syntaxerrorline (char *format,...)
 Syntaxerrorline. More...
 
void vinfoline (char *format, FILE *outfile,...)
 
void init_trace ()
 init_trace More...
 
void reset_step ()
 reset_step More...
 
void tracing ()
 tracing More...
 
void new_trace (long newtrace)
 new_trace More...
 
void new_step (long newstep)
 new_step More...
 
void set_trace_to_prove ()
 set_trace_to_prove More...
 
void toggle_trace ()
 toggle_trace More...
 
void toggle_step ()
 toggle_step More...
 
void perr (char *str)
 perr More...
 
void perr_s (char *s1, char *s2)
 perr_s More...
 
void perr_s2 (char *s1, char *s2, char *s3)
 perr_s2 More...
 
void perr_i (char *str, long i)
 perr_i More...
 
long warning ()
 warning More...
 
long warningx ()
 warningx More...
 
void report_error_main (ptr_psi_term g, char *s, char *s2)
 report_error_main More...
 
void report_error (ptr_psi_term g, char *s)
 report_error More...
 
long reportAndAbort (ptr_psi_term g, char *s)
 reportAndAbort More...
 
void report_warning (ptr_psi_term g, char *s)
 report_warning More...
 
void report_error2_main (ptr_psi_term g, char *s, char *s2)
 report_error2_main More...
 
void report_error2 (ptr_psi_term g, char *s)
 report_error2 More...
 
void report_warning2 (ptr_psi_term g, char *s)
 report_warning2 More...
 
void nonnum_warning (ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
 nonnum_warning More...
 
long nonint_warning (ptr_psi_term arg, REAL val, char *msg)
 nonint_warning More...
 
long bit_and_warning (ptr_psi_term arg, REAL val)
 bit_and_warning More...
 
long bit_or_warning (ptr_psi_term arg, REAL val)
 bit_or_warning More...
 
long bit_not_warning (ptr_psi_term arg, REAL val)
 bit_not_warning More...
 
long int_div_warning (ptr_psi_term arg, REAL val)
 int_div_warning More...
 
long mod_warning (ptr_psi_term arg, REAL val, int zero)
 mod_warning More...
 
long shift_warning (long dir, ptr_psi_term arg, REAL val)
 shift_warning More...
 
ptr_hash_table hash_create (int size)
 HASH_CREATE. More...
 
void hash_expand (ptr_hash_table table, int new_size)
 HASH_EXPAND. More...
 
int hash_code (ptr_hash_table table, char *symbol)
 HASH_CODE. More...
 
int hash_find (ptr_hash_table table, char *symbol)
 hash_find More...
 
ptr_keyword hash_lookup (ptr_hash_table table, char *symbol)
 HASH_LOOKUP. More...
 
void hash_insert (ptr_hash_table table, char *symbol, ptr_keyword keyword)
 HASH_INSERT. More...
 
void hash_display (ptr_hash_table table)
 HASH_DISPLAY. More...
 
void title ()
 TITLE. More...
 
void interrupt ()
 INTERRUPT() More...
 
void init_interrupt ()
 INIT_INTERRUPT. More...
 
void handle_interrupt ()
 HANDLE_INTERRUPT. More...
 
ptr_psi_term stack_psi_term (long stat)
 stack_psi_term More...
 
ptr_psi_term real_stack_psi_term (long stat, REAL thereal)
 real_stack_psi_term More...
 
ptr_psi_term heap_psi_term (long stat)
 heap_psi_term More...
 
void residuate_double (ptr_psi_term t, ptr_psi_term u)
 residuate_double More...
 
void residuate (ptr_psi_term t)
 residuate More...
 
void residuate2 (ptr_psi_term u, ptr_psi_term v)
 residuate2 More...
 
void residuate3 (ptr_psi_term u, ptr_psi_term v, ptr_psi_term w)
 residuate3 More...
 
void curry ()
 curry More...
 
long residuateGoalOnVar (ptr_goal g, ptr_psi_term var, ptr_psi_term othervar)
 residuateGoalOnVar More...
 
long do_residuation_user ()
 do_residuation_user() More...
 
long do_residuation ()
 do_residuation More...
 
void do_currying ()
 do_currying More...
 
void release_resid_main (ptr_psi_term t, long trailflag)
 release_resid_main More...
 
void release_resid (ptr_psi_term t)
 release_resid More...
 
void release_resid_notrail (ptr_psi_term t)
 release_resid_notrail More...
 
void append_resid (ptr_psi_term u, ptr_psi_term v)
 append_resid More...
 
long eval_aim ()
 eval_aim More...
 
void match_attr1 (ptr_node *u, ptr_node v, ptr_resid_block rb)
 void match_attr1 More...
 
void match_attr2 (ptr_node *u, ptr_node v, ptr_resid_block rb)
 match_attr2 More...
 
void match_attr3 (ptr_node *u, ptr_node v, ptr_resid_block rb)
 match_attr3 More...
 
void match_attr (ptr_node *u, ptr_node v, ptr_resid_block rb)
 match_attr More...
 
long match_aim ()
 match_aim More...
 
long i_eval_args (ptr_node n)
 i_eval_args More...
 
long eval_args (ptr_node n)
 eval_args More...
 
void check_disj (ptr_psi_term t)
 check_disj More...
 
void check_func (ptr_psi_term t)
 check_func More...
 
long check_type (ptr_psi_term t)
 check_type More...
 
long i_check_out (ptr_psi_term t)
 i_check_out More...
 
long f_check_out (ptr_psi_term t)
 f_check_out More...
 
long check_out (ptr_psi_term t)
 
long deref_eval (ptr_psi_term t)
 deref_eval More...
 
long deref_rec_eval (ptr_psi_term t)
 deref_rec_eval More...
 
void deref_rec_body (ptr_psi_term t)
 deref_rec_body More...
 
void deref_rec_args (ptr_node n)
 deref_rec_args More...
 
long deref_args_eval (ptr_psi_term t, long set)
 deref_args_eval More...
 
long in_set (char *str, long set)
 in_set More...
 
void deref_rec_args_exc (ptr_node n, long set)
 deref_rec_args_exc More...
 
void deref2_eval (ptr_psi_term t)
 deref2_eval More...
 
void deref2_rec_eval (ptr_psi_term t)
 deref2_rec_eval More...
 
void save_resid (ptr_resid_block rb, ptr_psi_term match_date)
 save_resid More...
 
void restore_resid (ptr_resid_block rb, ptr_psi_term *match_date)
 restore_resid More...
 
void eval_global_var (ptr_psi_term t)
 eval_global_var More...
 
void init_global_vars ()
 init_global_vars More...
 
char ** group_features (char **f, ptr_node n)
 group_features More...
 
void exit_if_true (long exitflag)
 exit_if_true More...
 
void init_io ()
 void init_io More...
 
void init_system ()
 init_system More...
 
void WFInit (long argc, char **argv)
 
int WFInput (char *query)
 WFInput. More...
 
PsiTerm WFGetVar (char *name)
 WFGetVar. More...
 
int WFfeature_count_loop (ptr_node n)
 WFfeature_count_loop. More...
 
int WFFeatureCount (ptr_psi_term psi)
 WFFeatureCount. More...
 
char * WFType (ptr_psi_term psi)
 WFType. More...
 
char ** WFFeatures (ptr_psi_term psi)
 WFFeatures. More...
 
double WFGetDouble (ptr_psi_term psi, int *ok)
 WFGetDouble. More...
 
char * WFGetString (ptr_psi_term psi, int *ok)
 WFGetString. More...
 
PsiTerm WFGetFeature (ptr_psi_term ps, char *feature)
 WFGetFeature. More...
 
int main (int argc, char *argv[])
 main More...
 
void List_SetLinkProc (RefListHeader header, RefListGetLinksProc getLinks)
 List_SetLinkProc. More...
 
void List_InsertAhead (RefListHeader header, Ref atom)
 List_InsertAhead. More...
 
void List_Append (RefListHeader header, Ref atom)
 void List_Append More...
 
void List_InsertBefore (RefListHeader header, Ref atom, Ref mark)
 List_InsertBefore. More...
 
void List_InsertAfter (RefListHeader header, Ref atom, Ref mark)
 List_InsertAfter. More...
 
void List_Swap (RefListHeader header, Ref first, Ref second)
 List_Swap. More...
 
void List_Reverse (RefListHeader header)
 List_Reverse. More...
 
void List_Remove (RefListHeader header, Ref atom)
 List_Remove. More...
 
void List_Concat (RefListHeader header1, RefListHeader header2)
 List_Concat. More...
 
long List_EnumFrom (RefListHeader header, Ref atom, RefListEnumProc proc, Ref closure)
 List_EnumFrom. More...
 
long List_Enum (RefListHeader header, RefListEnumProc proc, Ref closure)
 List_Enum. More...
 
long List_EnumBackFrom (RefListHeader header, Ref atom, RefListEnumProc proc, Ref closure)
 List_EnumBackFrom. More...
 
long List_EnumBack (RefListHeader header, RefListEnumProc proc, Ref closure)
 List_EnumBack. More...
 
long List_Card (RefListHeader header)
 List_Card. More...
 
long List_IsUnlink (RefListLinks links)
 List_IsUnlink. More...
 
void List_Cut (RefListHeader header, Ref atom, RefListHeader newHeader)
 List_Cut. More...
 
void get_two_args (ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
 get_two_args More...
 
void get_one_arg (ptr_node t, ptr_psi_term *a)
 get_one_arg More...
 
void get_one_arg_addr (ptr_node t, ptr_psi_term **a)
 get_one_arg_addr More...
 
void add_rule (ptr_psi_term head, ptr_psi_term body, def_type typ)
 add_rule More...
 
void assert_rule (psi_term t, def_type typ)
 assert_rule More...
 
void assert_clause (ptr_psi_term t)
 assert_clause More...
 
void start_chrono ()
 start_chrono More...
 
void push_ptr_value (type_ptr t, GENERIC *p)
 push_ptr_value More...
 
void push_def_ptr_value (ptr_psi_term q, GENERIC *p)
 push_def_ptr_value More...
 
void push_psi_ptr_value (ptr_psi_term q, GENERIC *p)
 push_psi_ptr_value More...
 
void push_ptr_value_global (type_ptr t, GENERIC *p)
 push_ptr_value_global More...
 
void push_window (long type, long disp, long wind)
 push_window More...
 
void push2_ptr_value (type_ptr t, GENERIC *p, GENERIC v)
 push2_ptr_value More...
 
void push_goal (goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
 push_goal More...
 
void push_choice_point (goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
 push_choice_point More...
 
void undo (ptr_stack limit)
 undo More...
 
void undo_actions ()
 undo_actions More...
 
void backtrack ()
 backtrack More...
 
void clean_undo_window (long disp, long wind)
 clean_undo_window More...
 
void merge1 (ptr_node *u, ptr_node v)
 merge1 More...
 
void merge2 (ptr_node *u, ptr_node v)
 merge2 More...
 
void merge3 (ptr_node *u, ptr_node v)
 merge3 More...
 
void merge (ptr_node *u, ptr_node v)
 merge More...
 
void merge_unify (ptr_node *u, ptr_node v)
 merge_unify More...
 
void show_count ()
 show_count More...
 
void fetch_def (ptr_psi_term u, long allflag)
 fetch_def More...
 
void fetch_def_lazy (ptr_psi_term u, ptr_definition old1, ptr_definition old2, ptr_node old1attr, ptr_node old2attr, long old1stat, long old2stat)
 fetch_def_lazy More...
 
long unify_aim_noeval ()
 unify_aim_noeval More...
 
long unify_aim ()
 unify_aim More...
 
long unify_body (long eval_flag)
 unify_body More...
 
long disjunct_aim ()
 disjunct_aim More...
 
long prove_aim ()
 prove_aim More...
 
void type_disj_aim ()
 type_disj_aim More...
 
long clause_aim (long r)
 clause_aim More...
 
long no_choices ()
 no_choices More...
 
long num_choices ()
 num_choices More...
 
long num_vars (ptr_node vt)
 num_vars More...
 
long what_next_cut ()
 what_next_cut More...
 
ptr_choice_point topmost_what_next ()
 topmost_what_next More...
 
void reset_stacks ()
 reset_stacks More...
 
long what_next_aim ()
 what_next_aim More...
 
long load_aim ()
 load_aim More...
 
void main_prove ()
 main_prove More...
 
int dummy_printf (char *f, char *s, char *t)
 dummy_printf More...
 
long trail_condition (psi_term *Q)
 trail_condition More...
 
ptr_int_list appendIntList (ptr_int_list tail, ptr_int_list more)
 appendIntList More...
 
void mark_ancestors (ptr_definition def, long *flags)
 mark_ancestors More...
 
ptr_int_list lub (ptr_psi_term a, ptr_psi_term b, ptr_psi_term *pp)
 
char * GetStrOption (char *name, char *def)
 GetStrOption. More...
 
int GetBoolOption (char *name)
 GetBoolOption. More...
 
int GetIntOption (char *name, int def)
 GetIntOption. More...
 
void pchoices ()
 pchoices More...
 
void print_undo_stack ()
 print_undo_stack More...
 
long bounds_undo_stack ()
 bounds_undo_stack More...
 
void fail_all ()
 fail_all More...
 
void check_hash_table (ptr_hash_table table)
 check_hash_table More...
 
void check_definition (ptr_definition *d)
 check_definition More...
 
void check_definition_list ()
 check_definition_list More...
 
void check_resid_block (ptr_resid_block *rb)
 check_resid_block More...
 
void check_psi_term (ptr_psi_term *t)
 check_psi_term More...
 
void check_attr (ptr_node *n)
 check_attr More...
 
void check_gamma_code ()
 check_gamma_code More...
 
void print_gc_info (long timeflag)
 print_gc_info More...
 
void garbage ()
 garbage More...
 
GENERIC heap_alloc (long s)
 heap_alloc More...
 
GENERIC stack_alloc (long s)
 stack_alloc More...
 
void init_memory ()
 init_memory () More...
 
long memory_check ()
 memory_check More...
 
void init_modules ()
 init_modules More...
 
ptr_module find_module (char *module)
 find_module More...
 
ptr_module create_module (char *module)
 ptr_module create_module(char *module) More...
 
ptr_module set_current_module (ptr_module module)
 set_current_module More...
 
ptr_module extract_module_from_name (char *str)
 extract_module_from_name More...
 
char * strip_module_name (char *str)
 strip_module_name More...
 
char * string_val (ptr_psi_term term)
 string_val More...
 
char * make_module_token (ptr_module module, char *str)
 make_module_token More...
 
ptr_definition new_definition (ptr_keyword key)
 new_definition More...
 
ptr_definition update_symbol (ptr_module module, char *symbol)
 update_symbol More...
 
char * print_symbol (ptr_keyword k)
 print_symbol More...
 
void pretty_symbol (ptr_keyword k)
 pretty_symbol More...
 
void pretty_quote_symbol (ptr_keyword k)
 pretty_quote_symbol More...
 
long c_set_module ()
 c_set_module More...
 
long c_open_module ()
 c_open_module More...
 
void open_module_tree (ptr_node n, int *onefailed)
 open_module_tree More...
 
void open_module_one (ptr_psi_term t, int *onefailed)
 open_module_one More...
 
long make_public (ptr_psi_term term, long bool)
 make_public More...
 
void traverse_tree (ptr_node n, int flag)
 traverse_tree More...
 
long c_public ()
 c_public More...
 
long c_private ()
 c_private More...
 
long c_display_modules ()
 c_display_modules More...
 
long c_display_persistent ()
 c_display_persistent More...
 
long c_trace_input ()
 c_trace_input More...
 
void replace (ptr_definition old, ptr_definition new, ptr_psi_term term)
 replace More...
 
void rec_replace (ptr_definition old, ptr_definition new, ptr_psi_term term)
 rec_replace More...
 
void replace_attr (ptr_node old_attr, ptr_psi_term term, ptr_definition old, ptr_definition new)
 replace_attr More...
 
long c_replace ()
 c_replace More...
 
long c_current_module ()
 c_current_module More...
 
long c_module_access ()
 c_module_access More...
 
int global_unify (ptr_psi_term u, ptr_psi_term v)
 global_unify More...
 
int global_unify_attr (ptr_node u, ptr_node v)
 global_unify_attr More...
 
long c_alias ()
 c_alias More...
 
int get_module (ptr_psi_term psi, ptr_module *module)
 get_module More...
 
int make_feature_private (ptr_psi_term term)
 make_feature_private More...
 
long c_private_feature ()
 c_private_feature More...
 
ptr_definition update_feature (ptr_module module, char *feature)
 update_feature More...
 
long all_public_symbols ()
 all_public_symbols More...
 
int bad_psi_term (ptr_psi_term t)
 bad_psi_term More...
 
void show (long limit)
 show More...
 
void push (psi_term tok, long prec, long op)
 push More...
 
long pop (ptr_psi_term tok, long *op)
 pop More...
 
long look ()
 look More...
 
long precedence (psi_term tok, long typ)
 precedence More...
 
ptr_psi_term stack_copy_psi_term (psi_term t)
 stack_copy_psi_term More...
 
ptr_psi_term heap_copy_psi_term (psi_term t)
 heap_copy_psi_term More...
 
void feature_insert (char *keystr, ptr_node *tree, ptr_psi_term psi)
 feature_insert More...
 
psi_term list_nil (ptr_definition type)
 list_nil More...
 
psi_term parse_list (ptr_definition typ, char e, char s)
 parse_list More...
 
psi_term read_psi_term ()
 read_psi_term More...
 
psi_term make_life_form (ptr_psi_term tok, ptr_psi_term arg1, ptr_psi_term arg2)
 make_life_form More...
 
void crunch (long prec, long limit)
 crunch More...
 
psi_term read_life_form (char ch1, char ch2)
 read_life_form More...
 
psi_term parse (long *q)
 parse More...
 
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...
 
long c_begin_raw ()
 
long c_get_raw ()
 
long c_put_raw ()
 
long c_end_raw ()
 
long c_in_raw ()
 
long c_window_flag ()
 
long c_reset_window_flag ()
 
void raw_setup_builtins ()
 raw_setup_builtins More...
 
long call_primitive (long(*fun)(), int num, psi_arg argi[], GENERIC info)
 call_primitive More...
 
ptr_psi_term fileptr2stream (FILE *fp, ptr_definition typ)
 fileptr2stream More...
 
int text_buffer_next (struct text_buffer *buf, int idx, char c, struct text_buffer **rbuf, int *ridx)
 text_buffer_next More...
 
char * text_buffer_cmp (struct text_buffer *buf, int idx, char *str)
 text_buffer_cmp More...
 
void text_buffer_push (struct text_buffer **buf, char c)
 text_buffer_push More...
 
void text_buffer_free (struct text_buffer *buf)
 text_buffer_free More...
 
int is_ipaddr (char *s)
 is_ipaddr More...
 
void make_sys_type_links ()
 make_sys_type_links More...
 
void check_sys_definitions ()
 check_sys_definitions More...
 
void insert_sys_builtins ()
 insert_sys_builtins More...
 
void insert_dbm_builtins ()
 
long get_arg (ptr_psi_term g, ptr_psi_term *arg, char *number)
 get_arg More...
 
void TOKEN_ERROR (ptr_psi_term p)
 TOKEN_ERROR. More...
 
void stdin_cleareof ()
 stdin_cleareof More...
 
void heap_add_int_attr (ptr_psi_term t, char *attrname, long value)
 heap_add_int_attr More...
 
void stack_add_int_attr (ptr_psi_term t, char *attrname, long value)
 stack_add_int_attr More...
 
void heap_mod_int_attr (ptr_psi_term t, char *attrname, long value)
 heap_mod_int_attr More...
 
void heap_add_str_attr (ptr_psi_term t, char *attrname, char *str)
 heap_add_str_attr More...
 
void stack_add_str_attr (ptr_psi_term t, char *attrname, char *str)
 stack_add_str_attr More...
 
void heap_mod_str_attr (ptr_psi_term t, char *attrname, char *str)
 heap_mod_str_attr More...
 
void heap_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g)
 heap_add_psi_attr More...
 
void stack_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g)
 stack_add_psi_attr More...
 
void bk_stack_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g)
 bk_stack_add_psi_attr More...
 
GENERIC get_attr (ptr_psi_term t, char *attrname)
 get_attr More...
 
FILE * get_stream (ptr_psi_term t)
 get_stream More...
 
void save_state (ptr_psi_term t)
 save_state More...
 
void restore_state (ptr_psi_term t)
 restore_state More...
 
void new_state (ptr_psi_term *t)
 new_state More...
 
void save_parse_state (ptr_parse_block pb)
 save_parse_state More...
 
void restore_parse_state (ptr_parse_block pb)
 restore_parse_state More...
 
void init_parse_state ()
 init_parse_state More...
 
void begin_terminal_io ()
 begin_terminal_io More...
 
void end_terminal_io ()
 end_terminal_io More...
 
char * expand_file_name (char *s)
 expand_file_name More...
 
long open_input_file (char *file)
 open_input_file More...
 
long open_output_file (char *file)
 
long read_char ()
 read_char More...
 
void put_back_char (long c)
 put_back_char More...
 
void put_back_token (psi_term t)
 put_back_token More...
 
void psi_term_error ()
 psi_term_error More...
 
void read_comment (ptr_psi_term tok)
 read_comment More...
 
void read_string_error (int n)
 read_string_error More...
 
int base2int (int n)
 base2int More...
 
void read_string (ptr_psi_term tok, long e)
 read_string More...
 
long symbolic (long c)
 symbolic More...
 
long legal_in_name (long c)
 legal_in_name More...
 
void read_name (ptr_psi_term tok, long ch, long(*f)(), ptr_definition typ)
 
void read_number (ptr_psi_term tok, long c)
 read_number More...
 
void read_token (ptr_psi_term tok)
 read_token More...
 
void read_token_b (ptr_psi_term tok)
 read_token_b More...
 
void read_token_main (ptr_psi_term tok, long for_parser)
 read_token_main More...
 
long intcmp (long a, long b)
 intcmp More...
 
long is_int (char **s, long *len, long *sgn)
 is_int More...
 
long featcmp (char *str1, char *str2)
 featcmp More...
 
char * heap_ncopy_string (char *s, int n)
 heap_ncopy_string More...
 
char * heap_copy_string (char *s)
 heap_copy_string More...
 
char * stack_copy_string (char *s)
 stack_copy_string More...
 
ptr_node general_insert (long comp, char *keystr, ptr_node *tree, GENERIC info, long heapflag, long copystr, long bkflag)
 ptr_node general_insert More...
 
void heap_insert_copystr (char *keystr, ptr_node *tree, GENERIC info)
 heap_insert_copystr More...
 
void stack_insert_copystr (char *keystr, ptr_node *tree, GENERIC info)
 stack_insert_copystr More...
 
ptr_node heap_insert (long comp, char *keystr, ptr_node *tree, GENERIC info)
 heap_insert More...
 
ptr_node stack_insert (long comp, char *keystr, ptr_node *tree, GENERIC info)
 stack_insert More...
 
ptr_node bk_stack_insert (long comp, char *keystr, ptr_node *tree, GENERIC info)
 bk_stack_insert More...
 
ptr_node bk2_stack_insert (long comp, char *keystr, ptr_node *tree, GENERIC info)
 bk2_stack_insert More...
 
ptr_node find (long comp, char *keystr, ptr_node tree)
 find More...
 
ptr_node find_data (GENERIC p, ptr_node t)
 find_data More...
 
void delete_attr (char *s, ptr_node *n)
 delete_attr More...
 
void print_def_type (def_type t)
 print_def_type More...
 
long yes_or_no ()
 yes_or_no More...
 
void remove_cycles (ptr_definition d, ptr_int_list *dl)
 remove_cycles More...
 
long redefine (ptr_psi_term t)
 redefine More...
 
ptr_int_list cons (GENERIC v, ptr_int_list l)
 cons More...
 
long assert_less (ptr_psi_term t1, ptr_psi_term t2)
 assert_less More...
 
void assert_protected (ptr_node n, long prot)
 assert_protected More...
 
void assert_args_not_eval (ptr_node n)
 assert_args_not_eval More...
 
void assert_delay_check (ptr_node n)
 assert_delay_check More...
 
void clear_already_loaded (ptr_node n)
 clear_already_loaded More...
 
void assert_type (ptr_psi_term t)
 assert_type More...
 
void assert_complicated_type (ptr_psi_term t)
 assert_complicated_type More...
 
void assert_attributes (ptr_psi_term t)
 assert_attributes More...
 
void find_adults ()
 find_adults More...
 
void insert_own_prop (ptr_definition d)
 insert_own_prop More...
 
void insert_prop (ptr_definition d, ptr_triple_list prop)
 insert_prop More...
 
void propagate_definitions ()
 propagate_definitions More...
 
long count_sorts (long c0)
 count_sorts More...
 
void clear_coding ()
 clear_coding More...
 
void least_sorts ()
 void least_sorts() More...
 
void all_sorts ()
 all_sorts More...
 
ptr_int_list two_to_the (long p)
 two_to_the More...
 
ptr_int_list copyTypeCode (ptr_int_list u)
 copyTypeCode More...
 
void or_codes (ptr_int_list u, ptr_int_list v)
 or_codes More...
 
void equalize_codes (int len)
 equalize_codes More...
 
void make_type_link (ptr_definition t1, ptr_definition t2)
 make_type_link More...
 
long type_member (ptr_definition t, ptr_int_list tlst)
 type_member More...
 
void perr_sort (ptr_definition d)
 perr_sort More...
 
void perr_sort_list (ptr_int_list anc)
 perr_sort_list More...
 
void perr_sort_cycle (ptr_int_list anc)
 perr_sort_cycle More...
 
long type_cyclicity (ptr_definition d, ptr_int_list anc)
 type_cyclicity More...
 
void propagate_always_check (ptr_definition d, long *ch)
 propagate_always_check More...
 
void one_pass_always_check (long *ch)
 one_pass_always_check More...
 
void inherit_always_check ()
 inherit_always_check More...
 
void encode_types ()
 encode_types More...
 
void print_codes ()
 print_codes More...
 
long glb_value (long result, long f, GENERIC c, GENERIC value1, GENERIC value2, GENERIC *value)
 glb_value More...
 
long glb_code (long f1, GENERIC c1, long f2, GENERIC c2, long *f3, GENERIC *c3)
 glb_code More...
 
long glb (ptr_definition t1, ptr_definition t2, ptr_definition *t3, ptr_int_list *c3)
 glb More...
 
long overlap_type (ptr_definition t1, ptr_definition t2)
 overlap_type More...
 
long sub_CodeType (ptr_int_list c1, ptr_int_list c2)
 sub_CodeType More...
 
long sub_type (ptr_definition t1, ptr_definition t2)
 sub_type More...
 
long matches (ptr_definition t1, ptr_definition t2, long *smaller)
 matches More...
 
long strict_matches (ptr_psi_term t1, ptr_psi_term t2, long *smaller)
 strict_matches More...
 
long bit_length (ptr_int_list c)
 bit_length More...
 
ptr_int_list decode (ptr_int_list c)
 decode More...
 
ptr_goal GoalFromPsiTerm (ptr_psi_term psiTerm)
 GoalFromPsiTerm. More...
 

Detailed Description

prototypes

Definition in file def_proto.h.

Function Documentation

long abort_life ( int  nlflag)

abort_life

Parameters
nlflag- int nlflag

Definition at line 2259 of file built_ins.c.

References aborthooksym, abortsym, wl_pair_list::bbbb_2, DEFRULES, FALSE, function_it, init_system(), main_loop_ok, NOTQUIET, NULL, prove, push_goal(), wl_definition::rule, stack_psi_term(), stdin_cleareof(), TRUE, wl_psi_term::type, wl_definition::type_def, undo(), and var_occurred.

2260 {
2262  !aborthooksym->rule->bbbb_2 ||
2264  /* Do a true abort if aborthook is not a function or is equal to 'abort'.*/
2265  main_loop_ok = FALSE;
2266  undo(NULL); /* 8.10 */
2267  if(NOTQUIET) fprintf(stderr,"\n*** Abort"); /* RM: Feb 17 1993 */
2268  if(NOTQUIET && nlflag) fprintf(stderr,"\n");/* RM: Feb 17 1993 */
2269  } else {
2270  /* Do a 'user-defined abort': initialize the system, then */
2271  /* prove the user-defined abort routine (which is set by */
2272  /* means of 'setq(aborthook,user_defined_abort)'. */
2273  ptr_psi_term aborthook;
2274 
2275  undo(NULL);
2276  init_system();
2278  stdin_cleareof();
2279  if(NOTQUIET) fprintf(stderr,"\n*** Abort"); /* RM: Feb 17 1993 */
2280  if(NOTQUIET && nlflag) fprintf(stderr,"\n");/* RM: Feb 17 1993 */
2281  aborthook=stack_psi_term(0);
2282  aborthook->type=aborthooksym;
2284  }
2285  fprintf(stderr,"\n*** END Abort");
2286  return TRUE;
2287 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void undo(ptr_stack limit)
undo
Definition: login.c:691
long main_loop_ok
Definition: def_glob.h:1023
#define NOTQUIET
Definition: def_macro.h:15
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void init_system()
init_system
Definition: lib.c:83
def_type type_def
Definition: def_struct.h:153
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition abortsym
symbol in bi module
Definition: def_glob.h:126
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_psi_term bbbb_2
Definition: def_struct.h:206
ptr_definition type
Definition: def_struct.h:181
ptr_definition aborthooksym
symbol in bi module
Definition: def_glob.h:133
void stdin_cleareof()
stdin_cleareof
Definition: token.c:51
long var_occurred
???
Definition: def_glob.h:839
void add_rule ( ptr_psi_term  head,
ptr_psi_term  body,
def_type  typ 
)

add_rule

Parameters
head- ptr_psi_term head
body- ptr_psi_term body
typ- def_type typ

ADD_RULE(head,body,typ) The TYP argument is either 'predicate', 'function', or 'type'. For predicates or functions, insert the clause 'HEAD :- BODY' or the rule 'HEAD -> BODY' into the definition of HEAD. For types, insert HEAD as a term of type attributes and BODY as a type constraint. The global flag ASSERT_FIRST indicates whether to do the insertion at the head or the tail of the existing list.

Definition at line 167 of file login.c.

References wl_pair_list::aaaa_2, assert_first, assert_ok, wl_psi_term::attr_list, wl_pair_list::bbbb_2, clear_copy(), wl_keyword::combined_name, wl_psi_term::coref, current_module, deref_ptr, Errorline(), HEAP, HEAP_ALLOC, wl_definition::keyword, MAX_BUILT_INS, wl_module::module_name, wl_pair_list::next, NULL, predicate_it, quote_copy(), redefine(), wl_psi_term::resid, wl_definition::rule, succeed, wl_keyword::symbol, TRUE, wl_psi_term::type, wl_definition::type_def, undef_it, and wl_psi_term::value_3.

168 {
169  psi_term succ;
170  ptr_psi_term head2;
171  ptr_definition def;
172  ptr_pair_list p, *p2;
173 
174  if (!body && typ==(def_type)predicate_it) {
175  succ.type=succeed;
176  succ.value_3=NULL;
177  succ.coref=NULL;
178  succ.resid=NULL;
179  succ.attr_list=NULL;
180  body= ≻
181  }
182 
183  deref_ptr(head);
184  head2=head;
185 
186  /* assert(head->resid==NULL); 10.8 */
187  /* assert(body->resid==NULL); 10.8 */
188 
189  if (redefine(head)) {
190 
191  def=head->type;
192 
193  if (def->type_def==(def_type)undef_it || def->type_def==typ)
194 
195  /* RM: Jan 27 1993 */
196  if(TRUE
197  /* def->type==undef_it ||
198  def->keyword->module==current_module */
199  /* RM: Feb 2 1993 Commented out */
200  ) {
201  if (def->rule && (unsigned long)def->rule<=MAX_BUILT_INS) {
202  Errorline("the built-in %T '%s' may not be redefined.\n",
203  def->type_def, def->keyword->symbol);
204  }
205  else {
206  def->type_def=typ;
207 
208  /* PVR single allocation in source */
210  clear_copy();
211  /* p->aaaa_3=exact_copy(head2,HEAP); 24.8 25.8 */
212  /* p->bbbb_3=exact_copy(body,HEAP); 24.8 25.8 */
213 
214  p->aaaa_2=quote_copy(head2,HEAP); /* 24.8 25.8 */
215  p->bbbb_2=quote_copy(body,HEAP); /* 24.8 25.8 */
216 
217  if (assert_first) {
218  p->next=def->rule;
219  def->rule=p;
220  }
221  else {
222  p->next=NULL;
223  p2= &(def->rule);
224  while (*p2) {
225  p2= &((*p2)->next);
226  }
227  *p2=p;
228  }
229  assert_ok=TRUE;
230  }
231  }
232  else { /* RM: Jan 27 1993 */
233  Errorline("the %T '%s' may not be redefined from within module %s.\n",
234  def->type_def,
235  def->keyword->combined_name,
237  }
238  else {
239  Errorline("the %T '%s' may not be redefined as a %T.\n",
240  def->type_def, def->keyword->symbol, typ);
241  }
242  }
243 }
ptr_psi_term aaaa_2
Definition: def_struct.h:205
ptr_residuation resid
Definition: def_struct.h:189
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
ptr_definition succeed
symbol in bi module
Definition: def_glob.h:389
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
long assert_first
Definition: def_glob.h:1032
void clear_copy()
clear_copy
Definition: copy.c:53
char * combined_name
Definition: def_struct.h:119
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
ptr_pair_list next
Definition: def_struct.h:207
long redefine(ptr_psi_term t)
redefine
Definition: types.c:104
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
char * symbol
Definition: def_struct.h:118
long assert_ok
Definition: def_glob.h:1033
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
quote_copy
Definition: copy.c:186
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term bbbb_2
Definition: def_struct.h:206
char * module_name
Definition: def_struct.h:106
ptr_psi_term coref
Definition: def_struct.h:188
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
ptr_definition type
Definition: def_struct.h:181
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_node attr_list
Definition: def_struct.h:187
long all_public_symbols ( )

all_public_symbols

ALL_PUBLIC_SYMBOLS Returns all public symbols from all modules or a specific module.

Definition at line 1363 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, deref_ptr, first_definition, get_module(), get_two_args(), wl_definition::keyword, wl_keyword::module, wl_definition::next, NULL, wl_keyword::public, push_goal(), stack_cons(), stack_nil(), stack_psi_term(), TRUE, wl_psi_term::type, and unify.

1364 {
1365  ptr_psi_term arg1,arg2,funct,result;
1366  ptr_psi_term list;
1367  ptr_psi_term car;
1368  ptr_module module=NULL;
1369  ptr_definition d;
1370 
1371  funct=aim->aaaa_1;
1372  deref_ptr(funct);
1373  result=aim->bbbb_1;
1374  get_two_args(funct->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
1375 
1376  if(arg1) {
1377  deref_ptr(arg1);
1378  (void)get_module(arg1,&module);
1379  }
1380  else
1381  module=NULL;
1382 
1383  list=stack_nil();
1384 
1385  for(d=first_definition;d;d=d->next)
1386  if(d->keyword->public && (!module || d->keyword->module==module)) {
1387  car=stack_psi_term(4);
1388  car->type=d;
1389  list=stack_cons(car,list);
1390  }
1391 
1392  push_goal(unify,result,list,NULL);
1393 
1394  return TRUE;
1395 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
ptr_definition next
Definition: def_struct.h:164
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_module module
Definition: def_struct.h:117
ptr_definition type
Definition: def_struct.h:181
int get_module(ptr_psi_term psi, ptr_module *module)
get_module
Definition: modules.c:1226
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
all_sorts ( )

all_sorts

ALL_SORTS() Build a list of all sorts (except nothing) in nothing->parents.

Definition at line 759 of file types.c.

References cons(), first_definition, wl_definition::next, nothing, wl_definition::parents, wl_definition::type_def, and type_it.

760 {
761  ptr_definition d;
762 
763  for(d=first_definition;d;d=d->next)
764  if (d->type_def==(def_type)type_it && d!=nothing)
766 }
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
def_type type_def
Definition: def_struct.h:153
ptr_int_list cons(GENERIC v, ptr_int_list l)
cons
Definition: types.c:179
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition next
Definition: def_struct.h:164
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_int_list parents
Definition: def_struct.h:151
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 append_files ( char *  s1,
char *  s2 
)

append_files

Parameters
s1- char *s1
s2- char *s2

Definition at line 5543 of file built_ins.c.

References Errorline(), FALSE, and TRUE.

5544 {
5545  FILE *f1;
5546  FILE *f2;
5547  long result=FALSE;
5548 
5549  f1=fopen(s1,"a");
5550  if(f1) {
5551  f2=fopen(s2,"r");
5552  if(f2) {
5553  while(!feof(f2))
5554  (void)fputc(fgetc(f2),f1);
5555  (void)fclose(f2);
5556  (void)fclose(f1);
5557  result=TRUE;
5558  }
5559  else
5560  Errorline("couldn't open \"%s\"\n",f2);
5561  /* printf("*** Error: couldn't open \"%s\"\n",f2); PVR 14.9.93 */
5562  }
5563  else
5564  Errorline("couldn't open \"%s\"\n",f1);
5565  /* printf("*** Error: couldn't open \"%s\"\n",f1); PVR 14.9.93 */
5566 
5567  return result;
5568 }
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
void append_resid ( ptr_psi_term  u,
ptr_psi_term  v 
)

append_resid

Parameters
u- ptr_psi_term u
v- ptr_psi_term v

APPEND_RESID(u,v) Append the residuations pending on V to U. This routine does not check that the same constraint is not present twice in the end on U. This doesn't matter since RELEASE_RESID ensures that the same constraint is not released more than once.

Definition at line 474 of file lefun.c.

References push_ptr_value(), wl_psi_term::resid, and resid_ptr.

475 {
476  ptr_residuation *g;
477 
478  g= &(u->resid);
479  while (*g)
480  g = &((*g)->next);
481 
483  *g=v->resid;
484 }
ptr_residuation resid
Definition: def_struct.h:189
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define resid_ptr
values of type_ptr
Definition: def_const.h:390
ptr_int_list appendIntList ( ptr_int_list  tail,
ptr_int_list  more 
)

appendIntList

Parameters
tail- ptr_int_list tail
more- ptr_int_list more

attach copies of more to tail

Definition at line 40 of file lub.c.

References wl_int_list::next, NULL, STACK_ALLOC, and wl_int_list::value_1.

41 {
42  while (more)
43  {
44  tail->next = STACK_ALLOC(int_list);
45  tail= tail->next;
46  tail->value_1 = more->value_1;
47  tail->next = NULL;
48  more = more->next;
49  }
50  return tail;
51 }
#define NULL
Definition: def_const.h:533
#define STACK_ALLOC(A)
Definition: def_macro.h:21
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
void assert_args_not_eval ( ptr_node  n)

assert_args_not_eval

Parameters
n- ptr_node n

ASSERT_ARGS_NOT_EVAL(n) Mark all the nodes in the attribute tree N as having unevaluated arguments, if they are functions or predicates.

Definition at line 294 of file types.c.

References wl_node::data, deref_ptr, wl_definition::evaluate_args, FALSE, wl_definition::keyword, wl_node::left, wl_node::right, wl_keyword::symbol, wl_psi_term::type, wl_definition::type_def, type_it, and warningline().

295 {
296  ptr_psi_term t;
297 
298  if (n) {
300 
301  t=(ptr_psi_term)n->data;
302  deref_ptr(t);
303  if (t->type) {
304  if (t->type->type_def==(def_type)type_it) {
305  warningline("'%s' is a sort--only functions and predicates\
306  can have unevaluated arguments.\n",t->type->keyword->symbol);
307  }
308  else
310  }
311 
313  }
314 }
char evaluate_args
Definition: def_struct.h:156
void assert_args_not_eval(ptr_node n)
assert_args_not_eval
Definition: types.c:294
def_type type_def
Definition: def_struct.h:153
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
char * symbol
Definition: def_struct.h:118
ptr_node left
Definition: def_struct.h:199
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
ptr_node right
Definition: def_struct.h:200
void assert_attributes ( ptr_psi_term  t)

assert_attributes

Parameters
t- ptr_psi_term t

ASSERT_ATTRIBUTES(t) T is of the form ':: type(attributes) | pred', the attributes must be appended to T's definition, and will be propagated after ENCODING to T's subtypes.

Definition at line 500 of file types.c.

References add_rule(), wl_psi_term::attr_list, deref_ptr, Errorline(), function_it, get_two_args(), wl_definition::keyword, NULL, predicate_it, wl_keyword::symbol, TRUE, wl_psi_term::type, wl_definition::type_def, type_it, types_modified, and wl_const_3.

501 {
502  ptr_psi_term arg1,arg2,pred=NULL,typ;
503  ptr_definition d;
504 
505  get_two_args(t->attr_list,&arg1,&arg2);
506 
507  if (arg1) {
508  typ=arg1;
509  deref_ptr(arg1);
510  if (!strcmp(arg1->type->keyword->symbol,"|")) {
511  get_two_args(arg1->attr_list,&arg1,&pred);
512  if (arg1) {
513  typ=arg1;
514  deref_ptr(arg1);
515  }
516  }
517 
518  if (arg1 && wl_const_3(*arg1)) {
519  /* if (!redefine(arg1)) return; RM: Feb 19 1993 */
520  d=arg1->type;
522  Errorline("the %T '%s' may not be redefined as a sort.\n",
523  d->type_def, d->keyword->symbol);
524  }
525  else {
528  add_rule(typ,pred,(def_type)type_it);
529  }
530  }
531  else {
532  Errorline("bad argument in sort declaration '%P' (%E).\n",t);
533  }
534  }
535  else {
536  Errorline("argument missing in sort declaration (%E).\n");
537  }
538 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
struct wl_definition * def_type
Definition: def_struct.h:60
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
char * symbol
Definition: def_struct.h:118
long types_modified
Definition: def_glob.h:1022
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define wl_const_3(S)
Definition: def_macro.h:109
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
void add_rule(ptr_psi_term head, ptr_psi_term body, def_type typ)
add_rule
Definition: login.c:167
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
void assert_clause ( ptr_psi_term  t)

assert_clause

Parameters
t- ptr_psi_term t

ASSERT_CLAUSE(t) Assert the clause T. Cope with various syntaxes for predicates.

ASSERT_FIRST is a flag indicating the position: 1= insert before existing rules (asserta), 0= insert after existing rules (assert),

Definition at line 287 of file login.c.

References add_rule(), assert_attributes(), assert_complicated_type(), assert_ok, assert_rule(), deref_ptr, equ_tok, FALSE, function_it, NULL, and predicate_it.

288 {
289  assert_ok=FALSE;
290  deref_ptr(t);
291 
292  /* RM: Feb 22 1993 defined c_alias in modules.c
293  if (equ_tok((*t),"alias")) {
294  get_two_args(t->attr_list,&arg1,&arg2);
295  if (arg1 && arg2) {
296  warningline("'%s' has taken the meaning of '%s'.\n",
297  arg2->type->keyword->symbol, arg1->type->keyword->symbol);
298  str=arg2->type->keyword->symbol;
299  assert_ok=TRUE;
300  deref_ptr(arg1);
301  deref_ptr(arg2);
302  *(arg2->type)= *(arg1->type);
303  arg2->type->keyword->symbol=str;
304  }
305  else
306  Errorline("arguments missing in %P.\n",t);
307  }
308  else
309  */
310 
311  if (equ_tok((*t),":-"))
313  else
314  if (equ_tok((*t),"->"))
316  else
317  if (equ_tok((*t),"::"))
319  else
320 
321 #ifdef CLIFE
322  if (equ_tok((*t),"block_struct"))
323  define_block(t);
324  else
325 #endif /* CLIFE */
326  /* if (equ_tok((*t),"<<<-")) { RM: Feb 10 1993
327  declare T as global. To do... maybe.
328  }
329  else
330  */
331 
332  if (equ_tok((*t),"<|") || equ_tok((*t),":="))
334  else
336 
337  /* if (!assert_ok && warning()) perr("the declaration is ignored.\n"); */
338 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
void assert_rule(psi_term t, def_type typ)
assert_rule
Definition: login.c:257
void assert_complicated_type(ptr_psi_term t)
assert_complicated_type
Definition: types.c:405
#define NULL
Definition: def_const.h:533
long assert_ok
Definition: def_glob.h:1033
#define deref_ptr(P)
Definition: def_macro.h:100
void assert_attributes(ptr_psi_term t)
assert_attributes
Definition: types.c:500
void add_rule(ptr_psi_term head, ptr_psi_term body, def_type typ)
add_rule
Definition: login.c:167
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define equ_tok(A, B)
Definition: def_macro.h:67
void assert_complicated_type ( ptr_psi_term  t)

assert_complicated_type

Parameters
t- ptr_psi_term t

ASSERT_COMPLICATED_TYPE This deals with all the type declarations of the form:

a(attr) <| b. % (a<|b) a(attr) <| b | pred.

a(attr) <| {b;c;d}. % (a<|b, a<|c, a<|d) a(attr) <| {b;c;d} | pred.

a := b(attr). % (a<|b) a := b(attr) | pred.

a := {b(attr1);c(attr2);d(attr3)}. % (b<|a,c<|a,d<|a) a := {b(attr1);c(attr2);d(attr3)} | pred.

Definition at line 405 of file types.c.

References add_rule(), assert_less(), assert_ok, wl_psi_term::attr_list, deref_ptr, disjunction, equ_tok, Errorline(), FALSE, get_two_args(), wl_definition::keyword, nil, NULL, wl_keyword::symbol, TRUE, wl_psi_term::type, type_it, and warningline().

406 {
407  ptr_psi_term arg2,typ1,typ2,pred=NULL;
408  // ptr_list lst;
409  long eqflag = equ_tok((*t),":=");
410  long ok, any_ok=FALSE;
411 
412  get_two_args(t->attr_list,&typ1,&arg2);
413 
414  if (typ1 && arg2) {
415  deref_ptr(typ1);
416  deref_ptr(arg2);
417  typ2=arg2;
418  if (!strcmp(arg2->type->keyword->symbol,"|")) {
419  typ2=NULL;
420  get_two_args(arg2->attr_list,&arg2,&pred);
421  if (arg2) {
422  deref_ptr(arg2);
423  typ2=arg2;
424  }
425  }
426  if (typ2) {
427  if (typ2->type==disjunction) {
428 
429  if (typ1->attr_list && eqflag) {
430  warningline("attributes ignored left of ':=' declaration (%E).\n");
431  }
432  while(typ2 && typ2->type!=nil) {
433  get_two_args(typ2->attr_list,&arg2,&typ2); /* RM: Dec 14 1992 */
434  if(typ2)
435  deref_ptr(typ2);
436  if (arg2) {
437  deref_ptr(arg2);
438  if (eqflag) {
439  ok=assert_less(arg2,typ1);
440  if (ok) any_ok=TRUE;
441  if (ok && (arg2->attr_list || pred!=NULL)) {
442  add_rule(arg2,pred,(def_type)type_it);
443  }
444  }
445  else {
446  ok=assert_less(typ1,arg2);
447  if (ok) any_ok=TRUE;
448  if (ok && arg2->attr_list) {
449  warningline("attributes ignored in sort declaration (%E).\n");
450  }
451  }
452  }
453  }
454  assert_ok=TRUE;
455  }
456  else if (eqflag) {
457  if (typ1->attr_list) {
458  warningline("attributes ignored left of ':=' declaration (%E).\n");
459  }
460  ok=assert_less(typ1,typ2);
461  if (ok) any_ok=TRUE;
462  typ2->type=typ1->type;
463  if (ok && (typ2->attr_list || pred!=NULL))
464  add_rule(typ2,pred,(def_type)type_it);
465  else
466  assert_ok=TRUE;
467  }
468  else {
469  if (typ2->attr_list) {
470  warningline("attributes ignored right of '<|' declaration (%E).\n");
471  }
472  ok=assert_less(typ1,typ2);
473  if (ok) any_ok=TRUE;
474  if (ok && (typ1->attr_list || pred!=NULL))
475  add_rule(typ1,pred,(def_type)type_it);
476  else
477  assert_ok=TRUE;
478  }
479  }
480  else {
481  Errorline("argument missing in sort declaration (%E).\n");
482  }
483  }
484  else {
485  Errorline("argument missing in sort declaration (%E).\n");
486  }
487  if (!any_ok) assert_ok=FALSE;
488 }
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long assert_less(ptr_psi_term t1, ptr_psi_term t2)
assert_less
Definition: types.c:200
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
char * symbol
Definition: def_struct.h:118
long assert_ok
Definition: def_glob.h:1033
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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
#define equ_tok(A, B)
Definition: def_macro.h:67
void add_rule(ptr_psi_term head, ptr_psi_term body, def_type typ)
add_rule
Definition: login.c:167
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
void assert_delay_check ( ptr_node  n)

assert_delay_check

Parameters
n- ptr_node n

ASSERT_DELAY_CHECK(n) Assert that the types in the attribute tree N will have their properties checked only when they have attributes. If they have no attributes, then no properties are checked.

Definition at line 326 of file types.c.

References wl_definition::always_check, wl_node::data, deref_ptr, FALSE, wl_node::left, wl_node::right, and wl_psi_term::type.

327 {
328  if (n) {
329  ptr_psi_term t;
331 
332  t=(ptr_psi_term)n->data;
333  deref_ptr(t);
334  if (t->type) {
335  t->type->always_check=FALSE;
336  }
337 
339  }
340 }
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
char always_check
Definition: def_struct.h:154
ptr_node left
Definition: def_struct.h:199
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
void assert_delay_check(ptr_node n)
assert_delay_check
Definition: types.c:326
ptr_definition type
Definition: def_struct.h:181
ptr_node right
Definition: def_struct.h:200
long assert_less ( ptr_psi_term  t1,
ptr_psi_term  t2 
)

assert_less

Parameters
t1- ptr_psi_term t1
t2- ptr_psi_term t2

ASSERT_LESS(t1,t2) Assert that T1 <| T2. Return false if some sort of error occurred.

Definition at line 200 of file types.c.

References deref_ptr, Errorline(), FALSE, function_it, wl_definition::keyword, make_type_link(), predicate_it, redefine(), wl_keyword::symbol, top, TRUE, wl_psi_term::type, wl_definition::type_def, type_it, types_modified, and wl_psi_term::value_3.

201 {
202  ptr_definition d1,d2;
203  long ok=FALSE;
204  deref_ptr(t1);
205  deref_ptr(t2);
206 
207  if (t1->type==top) {
208  Errorline("the top sort '@' may not be a subsort.\n");
209  return FALSE;
210  }
211  if (t1->value_3 || t2->value_3) {
212  Errorline("the declaration '%P <| %P' is illegal.\n",t1,t2);
213  return FALSE;
214  }
215  /* Note: A *full* cyclicity check of the hierarchy is done in encode_types. */
216  if (t1->type==t2->type) {
217  Errorline("cyclic sort declarations are not allowed.\n");
218  return FALSE;
219  }
220 
221  if (!redefine(t1)) return FALSE;
222  if (!redefine(t2)) return FALSE;
223  d1=t1->type;
224  d2=t2->type;
226  Errorline("the %T '%s' may not be redefined as a sort.\n",
227  d1->type_def, d1->keyword->symbol);
228  }
229  else if (d2->type_def==(def_type)predicate_it || d2->type_def==(def_type)function_it) {
230  Errorline("the %T '%s' may not be redefined as a sort.\n",
231  d2->type_def, d2->keyword->symbol);
232  }
233  else {
237  make_type_link(d1, d2); /* 1.7 */
238  /* d1->parents=cons(d2,d1->parents); */
239  /* d2->children=cons(d1,d2->children); */
240  ok=TRUE;
241  }
242 
243  return ok;
244 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
struct wl_definition * def_type
Definition: def_struct.h:60
long redefine(ptr_psi_term t)
redefine
Definition: types.c:104
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
long types_modified
Definition: def_glob.h:1022
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
void make_type_link(ptr_definition t1, ptr_definition t2)
make_type_link
Definition: types.c:901
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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
GENERIC value_3
Definition: def_struct.h:186
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition type
Definition: def_struct.h:181
void assert_protected ( ptr_node  n,
long  prot 
)

assert_protected

Parameters
n- ptr_node n
prot- long prot

ASSERT_PROTECTED(n,prot) Mark all the nodes in the attribute tree N with protect flag prot.

Definition at line 255 of file types.c.

References wl_node::data, wl_definition::date, deref_ptr, wl_definition::keyword, wl_node::left, MAX_BUILT_INS, wl_definition::protected, wl_node::right, wl_definition::rule, wl_keyword::symbol, wl_psi_term::type, wl_definition::type_def, type_it, and warningline().

256 {
257  ptr_psi_term t;
258 
259  if (n) {
260  assert_protected(n->left,prot);
261 
262  t=(ptr_psi_term)n->data;
263  deref_ptr(t);
264  if (t->type) {
265  if (t->type->type_def==(def_type)type_it) {
266  warningline("'%s' is a sort. It can be extended without a declaration.\n",
267  t->type->keyword->symbol);
268  }
269  else if ((unsigned long)t->type->rule<MAX_BUILT_INS &&
270  (unsigned long)t->type->rule>0) {
271  if (!prot)
272  warningline("'%s' is a built-in--it has not been made dynamic.\n",
273  t->type->keyword->symbol);
274  }
275  else {
276  t->type->protected=prot;
277  if (prot) t->type->date&=(~1); else t->type->date|=1;
278  }
279  }
280 
281  assert_protected(n->right,prot);
282  }
283 }
def_type type_def
Definition: def_struct.h:153
ptr_keyword keyword
Definition: def_struct.h:147
void assert_protected(ptr_node n, long prot)
assert_protected
Definition: types.c:255
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
char * symbol
Definition: def_struct.h:118
ptr_node left
Definition: def_struct.h:199
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_pair_list rule
Definition: def_struct.h:148
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
ptr_node right
Definition: def_struct.h:200
void assert_rule ( psi_term  t,
def_type  typ 
)

assert_rule

Parameters
t- psi_term t
typ- def_type typ

ASSERT_RULE(t,typ) Add a rule to the rule tree. It may be either a predicate or a function. The psi_term T is of the form 'H :- B' or 'H -> B', but it may be incorrect (report errors). TYP is the type, function or predicate.

Definition at line 257 of file login.c.

References add_rule(), wl_psi_term::attr_list, get_two_args(), and Syntaxerrorline().

258 {
259  ptr_psi_term head;
260  ptr_psi_term body;
261 
262  get_two_args(t.attr_list,&head,&body);
263  if (head)
264  if (body)
265  add_rule(head,body,typ);
266  else {
267  Syntaxerrorline("body missing in definition of %T '%P'.\n", typ, head);
268  }
269  else {
270  Syntaxerrorline("head missing in definition of %T.\n",typ);
271  }
272 }
void Syntaxerrorline(char *format,...)
Syntaxerrorline.
Definition: error.c:557
void add_rule(ptr_psi_term head, ptr_psi_term body, def_type typ)
add_rule
Definition: login.c:167
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_node attr_list
Definition: def_struct.h:187
void assert_type ( ptr_psi_term  t)

assert_type

Parameters
t- ptr_psi_term t

ASSERT_TYPE(t) T is the psi_term <|(type1,type2). Add that to the type-definitions.

Definition at line 372 of file types.c.

References assert_less(), assert_ok, wl_psi_term::attr_list, Errorline(), get_two_args(), and NULL.

373 {
374  ptr_psi_term arg1,arg2;
375 
376  get_two_args(t->attr_list,&arg1,&arg2);
377  if(arg1==NULL || arg2==NULL) {
378  Errorline("bad sort declaration '%P' (%E).\n",t);
379  }
380  else
381  assert_ok=assert_less(arg1,arg2);
382 }
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long assert_less(ptr_psi_term t1, ptr_psi_term t2)
assert_less
Definition: types.c:200
#define NULL
Definition: def_const.h:533
long assert_ok
Definition: def_glob.h:1033
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
ptr_node attr_list
Definition: def_struct.h:187
void backtrack ( )

backtrack

BACKTRACK() Undo everything back to the previous choice-point and take the alternative decision. This routine would have to be modified, along with UNDO to cope with goals to be proved on backtracking.

Definition at line 772 of file login.c.

References choice_stack, wl_choice_point::goal_stack, goal_stack, wl_choice_point::next, NULL, resid_aim, stack_pointer, wl_choice_point::stack_top, undo(), and wl_choice_point::undo_point.

773 {
774  // long gts;
775 
778 #ifdef TS
779  /* global_time_stamp=choice_stack->time_stamp; */ /* 9.6 */
780 #endif
783  resid_aim=NULL;
784 
785 
786  /* assert((unsigned long)stack_pointer>=(unsigned long)cut_point); 13.6 */
787  /* This situation occurs frequently in some benchmarks (e.g comb) */
788  /* printf("*** Possible GC error: cut_point is dangling\n"); */
789  /* fflush(stdout); */
790 
791  /* assert((unsigned long)stack_pointer>=(unsigned long)match_date); 13.6 */
792 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
ptr_goal goal_stack
Definition: def_glob.h:1025
void undo(ptr_stack limit)
undo
Definition: login.c:691
ptr_stack undo_point
Definition: def_struct.h:248
GENERIC stack_top
Definition: def_struct.h:251
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
ptr_choice_point next
Definition: def_struct.h:250
ptr_goal goal_stack
Definition: def_struct.h:249
ptr_choice_point choice_stack
Definition: def_glob.h:1026
int bad_psi_term ( ptr_psi_term  t)

bad_psi_term

Parameters
t- ptr_psi_term t

BAD_PSI_TERM(t) This returns true if T is a psi_term which is not allowed to be considered as a constant by the parser.

Example: "A=)+6." would otherwise be parsed as: "=(A,+(')',6))", this was going a bit far.

Definition at line 31 of file parser.c.

References final_dot, final_question, wl_definition::keyword, wl_keyword::symbol, TRUE, and wl_psi_term::type.

32 {
33  char *s,c;
34  long r;
35 
36  if(t->type==final_dot || t->type==final_question) /* RM: Jul 9 1993 */
37  return TRUE;
38 
39  s=t->type->keyword->symbol;
40  c=s[0];
41  r=(s[1]==0 &&
42  (c=='(' ||
43  c==')' ||
44  c=='[' ||
45  c==']' ||
46  c=='{' ||
47  c=='}'
48  /* || c=='.' || c=='?' RM: Jul 7 1993 */
49  )
50  );
51 
52  return r;
53 }
ptr_definition final_question
symbol in syntax module
Definition: def_glob.h:615
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
ptr_definition final_dot
symbol in syntax module
Definition: def_glob.h:608
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_definition type
Definition: def_struct.h:181
int base2int ( int  n)

base2int

Parameters
n- int n

Definition at line 816 of file token.c.

817 {
818  switch (n) {
819  case '0': return 0;
820  case '1': return 1;
821  case '2': return 2;
822  case '3': return 3;
823  case '4': return 4;
824  case '5': return 5;
825  case '6': return 6;
826  case '7': return 7;
827  case '8': return 8;
828  case '9': return 9;
829  case 'a':
830  case 'A': return 10;
831  case 'b':
832  case 'B': return 11;
833  case 'c':
834  case 'C': return 12;
835  case 'd':
836  case 'D': return 13;
837  case 'e':
838  case 'E': return 14;
839  case 'f':
840  case 'F': return 15;
841  default:
842  fprintf(stderr,"base2int('%c'): illegal argument\n",n);
843  exit(EXIT_FAILURE);
844  }
845 }
void begin_terminal_io ( )

begin_terminal_io

BEGIN_TERMINAL_IO() These two routines must bracket any I/O directed to the terminal. This is to avoid mix-ups between terminal and file I/O since the program's input and output streams may be different from stdin stdout. See the routine what_next_aim(), which uses them to isolate the user interface I/O from the program's own I/O.

Definition at line 493 of file token.c.

References inchange, input_state, input_stream, open_input_file(), out, outchange, and output_stream.

494 {
495  inchange = (input_stream!=stdin);
496  outchange = (output_stream!=stdout);
497 
498  if (outchange) {
500  output_stream=stdout;
501  }
502 
503  if (inchange) {
505  (void)open_input_file("stdin");
506  }
507 }
ptr_psi_term input_state
Definition: def_glob.h:856
ptr_psi_term old_state
Definition: token.c:480
static long outchange
Definition: token.c:478
FILE * input_stream
Definition: def_glob.h:1014
static long inchange
Definition: token.c:478
static FILE * out
Definition: token.c:479
FILE * output_stream
Definition: def_glob.h:1017
long open_input_file(char *file)
open_input_file
Definition: token.c:594
long bit_and_warning ( ptr_psi_term  arg,
REAL  val 
)

bit_and_warning

Parameters
arg- ptr_psi_term arg
val- REAL val

Definition at line 992 of file error.c.

References nonint_warning().

993 {
994  return nonint_warning(arg,val,"of bitwise 'and' operation is not an integer");
995 }
long nonint_warning(ptr_psi_term arg, REAL val, char *msg)
nonint_warning
Definition: error.c:974
long bit_length ( ptr_int_list  c)

bit_length

Parameters
c- ptr_int_list c

BIT_LENGTH(c) Returns the number of bits needed to code C. That is the rank of the first non NULL bit of C.

Examples: C= 1001001000 result=7 C= 10000 result=1 C= 0000000 result=0

Definition at line 1753 of file types.c.

References INT_SIZE, wl_int_list::next, and wl_int_list::value_1.

1754 {
1755  unsigned long p=0,dp=0,v=0,dv=0;
1756 
1757  while (c) {
1758  v=(unsigned long)c->value_1;
1759  if(v) {
1760  dp=p;
1761  dv=v;
1762  }
1763  c=c->next;
1764  p=p+INT_SIZE;
1765  }
1766 
1767  while (dv) {
1768  dp++;
1769  dv=dv>>1;
1770  }
1771 
1772  return dp;
1773 }
#define INT_SIZE
How many types can be encoded on one integer in the transitive closure encoding.
Definition: def_const.h:317
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
long bit_not_warning ( ptr_psi_term  arg,
REAL  val 
)

bit_not_warning

Parameters
arg- ptr_psi_term arg
val- REAL val

Definition at line 1016 of file error.c.

References nonint_warning().

1017 {
1018  return nonint_warning(arg,val,"of bitwise 'not' operation is not an integer");
1019 }
long nonint_warning(ptr_psi_term arg, REAL val, char *msg)
nonint_warning
Definition: error.c:974
long bit_or_warning ( ptr_psi_term  arg,
REAL  val 
)

bit_or_warning

Parameters
arg- ptr_psi_term arg
val- REAL val

Definition at line 1004 of file error.c.

References nonint_warning().

1005 {
1006  return nonint_warning(arg,val,"of bitwise 'or' operation is not an integer");
1007 }
long nonint_warning(ptr_psi_term arg, REAL val, char *msg)
nonint_warning
Definition: error.c:974
ptr_node bk2_stack_insert ( long  comp,
char *  keystr,
ptr_node tree,
GENERIC  info 
)

bk2_stack_insert

Parameters
comp- long comp
keystr- char *keystr
tree- ptr_node *tree
info- GENERIC info

BK2_STACK_INSERT(comp,keystr,tree,info) Insert the pointer INFO under the reference string KEYSTR of length len in the binary tree TREE. Return the pointer to the permanent storage place of KEY. This is used by C_APPLY_LABEL Always trail the change.

Definition at line 377 of file trees.c.

References FALSE, general_insert(), and STACK.

378 {
379 
380  return general_insert(comp,keystr,tree,info,STACK,FALSE,2L);
381 }
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_node general_insert(long comp, char *keystr, ptr_node *tree, GENERIC info, long heapflag, long copystr, long bkflag)
ptr_node general_insert
Definition: trees.c:224
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
void bk_mark_quote ( ptr_psi_term  t)

bk_mark_quote

Parameters
t- ptr_psi_term t

Back-trackably mark a psi-term as completely evaluated.

Definition at line 708 of file copy.c.

References wl_psi_term::attr_list, bk_mark_quote(), bk_mark_quote_tree(), wl_psi_term::coref, wl_psi_term::flags, heap_pointer, int_ptr, push_ptr_value(), QUOTED_TRUE, RMASK, and wl_psi_term::status.

709 {
710  if (t && !(t->status&RMASK)) {
711  if(t->status!=4 && (GENERIC)t<heap_pointer)/* RM: Jul 16 1993 */
713  t->status = 4;
714  t->flags=QUOTED_TRUE; /* 14.9 */
715  t->status |= RMASK;
716  bk_mark_quote(t->coref);
718  t->status &= ~RMASK;
719  }
720 }
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
void bk_mark_quote_tree(ptr_node t)
bk_mark_quote_tree
Definition: copy.c:728
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
void bk_mark_quote(ptr_psi_term t)
bk_mark_quote
Definition: copy.c:708
#define RMASK
Bit mask for status field of psi-terms: RMASK is used as a flag to avoid infinite loops when tracing ...
Definition: def_const.h:359
ptr_psi_term coref
Definition: def_struct.h:188
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void bk_mark_quote_tree ( ptr_node  t)

bk_mark_quote_tree

Parameters
t- ptr_node t

Definition at line 728 of file copy.c.

References bk_mark_quote(), bk_mark_quote_tree(), wl_node::data, wl_node::left, and wl_node::right.

729 {
730  if (t) {
734  }
735 }
void bk_mark_quote_tree(ptr_node t)
bk_mark_quote_tree
Definition: copy.c:728
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
void bk_mark_quote(ptr_psi_term t)
bk_mark_quote
Definition: copy.c:708
ptr_node right
Definition: def_struct.h:200
void bk_stack_add_psi_attr ( ptr_psi_term  t,
char *  attrname,
ptr_psi_term  g 
)

bk_stack_add_psi_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
g- ptr_psi_term g

Definition at line 252 of file token.c.

References wl_psi_term::attr_list, bk_stack_insert(), FEATCMP, and heap_copy_string().

253 {
254  (void)bk_stack_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list), (GENERIC)g);
255 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_node bk_stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
bk_stack_insert
Definition: trees.c:357
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
ptr_node attr_list
Definition: def_struct.h:187
ptr_node bk_stack_insert ( long  comp,
char *  keystr,
ptr_node tree,
GENERIC  info 
)

bk_stack_insert

Parameters
comp- long comp
keystr- char *keystr
tree- ptr_node *tree
info- GENERIC info

BK_STACK_INSERT(comp,keystr,tree,info) Insert the pointer INFO under the reference string KEYSTR of length len in the binary tree TREE. Return the pointer to the permanent storage place of KEY. This is used by C_APPLY_LABEL Trail the change with a trail check.

Definition at line 357 of file trees.c.

References FALSE, general_insert(), and STACK.

358 {
359 
360  return general_insert(comp,keystr,tree,info,STACK,FALSE,1L);
361 }
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_node general_insert(long comp, char *keystr, ptr_node *tree, GENERIC info, long heapflag, long copystr, long bkflag)
ptr_node general_insert
Definition: trees.c:224
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
long bounds_undo_stack ( )

bounds_undo_stack

Address field in undo_stack is within range The only valid address outside this range is that of xevent_state

Definition at line 143 of file memory.c.

References wl_stack::aaaa_3, FALSE, mem_base, mem_limit, wl_stack::next, TRUE, wl_stack::type, undo_action, undo_stack, and VALID_ADDRESS.

144 {
146 
147  while (u) {
148  if ( (GENERIC)u<mem_base
149  || (GENERIC)u>mem_limit
150  || (!VALID_ADDRESS(u->aaaa_3) && !(u->type & undo_action))
151  ) {
152  if ((GENERIC)u<mem_base || (GENERIC)u>mem_limit) {
153  printf("\nUNDO: u=%lx\n",(long)u);
154  }
155  else {
156  printf("\nUNDO: u:%lx type:%ld a:%lx b:%lx next:%lx\n",
157  (unsigned long)u,(unsigned long)u->type,(unsigned long)u->aaaa_3,(unsigned long)u->bbbb_3,(unsigned long)u->next);
158  }
159  (void)fflush(stdout);
160  return FALSE;
161  }
162  u=u->next;
163  }
164 
165  return TRUE;
166 }
#define VALID_ADDRESS(A)
Definition: def_macro.h:137
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
type_ptr type
Definition: def_struct.h:231
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC * aaaa_3
Definition: def_struct.h:232
#define undo_action
Fast checking for an undo action.
Definition: def_const.h:484
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
ptr_stack next
Definition: def_struct.h:234
long c_abort ( )

c_abort

C_ABORT Return to the top level of the interpreter.

Definition at line 2247 of file built_ins.c.

References abort_life(), and TRUE.

2248 {
2249  return (abort_life(TRUE));
2250 }
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
#define TRUE
Standard boolean.
Definition: def_const.h:268
long c_alias ( )

c_alias

C_ALIAS Alias one keyword to another.

Definition at line 1180 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_keyword::combined_name, wl_keyword::definition, deref_ptr, Errorline(), FALSE, get_two_args(), hash_lookup(), wl_definition::keyword, wl_module::module_name, wl_keyword::symbol, wl_module::symbol_table, TRUE, wl_psi_term::type, and warningline().

1181 {
1182  long success=TRUE;
1183  ptr_psi_term arg1,arg2,g;
1184  ptr_keyword key;
1185 
1186  g=aim->aaaa_1;
1187 
1188  deref_ptr(g);
1189  get_two_args(g->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
1190  if (arg1 && arg2) {
1191  deref_ptr(arg1);
1192  deref_ptr(arg2);
1193 
1195  if(key) {
1196  if(key->definition!=arg2->type) {
1197  warningline("alias: '%s' has now been overwritten by '%s'\n",
1198  key->combined_name,
1199  arg2->type->keyword->combined_name);
1200 
1201  key->definition=arg2->type;
1202  }
1203  }
1204  else
1205  Errorline("module violation: cannot alias '%s' from module \"%s\"\n",
1206  key->combined_name,
1208  }
1209  else {
1210  success=FALSE;
1211  Errorline("argument(s) missing in '%P'\n",g);
1212  }
1213 
1214  return success;
1215 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
char * combined_name
Definition: def_struct.h:119
ptr_definition definition
Definition: def_struct.h:122
ptr_hash_table symbol_table
Definition: def_struct.h:110
ptr_keyword keyword
Definition: def_struct.h:147
ptr_module current_module
Definition: modules.c:15
char * symbol
Definition: def_struct.h:118
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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_goal aim
Definition: def_glob.h:1024
char * module_name
Definition: def_struct.h:106
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long c_append_file ( )

c_append_file

C_APPEND_FILE Append the file named by argument 2 to the file named by argument 1. This predicate will not residuate; it requires string arguments.

Definition at line 5890 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_node::data, deref, deref_args, deref_ptr, Errorline(), FALSE, FEATCMP, find(), one, overlap_type(), quoted_string, set_1_2, TRUE, two, wl_psi_term::type, and wl_psi_term::value_3.

5891 {
5892  ptr_psi_term g;
5893  ptr_node n1,n2;
5894  long success=TRUE;
5895  ptr_psi_term arg1;
5896  char * c_arg1;
5897  ptr_psi_term arg2;
5898  char * c_arg2;
5899 
5900  g=aim->aaaa_1;
5901  deref_ptr(g);
5902 
5903  /* Evaluate all arguments first: */
5904  n1=find(FEATCMP,one,g->attr_list);
5905  if (n1) {
5906  arg1= (ptr_psi_term )n1->data;
5907  deref(arg1);
5908  }
5909  n2=find(FEATCMP,two,g->attr_list);
5910  if (n2) {
5911  arg2= (ptr_psi_term )n2->data;
5912  deref(arg2);
5913  }
5914  deref_args(g,set_1_2);
5915 
5916  if (success) {
5917  if (n1) {
5918  if (overlap_type(arg1->type,quoted_string))
5919  if (arg1->value_3)
5920  c_arg1= (char *)arg1->value_3;
5921  else {
5922  success=FALSE;
5923  Errorline("bad argument in %P.\n",g);
5924  }
5925  else
5926  success=FALSE;
5927  }
5928  else {
5929  success=FALSE;
5930  Errorline("bad argument in %P.\n",g);
5931  };
5932  };
5933 
5934  if (success) {
5935  if (n2) {
5936  if (overlap_type(arg2->type,quoted_string))
5937  if (arg2->value_3)
5938  c_arg2= (char *)arg2->value_3;
5939  else {
5940  success=FALSE;
5941  Errorline("bad argument in %P.\n",g);
5942  }
5943  else
5944  success=FALSE;
5945  }
5946  else {
5947  success=FALSE;
5948  Errorline("bad argument in %P.\n",g);
5949  };
5950  };
5951 
5952  if (success)
5953  success=append_files(c_arg1,c_arg2);
5954 
5955  return success;
5956 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * two
Definition: def_glob.h:892
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
long append_files(char *s1, char *s2)
append_files
Definition: built_ins.c:5543
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long c_args ( )

c_args

C_ARGS Return the Unix "ARGV" array as a list of strings. RM: Sep 20 1993

Definition at line 6123 of file built_ins.c.

References aim, arg_c, arg_v, wl_goal::bbbb_1, heap_copy_string(), NULL, push_goal(), quoted_string, stack_cons(), stack_nil(), stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

6124 {
6125  ptr_psi_term result,list,str;
6126  long success=TRUE;
6127  int i;
6128 
6129  result=aim->bbbb_1;
6130 
6131  list=stack_nil();
6132  for(i=arg_c-1; i>=0; i--) {
6133  str=stack_psi_term(0);
6134  str->type=quoted_string;
6136  list=stack_cons((ptr_psi_term)str,(ptr_psi_term)list);
6137  }
6138  push_goal(unify,result,list,NULL);
6139 
6140  return success;
6141 }
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
int arg_c
set from argc in either life.c or lib.c
Definition: def_glob.h:20
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
char * arg_v[ARGNN]
set from argv in either life.c or lib.c
Definition: def_glob.h:27
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long c_begin_raw ( )
long c_concatenate ( )

c_concatenate

C_CONCATENATE Concatenate the strings in arguments 1 and 2.

Definition at line 5577 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), one, overlap_type(), quoted_string, residuate(), set_1_2, TRUE, two, wl_psi_term::type, and wl_psi_term::value_3.

5578 {
5579  ptr_psi_term result,funct,temp_result;
5580  ptr_node n1, n2;
5581  long success=TRUE;
5582  long all_args=TRUE;
5583  char * c_result;
5584  ptr_psi_term arg1;
5585  char * c_arg1;
5586  ptr_psi_term arg2;
5587  char * c_arg2;
5588 
5589  funct=aim->aaaa_1;
5590  deref_ptr(funct);
5591  result=aim->bbbb_1;
5592 
5593  /* Evaluate all arguments first: */
5594  n1=find(FEATCMP,one,funct->attr_list);
5595  if (n1) {
5596  arg1= (ptr_psi_term )n1->data;
5597  deref(arg1);
5598  }
5599  n2=find(FEATCMP,two,funct->attr_list);
5600  if (n2) {
5601  arg2= (ptr_psi_term )n2->data;
5602  deref(arg2);
5603  }
5604  deref_args(funct,set_1_2);
5605 
5606  if (success) {
5607  if (n1) {
5608  if (overlap_type(arg1->type,quoted_string)) /* 10.8 */
5609  if (arg1->value_3)
5610  c_arg1= (char *)arg1->value_3;
5611  else {
5612  residuate(arg1);
5613  all_args=FALSE;
5614  }
5615  else
5616  success=FALSE;
5617  }
5618  else {
5619  all_args=FALSE;
5620  curry();
5621  };
5622  };
5623 
5624  if (success) {
5625  if (n2) {
5626  if (overlap_type(arg2->type,quoted_string)) /* 10.8 */
5627  if (arg2->value_3)
5628  c_arg2= (char *)arg2->value_3;
5629  else {
5630  residuate(arg2);
5631  all_args=FALSE;
5632  }
5633  else
5634  success=FALSE;
5635  }
5636  else {
5637  all_args=FALSE;
5638  curry();
5639  }
5640  }
5641 
5642  if(success && all_args) {
5643  c_result=str_conc( c_arg1, c_arg2 );
5644  temp_result=stack_psi_term(0);
5645  temp_result->type=quoted_string;
5646  temp_result->value_3= (GENERIC)c_result;
5647  push_goal(unify,temp_result,result,NULL);
5648  }
5649 
5650  return success;
5651 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
char * two
Definition: def_glob.h:892
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#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 deref(P)
Definition: def_macro.h:147
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
char * str_conc(char *s1, char *s2)
str_conc
Definition: built_ins.c:5496
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long c_current_module ( )

c_current_module

C_CURRENT_MODULE Return the current module.

Definition at line 974 of file modules.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, deref_ptr, heap_copy_string(), wl_module::module_name, NULL, push_goal(), quoted_string, resid_aim, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

975 {
976  long success=TRUE;
977  ptr_psi_term result,g,other;
978 
979  g=aim->aaaa_1;
980  deref_ptr(g);
981  result=aim->bbbb_1;
982  deref_ptr(result);
983 
984  other=stack_psi_term(4);
985  /* PVR 24.1.94 */
986  other->type=quoted_string;
988  /*
989  update_symbol(current_module,
990  current_module->module_name)
991  ->keyword->symbol
992  );
993 */ /* RM: 2/15/1994 */
994  /* other->type=update_symbol(current_module,current_module->module_name); */
995  resid_aim=NULL;
996  push_goal(unify,result,other,NULL);
997 
998  return success;
999 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
ptr_module current_module
Definition: modules.c:15
ptr_goal resid_aim
Definition: def_glob.h:865
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * module_name
Definition: def_struct.h:106
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long c_deref_length ( )

c_deref_length

C_DEREF_LENGTH Return the length of the dereference chain for argument 1. RM: Jul 15 1993

Definition at line 6087 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, wl_psi_term::coref, curry(), wl_node::data, deref_ptr, FEATCMP, find(), one, REAL, TRUE, and unify_real_result().

6088 {
6089  ptr_psi_term result,funct;
6090  long success=TRUE;
6091  int count;
6092  ptr_psi_term arg1; // ,arg2;
6093  ptr_node n1;
6094 
6095  funct=aim->aaaa_1;
6096  deref_ptr(funct);
6097  result=aim->bbbb_1;
6098 
6099  n1=find(FEATCMP,one,funct->attr_list);
6100  if (n1) {
6101  count=0;
6102  arg1= (ptr_psi_term )n1->data;
6103  while(arg1->coref) {
6104  count++;
6105  arg1=arg1->coref;
6106  }
6107  success=unify_real_result(result,(REAL)count);
6108  }
6109  else
6110  curry();
6111 
6112  return success;
6113 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long c_display_modules ( )

c_display_modules

C_DISPLAY_MODULES(); Set the display modules switch.

Definition at line 739 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, display_modules, Errorline(), FALSE, get_two_args(), lf_false, lf_true, TRUE, and wl_psi_term::type.

740 {
741  ptr_psi_term arg1,arg2;
742  ptr_psi_term call;
743  int success=TRUE;
744 
745 
746  call=aim->aaaa_1;
747  deref_ptr(call);
748  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
749 
750  if(arg1) {
751  deref_ptr(arg1);
752  if(arg1->type==lf_true)
754  else
755  if(arg1->type==lf_false)
757  else {
758  Errorline("argument should be boolean in '%P'\n",call);
759  success=FALSE;
760  }
761  }
762  else /* No argument: toggle */
764 
765  return success;
766 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
long display_modules
Definition: modules.c:25
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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_goal aim
Definition: def_glob.h:1024
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long c_display_persistent ( )

c_display_persistent

C_DISPLAY_PERSISTENT(); Set the display persistent switch.

Definition at line 775 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, display_persistent, Errorline(), FALSE, get_two_args(), lf_false, lf_true, TRUE, and wl_psi_term::type.

776 {
777  ptr_psi_term arg1,arg2;
778  ptr_psi_term call;
779  int success=TRUE;
780 
781  call=aim->aaaa_1;
782  deref_ptr(call);
783  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
784 
785  if(arg1) {
786  deref_ptr(arg1);
787  if(arg1->type==lf_true)
789  else
790  if(arg1->type==lf_false)
792  else {
793  Errorline("argument should be boolean in '%P'\n",call);
794  success=FALSE;
795  }
796  }
797  else /* No argument: toggle */
799 
800  return success;
801 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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_goal aim
Definition: def_glob.h:1024
long display_persistent
if true print persistent values preceded by "$"
Definition: def_glob.h:748
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long c_end_raw ( )
long c_get_raw ( )
long c_glb ( )

long c_glb

greatest lower bound (djd)

C_GLB(A,B) Return glb(A,B). Continued calls will return each following type in the disjunction of the glb of A,B.

Definition at line 709 of file bi_type.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), decode(), deref, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), glb(), isSubTypeValue(), isValue(), makePsiTerm(), wl_int_list::next, NULL, push_choice_point(), push_goal(), resid_aim, set_1_2, TRUE, wl_psi_term::type, type_disj, unify, wl_int_list::value_1, and wl_psi_term::value_3.

710 {
711  ptr_psi_term func,arg1,arg2, result, other;
712  ptr_definition ans;
713  ptr_int_list complexType;
714  ptr_int_list decodedType = NULL;
715  long ret;
716 
717  func=aim->aaaa_1;
718  deref_ptr(func);
719  get_two_args(func->attr_list,&arg1,&arg2);
720 
721  if ((!arg1) || (!arg2)) {
722  curry();
723  return TRUE;
724  }
725  result = aim->bbbb_1;
726  deref(result);
727  deref(arg1);
728  deref(arg2);
729  deref_args(func, set_1_2);
730 
731  if ((ret=glb(arg1->type, arg2->type, &ans, &complexType)) == 0)
732  return FALSE;
733 
734  if ((ret != 4)&&(isValue(arg1)||isValue(arg2))) {
735  /* glb is one of arg1->type or arg2->type AND at least one is a value */
736  if (!isSubTypeValue(arg1, arg2) && !isSubTypeValue(arg2, arg1))
737  return FALSE;
738  }
739  if (!ans) {
740  decodedType = decode(complexType);
741  ans = (ptr_definition)decodedType->value_1;
742  decodedType = decodedType->next;
743  }
744  other=makePsiTerm(ans);
745 
746  if (isValue(arg1)) other->value_3=arg1->value_3;
747  if (isValue(arg2)) other->value_3=arg2->value_3;
748 
749  if (isValue(arg1) || isValue(arg2)) {
750  if (decodedType) {
751  Errorline("glb of multiple-inheritance value sorts not yet implemented.\n");
752  return FALSE;
753  }
754  }
755 
756  if (decodedType)
757  push_choice_point(type_disj, result,(ptr_psi_term) decodedType,(GENERIC) NULL);
758 
759  resid_aim = NULL;
760  push_goal(unify,result,other,NULL);
761  return TRUE;
762 }
ptr_psi_term makePsiTerm(ptr_definition x)
ptr_psi_term makePsiTerm
Definition: bi_sys.c:573
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
int isSubTypeValue(ptr_psi_term arg1, ptr_psi_term arg2)
isSubTypeValue
Definition: bi_type.c:180
long glb(ptr_definition t1, ptr_definition t2, ptr_definition *t3, ptr_int_list *c3)
glb
Definition: types.c:1481
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_int_list decode(ptr_int_list c)
decode
Definition: types.c:1784
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#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 deref(P)
Definition: def_macro.h:147
struct wl_definition * ptr_definition
Definition: def_struct.h:59
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
#define type_disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1128
long isValue(ptr_psi_term p)
isValue(p)
Definition: bi_type.c:694
ptr_definition type
Definition: def_struct.h:181
GENERIC value_1
Definition: def_struct.h:85
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_int_list next
Definition: def_struct.h:86
long c_halt ( )

c_halt

C_HALT Exit the Wild_Life interpreter.

Definition at line 2208 of file built_ins.c.

References exit_life(), and TRUE.

2209 {
2210  exit_life(TRUE);
2211 }
void exit_life(long nl_flag)
exit_life
Definition: built_ins.c:2219
#define TRUE
Standard boolean.
Definition: def_const.h:268
long c_in_raw ( )
long c_initrandom ( )

c_initrandom

C_INITRANDOM Uses its integer argument to initialize the random number generator, which is the Unix random() function.

Definition at line 6032 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), integer, one, overlap_type(), residuate(), set_1, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

6033 {
6034  ptr_psi_term t;
6035  ptr_node n1;
6036  long success=TRUE;
6037  long all_args=TRUE;
6038  // long c_result;
6039  ptr_psi_term arg1;
6040  long c_arg1;
6041 
6042  t=aim->aaaa_1;
6043  deref_ptr(t);
6044 
6045  /* Evaluate all arguments first: */
6046  n1=find(FEATCMP,one,t->attr_list);
6047  if (n1) {
6048  arg1= (ptr_psi_term )n1->data;
6049  deref(arg1);
6050  }
6051  deref_args(t,set_1);
6052 
6053  if (success) {
6054  if (n1) {
6055  if (overlap_type(arg1->type,integer))
6056  if (arg1->value_3)
6057  c_arg1= (long)(* (double *)(arg1->value_3));
6058  else {
6059  residuate(arg1);
6060  all_args=FALSE;
6061  }
6062  else
6063  success=FALSE;
6064  }
6065  else {
6066  all_args=FALSE;
6067  }
6068  }
6069 
6070 #ifdef SOLARIS
6071  if (success && all_args) randomseed=c_arg1;
6072 #else
6073  if (success && all_args) srandom(c_arg1);
6074 #endif
6075 
6076  return success;
6077 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
#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 deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long c_isa_subsort ( )

long c_isa_subsort

C_ISA_SUBSORT(A,B) if A is a subsort of B => succeed and residuate on B else => fail

Definition at line 664 of file bi_type.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref, deref_args, deref_ptr, FALSE, get_two_args(), isa(), reportAndAbort(), residuate(), set_1_2, and TRUE.

665 {
666  ptr_psi_term pred,arg1,arg2;
667 
668  pred=aim->aaaa_1;
669  deref_ptr(pred);
670  get_two_args(pred->attr_list,&arg1,&arg2);
671 
672  if (!arg1) (void)reportAndAbort(pred,"no first argument");
673  deref(arg1);
674 
675  if (!arg2) (void)reportAndAbort(pred,"no second argument");
676  deref(arg2);
677 
678  deref_args(pred, set_1_2);
679 
680  if (isa(arg1, arg2))
681  {
682  residuate(arg2);
683  return TRUE;
684  }
685  return FALSE;
686 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
static long isa(ptr_psi_term arg1, ptr_psi_term arg2)
isa
Definition: bi_type.c:219
long reportAndAbort(ptr_psi_term g, char *s)
reportAndAbort
Definition: error.c:872
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#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 deref(P)
Definition: def_macro.h:147
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_node attr_list
Definition: def_struct.h:187
long c_lub ( )

long c_lub

least upper bound (djd) C_LUB(A,B) Return lub(A,B). Continued calls will return each following type in the disjunction of the lub of A,B.

Definition at line 773 of file bi_type.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), deref, deref_args, deref_ptr, get_two_args(), lub(), makePsiTerm(), wl_int_list::next, NULL, push_choice_point(), push_goal(), resid_aim, set_1_2, TRUE, type_disj, unify, and wl_int_list::value_1.

774 {
775  ptr_psi_term func,arg1,arg2, result, other;
776  ptr_definition ans=NULL;
777  ptr_int_list decodedType = NULL;
778 
779  func=aim->aaaa_1;
780  deref_ptr(func);
781  get_two_args(func->attr_list,&arg1,&arg2);
782 
783  if ((!arg1) || (!arg2))
784  {
785  curry();
786  return TRUE;
787  }
788  result = aim->bbbb_1;
789  deref(result);
790  deref(arg1);
791  deref(arg2);
792  deref_args(func, set_1_2);
793 
794  /* now lets find the list of types that is the lub */
795 
796  decodedType = lub(arg1, arg2, &other);
797 
798  if (decodedType) {
799  ans = (ptr_definition)decodedType->value_1;
800  decodedType = decodedType->next;
801  other = makePsiTerm(ans);
802  }
803 
804  if (decodedType)
805  push_choice_point(type_disj, result,(ptr_psi_term) decodedType,(GENERIC) NULL);
806 
807  resid_aim = NULL;
808  push_goal(unify,result,other,NULL);
809  return TRUE;
810 }
ptr_psi_term makePsiTerm(ptr_definition x)
ptr_psi_term makePsiTerm
Definition: bi_sys.c:573
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define set_1_2
Set constants for deref_args in lefun.c.
Definition: def_const.h:514
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define deref(P)
Definition: def_macro.h:147
ptr_int_list lub(ptr_psi_term a, ptr_psi_term b, ptr_psi_term *pp)
Definition: lub.c:173
struct wl_definition * ptr_definition
Definition: def_struct.h:59
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
#define type_disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1128
GENERIC value_1
Definition: def_struct.h:85
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_int_list next
Definition: def_struct.h:86
long c_module_access ( )

c_module_access

C_MODULE_ACCESS Return the psi-term Module::Symbol

Definition at line 1008 of file modules.c.

References wl_goal::aaaa_1, aim, deref_ptr, FALSE, and warningline().

1009 {
1010  long success=FALSE;
1011  // ptr_psi_term result,module,symbol,call,other;
1012  ptr_psi_term call;
1013 
1014 
1015  call=aim->aaaa_1;
1016  deref_ptr(call);
1017 
1018  /*
1019  result=aim->bbbb_1;
1020  deref_ptr(result);
1021  get_two_args(call,(ptr_psi_term *)&module,(ptr_psi_term *)&symbol);
1022 
1023  if(module && symbol) {
1024  other=stack_psi_term(4);
1025  other->type=update_symbol(module_access,module_access->module_name);
1026  resid_aim=NULL;
1027  push_goal(unify,result,other,NULL);
1028 
1029  }
1030  */
1031 
1032  warningline("%P not implemented yet...\n",call);
1033 
1034  return success;
1035 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
void warningline(char *format,...)
warningline
Definition: error.c:371
long c_open_module ( )

c_open_module

C_OPEN_MODULE() Open one or more modules, that is, alias all the public words in the current module to the definitions in the argument. An error message is printed for each module that is not successfully opened. If at least one module was not successfully opened, the routine fails.

Definition at line 519 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, and open_module_tree().

520 {
521  ptr_psi_term call;
522  int onefailed=FALSE;
523  call=aim->aaaa_1;
524  deref_ptr(call);
525  if (call->attr_list) {
526  open_module_tree(call->attr_list, &onefailed);
527  }
528  else {
529  Errorline("argument missing in '%P'\n",call);
530  }
531 
532  return !onefailed;
533 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void open_module_tree(ptr_node n, int *onefailed)
open_module_tree
Definition: modules.c:542
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
long c_private ( )

c_private

C_PRIVATE() The argument is a single symbol or a list of symbols. Make them private in the current module if they belong to it.

Definition at line 714 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, MAKE_PRIVATE, traverse_tree(), and TRUE.

715 {
716  ptr_psi_term call;
717  int success;
718 
719  call=aim->aaaa_1;
720  deref_ptr(call);
721  if (call->attr_list) {
723  success=TRUE;
724  } else {
725  Errorline("argument missing in '%P'\n",call);
726  success=FALSE;
727  }
728 
729  return success;
730 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void traverse_tree(ptr_node n, int flag)
traverse_tree
Definition: modules.c:656
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define MAKE_PRIVATE
Definition: modules.c:644
#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_goal aim
Definition: def_glob.h:1024
ptr_node attr_list
Definition: def_struct.h:187
long c_private_feature ( )

c_private_feature

C_PRIVATE_FEATURE() The argument is a single symbol or a list of symbols. Make this feature private to the current module.

Definition at line 1302 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, MAKE_FEATURE_PRIVATE, traverse_tree(), and TRUE.

1303 {
1304  // ptr_psi_term arg1,arg2;
1305  ptr_psi_term call;
1306  int success;
1307 
1308  call=aim->aaaa_1;
1309  deref_ptr(call);
1310  if (call->attr_list) {
1312  success=TRUE;
1313  } else {
1314  Errorline("argument missing in '%P'\n",call);
1315  success=FALSE;
1316  }
1317 
1318  return success;
1319 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void traverse_tree(ptr_node n, int flag)
traverse_tree
Definition: modules.c:656
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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_goal aim
Definition: def_glob.h:1024
#define MAKE_FEATURE_PRIVATE
Definition: modules.c:645
ptr_node attr_list
Definition: def_struct.h:187
long c_public ( )

c_public

C_PUBLIC() The argument(s) are symbols. Make them public in the current module if they belong to it.

Definition at line 687 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, MAKE_PUBLIC, traverse_tree(), and TRUE.

688 {
689  // ptr_psi_term arg1,arg2;
690  ptr_psi_term call;
691  int success;
692 
693  call=aim->aaaa_1;
694  deref_ptr(call);
695  if (call->attr_list) {
697  success=TRUE;
698  } else {
699  Errorline("argument missing in '%P'\n",call);
700  success=FALSE;
701  }
702 
703  return success;
704 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void traverse_tree(ptr_node n, int flag)
traverse_tree
Definition: modules.c:656
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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_goal aim
Definition: def_glob.h:1024
#define MAKE_PUBLIC
Definition: modules.c:643
ptr_node attr_list
Definition: def_struct.h:187
long c_put_raw ( )
long c_quiet ( )

c_quiet

Return the value of not(NOTQUIET).

Definition at line 186 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_goal::bbbb_1, deref_args, deref_ptr, lf_false, lf_true, NOTQUIET, NULL, push_goal(), set_empty, stack_psi_term(), TRUE, wl_psi_term::type, and unify.

187 {
188  ptr_psi_term t,result,ans;
189  long success=TRUE;
190 
191  t=aim->aaaa_1;
193  result=aim->bbbb_1;
194  deref_ptr(result);
195  ans=stack_psi_term(4);
196  ans->type = NOTQUIET ? lf_false : lf_true;
197  push_goal(unify,result,ans,NULL);
198  return success;
199 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
#define NOTQUIET
Definition: def_macro.h:15
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define NULL
Definition: def_const.h:533
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_goal aim
Definition: def_glob.h:1024
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
long c_random ( )

c_random

C_RANDOM Return an integer random number between 0 and abs(argument1). Uses the Unix random() function (rand_r(&seed) for Solaris).

Definition at line 5966 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), integer, NULL, one, overlap_type(), push_goal(), REAL, real_stack_psi_term(), residuate(), set_1, TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

5967 {
5968  ptr_psi_term result,funct;
5969  ptr_node n1;
5970  long success=TRUE;
5971  long all_args=TRUE;
5972  long c_result;
5973  ptr_psi_term arg1;
5974  long c_arg1;
5975 
5976  funct=aim->aaaa_1;
5977  deref_ptr(funct);
5978  result=aim->bbbb_1;
5979 
5980  /* Evaluate all arguments first: */
5981  n1=find(FEATCMP,one,funct->attr_list);
5982  if (n1) {
5983  arg1= (ptr_psi_term )n1->data;
5984  deref(arg1);
5985  }
5986  deref_args(funct,set_1);
5987 
5988  if (success) {
5989  if (n1) {
5990  if (overlap_type(arg1->type,integer))
5991  if (arg1->value_3)
5992  c_arg1= (long)(* (double *)(arg1->value_3));
5993  else {
5994  residuate(arg1);
5995  all_args=FALSE;
5996  }
5997  else
5998  success=FALSE;
5999  }
6000  else {
6001  all_args=FALSE;
6002  curry();
6003  }
6004  }
6005 
6006  if (success && all_args) {
6007  if (c_arg1) {
6008 #ifdef SOLARIS
6009  c_result=(rand_r(&randomseed)<<15) + rand_r(&randomseed);
6010 #else
6011  c_result=random();
6012 #endif
6013  c_result=c_result-(c_result/c_arg1)*c_arg1;
6014  }
6015  else
6016  c_result=0;
6017 
6018  push_goal(unify,real_stack_psi_term(0,(REAL)c_result),result,NULL);
6019  }
6020 
6021  return success;
6022 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_psi_term real_stack_psi_term(long stat, REAL thereal)
real_stack_psi_term
Definition: lefun.c:48
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
#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 deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
long c_replace ( )

c_replace

C_REPLACE() Replace all occurrences of type ARG1 with ARG2 in ARG3.

Definition at line 936 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_node::data, deref_ptr, Errorline(), FALSE, FEATCMP, find(), get_two_args(), NULL, replace(), three, TRUE, and wl_psi_term::type.

937 {
938  ptr_psi_term arg1=NULL;
939  ptr_psi_term arg2=NULL;
940  ptr_psi_term arg3=NULL;
941  ptr_psi_term call;
942  int success=FALSE;
943  ptr_node n;
944 
945  call=aim->aaaa_1;
946  deref_ptr(call);
947 
948  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
949  n=find(FEATCMP,three,call->attr_list);
950  if (n)
951  arg3=(ptr_psi_term)n->data;
952 
953  if(arg1 && arg2 && arg3) {
954  deref_ptr(arg1);
955  deref_ptr(arg2);
956  deref_ptr(arg3);
957  replace(arg1->type,arg2->type,arg3);
958  success=TRUE;
959  }
960  else {
961  Errorline("argument missing in '%P'\n",call);
962  }
963 
964  return success;
965 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
char * three
Definition: def_glob.h:893
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
void replace(ptr_definition old, ptr_definition new, ptr_psi_term term)
replace
Definition: modules.c:851
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
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 c_reset_window_flag ( )
long c_set_module ( )

c_set_module

C_SET_MODULE() This routine retrieves the necessary psi-term to determine the current state of the module mechanism from the heap.

Definition at line 488 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, create_module(), deref_ptr, Errorline(), FALSE, get_two_args(), set_current_module(), string_val(), and TRUE.

489 {
490  ptr_psi_term arg1,arg2;
491  ptr_psi_term call;
492 
493  call=aim->aaaa_1;
494  deref_ptr(call);
495  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
496 
497  if(arg1) {
499  return TRUE;
500  }
501  else {
502  Errorline("argument missing in '%P'\n",call);
503  return FALSE;
504  }
505 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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_goal aim
Definition: def_glob.h:1024
ptr_module create_module(char *module)
ptr_module create_module(char *module)
Definition: modules.c:72
char * string_val(ptr_psi_term term)
string_val
Definition: modules.c:169
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
ptr_node attr_list
Definition: def_struct.h:187
long c_string_length ( )

c_string_length

C_STRING_LENGTH Return the length of the string in argument 1.

Definition at line 5726 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), one, overlap_type(), quoted_string, residuate(), set_1, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

5727 {
5728  ptr_psi_term result,funct;
5729  ptr_node n1;
5730  long success=TRUE;
5731  long all_args=TRUE;
5732  long c_result;
5733  ptr_psi_term arg1;
5734  char * c_arg1;
5735 
5736  funct=aim->aaaa_1;
5737  deref_ptr(funct);
5738  result=aim->bbbb_1;
5739 
5740  /* Evaluate all arguments first: */
5741  n1=find(FEATCMP,one,funct->attr_list);
5742  if (n1) {
5743  arg1= (ptr_psi_term )n1->data;
5744  deref(arg1);
5745  }
5746  deref_args(funct,set_1);
5747 
5748  if (success) {
5749  if (n1) {
5750  if (overlap_type(arg1->type,quoted_string)) /* 10.8 */
5751  if (arg1->value_3)
5752  c_arg1= (char *)arg1->value_3;
5753  else {
5754  residuate(arg1);
5755  all_args=FALSE;
5756  }
5757  else
5758  success=FALSE;
5759  }
5760  else {
5761  all_args=FALSE;
5762  curry();
5763  };
5764  };
5765 
5766  if (success && all_args) {
5767  c_result=strlen(c_arg1);
5768  push_goal(unify,real_stack_psi_term(0,(REAL)c_result),result,NULL);
5769  };
5770 
5771  return success;
5772 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_psi_term real_stack_psi_term(long stat, REAL thereal)
real_stack_psi_term
Definition: lefun.c:48
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define set_1
Set constants for deref_args in lefun.c.
Definition: def_const.h:500
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
#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 deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long c_sub_string ( )

c_sub_string

C_SUB_STRING Return the substring of argument 1 from position argument 2 for a length of argument 3 characters.

Definition at line 5781 of file built_ins.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, curry(), wl_node::data, deref, deref_args, deref_ptr, FALSE, FEATCMP, find(), one, overlap_type(), quoted_string, residuate(), set_1_2_3, three, TRUE, two, wl_psi_term::type, and wl_psi_term::value_3.

5782 {
5783  ptr_psi_term result,funct,temp_result;
5784  ptr_node n1,n2,n3;
5785  long success=TRUE;
5786  long all_args=TRUE;
5787  char * c_result;
5788  ptr_psi_term arg1;
5789  char * c_arg1;
5790  ptr_psi_term arg2;
5791  long c_arg2;
5792  ptr_psi_term arg3;
5793  long c_arg3;
5794 
5795  funct=aim->aaaa_1;
5796  deref_ptr(funct);
5797  result=aim->bbbb_1;
5798 
5799  /* Evaluate all arguments first: */
5800  n1=find(FEATCMP,one,funct->attr_list);
5801  if (n1) {
5802  arg1= (ptr_psi_term )n1->data;
5803  deref(arg1);
5804  }
5805  n2=find(FEATCMP,two,funct->attr_list);
5806  if (n2) {
5807  arg2= (ptr_psi_term )n2->data;
5808  deref(arg2);
5809  }
5810  n3=find(FEATCMP,three,funct->attr_list);
5811  if (n3) {
5812  arg3= (ptr_psi_term )n3->data;
5813  deref(arg3);
5814  }
5815  deref_args(funct,set_1_2_3);
5816 
5817  if (success) {
5818  if (n1) {
5819  if (overlap_type(arg1->type,quoted_string)) /* 10.8 */
5820  if (arg1->value_3)
5821  c_arg1= (char *)arg1->value_3;
5822  else {
5823  residuate(arg1);
5824  all_args=FALSE;
5825  }
5826  else
5827  success=FALSE;
5828  }
5829  else {
5830  all_args=FALSE;
5831  curry();
5832  };
5833  };
5834 
5835  if (success) {
5836  if (n2) {
5837  if (overlap_type(arg2->type,integer)) /* 10.8 */
5838  if (arg2->value_3)
5839  c_arg2= (long)(* (double *)(arg2->value_3));
5840  else {
5841  residuate(arg2);
5842  all_args=FALSE;
5843  }
5844  else
5845  success=FALSE;
5846  }
5847  else {
5848  all_args=FALSE;
5849  curry();
5850  };
5851  };
5852 
5853  if (success) {
5854  if (n3) {
5855  if (overlap_type(arg3->type,integer)) /* 10.8 */
5856  if (arg3->value_3)
5857  c_arg3= (long)(* (double *)(arg3->value_3));
5858  else {
5859  residuate(arg3);
5860  all_args=FALSE;
5861  }
5862  else
5863  success=FALSE;
5864  }
5865  else {
5866  all_args=FALSE;
5867  curry();
5868  };
5869  };
5870 
5871  if (success && all_args) {
5872  c_result=sub_str(c_arg1,c_arg2,c_arg3);
5873  temp_result=stack_psi_term(0);
5874  temp_result->type=quoted_string;
5875  temp_result->value_3=(GENERIC)c_result;
5876  push_goal(unify,temp_result,result,NULL);
5877  };
5878 
5879  return success;
5880 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
char * two
Definition: def_glob.h:892
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
char * three
Definition: def_glob.h:893
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * sub_str(char *s, long p, long n)
sub_str
Definition: built_ins.c:5514
#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 deref(P)
Definition: def_macro.h:147
#define set_1_2_3
Set constants for deref_args in lefun.c.
Definition: def_const.h:521
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
char * one
Definition: def_glob.h:891
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long c_tprove ( )

c_tprove

UNSURE

Definition at line 81 of file bi_sys.c.

References wl_goal::aaaa_1, aim, deref_args, set_empty, set_trace_to_prove(), and TRUE.

82 {
83  ptr_psi_term t;
84 
85  t=aim->aaaa_1;
88  return TRUE;
89 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
void set_trace_to_prove()
set_trace_to_prove
Definition: error.c:727
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
long c_trace ( )

trace

long c_trace() turn tracing on or off

Definition at line 30 of file bi_sys.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_args, deref_ptr, Errorline(), FALSE, get_two_args(), is_top, lf_false, lf_true, set_empty, stepflag, toggle_trace(), trace, TRUE, wl_psi_term::type, and unify_bool_result().

31 {
32  long success=TRUE;
33  ptr_psi_term t,arg1,arg2;
34 
35  t=aim->aaaa_1;
37  get_two_args(t->attr_list,&arg1,&arg2);
38  if (arg1) {
39  deref_ptr(arg1);
40  if (is_top(arg1)) {
42  trace=FALSE;
43  }
44  else if (arg1->type==lf_true)
45  trace=TRUE;
46  else if (arg1->type==lf_false)
47  trace=FALSE;
48  else {
49  Errorline("bad first argument in %P.\n",t);
50  /* report_error(t,"bad first argument"); */
51  success=FALSE;
52  }
53  }
54  if (arg2) {
55  deref_ptr(arg2);
56  if (is_top(arg2)) {
59  }
60  else if (arg2->type==lf_true)
61  stepflag=TRUE;
62  else if (arg2->type==lf_false)
64  else {
65  Errorline("bad second argument in %P.\n",t);
66  /* report_error(t,"bad second argument"); */
67  success=FALSE;
68  }
69  }
70  if (!arg1 && !arg2)
71  toggle_trace();
72  return success;
73 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
#define is_top(T)
Definition: def_macro.h:113
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
long trace
Definition: def_glob.h:913
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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
void toggle_trace()
toggle_trace
Definition: error.c:737
long stepflag
Definition: def_glob.h:676
ptr_goal aim
Definition: def_glob.h:1024
#define deref_args(P, S)
Definition: def_macro.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long c_trace_input ( )

c_trace_input

C_TRACE_INPUT(); Set the trace_input switch.

Definition at line 810 of file modules.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, deref_ptr, Errorline(), FALSE, get_two_args(), lf_false, lf_true, trace_input, TRUE, and wl_psi_term::type.

811 {
812  ptr_psi_term arg1,arg2;
813  ptr_psi_term call;
814  int success=TRUE;
815 
816  call=aim->aaaa_1;
817  deref_ptr(call);
818  get_two_args(call->attr_list,(ptr_psi_term *)&arg1,(ptr_psi_term *)&arg2);
819 
820  if(arg1) {
821  deref_ptr(arg1);
822  if(arg1->type==lf_true)
824  else
825  if(arg1->type==lf_false)
827  else {
828  Errorline("argument should be boolean in '%P'\n",call);
829  success=FALSE;
830  }
831  }
832  else /* No argument: toggle */
834 
835  return success;
836 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
long trace_input
whether to echo characters read
Definition: def_glob.h:756
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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_goal aim
Definition: def_glob.h:1024
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
long c_window_flag ( )
long call_primitive ( long(*)()  fun,
int  num,
psi_arg  argi[],
GENERIC  info 
)

call_primitive

Parameters
fun- (long (*fun)(),
num- int num
argi- psi_arg argi[]
info- GENERIC info

Definition at line 24 of file sys.c.

References wl_goal::aaaa_1, aim, ARGNN, wl_psi_term::attr_list, wl_goal::bbbb_1, c_abort(), curry(), wl_node::data, deref, deref_ptr, Errorline(), FALSE, FEATCMP, find(), JUSTFAIL, MANDATORY, NOVALUE, NULL, overlap_type(), POLYTYPE, REQUIRED, residuate(), sub_type(), TRUE, wl_psi_term::type, psi_arg::type, UNEVALED, and wl_psi_term::value_3.

25 {
26  ptr_psi_term funct,arg,result,argo[ARGNN]; /* no more than 10 arguments */
27  ptr_node n;
28  int allargs=1,allvalues=1,i;
29  funct=aim->aaaa_1;
30  deref_ptr(funct);
31  result=aim->bbbb_1;
32  for (i=0;i<num;i++) {
33  n=find(FEATCMP,argi[i].feature,funct->attr_list);
34  /* argument present */
35  if (n) {
36  arg = (ptr_psi_term) n->data;
37  /* in case we don't want to evaluate the argument
38  just follow the chain of corefs and don't do
39  any of the other checks: they'll have do be done
40  by fun; just go on to the next arg */
41  if (argi[i].options&UNEVALED) {
42  deref_ptr(arg);
43  argo[i]=arg;
44  continue; }
45  /* this arg should be evaled */
46  deref(arg);
47  argo[i]=arg;
48  /* arg of admissible type */
49  if (argi[i].options&POLYTYPE) {
50  ptr_definition *type = (ptr_definition *)argi[i].type;
51  while (*type != NULL)
52  if (overlap_type(arg->type,*type))
53  goto admissible;
54  else type++;
55  }
56  else {
57  if (overlap_type(arg->type,argi[i].type))
58  goto admissible;
59  }
60  /* not admissible */
61  if (argi[i].options&JUSTFAIL) return FALSE;
62  Errorline("Illegal argument in %P.\n",funct);
63  return (c_abort());
64  /* admissible */
65  admissible:
66  /* has value */
67  if (arg->value_3) {
68  ptr_definition *type = (ptr_definition *)argi[i].type;
69  /* paranoid check: really correct type */
70  if (argi[i].options&POLYTYPE) {
71  while (*type != NULL)
72  if (sub_type(arg->type,*type))
73  goto correct;
74  else type++;
75  }
76  else {
77  if (sub_type(arg->type,(ptr_definition)type)) goto correct;
78  }
79  /* type incorrect */
80  if (argi[i].options&JUSTFAIL) return FALSE;
81  Errorline("Illegal argument in %P.\n",funct);
82  return (c_abort());
83  /* correct */
84  correct:;
85  }
86  /* missing value - do we need it */
87  else if (!(argi[i].options&NOVALUE)) allvalues=0;
88  }
89  /* argument missing */
90  else {
91  argo[i]=NULL;
92  if (argi[i].options&MANDATORY) {
93  Errorline("Missing argument '%s' in %P.\n",argi[i].feature,funct);
94  return (c_abort());
95  }
96  else if (argi[i].options&REQUIRED) allargs=0;
97  }
98  }
99  if (allargs)
100  if (allvalues) {
101  return fun(argo,result,funct,info);
102  }
103  else {
104  for (i=0;i<num;i++) {
105  /* if arg present and should be evaled but has no value */
106  if (argo[i] && !(argi[i].options&UNEVALED) && !argo[i]->value_3)
107  residuate(argo[i]);
108  }
109  }
110  else curry();
111  return TRUE;
112 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define MANDATORY
for call_primitive
Definition: def_const.h:818
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
long c_abort()
c_abort
Definition: built_ins.c:2247
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
#define JUSTFAIL
for call_primitive
Definition: def_const.h:725
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_definition type
Definition: def_struct.h:365
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define NOVALUE
for call_primitive
Definition: def_const.h:865
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
#define ARGNN
primitive in sys.c does not allow more than ARGNN (10) arguments
Definition: def_const.h:1387
#define POLYTYPE
for call_primitive
Definition: def_const.h:772
#define UNEVALED
for call_primitive
Definition: def_const.h:678
void check_attr ( ptr_node n)

check_attr

Parameters
n- ptr_node *n

CHECK_ATTR(attribute-tree) Check an attribute tree. (Could improve this by randomly picking left or right subtree for last call optimization. This would never overflow, even on very skewed attribute trees.)

Definition at line 1055 of file memory.c.

References check_psi_term(), check_string(), and unchecked().

1056 {
1057  while (unchecked((GENERIC *)n,sizeof(node))) { // added cast DJD 12/8/2016
1058  check_attr(&((*n)->left));
1059  check_string((GENERIC *)&((*n)->key)); // added cast DJD 12/8/2016
1060  check_psi_term((struct wl_psi_term **)&((*n)->data));
1061 
1062  n = &((*n)->right);
1063  /* check_attr(&((*n)->right)); 9.6 */
1064  }
1065 }
static void check_string(GENERIC *s)
check_string
Definition: memory.c:406
static long unchecked(GENERIC *p, long len)
unchecked
Definition: memory.c:339
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
void check_psi_term(ptr_psi_term *t)
check_psi_term
Definition: memory.c:988
void check_attr(ptr_node *n)
check_attr
Definition: memory.c:1055
void check_definition ( ptr_definition d)

check_definition

Parameters
d- ptr_definition *d

CHECK_DEFINITION This goes through the type tree which contains the parents and children lists for all types, and the attributed code. The code field is not checked as this has been done separately by CHECK_GAMMA.

Definition at line 663 of file memory.c.

References check_code(), check_keyword(), check_kids(), check_operator_data(), check_pair_list(), check_psi_term(), check_triple_list(), wl_definition::keyword, wl_keyword::symbol, type_it, and unchecked().

664 {
665  if(unchecked((GENERIC *)d,sizeof(definition))) { // added cast DJD 12/8/2016
666 
667  check_keyword((ptr_keyword *)&((*d)->keyword)); /* RM: Jan 12 1993 */ // added cast DJD 12/8/2016
668 
669 #ifdef prlDEBUG
670  printf("%lx %20s %ld\n",*d,(*d)->keyword->symbol,amount_used);
671 #endif
672 
673  check_code((ptr_int_list *)&((*d)->code)); // added cast DJD 12/8/2016
674  check_pair_list((ptr_pair_list *)&((*d)->rule)); // added cast DJD 12/8/2016
675  check_triple_list(&((*d)->properties));
676 
677  if ((*d)->type_def==(def_type)type_it) {
678  check_kids(&((*d)->parents));
679  check_kids(&((*d)->children));
680  }
681 
682  check_psi_term(&((*d)->global_value)); /* RM: Feb 9 1993 */
683  check_psi_term(&((*d)->init_value)); /* RM: Mar 23 1993 */
684 
685  check_operator_data(&((*d)->op_data)); /* PVR 5.6 */
686 
687 #ifdef CLIFE
688  check_block_def(&((*d)->block_def)); /* RM: Jan 27 1993 */
689 #endif /* CLIFE */
690  }
691 }
static void check_operator_data(ptr_operator_data *op)
check_operator_data
Definition: memory.c:552
ptr_keyword keyword
Definition: def_struct.h:147
static void check_pair_list(ptr_pair_list *p)
check_pair_list
Definition: memory.c:501
char * symbol
Definition: def_struct.h:118
static long unchecked(GENERIC *p, long len)
unchecked
Definition: memory.c:339
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
static void check_kids(ptr_int_list *c)
check_kids
Definition: memory.c:536
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
static void check_triple_list(ptr_triple_list *p)
check_triple_list
Definition: memory.c:518
void check_psi_term(ptr_psi_term *t)
check_psi_term
Definition: memory.c:988
static void check_code(ptr_int_list *c)
check_code
Definition: memory.c:487
static void check_keyword()
void check_definition_list ( )

check_definition_list

CHECK_DEFINITION_LIST This checks the entire list of definitions.

Definition at line 700 of file memory.c.

References check_definition(), and first_definition.

701 {
702  ptr_definition *d;
703 
704  d= &first_definition;
705 
706  while(*d) {
707  check_definition(d);
708  d= &((*d)->next);
709  }
710 }
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
void check_definition(ptr_definition *d)
check_definition
Definition: memory.c:663
void check_disj ( ptr_psi_term  t)

check_disj

Parameters
t- ptr_psi_term t

CHECK_DISJ(t) Deal with disjunctions.

Definition at line 910 of file lefun.c.

References disj, fail, NULL, push_goal(), traceline(), TRUE, and wl_psi_term::value_3.

911 {
912  traceline("push disjunction goal %P\n",t);
913  if (t->value_3)
914  push_goal(disj,t,t,(GENERIC)TRUE); /* 18.2 PVR */
915  else
917 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
void traceline(char *format,...)
traceline
Definition: error.c:186
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
GENERIC value_3
Definition: def_struct.h:186
#define fail
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1044
#define disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1072
void check_func ( ptr_psi_term  t)

check_func

Parameters
t- ptr_psi_term t

CHECK_FUNC(t) Deal with an unevaluated function: push an 'eval' goal for it, which will cause it to be evaluated.

Definition at line 928 of file lefun.c.

References wl_psi_term::attr_list, check_func_flag, check_out(), copy(), wl_psi_term::coref, disjunction, eval, eval_args(), wl_definition::evaluate_args, get_one_arg(), iff, push_goal(), push_psi_ptr_value(), RMASK, wl_definition::rule, stack_copy_psi_term(), stack_psi_term(), wl_psi_term::status, such_that, traceline(), TRUE, and wl_psi_term::type.

929 {
930  ptr_psi_term result,t1,copy;
931 
932  /* Check for embedded definitions
933  RM: Dec 16 1992 Re-instated this check then disabled it again
934  if (resid_aim) {
935  Errorline("embedded functions appeared in %P.\n",resid_aim->aaaa_1);
936  fail_all();
937  }
938  else */ {
939 
940  traceline("setting up function call %P\n",t);
941  /* Create a psi-term to put the result */
942  result = stack_psi_term(0);
943 
944  /* Make a partial copy of the calling term */
945  copy=stack_copy_psi_term(*t);
946  copy->status &= ~RMASK;
947 
948  /* Bind the calling term to the result */
949  /* push_ptr_value(psi_term_ptr,(GENERIC *)&(t->coref)); */
950  push_psi_ptr_value(t,(GENERIC *)&(t->coref));
951  t->coref=result;
952 
953  /* Evaluate the copy of the calling term */
954  push_goal(eval,copy,result,(GENERIC)t->type->rule);
955 
956  /* Avoid evaluation for built-in functions with unevaluated arguments */
957  /* (cond and such_that) */
959  if (t->type==iff) {
960  get_one_arg(t->attr_list,&t1);
961  if (t1) {
962  /* mark_eval(t1); 24.8 */
963  (void)check_out(t1);
964  }
965  }
966  else if(t->type==disjunction) {
967  }
968  else if (t->type!=such_that) {
969  if (t->type->evaluate_args)
970  (void)eval_args(t->attr_list);
971  /* else mark_quote_tree(t->attr_list); 24.8 25.8 */
972  }
973  }
974 }
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
long eval_args(ptr_node n)
eval_args
Definition: lefun.c:889
char evaluate_args
Definition: def_struct.h:156
long check_out(ptr_psi_term t)
Definition: lefun.c:1083
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_definition iff
symbol in bi module
Definition: def_glob.h:305
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
Definition: login.c:99
#define eval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1086
void traceline(char *format,...)
traceline
Definition: error.c:186
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
copy
Definition: copy.c:248
#define RMASK
Bit mask for status field of psi-terms: RMASK is used as a flag to avoid infinite loops when tracing ...
Definition: def_const.h:359
ptr_pair_list rule
Definition: def_struct.h:148
ptr_definition such_that
symbol in syntax module
Definition: def_glob.h:396
ptr_psi_term coref
Definition: def_struct.h:188
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
static long check_func_flag
Definition: lefun.c:13
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
void check_gamma_code ( )

check_gamma_code

CHECK_GAMMA_CODE() Check and update the code reversing table. In this part, only the codes are checked in the definitions, this is vital because these codes are used later to distinguish between the various data types and to determine the type of the VALUE field in psi_terms. Misunderstanding this caused a lot of bugs in the GC.

Definition at line 1079 of file memory.c.

References check_def_code(), gamma_table, type_count, and unchecked().

1080 {
1081  long i;
1082 
1083  if (unchecked((GENERIC *)&gamma_table,type_count*sizeof(ptr_definition))) { // added cast DJD 12/8/2016
1084  for (i=0;i<type_count;i++)
1085  check_def_code(&(gamma_table[i]));
1086  }
1087 }
long type_count
Definition: def_glob.h:1021
static long unchecked(GENERIC *p, long len)
unchecked
Definition: memory.c:339
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
static void check_def_code(ptr_definition *d)
check_def_code
Definition: memory.c:721
ptr_definition * gamma_table
Definition: def_glob.h:950
void check_hash_table ( ptr_hash_table  table)

check_hash_table

Parameters
table- ptr_hash_table table

CHECK_HASH_TABLE(table) Check a hash table of keywords. The actual table is not stored within LIFE memory.

Definition at line 626 of file memory.c.

References check_keyword(), wl_hash_table::data, and wl_hash_table::size.

627 {
628  long i;
629 
630  for(i=0;i<table->size;i++)
631  if(table->data[i])
632  check_keyword((ptr_keyword *)&(table->data[i]));
633 }
ptr_keyword * data
Definition: def_struct.h:139
static void check_keyword()
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
long check_out ( ptr_psi_term  t)

Definition at line 1083 of file lefun.c.

References wl_psi_term::attr_list, check_func(), check_func_flag, check_type(), deref_ptr, eval_args(), eval_global_var(), FALSE, function_it, global_it, heap_pointer, RMASK, wl_psi_term::status, traceline(), TRUE, wl_psi_term::type, wl_definition::type_def, and type_it.

1084 {
1085  long flag=FALSE;
1086  deref_ptr(t);
1087 
1088  /* traceline("PVR: entering check_out with status %d and term %P\n",
1089  t->status,t); for brunobug.lf PVR 14.2.94 */
1090  traceline("PVR: entering check_out with status %d and term %P\n",
1091  t->status,t); /* for brunobug.lf PVR 14.2.94 */
1092 
1093  if (t->status || (GENERIC)t>=heap_pointer) /* RM: Feb 8 1993 */
1094  flag=TRUE;
1095  else {
1096  t->status |= RMASK;
1097 
1098  switch((long)t->type->type_def) { /* RM: Feb 8 1993 */
1099 
1100  case (long)function_it:
1101  if (check_func_flag) {
1102  check_func(t);
1103  flag=TRUE;
1104  }
1105  else {
1106  /* Function evaluation handled during matching and unification */
1107  flag=TRUE;
1108  }
1109  break;
1110 
1111  case (long)type_it:
1112  flag=check_type(t);
1113  break;
1114 
1115  case (long)global_it: /* RM: Feb 8 1993 */
1116  eval_global_var(t);
1117  (void)check_out(t);
1118  flag=FALSE;
1119  break;
1120 
1121  default:
1122  flag=eval_args(t->attr_list);
1123  }
1124  t->status &= ~RMASK;
1125  }
1126 
1127  return flag;
1128 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
long eval_args(ptr_node n)
eval_args
Definition: lefun.c:889
void eval_global_var(ptr_psi_term t)
eval_global_var
Definition: lefun.c:1440
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
long check_out(ptr_psi_term t)
Definition: lefun.c:1083
def_type type_def
Definition: def_struct.h:153
long check_type(ptr_psi_term t)
check_type
Definition: lefun.c:990
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
void traceline(char *format,...)
traceline
Definition: error.c:186
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define RMASK
Bit mask for status field of psi-terms: RMASK is used as a flag to avoid infinite loops when tracing ...
Definition: def_const.h:359
#define FALSE
Standard boolean.
Definition: def_const.h:275
void check_func(ptr_psi_term t)
check_func
Definition: lefun.c:928
static long check_func_flag
Definition: lefun.c:13
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
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
void check_psi_term ( ptr_psi_term t)

check_psi_term

Parameters
t- ptr_psi_term *t

CHECK_PSI_TERM(t) Explore a psi_term.

Definition at line 988 of file memory.c.

References alist, assert, check_attr(), check_bytedata(), check_definition(), check_resid(), check_string(), choice_stack, cut, Errorline(), heap_pointer, LONELY, mem_limit, NULL, pass, quoted_string, REAL, real, stream, sub_type(), sys_bytedata, unchecked(), and variable.

989 {
990  ptr_list *l;
991 
992  while (unchecked((GENERIC *)t,sizeof(psi_term))) { // added cast DJD 12/8/2016
993 
994  /* A psi-term on the heap has no residuation list. */
995  if (pass==1 && (GENERIC)(*t)>=heap_pointer && (GENERIC)(*t)<mem_limit) {
996  assert((*t)->resid==NULL);
997  }
998  check_definition(&((*t)->type));
999  check_attr(&((*t)->attr_list));
1000 
1001  if ((*t)->value_3) {
1002 
1003  if ((*t)->type==alist) { /* RM: Dec 15 1992 Should be removed */
1004  l=(ptr_list *) &((*t)->value_3);
1005  if (l)
1006  printf("Found an old list!\n");
1007  }
1008  else
1009 
1010  if (sub_type((*t)->type,real))
1011  (void)unchecked((GENERIC *)&((*t)->value_3),sizeof(REAL)); // added cast DJD 12/8/2016
1012  else if (sub_type((*t)->type,quoted_string))
1013  check_string((GENERIC *)&((*t)->value_3)); // added cast DJD 12/8/2016
1014  /* DENYS: BYTEDATA */
1015  else if (sub_type((*t)->type,sys_bytedata))
1016  check_bytedata(&((*t)->value_3));
1017 #ifdef CLIFE
1018  else if ((*t)->type->type==block) { /* RM: Jan 27 1993 */
1019  check_block_value(&((*t)->value_3));
1020  }
1021 #endif /* CLIFE */
1022  else if ((*t)->type==cut) { /* RM: Oct 28 1993 */
1023  /* assert((*t)->value_3 <= (GENERIC)choice_stack); 12.7 17.7 */
1024  if (pass==1 && (*t)->value_3>(GENERIC)choice_stack)
1025  (*t)->value_3=(GENERIC)choice_stack;
1026  (void)unchecked((GENERIC *)&((*t)->value_3),LONELY); // added cast DJD 12/8/2016
1027  }
1028  else if (sub_type((*t)->type,variable)) /* 8.8 */
1029  check_string((GENERIC *)&((*t)->value_3)); // added cast DJD 12/8/2016
1030  else if ((*t)->type!=stream)
1031  Errorline("non-NULL value field in garbage collector, type='%s', value=%d.\n",
1032  (*t)->type->keyword->combined_name,
1033  (*t)->value_3);
1034  }
1035 
1036  /* check_psi_term(&((*t)->coref)); 9.6 */
1037  if ((*t)->resid)
1038  check_resid((ptr_residuation *)&((*t)->resid)); // added cast DJD 12/8/2016
1039 
1040  t = &((*t)->coref);
1041  }
1042 }
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
static void check_bytedata(GENERIC *s)
check_bytedata
Definition: memory.c:451
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
static void check_resid(ptr_residuation *r)
check_resid
Definition: memory.c:915
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
static void check_string(GENERIC *s)
check_string
Definition: memory.c:406
static long pass
Definition: memory.c:21
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
static long unchecked(GENERIC *p, long len)
unchecked
Definition: memory.c:339
struct wl_list * ptr_list
Definition: def_struct.h:66
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
void check_definition(ptr_definition *d)
check_definition
Definition: memory.c:663
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_definition variable
symbol in bi module
Definition: def_glob.h:438
#define LONELY
Definition: memory.c:24
void check_attr(ptr_node *n)
check_attr
Definition: memory.c:1055
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
ptr_choice_point choice_stack
Definition: def_glob.h:1026
#define assert(N)
Definition: memory.c:114
long check_real ( ptr_psi_term  t,
REAL v,
long *  n 
)

check_real

Parameters
t- ptr_psi_term t
v- REAL *v
n- long *n

CHECK_REAL(t,v,n) Like get_real_value, but does not force the type of T to be real.

Definition at line 231 of file built_ins.c.

References FALSE, matches(), REAL, real, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

232 {
233  long success=FALSE;
234  long smaller;
235 
236  if (t) {
237  success=matches(t->type,real,&smaller);
238  if (success) {
239  *n=FALSE;
240  if (smaller && t->value_3) {
241  *v= *(REAL *)t->value_3;
242  *n=TRUE;
243  }
244  }
245  }
246  return success;
247 }
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
void check_resid_block ( ptr_resid_block rb)

check_resid_block

Parameters
rb- ptr_resid_block *rb

CHECK_RESID_BLOCK(rb) Explore a residuation block.

Definition at line 966 of file memory.c.

References check_goal_stack(), check_resid_list(), LONELY, and unchecked().

967 {
968  if (*rb) {
969  if (unchecked((GENERIC *)rb,sizeof(resid_block))) { // added cast DJD 12/8/2016
970  check_goal_stack((ptr_goal *)&((*rb)->ra)); // added cast DJD 12/8/2016
971  check_resid_list(&((*rb)->rv)); /* 21.9 */
972  /* unchecked(&((*rb)->rl),LONELY); 12.6 */ /* 10.6 */
973  (void)unchecked((GENERIC *)&((*rb)->md),LONELY); /* 10.6 */ // added cast DJD 12/8/2016
974  /* check_goal_stack(&((*rb)->rl)); 10.6 */
975  /* check_psi_term(&((*rb)->md)); 10.6 */
976  }
977  }
978 }
static void check_resid_list()
static void check_goal_stack(ptr_goal *g)
check_goal_stack
Definition: memory.c:801
static long unchecked(GENERIC *p, long len)
unchecked
Definition: memory.c:339
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define LONELY
Definition: memory.c:24
void check_sys_definitions ( )

check_sys_definitions

Definition at line 2186 of file sys.c.

References check_definition(), sys_bitvector, sys_bytedata, sys_file_stream, sys_process_continued, sys_process_exited, sys_process_no_children, sys_process_signaled, sys_process_stopped, sys_regexp, sys_socket_stream, and sys_stream.

2187 {
2188  check_definition(&sys_bytedata); /* DENYS: BYTEDATA */
2199 #ifdef LIFE_NDBM
2200  check_ndbm_definitions();
2201 #endif
2202 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
ptr_definition sys_regexp
symbol in sys module
Definition: def_glob.h:578
ptr_definition sys_process_continued
symbol in sys module
Definition: def_glob.h:650
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
ptr_definition sys_process_no_children
symbol in sys module
Definition: def_glob.h:622
void check_definition(ptr_definition *d)
check_definition
Definition: memory.c:663
ptr_definition sys_process_signaled
symbol in sys module
Definition: def_glob.h:636
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
ptr_definition sys_process_exited
symbol in sys module
Definition: def_glob.h:629
ptr_definition sys_process_stopped
symbol in sys module
Definition: def_glob.h:643
long check_type ( ptr_psi_term  t)

check_type

Parameters
t- ptr_psi_term t

CHECK_TYPE(t) Here we deal with a type which may need checking. This routine will have to be modified to deal with the infinite loops currently caused by definitions such as:

:: H:husband(spouse => wife(spouse => H)). :: W:wife(spouse => husband(spouse => W)).

Definition at line 990 of file lefun.c.

References wl_definition::always_check, wl_psi_term::attr_list, eval_args(), FALSE, fetch_def(), int_ptr, wl_definition::properties, push2_ptr_value(), RMASK, SMASK, wl_psi_term::status, TRUE, and wl_psi_term::type.

991 {
992  long flag=FALSE;
993 
995  /* push_ptr_value(int_ptr,(GENERIC *)&(t->status)); */
996 
997  if (t->type->properties) {
998  if (t->attr_list || t->type->always_check) {
999  /* Check all constraints here: */
1000  fetch_def(t, TRUE); /* PVR 18.2.94 */
1001  /* t->status=(2 & SMASK) | (t->status & RMASK); PVR 18.2.94 */
1002 
1003  (void)eval_args(t->attr_list);
1004  flag=FALSE;
1005  }
1006  else {
1007  /* definition pending on more information */
1008  t->status= (2 & SMASK) | (t->status & RMASK);
1009  flag=TRUE;
1010  }
1011  }
1012  else {
1013 
1014  /* RM: Dec 15 1992 I don't know what this is for
1015  if (!ovverlap_type(t->type,alist))
1016  t->status= (4 & SMASK) | (t->status & RMASK);
1017  */
1018 
1019  flag=eval_args(t->attr_list);
1020  }
1021 
1022  return flag;
1023 }
long eval_args(ptr_node n)
eval_args
Definition: lefun.c:889
void push2_ptr_value(type_ptr t, GENERIC *p, GENERIC v)
push2_ptr_value
Definition: login.c:573
char always_check
Definition: def_struct.h:154
void fetch_def(ptr_psi_term u, long allflag)
fetch_def
Definition: login.c:1208
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define RMASK
Bit mask for status field of psi-terms: RMASK is used as a flag to avoid infinite loops when tracing ...
Definition: def_const.h:359
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition type
Definition: def_struct.h:181
ptr_triple_list properties
Definition: def_struct.h:149
#define SMASK
Bit mask for status field of psi-terms: SMASK masks off the status bits. These are used in the 'mark'...
Definition: def_const.h:367
ptr_node attr_list
Definition: def_struct.h:187
#define int_ptr
values of type_ptr
Definition: def_const.h:397
long clause_aim ( long  r)

clause_aim

Parameters
r- long r

CLAUSE_AIM(r) Prove a CLAUSE or RETRACT goal. That is try to unify the calling argument with the current rule. If this succeeds and R=TRUE then delete the rule (RETRACT).

Definition at line 1879 of file login.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, wl_goal::cccc_1, clause, clear_copy(), del_clause, Errorline(), FALSE, i_eval_args(), wl_definition::keyword, MAX_BUILT_INS, NULL, push_choice_point(), push_goal(), quote_copy(), retract, STACK, wl_psi_term::status, wl_keyword::symbol, traceline(), TRUE, wl_psi_term::type, and unify.

1880 {
1881  long success=FALSE;
1882  ptr_pair_list *p;
1883  ptr_psi_term head,body,rule_head,rule_body;
1884 
1885  head=(ptr_psi_term)aim->aaaa_1;
1886  body=(ptr_psi_term)aim->bbbb_1;
1887  p=(ptr_pair_list *)aim->cccc_1;
1888 
1889  if ((unsigned long)(*p)>MAX_BUILT_INS) {
1890  success=TRUE;
1891  /* deref(head); 17.9 */
1892 
1893  if ((*p)->next) {
1894  if (r) {
1895  traceline("pushing 'retract' choice point for %P\n", head);
1896  push_choice_point(del_clause,head,(ptr_psi_term)body,(GENERIC)&((*p)->next));
1897  /* push_choice_point(del_clause,head,body,p); */
1898  }
1899  else {
1900  traceline("pushing 'clause' choice point for %P\n", head);
1901  push_choice_point(clause,head,(ptr_psi_term)body,(GENERIC)&((*p)->next));
1902  }
1903  }
1904 
1905  if (r)
1907  if ((*p)->aaaa_2) {
1908  clear_copy();
1909  rule_head=quote_copy((*p)->aaaa_2,STACK);
1910  rule_body=quote_copy((*p)->bbbb_2,STACK);
1911 
1912  push_goal(unify,(ptr_psi_term)body,(ptr_psi_term)rule_body,NULL);
1913  push_goal(unify,(ptr_psi_term)head,(ptr_psi_term)rule_head,NULL);
1914 
1915  rule_head->status=4;
1916  rule_body->status=4;
1917 
1918  (void)i_eval_args(rule_body->attr_list);
1919  (void)i_eval_args(rule_head->attr_list);
1920 
1921  traceline("fetching next clause for %s\n", head->type->keyword->symbol);
1922  }
1923  else {
1924  success=FALSE;
1925  traceline("following clause had been retracted\n");
1926  }
1927  }
1928  else if ((unsigned long)(*p)>0) {
1929  if (r)
1930  Errorline("the built-in %P cannot be retracted.\n",head);
1931  else
1932  Errorline("the definition of built-in %P is not accessible.\n",head);
1933  }
1934 
1935  return success;
1936 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void clear_copy()
clear_copy
Definition: copy.c:53
void push_goal(goals t, ptr_psi_term aaaa_5, ptr_psi_term bbbb_5, GENERIC cccc_5)
push_goal
Definition: login.c:600
GENERIC cccc_1
Definition: def_struct.h:241
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:533
char * symbol
Definition: def_struct.h:118
void traceline(char *format,...)
traceline
Definition: error.c:186
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
quote_copy
Definition: copy.c:186
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1135
ptr_goal aim
Definition: def_glob.h:1024
#define retract
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1149
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long i_eval_args(ptr_node n)
i_eval_args
Definition: lefun.c:874
#define del_clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1142
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
void push_choice_point(goals t, ptr_psi_term aaaa_6, ptr_psi_term bbbb_6, GENERIC cccc_6)
push_choice_point
Definition: login.c:638
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
void clean_undo_window ( long  disp,
long  wind 
)

clean_undo_window

Parameters
disp- long disp
wind- long wind

CLEAN_UNDO_WINDOW(disp,wind) Remove all trail entries that reference a given window. This is called when the window is destroyed.

Definition at line 848 of file login.c.

References wl_stack::aaaa_3, wl_stack::bbbb_3, choice_stack, wl_stack::next, wl_choice_point::next, wl_stack::type, undo_action, wl_choice_point::undo_point, and undo_stack.

849 {
850  ptr_stack *prev,u;
852 
853 #ifdef X11
854  /* Remove entries on the trail */
855  u = undo_stack;
856  prev = &undo_stack;
857  while (u) {
858  if ((u->type & undo_action) &&
859  ((unsigned long)u->aaaa_3==disp) && ((unsigned long)u->bbbb_3==wind)) {
860  *prev = u->next;
861  }
862  prev = &(u->next);
863  u = u->next;
864  }
865 
866  /* Remove entries at the *tops* of trail entry points from the */
867  /* choice point stack. It's only necessary to look at the tops, */
868  /* since those are the only ones that haven't been touched by */
869  /* the previous while loop. */
870  c = choice_stack;
871  while (c) {
872  u = c->undo_point;
873  prev = &(c->undo_point);
874  while (u && (u->type & undo_action) &&
875  ((unsigned long)u->aaaa_3==disp) && ((unsigned long)u->bbbb_3==wind)) {
876  *prev = u->next;
877  prev = &(u->next);
878  u = u->next;
879  }
880  c = c->next;
881  }
882 #endif
883 }
GENERIC * bbbb_3
Definition: def_struct.h:233
ptr_stack undo_point
Definition: def_struct.h:248
ptr_choice_point next
Definition: def_struct.h:250
ptr_stack undo_stack
Definition: def_glob.h:1027
type_ptr type
Definition: def_struct.h:231
GENERIC * aaaa_3
Definition: def_struct.h:232
#define undo_action
Fast checking for an undo action.
Definition: def_const.h:484
ptr_stack next
Definition: def_struct.h:234
ptr_choice_point choice_stack
Definition: def_glob.h:1026
void clear_already_loaded ( ptr_node  n)

clear_already_loaded

Parameters
n- ptr_node n

CLEAR_ALREADY_LOADED() Clear the 'already_loaded' flags in all symbol table entries. Done at each top level prompt.

Definition at line 351 of file types.c.

References wl_definition::already_loaded, wl_node::data, FALSE, wl_node::left, and wl_node::right.

352 {
353  ptr_definition d;
354 
355  if (n) {
356  d=((ptr_keyword)n->data)->definition;
360  }
361 }
char already_loaded
Definition: def_struct.h:157
void clear_already_loaded(ptr_node n)
clear_already_loaded
Definition: types.c:351
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
#define FALSE
Standard boolean.
Definition: def_const.h:275
struct wl_keyword * ptr_keyword
Definition: def_struct.h:125
ptr_node right
Definition: def_struct.h:200
void clear_coding ( )

clear_coding

CLEAR_CODING() Clear the bit-vector coding of the sorts.

Definition at line 727 of file types.c.

References wl_definition::code, first_definition, wl_definition::next, NOT_CODED, wl_definition::type_def, and type_it.

728 {
729  ptr_definition d;
730 
731  for(d=first_definition;d;d=d->next)
732  if (d->type_def==(def_type)type_it) d->code=NOT_CODED;
733 }
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
def_type type_def
Definition: def_struct.h:153
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition next
Definition: def_struct.h:164
ptr_int_list code
Definition: def_struct.h:150
void clear_copy ( )

clear_copy

CLEAR_COPY() Erase the hash table. This must be done as a prelude to any copying operation.

Definition at line 53 of file copy.c.

References hashfree, and hashtime.

54 {
55  hashtime++;
56  hashfree=0;
57 }
static long hashfree
Definition: copy.c:19
static long hashtime
Definition: copy.c:18
ptr_psi_term collect_symbols ( long  sel)

collect_symbols

Parameters
sel- long sel

Collect properties of the symbols in the symbol table, and make a psi-term list of them. This routine is parameterized (by sel) to collect three properties:

  1. All symbols that are types with no parents.
  2. All symbols that are of 'undef' type.
  3. The operator triples of all operators.

Note the similarity between this routine and a tree-to-list routine in Prolog. The pointer manipulations are simpler in Prolog, though.

If the number of symbols is very large, this routine may run out of space before garbage collection.

Definition at line 3699 of file built_ins.c.

References wl_definition::children, first_definition, fx, fx_sym, fy, fy_sym, greatest_sel, hidden_type(), least_sel, wl_operator_data::next, wl_definition::next, nothing, NULL, one, wl_definition::op_data, op_sel, opsym, wl_definition::parents, wl_operator_data::precedence, stack_add_int_attr(), stack_add_psi_attr(), stack_cons(), stack_nil(), stack_psi_term(), three, top, two, wl_psi_term::type, wl_definition::type_def, type_it, undef_it, xf, xf_sym, xfx, xfx_sym, xfy, xfy_sym, yf, yf_sym, yfx, and yfx_sym.

3700 {
3701  ptr_psi_term new;
3702  ptr_definition def;
3703  long botflag;
3704  ptr_psi_term result;
3705 
3706 
3707  result=stack_nil();
3708 
3709  for(def=first_definition;def;def=def->next) {
3710 
3711  if (sel==least_sel || sel==greatest_sel) {
3712  botflag=(sel==least_sel);
3713 
3714  /* Insert the node if it's a good one */
3715  if (((botflag?def->children:def->parents)==NULL &&
3716  def!=top && def!=nothing &&
3717  def->type_def==(def_type)type_it ||
3718  def->type_def==(def_type)undef_it)
3719  && !hidden_type(def)) {
3720  /* Create the node that will be inserted */
3721  new=stack_psi_term(4);
3722  new->type=def;
3723  result=stack_cons((ptr_psi_term)new,(ptr_psi_term)result);
3724  }
3725  }
3726  else if (sel==op_sel) {
3727  ptr_operator_data od=def->op_data;
3728 
3729  while (od) {
3730  ptr_psi_term name_loc,type;
3731 
3732  new=stack_psi_term(4);
3733  new->type=opsym;
3734  result=stack_cons((ptr_psi_term)new,(ptr_psi_term)result);
3735 
3737 
3738  type=stack_psi_term(4);
3739  switch (od->type) {
3740  case xf:
3741  type->type=xf_sym;
3742  break;
3743  case yf:
3744  type->type=yf_sym;
3745  break;
3746  case fx:
3747  type->type=fx_sym;
3748  break;
3749  case fy:
3750  type->type=fy_sym;
3751  break;
3752  case xfx:
3753  type->type=xfx_sym;
3754  break;
3755  case xfy:
3756  type->type=xfy_sym;
3757  break;
3758  case yfx:
3759  type->type=yfx_sym;
3760  break;
3761  }
3762  stack_add_psi_attr(new,two,type);
3763 
3764  name_loc=stack_psi_term(4);
3765  name_loc->type=def;
3766  stack_add_psi_attr(new,three,name_loc);
3767 
3768  od=od->next;
3769  }
3770  }
3771  }
3772 
3773  return result;
3774 }
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
#define yfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1037
ptr_definition xf_sym
symbol in bi module
Definition: def_glob.h:515
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
#define least_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:11
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
#define xfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1021
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
char * two
Definition: def_glob.h:892
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
def_type type_def
Definition: def_struct.h:153
ptr_definition fx_sym
symbol in bi module
Definition: def_glob.h:522
ptr_definition opsym
symbol in bi module
Definition: def_glob.h:445
#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
char * three
Definition: def_glob.h:893
#define op_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:25
void stack_add_psi_attr(ptr_psi_term t, char *attrname, ptr_psi_term g)
stack_add_psi_attr
Definition: token.c:239
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition yf_sym
symbol in bi module
Definition: def_glob.h:529
ptr_definition next
Definition: def_struct.h:164
void stack_add_int_attr(ptr_psi_term t, char *attrname, long value)
stack_add_int_attr
Definition: token.c:94
#define greatest_sel
used by collect_symbols in built_ins.c
Definition: def_const.h:18
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_definition xfy_sym
symbol in bi module
Definition: def_glob.h:550
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
char * one
Definition: def_glob.h:891
#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
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition yfx_sym
symbol in bi module
Definition: def_glob.h:557
ptr_definition fy_sym
symbol in bi module
Definition: def_glob.h:536
ptr_definition type
Definition: def_struct.h:181
ptr_definition xfx_sym
symbol in bi module
Definition: def_glob.h:543
long hidden_type(ptr_definition t)
hidden_type
Definition: built_ins.c:3672
ptr_int_list children
Definition: def_struct.h:152
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
ptr_int_list parents
Definition: def_struct.h:151
ptr_int_list cons ( GENERIC  v,
ptr_int_list  l 
)

cons

Parameters
v- GENERIC v
l- ptr_int_list l

CONS(value,list) Returns the list [VALUE|LIST]

Definition at line 179 of file types.c.

References HEAP_ALLOC, wl_int_list::next, and wl_int_list::value_1.

180 {
181  ptr_int_list n;
182 
183  n=HEAP_ALLOC(int_list);
184  n->value_1=v;
185  n->next=l;
186 
187  return n;
188 }
GENERIC value_1
Definition: def_struct.h:85
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_int_list next
Definition: def_struct.h:86
ptr_psi_term copy ( ptr_psi_term  t,
long  copy_flag,
long  heap_flag 
)

copy

Parameters
t- ptr_psi_term t
copy_flag- long copy_flag
heap_flag- long heap_flag

COPY(t) This is the workhorse of the interpreter (alas!). All copy-related routines are non-interruptible by the garbage collector.

Make a copy in the STACK or in the HEAP of psi_term t, which is located in the HEAP. A copy is done whenever invoking a rule, so it had better be fast. This routine uses hash tables with buckets and partial inlining for speed.

The following three versions of copy all rename their variables and return a completely dereferenced object:

u=exact_copy(t,hf) u is an exact copy of t. u=quote_copy(t,hf) u is a copy of t that is recursively marked evaluated. u=eval_copy(t,hf) u is a copy of t that is recursively marked unevaluated.

This version of copy is an incremental copy to the heap. It copies only those parts of a psi_term that are on the stack, leaving the others unchanged:

u=inc_heap_copy(t) u is an exact copy of t, on the heap. This is like hf==HEAP, except that objects already on the heap are untouched. Relies on no pointers from heap to stack.

hf = heap_flag. hf = HEAP or STACK means allocate in the HEAP or STACK. Marking eval/uneval is done by modifying the STATUS field of the copied psi_term. In eval_copy, a term's status is set to 0 if the term or any subterm needs evaluation. Terms are dereferenced when copying them to the heap.

Definition at line 248 of file copy.c.

References abort_life(), wl_psi_term::attr_list, choice_stack, COPY_THRESHOLD, copy_tree(), curr_status, cut, deref_ptr, env, Errorline(), EVAL_FLAG, wl_definition::evaluate_args, FALSE, wl_psi_term::flags, function_it, global_it, global_time_stamp, HEAP, heap_pointer, HEAPDONE, insert_translation(), mark_quote_c(), NEW, NULL, wl_definition::properties, QUOTE_FLAG, QUOTE_STUB, QUOTED_TRUE, wl_psi_term::resid, stack_pointer, wl_psi_term::status, traceline(), translate(), TRUE, wl_psi_term::type, wl_definition::type_def, type_it, and wl_psi_term::value_3.

249 {
250  ptr_psi_term u;
251  long old_status;
252  long local_copy_flag;
253  long *infoptr;
254 
255 
256  if ((u=t)) {
257  deref_ptr(t); /* Always dereference when copying */
258 
259  if (HEAPDONE(t)) return t;
260  u = translate(t,&infoptr);
261 
262  if (u && *infoptr!=QUOTE_STUB) { /* 24.8 */
263  /* If it was eval-copied before, then quote it now. */
264  if (*infoptr==EVAL_FLAG && copy_flag==QUOTE_FLAG) { /* 24.8 25.8 */
265  mark_quote_c(t,heap_flag);
266  *infoptr=QUOTE_FLAG; /* I.e. don't touch this term any more */
267  }
268  if (copy_flag==EVAL_FLAG) { /* PVR 14.2.94 */
269  /* If any subterm has zero curr_status (i.e., if u->status==0),
270  then so does the whole term: */
271  old_status=curr_status;
272  curr_status=u->status;
273  if (curr_status) curr_status=old_status;
274  }
275  }
276  else {
278  Errorline("psi-term too large -- get a bigger Life!\n");
279  (void)abort_life(TRUE);
280  longjmp(env,FALSE); /* Back to main loop */ /* RM: Feb 15 1993 */
281  }
282  if (copy_flag==EVAL_FLAG && !t->type->evaluate_args) /* 24.8 25.8 */
283  local_copy_flag=QUOTE_FLAG; /* All arguments will be quoted 24.8 */
284  else /* 24.8 */
285  local_copy_flag=copy_flag;
286  if (copy_flag==EVAL_FLAG) {
287  old_status = curr_status;
288  curr_status = 4;
289  }
290  if (u) { /* 15.9 */
291  *infoptr=QUOTE_FLAG;
292  local_copy_flag=QUOTE_FLAG;
293  copy_flag=QUOTE_FLAG;
294  }
295  else {
296  u=NEW(t,psi_term);
297  insert_translation(t,u,local_copy_flag); /* 24.8 */
298  }
299  *u = *t;
300  u->resid=NULL; /* 24.8 Don't copy residuations */
301 #ifdef TS
302  u->time_stamp=global_time_stamp; /* 9.6 */
303 #endif
304 
305  if (t->attr_list)
306  u->attr_list=copy_tree(t->attr_list, local_copy_flag, heap_flag);
307 
308  if (copy_flag==EVAL_FLAG) {
309  switch((long)t->type->type_def) {
310  case (long)type_it:
311  if (t->type->properties)
312  curr_status=0;
313  break;
314 
315  case (long)function_it:
316  curr_status=0;
317  break;
318 
319  case (long)global_it: /* RM: Feb 8 1993 */
320  curr_status=0;
321  break;
322 
323  default:
324  break;
325  }
326  u->status=curr_status;
327  u->flags=curr_status?QUOTED_TRUE:FALSE; /* 14.9 */
328  /* If any subterm has zero curr_status,
329  then so does the whole term: */
330  if (curr_status) curr_status=old_status;
331  } else if (copy_flag==QUOTE_FLAG) {
332  u->status=4;
333  u->flags=QUOTED_TRUE; /* 14.9 */
334  }
335  /* else copy_flag==EXACT_FLAG & u->status=t->status */
336 
337  if (heap_flag==HEAP) {
338  if (t->type==cut) u->value_3=NULL;
339  } else {
340  if (t->type==cut) {
342  traceline("current choice point is %x\n",choice_stack);
343  }
344  }
345  }
346  }
347 
348  return u;
349 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
#define COPY_THRESHOLD
Copy threshold (1/8 of GC_THRESHOLD is reasonable)
Definition: def_const.h:125
ptr_residuation resid
Definition: def_struct.h:189
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
translate
Definition: copy.c:108
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
char evaluate_args
Definition: def_struct.h:156
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
#define QUOTE_STUB
flag having to do with copying in copy.c
Definition: def_const.h:1328
def_type type_def
Definition: def_struct.h:153
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
insert_translation
Definition: copy.c:67
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
#define NULL
Definition: def_const.h:533
#define NEW(A, TYPE)
Definition: def_macro.h:284
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
void traceline(char *format,...)
traceline
Definition: error.c:186
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
#define EVAL_FLAG
flag to copy function in copy.c to indicate kind of copy
Definition: def_const.h:1320
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
static ptr_node copy_tree(ptr_node t, long copy_flag, long heap_flag)
ptr_node copy_tree
Definition: copy.c:148
static long curr_status
Definition: copy.c:209
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
void mark_quote_c(ptr_psi_term t, long heap_flag)
mark_quote_c
Definition: copy.c:434
jmp_buf env
Definition: def_glob.h:877
unsigned long global_time_stamp
Definition: login.c:28
#define HEAPDONE(R)
Definition: def_macro.h:296
#define QUOTE_FLAG
flag to copy function in copy.c to indicate kind of copy
Definition: def_const.h:1313
ptr_definition type
Definition: def_struct.h:181
ptr_triple_list properties
Definition: def_struct.h:149
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
ptr_choice_point choice_stack
Definition: def_glob.h:1026
ptr_int_list copyTypeCode ( ptr_int_list  u)

copyTypeCode

Parameters
u- ptr_int_list u

copyTypeCode(code) returns copy of code on the heap

Definition at line 808 of file types.c.

References HEAP_ALLOC, wl_int_list::next, NULL, or_codes(), and wl_int_list::value_1.

809 {
810  ptr_int_list code;
811 
812  code = HEAP_ALLOC(int_list);
813  code->value_1=0;
814  code->next=NULL;
815 
816  or_codes(code, u);
817 
818  return code;
819 }
#define NULL
Definition: def_const.h:533
GENERIC value_1
Definition: def_struct.h:85
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
void or_codes(ptr_int_list u, ptr_int_list v)
or_codes
Definition: types.c:831
ptr_int_list next
Definition: def_struct.h:86
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
long count_sorts ( long  c0)

count_sorts

Parameters
c0- long c0

COUNT_SORTS(c) Count the number of sorts in the symbol table T. Overestimates in the module version. RM: Jan 21 1993 No longer !! RM: Feb 3 1993

Definition at line 710 of file types.c.

References first_definition, wl_definition::next, wl_definition::type_def, and type_it.

711 {
712  ptr_definition d;
713 
714  for(d=first_definition;d;d=d->next)
715  if (d->type_def==(def_type)type_it) c0++;
716 
717  return c0;
718 }
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
def_type type_def
Definition: def_struct.h:153
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition next
Definition: def_struct.h:164
ptr_module create_module ( char *  module)

ptr_module create_module(char *module)

CREATE_MODULE(module) Create a new module.

Definition at line 72 of file modules.c.

References find_module(), hash_create(), HEAP_ALLOC, heap_copy_string(), heap_insert(), input_file_name, NULL, and STRCMP.

73 {
74  ptr_module new;
75 
76 
77  new=find_module(module);
78  if(!new) {
79  new=HEAP_ALLOC(struct wl_module);
80  new->module_name=(char *)heap_copy_string(module);
81  new->source_file=(char *)heap_copy_string(input_file_name);
82  new->open_modules=NULL;
83  new->inherited_modules=NULL;
84  new->symbol_table=hash_create(16); /* RM: Feb 3 1993 */
85 
86  (void)heap_insert(STRCMP,new->module_name,&module_table,(GENERIC)new);
87 
88  }
89  return new;
90 }
ptr_node module_table
Definition: modules.c:14
string input_file_name
Definition: def_glob.h:1016
ptr_hash_table hash_create(int size)
HASH_CREATE.
Definition: hash_table.c:25
#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
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define STRCMP
indicates to use strcmp for comparison (c function)
Definition: def_const.h:963
ptr_module find_module(char *module)
find_module
Definition: modules.c:54
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
void crunch ( long  prec,
long  limit 
)

crunch

Parameters
prec- long prec
limit- long limit

CRUNCH(prec,limit) Crunch up = work out the arguments of anything on the stack whose precedence is <= PREC, and replace it with the corresponding psi-term. Do not go any further than LIMIT which is the end of the current expression.

Definition at line 662 of file parser.c.

References error_psi_term, FALSE, fx, look(), make_life_form(), nop, NULL, parse_ok, parser_stack_index, pop(), push(), xf, and xfx.

663 {
664  psi_term t,t1,t2,t3;
665  long op1,op2,op3;
666 
667  if(parse_ok && prec>=look() && parser_stack_index>limit) {
668 
669  (void)pop(&t1,&op1);
670 
671  switch(op1) {
672 
673  case nop:
674  (void)pop(&t2,&op2);
675  if(op2==fx)
676  t=make_life_form(&t2,&t1,NULL);
677  else
678  if(op2==xfx) {
679  (void)pop(&t3,&op3);
680  if(op3==nop)
681  t=make_life_form(&t2,&t3,&t1);
682  else {
683  printf("*** Parser: ooops, NOP expected.\n");
684  parse_ok=FALSE;
685  t= *error_psi_term;
686  }
687  }
688  break;
689 
690  case xf:
691  (void)pop(&t2,&op2);
692  if(op2==nop)
693  t=make_life_form(&t1,&t2,NULL);
694  else {
695  printf("*** Parser: ugh, NOP expected.\n");
696  t= *error_psi_term;
697  parse_ok=FALSE;
698  }
699  break;
700 
701  default:
702  printf("*** Parser: yuck, weirdo operator.\n");
703  }
704 
705  push(t,look(),nop);
706 
707  crunch(prec,limit);
708  }
709 }
#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
long look()
look
Definition: parser.c:163
void push(psi_term tok, long prec, long op)
push
Definition: parser.c:107
#define NULL
Definition: def_const.h:533
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
#define nop
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:986
long pop(ptr_psi_term tok, long *op)
pop
Definition: parser.c:132
void crunch(long prec, long limit)
crunch
Definition: parser.c:662
#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
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
psi_term make_life_form(ptr_psi_term tok, ptr_psi_term arg1, ptr_psi_term arg2)
make_life_form
Definition: parser.c:571
long parser_stack_index
index to parser stack
Definition: def_glob.h:164
void curry ( )

curry

Decide that the current function will have to be curried. This has become so simple it could be a MACRO. The real work is done by DO_CURRY.

Definition at line 174 of file lefun.c.

References can_curry, curried, and TRUE.

175 {
176  if (can_curry)
177  curried=TRUE;
178 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
long can_curry
Definition: def_glob.h:869
long curried
Definition: def_glob.h:868
long declare_operator ( ptr_psi_term  t)

declare_operator

Parameters
t- ptr_psi_term t

DECLARE_OPERATOR(t) Declare a new operator or change a pre-existing one.

For example: 'op'(3,xfx,+)? T is the OP declaration.

Definition at line 5436 of file built_ins.c.

References wl_psi_term::attr_list, wl_node::data, deref_ptr, Errorline(), FALSE, FEATCMP, find(), fx, fx_sym, fy, fy_sym, get_two_args(), integer, wl_definition::keyword, MAX_PRECEDENCE, nop, op_declare(), REAL, sub_type(), wl_keyword::symbol, three, TRUE, wl_psi_term::type, wl_psi_term::value_3, xf, xf_sym, xfx, xfx_sym, xfy, xfy_sym, yf, yf_sym, yfx, and yfx_sym.

5437 {
5438  ptr_psi_term prec,type,atom;
5439  ptr_node n;
5440  char *s;
5441  long p;
5442  operator kind=nop;
5443  long success=FALSE;
5444 
5445  deref_ptr(t);
5446  n=t->attr_list;
5447  get_two_args(n,&prec,&type);
5448  n=find(FEATCMP,three,n);
5449  if (n && prec && type) {
5450  atom=(ptr_psi_term )n->data;
5451  deref_ptr(prec);
5452  deref_ptr(type);
5453  deref_ptr(atom);
5454  if (!atom->value_3) {
5455  s=atom->type->keyword->symbol;
5456  if (sub_type(prec->type,integer) && prec->value_3) { /* 10.8 */
5457  p = * (REAL *)prec->value_3;
5458  if (p>0 && p<=MAX_PRECEDENCE) {
5459 
5460  if (type->type == xf_sym) kind=xf;
5461  else if (type->type == yf_sym) kind=yf;
5462  else if (type->type == fx_sym) kind=fx;
5463  else if (type->type == fy_sym) kind=fy;
5464  else if (type->type == xfx_sym) kind=xfx;
5465  else if (type->type == xfy_sym) kind=xfy;
5466  else if (type->type == yfx_sym) kind=yfx;
5467  else
5468  Errorline("bad operator kind '%s'.\n",type->type->keyword->symbol);
5469 
5470  if (kind!=nop) {
5471  op_declare(p,kind,s);
5472  success=TRUE;
5473  }
5474  }
5475  else
5476  Errorline("precedence must range from 1 to 1200 in %P.\n",t);
5477  }
5478  else
5479  Errorline("precedence must be a positive integer in %P.\n",t);
5480  }
5481  else
5482  Errorline("numbers or strings may not be operators in %P.\n",t);
5483  }
5484  else
5485  Errorline("argument missing in %P.\n",t);
5486 
5487  return success;
5488 }
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 FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition xf_sym
symbol in bi module
Definition: def_glob.h:515
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#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
ptr_definition fx_sym
symbol in bi module
Definition: def_glob.h:522
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define xfy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1030
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
char * three
Definition: def_glob.h:893
char * symbol
Definition: def_struct.h:118
#define nop
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:986
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
ptr_definition yf_sym
symbol in bi module
Definition: def_glob.h:529
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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
GENERIC value_3
Definition: def_struct.h:186
ptr_definition xfy_sym
symbol in bi module
Definition: def_glob.h:550
#define xf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:993
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define yf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1007
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
ptr_definition yfx_sym
symbol in bi module
Definition: def_glob.h:557
ptr_definition fy_sym
symbol in bi module
Definition: def_glob.h:536
static void op_declare(long p, operator t, char *s)
op_declare
Definition: built_ins.c:5404
ptr_definition type
Definition: def_struct.h:181
ptr_definition xfx_sym
symbol in bi module
Definition: def_glob.h:543
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
ptr_int_list decode ( ptr_int_list  c)

decode

Parameters
c- ptr_int_list c

DECODE(c) Returns a list of the symbol names which make up the disjunction whose code is C.

Definition at line 1784 of file types.c.

References bit_length(), wl_definition::code, cons(), wl_int_list::next, NULL, STACK_ALLOC, and wl_int_list::value_1.

1785 {
1786  ptr_int_list c2,c3,c4,result=NULL,*prev;
1787  long p;
1788 
1789  p=bit_length(c);
1790 
1791  while (p) {
1792  p--;
1793  c2=gamma_table[p]->code;
1794  result=cons((GENERIC)gamma_table[p],result);
1795  prev= &c4;
1796  *prev=NULL;
1797 
1798  while (c2) {
1799  c3=STACK_ALLOC(int_list);
1800  *prev=c3;
1801  prev= &(c3->next);
1802  *prev=NULL;
1803 
1804  c3->value_1=(GENERIC)(((unsigned long)(c->value_1)) & ~((unsigned long)(c2->value_1)));
1805 
1806  c=c->next;
1807  c2=c2->next;
1808  }
1809 
1810  c=c4;
1811  p=bit_length(c);
1812  }
1813 
1814  return result;
1815 }
ptr_definition * gamma_table
Definition: types.c:14
ptr_int_list cons(GENERIC v, ptr_int_list l)
cons
Definition: types.c:179
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
long bit_length(ptr_int_list c)
bit_length
Definition: types.c:1753
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_int_list code
Definition: def_struct.h:150
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
void delete_attr ( char *  s,
ptr_node n 
)

delete_attr

Parameters
s- char *s
n- ptr_node *n

DELETE_ATTR(key,tree) Remove the node addressed by KEY from TREE.

Definition at line 522 of file trees.c.

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

523 {
524  long cmp;
525  ptr_node new,r;
526 
527  if (*n) {
528  cmp=featcmp(s,(*n)->key);
529  if (cmp<0)
530  delete_attr(s,&((*n)->left));
531  else if (cmp>0)
532  delete_attr(s,&((*n)->right));
533  else if ((*n)->left) {
534  if ((*n)->right) {
535  r=(*n)->right;
536  new=heap_insert(FEATCMP,r->key,&((*n)->left),r->data);
537  new->left=r->left;
538  new->right=r->right;
539  *n = (*n) -> left;
540  }
541  else
542  *n = (*n)->left;
543  }
544  else
545  *n = (*n)->right;
546  }
547 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
heap_insert
Definition: trees.c:320
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
void delete_attr(char *s, ptr_node *n)
delete_attr
Definition: trees.c:522
ptr_node right
Definition: def_struct.h:200
void deref2_eval ( ptr_psi_term  t)

deref2_eval

Parameters
t- ptr_psi_term t

Definition at line 1356 of file lefun.c.

References check_func(), deref_ptr, eval_global_var(), function_it, global_it, wl_psi_term::status, wl_psi_term::type, and wl_definition::type_def.

1357 {
1358  deref_ptr(t);
1359  if (t->status==0) {
1360  if (t->type->type_def==(def_type)function_it) {
1361  check_func(t);
1362  }
1363  else
1364  if(t->type->type_def==(def_type)global_it) { /* RM: Feb 10 1993 */
1365  eval_global_var(t);
1366  deref_ptr(t);/* RM: Jun 25 1993 */
1367  deref2_eval(t);
1368  }
1369  else {
1370  t->status=4;
1371  }
1372  }
1373 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void deref2_eval(ptr_psi_term t)
deref2_eval
Definition: lefun.c:1356
void eval_global_var(ptr_psi_term t)
eval_global_var
Definition: lefun.c:1440
def_type type_def
Definition: def_struct.h:153
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
#define deref_ptr(P)
Definition: def_macro.h:100
void check_func(ptr_psi_term t)
check_func
Definition: lefun.c:928
ptr_definition type
Definition: def_struct.h:181
void deref2_rec_eval ( ptr_psi_term  t)

deref2_rec_eval

Parameters
t- ptr_psi_term t

Same as deref_rec_eval, but assumes goal_stack already restored.

Definition at line 1382 of file lefun.c.

References deref_ptr, and deref_rec_body().

1383 {
1384  deref_ptr(t);
1385  deref_rec_body(t);
1386 }
#define deref_ptr(P)
Definition: def_macro.h:100
void deref_rec_body(ptr_psi_term t)
deref_rec_body
Definition: lefun.c:1243
long deref_args_eval ( ptr_psi_term  t,
long  set 
)

deref_args_eval

Parameters
t- ptr_psi_term t
set- long set

Same as deref_rec_eval, but doesn't look at either the top level or the arguments in the set.

Definition at line 1294 of file lefun.c.

References aim, wl_psi_term::attr_list, deref_flag, deref_rec_args_exc(), FALSE, and goal_stack.

1295 {
1296  ptr_goal save = goal_stack;
1297  ptr_goal top_loc = aim;
1298 
1299  deref_flag = FALSE;
1300  goal_stack = top_loc;
1301  deref_rec_args_exc(t->attr_list,set);
1302  if (!deref_flag) goal_stack = save;
1303  return (deref_flag);
1304 }
ptr_goal goal_stack
Definition: def_glob.h:1025
static long deref_flag
Definition: lefun.c:1166
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
void deref_rec_args_exc(ptr_node n, long set)
deref_rec_args_exc
Definition: lefun.c:1332
ptr_node attr_list
Definition: def_struct.h:187
long deref_eval ( ptr_psi_term  t)

deref_eval

Parameters
t- ptr_psi_term t

deref_eval(P) If the psi-term P is a function, call check_func to push eval goals so that the function will be evaluated. Then return TRUE so that the caller can itself return. This only looks at the top level.

Definition at line 1180 of file lefun.c.

References aim, check_func(), deref_flag, deref_ptr, eval_global_var(), FALSE, function_it, global_it, goal_stack, heap_pointer, int_ptr, push_ptr_value(), wl_psi_term::status, TRUE, wl_psi_term::type, and wl_definition::type_def.

1181 {
1182  ptr_goal save=goal_stack;
1183 
1184  deref_flag=FALSE;
1185  goal_stack=aim;
1186 
1187  if (t->status==0) {
1188  if(t->type->type_def==(def_type)function_it) {
1189  check_func(t); /* Push eval goals to evaluate the function. */
1190  deref_flag=TRUE; /* TRUE so that caller will return to main_prove. */
1191  }
1192  else
1193  if(t->type->type_def==(def_type)global_it) { /* RM: Feb 10 1993 */
1194  eval_global_var(t);
1195  deref_ptr(t);/* RM: Jun 25 1993 */
1197  }
1198  else {
1199  if (((long)t->status)!=2) {
1200  if((GENERIC)t<heap_pointer)
1201  push_ptr_value(int_ptr,(GENERIC *)&(t->status)); /* RM: Jul 15 1993 */
1202  t->status=4;
1203  deref_flag=FALSE;
1204  }
1205  }
1206  }
1207  else
1208  deref_flag=FALSE;
1209 
1210  if (!deref_flag) goal_stack=save;
1211  return (deref_flag);
1212 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
long deref_eval(ptr_psi_term t)
deref_eval
Definition: lefun.c:1180
void eval_global_var(ptr_psi_term t)
eval_global_var
Definition: lefun.c:1440
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
ptr_goal goal_stack
Definition: def_glob.h:1025
static long deref_flag
Definition: lefun.c:1166
def_type type_def
Definition: def_struct.h:153
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#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
void check_func(ptr_psi_term t)
check_func
Definition: lefun.c:928
ptr_goal aim
Definition: def_glob.h:1024
ptr_definition type
Definition: def_struct.h:181
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void deref_rec_args ( ptr_node  n)

deref_rec_args

Parameters
n- ptr_node n

Definition at line 1272 of file lefun.c.

References wl_node::data, deref_ptr, deref_rec_body(), wl_node::left, and wl_node::right.

1273 {
1274  ptr_psi_term t1;
1275 
1276  if (n) {
1277  deref_rec_args(n->right);
1278  t1 = (ptr_psi_term) (n->data);
1279  deref_ptr(t1);
1280  deref_rec_body(t1);
1281  deref_rec_args(n->left);
1282  }
1283 }
void deref_rec_args(ptr_node n)
deref_rec_args
Definition: lefun.c:1272
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
void deref_rec_body(ptr_psi_term t)
deref_rec_body
Definition: lefun.c:1243
ptr_node right
Definition: def_struct.h:200
void deref_rec_args_exc ( ptr_node  n,
long  set 
)

deref_rec_args_exc

Parameters
n- ptr_node n
set- long set

Definition at line 1332 of file lefun.c.

References wl_node::data, deref_ptr, deref_rec_body(), in_set(), wl_node::key, wl_node::left, and wl_node::right.

1333 {
1334  ptr_psi_term t;
1335 
1336  if (n) {
1337  deref_rec_args_exc(n->right,set);
1338  if (!in_set(n->key,set)) {
1339  t = (ptr_psi_term) (n->data);
1340  deref_ptr(t);
1341  deref_rec_body(t);
1342  }
1343  deref_rec_args_exc(n->left,set);
1344  }
1345 }
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
void deref_rec_body(ptr_psi_term t)
deref_rec_body
Definition: lefun.c:1243
void deref_rec_args_exc(ptr_node n, long set)
deref_rec_args_exc
Definition: lefun.c:1332
long in_set(char *str, long set)
in_set
Definition: lefun.c:1316
ptr_node right
Definition: def_struct.h:200
void deref_rec_body ( ptr_psi_term  t)

deref_rec_body

Parameters
t- ptr_psi_term t

Definition at line 1243 of file lefun.c.

References wl_psi_term::attr_list, check_func(), deref_flag, deref_ptr, deref_rec_args(), eval_global_var(), function_it, global_it, heap_pointer, int_ptr, push_ptr_value(), wl_psi_term::status, TRUE, wl_psi_term::type, and wl_definition::type_def.

1244 {
1245  if (t->status==0) {
1246  if (t->type->type_def==(def_type)function_it) {
1247  check_func(t);
1248  deref_flag=TRUE;
1249  }
1250  else
1251  if(t->type->type_def==(def_type)global_it) { /* RM: Feb 10 1993 */
1252  eval_global_var(t);
1253  deref_ptr(t);/* RM: Jun 25 1993 */
1254  deref_rec_body(t);
1255  }
1256  else {
1257  /* if (t->status!=2) Tried adding this -- PVR 9.2.94 */
1258  if((GENERIC)t<heap_pointer)
1259  push_ptr_value(int_ptr,(GENERIC *)&(t->status));/* RM: Jul 15 1993 */
1260  t->status=4;
1262  }
1263  }
1264 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
void eval_global_var(ptr_psi_term t)
eval_global_var
Definition: lefun.c:1440
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
void deref_rec_args(ptr_node n)
deref_rec_args
Definition: lefun.c:1272
static long deref_flag
Definition: lefun.c:1166
def_type type_def
Definition: def_struct.h:153
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
void check_func(ptr_psi_term t)
check_func
Definition: lefun.c:928
void deref_rec_body(ptr_psi_term t)
deref_rec_body
Definition: lefun.c:1243
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
#define int_ptr
values of type_ptr
Definition: def_const.h:397
long deref_rec_eval ( ptr_psi_term  t)

deref_rec_eval

Parameters
t- ptr_psi_term t

deref_rec(P) If the psi-term P recursively contains any functions, then push eval goals to evaluate all of them. Set a global variable deref_flag if this is the case.

Definition at line 1226 of file lefun.c.

References aim, deref_flag, deref_rec_body(), FALSE, and goal_stack.

1227 {
1228  ptr_goal save=goal_stack;
1229 
1230  deref_flag=FALSE;
1231  goal_stack=aim;
1232  deref_rec_body(t);
1233  if (!deref_flag) goal_stack=save;
1234  return (deref_flag);
1235 }
ptr_goal goal_stack
Definition: def_glob.h:1025
static long deref_flag
Definition: lefun.c:1166
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
void deref_rec_body(ptr_psi_term t)
deref_rec_body
Definition: lefun.c:1243
long disjunct_aim ( )

disjunct_aim

DISJUNCT_AIM() This is the disjunction enumeration routine. If U is the disjunction {H|T} then first bind U to H, then on backtracking enumerate the disjunction T. U is always passed along so that every choice of the disjunction can be bound to U.

Definition at line 1621 of file login.c.

References TRUE.

1622 {
1623  // ptr_psi_term u,v;
1624  // ptr_list l;
1625  long success=TRUE;
1626 
1627  printf("Call to disjunct_aim\nThis routine inhibited by RM: Dec 9 1992\n");
1628 
1629  return success;
1630 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
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
ptr_psi_term distinct_copy ( ptr_psi_term  t)

distinct_copy

Parameters
t- ptr_psi_term t

DISTINCT_COPY(t) Make a distinct copy of T and T's attribute tree, which are identical to T, only located elsewhere in memory. This is used by apply to build the calling psi-term which is used for matching. Note that this routine is not recursive, i.e. it only copies the main functor & the attribute tree.

Definition at line 393 of file copy.c.

References wl_psi_term::attr_list, distinct_tree(), global_time_stamp, and STACK_ALLOC.

394 {
395  ptr_psi_term res;
396 
397  res=STACK_ALLOC(psi_term);
398  *res= *t;
399 #ifdef TS
400  res->time_stamp=global_time_stamp; /* 9.6 */
401 #endif
402  /* res->coref=distinct_copy(t->coref); */
404 
405  return res;
406 }
ptr_node distinct_tree(ptr_node t)
distinct_tree
Definition: copy.c:366
#define STACK_ALLOC(A)
Definition: def_macro.h:21
unsigned long global_time_stamp
Definition: login.c:28
ptr_node attr_list
Definition: def_struct.h:187
ptr_node distinct_tree ( ptr_node  t)

distinct_tree

Parameters
t- ptr_node t

DISTINCT_TREE(t) Return an exact copy of an attribute tree. This is used by APPLY in order to build the calling psi-term which is used for matching.

Definition at line 366 of file copy.c.

References wl_node::data, distinct_tree(), wl_node::key, wl_node::left, NULL, wl_node::right, and STACK_ALLOC.

367 {
368  ptr_node n;
369 
370  n=NULL;
371  if (t) {
372  n=STACK_ALLOC(node);
373  n->key=t->key;
374  n->data=t->data;
375  n->left=distinct_tree(t->left);
376  n->right=distinct_tree(t->right);
377  }
378 
379  return n;
380 }
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node distinct_tree(ptr_node t)
distinct_tree
Definition: copy.c:366
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_node right
Definition: def_struct.h:200
void do_currying ( )

do_currying

This performs CURRYing: all that needs to be done is to yield the calling term as the result after having given up on evaluation. In effect the calling psi-term is left intact.

Definition at line 383 of file lefun.c.

References wl_goal::aaaa_1, wl_goal::bbbb_1, goal_stack, wl_goal::next, NULL, push_goal(), resid_aim, traceline(), and unify_noeval.

384 {
385  ptr_psi_term funct,result;
386 
387  /* PVR 5.11 undo(resid_limit); */
388  /* PVR 5.11 choice_stack=cut_point; */
390  funct=(ptr_psi_term )resid_aim->aaaa_1;
391  result=(ptr_psi_term )resid_aim->bbbb_1;
392 
393  traceline("currying %P\n",funct);
394 
395  push_goal(unify_noeval,funct,result,NULL);
396  resid_aim=NULL;
397 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_goal goal_stack
Definition: def_glob.h:1025
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
void traceline(char *format,...)
traceline
Definition: error.c:186
#define unify_noeval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1065
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_goal next
Definition: def_struct.h:242
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
long do_residuation ( )

do_residuation

C-defined routines do all stack manipulation themselves

Definition at line 336 of file lefun.c.

References wl_goal::aaaa_1, deref_ptr, FALSE, wl_resid_list::next, wl_resid_list::othervar, print_resid_message(), resid_aim, resid_vars, residuateGoalOnVar(), trace, traceline(), tracing(), TRUE, and wl_resid_list::var.

337 {
338  long success;
339  ptr_psi_term t,u;
340  // ptr_goal *gs;
341 
342  /* This undoes perfectly valid work! */
343  /* The old version of Wild_Life did not trail anything
344  during matching, so I think this was a nop for it. */
345  /* PVR 11.5 undo(resid_limit); */
346  /* PVR 11.5 choice_stack=cut_point; */
347 
348  /* PVR 9.2.94 */
349  /* goal_stack=resid_aim->next; */
350 
351  if (trace) {
352  tracing();
354  }
355 
356  while (resid_vars) {
357 
358  t=resid_vars->var; /* 21.9 */
359  u=resid_vars->othervar; /* 21.9 */
360  /* PVR */ deref_ptr(t);
362  traceline("residuating on %P (other = %P)\n",t,u);
363 
364  success=residuateGoalOnVar(resid_aim, t, u); /* 21.9 */
365  if (!success) { /* 21.9 */
366  traceline("failure because of disentailment\n");
367  return FALSE;
368  }
369  }
370 
371  traceline("no failure because of disentailment\n");
372  return TRUE; /* 21.9 */
373 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void tracing()
tracing
Definition: error.c:678
ptr_resid_list next
Definition: def_struct.h:97
ptr_goal resid_aim
Definition: def_glob.h:865
ptr_resid_list resid_vars
Definition: def_glob.h:866
long trace
Definition: def_glob.h:913
void traceline(char *format,...)
traceline
Definition: error.c:186
#define deref_ptr(P)
Definition: def_macro.h:100
void print_resid_message(ptr_psi_term t, ptr_resid_list r)
print_resid_message
Definition: print.c:1690
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term var
Definition: def_struct.h:95
ptr_psi_term othervar
Definition: def_struct.h:96
long residuateGoalOnVar(ptr_goal g, ptr_psi_term var, ptr_psi_term othervar)
residuateGoalOnVar
Definition: lefun.c:192
long do_residuation_user ( )

do_residuation_user()

Undo anything that matching may have done, then create a residuated expression. Check that the same constraint does not hang several times on the same variable.

This routine takes time proportional to the square of the number of residuations. This is too slow; eventually it should be sped up, especially if equality constraints are often used.

Definition at line 324 of file lefun.c.

References do_residuation(), goal_stack, wl_goal::next, and resid_aim.

325 {
326  goal_stack=resid_aim->next; /* reset goal stack */
327  return do_residuation();
328 }
long do_residuation()
do_residuation
Definition: lefun.c:336
ptr_goal goal_stack
Definition: def_glob.h:1025
ptr_goal resid_aim
Definition: def_glob.h:865
ptr_goal next
Definition: def_struct.h:242
int dummy_printf ( char *  f,
char *  s,
char *  t 
)

dummy_printf

Parameters
f- char *f
s- char *s
t- char *t

Definition at line 2617 of file login.c.

2618 {
2619  return strlen(f);
2620 }
void encode_types ( )

encode_types

ENCODE_TYPES() This routine performs type-coding using transitive closure. First any previous coding is undone. Then a new encryption is performed.

Some of these routines loop indefinitely if there is a circular type definition (an error should be reported but it isn't implemented (but it's quite easy to do)).

Definition at line 1091 of file types.c.

References all_sorts(), built_in, wl_definition::children, clear_coding(), wl_definition::code, cons(), count_sorts(), equalize_codes(), Errorline(), FALSE, heap_alloc(), inherit_always_check(), integer, wl_definition::keyword, least_sorts(), lf_false, lf_true, make_sys_type_links(), make_type_link(), wl_int_list::next, NOT_CODED, nothing, NULL, or_codes(), overlap_type(), wl_definition::parents, perr(), propagate_definitions(), quoted_string, real, wl_keyword::symbol, top, traceline(), TRUE, two_to_the(), type_count, type_cyclicity(), types_done, types_modified, and wl_int_list::value_1.

1092 {
1093  long p=0,i,possible,ok=TRUE;
1094  ptr_int_list layer,l,kids,dads,code;
1095  ptr_definition xdef,kdef,ddef; //,err;
1096 
1097  if (types_modified) {
1098 
1099  nothing->parents=NULL;
1101 
1102  top->parents=NULL;
1103  top->children=NULL;
1104 
1105  /* The following definitions are vital to avoid crashes */
1107  make_type_link(lf_true,boolean);
1108  make_type_link(lf_false,boolean);
1109 
1110  /* These just might be useful */
1112  make_type_link(boolean,built_in);
1114 
1116 
1117  type_count=count_sorts(-1); /* bottom does not count */
1118  clear_coding();
1119  nothing->parents=NULL; /* Must be cleared before all_sorts */
1120  all_sorts();
1121  if (type_cyclicity(nothing,NULL)) {
1122  clear_coding();
1123  return;
1124  }
1125  clear_coding();
1126  nothing->parents=NULL; /* Must be cleared before least_sorts */
1127  least_sorts();
1128 
1129  nothing->code=NULL;
1130 
1131  /* RM: Feb 17 1993 */
1132  traceline("*** Codes:\n%C= %s\n", NULL, nothing->keyword->symbol);
1133 
1135 
1136  layer=nothing->parents;
1137 
1138  while (layer) {
1139  l=layer;
1140  do {
1141  xdef=(ptr_definition)l->value_1;
1142  if (xdef->code==NOT_CODED && xdef!=top) {
1143 
1144  kids=xdef->children;
1145  code=two_to_the(p);
1146 
1147  while (kids) {
1148  kdef=(ptr_definition)kids->value_1;
1149  or_codes(code,kdef->code);
1150  kids=kids->next;
1151  }
1152 
1153  xdef->code=code;
1154  gamma_table[p]=xdef;
1155 
1156  /* RM: Feb 17 1993 */
1157  traceline("%C = %s\n", code, xdef->keyword->symbol);
1158  p=p+1;
1159  }
1160 
1161  l=l->next;
1162 
1163  } while (l);
1164 
1165  l=layer;
1166  layer=NULL;
1167 
1168  do {
1169  xdef=(ptr_definition)l->value_1;
1170  dads=xdef->parents;
1171 
1172  while (dads) {
1173  ddef=(ptr_definition)dads->value_1;
1174  if(ddef->code==NOT_CODED) {
1175 
1176  possible=TRUE;
1177  kids=ddef->children;
1178 
1179  while(kids && possible) {
1180  kdef=(ptr_definition)kids->value_1;
1181  if(kdef->code==NOT_CODED)
1182  possible=FALSE;
1183  kids=kids->next;
1184  }
1185  if(possible)
1186  layer=cons((GENERIC)ddef,layer);
1187  }
1188  dads=dads->next;
1189  }
1190  l=l->next;
1191  } while(l);
1192  }
1193 
1194  top->code=two_to_the(p);
1195  for (i=0;i<p;i++)
1196  or_codes(top->code,two_to_the(i));
1197 
1198  gamma_table[p]=top;
1199 
1200  /* RM: Jan 13 1993 */
1201  /* Added the following line because type_count is now over generous
1202  because the same definition can be referenced several times in
1203  the symbol table because of modules
1204  */
1205  type_count=p+1;
1206  for(i=type_count;i<type_count;i++)
1207  gamma_table[i]=NULL;
1208 
1209  traceline("%C = @\n\n", top->code);
1210  equalize_codes(p/32+1);
1211 
1213 
1214  /* Inherit 'FALSE' always_check flags to all types' children */
1216 
1217  traceline("*** Encoding done, %d sorts\n",type_count);
1218 
1220  Errorline("the sorts 'real' and 'string' are not disjoint.\n");
1221  ok=FALSE;
1222  }
1223 
1224  /* RM: Dec 15 1992 I don't think this really matters any more
1225  if (overlap_type(real,alist)) {
1226  Errorline("the sorts 'real' and 'list' are not disjoint.\n");
1227  ok=FALSE;
1228  }
1229  */
1230 
1231  /* RM: Dec 15 1992 I don't think this really matters any more
1232  if (overlap_type(alist,quoted_string)) {
1233  Errorline("the sorts 'list' and 'string' are not disjoint.\n");
1234  ok=FALSE;
1235  }
1236  */
1237 
1238  if (!ok) {
1239  perr("*** Internal problem:\n");
1240  perr("*** Wild_Life may behave abnormally because some basic types\n");
1241  perr("*** have been defined incorrectly.\n\n");
1242  }
1243 
1245  types_done=TRUE;
1246  }
1247 }
long type_cyclicity(ptr_definition d, ptr_int_list anc)
type_cyclicity
Definition: types.c:977
ptr_definition * gamma_table
Definition: types.c:14
void least_sorts()
void least_sorts()
Definition: types.c:743
void perr(char *str)
perr
Definition: error.c:763
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
long type_count
Definition: def_glob.h:1021
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
ptr_int_list two_to_the(long p)
two_to_the
Definition: types.c:776
void propagate_definitions()
propagate_definitions
Definition: types.c:662
void clear_coding()
clear_coding
Definition: types.c:727
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
ptr_keyword keyword
Definition: def_struct.h:147
ptr_int_list cons(GENERIC v, ptr_int_list l)
cons
Definition: types.c:179
#define NULL
Definition: def_const.h:533
void make_sys_type_links()
make_sys_type_links
Definition: sys.c:2168
char * symbol
Definition: def_struct.h:118
long types_modified
Definition: def_glob.h:1022
void inherit_always_check()
inherit_always_check
Definition: types.c:1068
ptr_definition built_in
symbol in bi module
Definition: def_glob.h:199
void traceline(char *format,...)
traceline
Definition: error.c:186
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
void make_type_link(ptr_definition t1, ptr_definition t2)
make_type_link
Definition: types.c:901
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
void all_sorts()
all_sorts
Definition: types.c:759
#define FALSE
Standard boolean.
Definition: def_const.h:275
struct wl_definition * ptr_definition
Definition: def_struct.h:59
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
void equalize_codes(int len)
equalize_codes
Definition: types.c:859
long types_done
Definition: def_glob.h:1012
ptr_int_list code
Definition: def_struct.h:150
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
GENERIC value_1
Definition: def_struct.h:85
long count_sorts(long c0)
count_sorts
Definition: types.c:710
ptr_int_list children
Definition: def_struct.h:152
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void or_codes(ptr_int_list u, ptr_int_list v)
or_codes
Definition: types.c:831
ptr_int_list next
Definition: def_struct.h:86
ptr_int_list parents
Definition: def_struct.h:151
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 end_terminal_io ( )

end_terminal_io

END_TERMINAL_IO() End of terminal I/O bracketing.

Definition at line 516 of file token.c.

References inchange, input_state, NULL, old_state, out, outchange, output_stream, and restore_state().

517 {
518  if (inchange) {
521  old_state=NULL; /* RM: Feb 17 1993 */
522  }
523  if (outchange)
525 }
#define NULL
Definition: def_const.h:533
ptr_psi_term input_state
Definition: def_glob.h:856
ptr_psi_term old_state
Definition: token.c:480
static long outchange
Definition: token.c:478
void restore_state(ptr_psi_term t)
restore_state
Definition: token.c:334
static long inchange
Definition: token.c:478
static FILE * out
Definition: token.c:479
FILE * output_stream
Definition: def_glob.h:1017
void equalize_codes ( int  len)

equalize_codes

Parameters
len- int len

EQUALIZE_CODES(w) Make sure all codes are w words long, by increasing the length of the shorter ones. This simplifies greatly the bitvector manipulation routines. This operation should be done after encoding. For correct operation, w>=maximum number of words used for a code.

Definition at line 859 of file types.c.

References assert, wl_definition::code, first_definition, HEAP_ALLOC, wl_int_list::next, wl_definition::next, NULL, wl_definition::type_def, and type_it.

860 {
861  ptr_definition d;
862  ptr_int_list c,*ci;
863  long i;
864  int w;
865 
866  for(d=first_definition;d;d=d->next)
867  if (d->type_def==(def_type)type_it) {
868  c = d->code;
869  ci = &(d->code); /* RM: Feb 15 1993 */
870  w=len;
871 
872  /* Count how many words have to be added */
873  while (c) {
874  ci= &(c->next);
875  c=c->next;
876  w--;
877  }
878  assert(w>=0);
879  /* Add the words */
880  for (i=0; i<w; i++) {
881  *ci = HEAP_ALLOC(int_list);
882  (*ci)->value_1=0;
883  ci= &((*ci)->next);
884  }
885  (*ci)=NULL;
886  }
887 }
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
def_type type_def
Definition: def_struct.h:153
#define NULL
Definition: def_const.h:533
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition next
Definition: def_struct.h:164
ptr_int_list code
Definition: def_struct.h:150
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
#define assert(N)
Definition: memory.c:114
ptr_int_list next
Definition: def_struct.h:86
void Errorline ( char *  format,
  ... 
)

Errorline.

Parameters
format- char *format
...New error printing routine

Definition at line 465 of file error.c.

References assert, display_psi(), FALSE, input_file_name, parse_ok, perr_i(), perr_s(), print_code(), print_def_type(), print_operator_kind(), and psi_term_line_number.

466 {
467  va_list VarArg;
468  // int l;
469  char buffer_loc[5];
470  char *p;
471  unsigned long lng2;
472  char *cptr;
473  ptr_int_list pil;
474  ptr_psi_term psi;
475  operator kind;
476  def_type t ;
477 
478  va_start(VarArg,format);
479  // fprintf(stderr,"format = %lx %s\n",(long)format,format);fflush(stdout);
480  fprintf(stderr,"*** Error: ");
481  // fprintf(stderr,"format2 = %lx %s\n",(long)format,format);
482  // vinfoline(format, stderr, VarArg);
483  //#define vinfoline(format, stderr, xxxx) {
484  for (p=format;p && *p; p++)
485  {
486  if (*p == '%')
487  {
488  p++;
489  switch (*p)
490  {
491  case 'd':
492  case 'x':
493  buffer_loc[0] = '%';
494  buffer_loc[1] = 'l';
495  buffer_loc[2] = *p;
496  buffer_loc[3] = 0;
497  lng2 = va_arg(VarArg,long);
498  fprintf(stderr, buffer_loc, lng2);
499  break;
500  case 's':
501  buffer_loc[0] = '%';
502  buffer_loc[1] = *p;
503  buffer_loc[2] = 0;
504  cptr = va_arg(VarArg,char *);
505  fprintf(stderr, buffer_loc, cptr);
506  break;
507  case 'C':
508  /* type coding as bin string */
509  pil = va_arg(VarArg,ptr_int_list);
510  print_code(stderr,pil);
511  break;
512  case 'P':
513  psi = va_arg(VarArg,ptr_psi_term);
514  display_psi(stderr,psi);
515  break;
516  case 'O':
517  kind = va_arg(VarArg,operator);
518  print_operator_kind(stderr,kind);
519  break;
520  case 'T':
521  assert(stderr==stderr);
522  t = va_arg(VarArg,def_type);
523  print_def_type(t);
524  break;
525  case 'E':
526  assert(stderr==stderr);
527  perr_i("near line %ld",psi_term_line_number);
528  if (strcmp(input_file_name,"stdin")) {
529  perr_s(" in file \042%s\042",input_file_name);
530  }
531  parse_ok=FALSE;
532  break;
533  case '%':
534  (void)putc(*p,stderr);
535  break;
536  default:
537  fprintf(stderr,"<%c follows %% : report bug >", *p);
538  break;
539  }
540  }
541  else
542  (void)putc(*p,stderr);
543  }
544  va_end(VarArg);
545 #ifdef CLIFE
546  exit(0);
547 #endif
548 }
void perr_i(char *str, long i)
perr_i
Definition: error.c:800
long psi_term_line_number
Definition: def_glob.h:909
string input_file_name
Definition: def_glob.h:1016
void display_psi(FILE *s, ptr_psi_term t)
display_psi
Definition: print.c:1579
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
void print_code(FILE *s, ptr_int_list c)
print_code
Definition: print.c:167
void print_def_type(def_type t)
print_def_type
Definition: types.c:24
#define FALSE
Standard boolean.
Definition: def_const.h:275
void print_operator_kind(FILE *s, long kind)
print_operator_kind
Definition: print.c:192
#define assert(N)
Definition: memory.c:114
long eval_aim ( )

eval_aim

EVAL_AIM() Evaluate a function. This copies the current definition of the function and stacking the various goals that are necessary to evaluate the function correctly. It creates an extra psi-term (with value top) in which to write the result.

Definition at line 497 of file lefun.c.

References wl_goal::aaaa_1, wl_pair_list::aaaa_2, aim, wl_goal::bbbb_1, wl_pair_list::bbbb_2, c_rule, can_curry, wl_goal::cccc_1, choice_stack, clear_copy(), curried, deref_ptr, do_currying(), do_residuation(), eval, eval_copy(), eval_cut, FALSE, int_ptr, match, MAX_BUILT_INS, wl_pair_list::next, NULL, push2_ptr_value(), push_choice_point(), push_goal(), quote_copy(), resid_aim, resid_vars, save_resid(), SMASK, STACK, STACK_ALLOC, stack_pointer, wl_psi_term::status, traceline(), TRUE, and unify.

498 {
499  long success=TRUE;
500  ptr_psi_term funct,result,head,body;
501  ptr_pair_list rule;
502  /* RESID */ ptr_resid_block rb;
503  ptr_choice_point cutpt;
504  ptr_psi_term match_date; /* 13.6 */
505 
506  funct=(ptr_psi_term )aim->aaaa_1;
507  deref_ptr(funct);
508 
509  /* RM: Jun 18 1993 */
510  push2_ptr_value(int_ptr,(GENERIC *)&(funct->status),(GENERIC)(funct->status & SMASK));
511  funct->status=4;
512 
513  /* if (!funct->type->evaluate_args) mark_quote(funct); 25.8 */ /* 18.2 PVR */
514  result=(ptr_psi_term )aim->bbbb_1;
515  rule=(ptr_pair_list )aim->cccc_1;
516 
517  match_date=(ptr_psi_term )stack_pointer;
518  cutpt=choice_stack; /* 13.6 */
519 
520  /* For currying and residuation */
521  curried=FALSE;
522  can_curry=TRUE;
523  /* resid_aim=aim; */
525  /* resid_limit=(ptr_goal )stack_pointer; 12.6 */
526 
527  if (rule) {
528  traceline("evaluate %P\n",funct);
529  if ((unsigned long)rule<=MAX_BUILT_INS) {
530 
531  resid_aim=aim;
532  success=c_rule[(unsigned long)rule]();
533 
534  if (curried)
535  do_currying();
536  else
537  if (resid_vars)
538  success=do_residuation(); /* 21.9 */
539  else {
540  /* resid_aim=NULL; */
541  }
542  }
543  else {
544  while (rule && (rule->aaaa_2==NULL || rule->bbbb_2==NULL)) {
545  rule=rule->next;
546  traceline("alternative rule has been retracted\n");
547  }
548  if (rule) {
549  /* push_choice_point(eval,funct,result,rule->next); */ /* 17.6 */
550 
551  resid_aim=aim;
552  /* RESID */ rb = STACK_ALLOC(resid_block);
553  /* RESID */ save_resid(rb,match_date);
554  /* RESID */ /* resid_aim = NULL; */
555 
556  clear_copy();
557 
558  /* RM: Jun 18 1993: no functions in head */
559  /* if (TRUE)
560  head=eval_copy(rule->aaaa_1,STACK);
561  else */
562 
563  head=quote_copy(rule->aaaa_2,STACK);
564  body=eval_copy(rule->bbbb_2,STACK);
565  head->status=4;
566 
567  if (rule->next) /* 17.6 */
568  push_choice_point(eval,funct,result,(GENERIC)rule->next);
569 
570  push_goal(unify,body,result,NULL);
571  /* RESID */ push_goal(eval_cut,body,(ptr_psi_term)cutpt,(GENERIC)rb); /* 13.6 */
572  /* RESID */ push_goal(match,funct,head,(GENERIC)rb);
573  /* eval_args(head->attr_list); */
574  }
575  else {
576  success=FALSE;
577  /* resid_aim=NULL; */
578  }
579  }
580  }
581  else {
582  success=FALSE;
583  /* resid_aim=NULL; */
584  }
585  resid_aim=NULL;
586  /* match_date=NULL; */ /* 13.6 */
587  return success;
588 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_psi_term aaaa_2
Definition: def_struct.h:205
long do_residuation()
do_residuation
Definition: lefun.c:336
void clear_copy()
clear_copy
Definition: copy.c:53
void push2_ptr_value(type_ptr t, GENERIC *p, GENERIC v)
push2_ptr_value
Definition: login.c:573
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_pair_list next
Definition: def_struct.h:207
GENERIC cccc_1
Definition: def_struct.h:241
long(* c_rule[MAX_BUILT_INS])()
Definition: def_glob.h:888
void do_currying()
do_currying
Definition: lefun.c:383
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
ptr_resid_list resid_vars
Definition: def_glob.h:866
#define eval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1086
void traceline(char *format,...)
traceline
Definition: error.c:186
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
quote_copy
Definition: copy.c:186
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define match
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1121
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term bbbb_2
Definition: def_struct.h:206
ptr_goal aim
Definition: def_glob.h:1024
#define STACK_ALLOC(A)
Definition: def_macro.h:21
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long can_curry
Definition: def_glob.h:869
long curried
Definition: def_glob.h:868
#define eval_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1093
void save_resid(ptr_resid_block rb, ptr_psi_term match_date)
save_resid
Definition: lefun.c:1398
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
ptr_psi_term eval_copy(ptr_psi_term t, long heap_flag)
eval_copy
Definition: copy.c:196
ptr_psi_term bbbb_1
Definition: def_struct.h:240
#define SMASK
Bit mask for status field of psi-terms: SMASK masks off the status bits. These are used in the 'mark'...
Definition: def_const.h:367
ptr_choice_point choice_stack
Definition: def_glob.h:1026
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
#define int_ptr
values of type_ptr
Definition: def_const.h:397
long eval_args ( ptr_node  n)

eval_args

Parameters
n- ptr_node n

EVAL_ARGS(n) N is an attribute tree, the attributes must be examined, if any reveal themselves to need evaluating then return FALSE.

Definition at line 889 of file lefun.c.

References check_out(), wl_node::data, wl_node::left, wl_node::right, and TRUE.

890 {
891  long flag=TRUE;
892 
893  if (n) {
894  flag = eval_args(n->right);
895  flag = check_out((ptr_psi_term)n->data) && flag;
896  flag = eval_args(n->left) && flag;
897  }
898 
899  return flag;
900 }
long eval_args(ptr_node n)
eval_args
Definition: lefun.c:889
long check_out(ptr_psi_term t)
Definition: lefun.c:1083
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_node right
Definition: def_struct.h:200
ptr_psi_term eval_copy ( ptr_psi_term  t,
long  heap_flag 
)

eval_copy

Parameters
t- ptr_psi_term t
heap_flag- long heap_flag

Definition at line 196 of file copy.c.

References copy(), EVAL_FLAG, FALSE, and to_heap.

197 { to_heap=FALSE; return (copy(t, EVAL_FLAG, heap_flag)); }
#define EVAL_FLAG
flag to copy function in copy.c to indicate kind of copy
Definition: def_const.h:1320
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
copy
Definition: copy.c:248
long to_heap
Definition: def_glob.h:905
#define FALSE
Standard boolean.
Definition: def_const.h:275
void eval_global_var ( ptr_psi_term  t)

eval_global_var

Parameters
t- ptr_psi_term t

EVAL_GLOBAL_VAR(t) Dereference a global variable.

Definition at line 1440 of file lefun.c.

References wl_stack::aaaa_3, wl_stack::bbbb_3, clear_copy(), wl_psi_term::coref, deref_ptr, eval_copy(), global_it, wl_definition::global_value, wl_definition::init_value, wl_stack::next, NULL, psi_term_ptr, push_psi_ptr_value(), STACK, STACK_ALLOC, traceline(), wl_psi_term::type, wl_stack::type, wl_definition::type_def, and undo_stack.

1441 {
1442  deref_ptr(t);
1443 
1444  /* Global variable (not persistent) */
1445 
1446  traceline("dereferencing variable %P\n",t);
1447 
1448  /* Trails the heap RM: Nov 10 1993 */
1449  if(!t->type->global_value) {
1450 
1451  /* Trail the heap !! */
1452  {
1453  ptr_stack n;
1454  n=STACK_ALLOC(stack);
1455  n->type=psi_term_ptr;
1456  n->aaaa_3= (GENERIC *) &(t->type->global_value);
1457  n->bbbb_3= (GENERIC *) NULL;
1458  n->next=undo_stack;
1459  undo_stack=n;
1460  }
1461 
1462 
1463  clear_copy();
1465 
1466  }
1467 
1468  /* var_occurred=TRUE; RM: Feb 4 1994 */
1469 
1470  if(t->type->type_def==(def_type)global_it && t!=t->type->global_value) {
1471  /*traceline("dereferencing variable %P\n",t);*/
1472  push_psi_ptr_value(t,(GENERIC *)&(t->coref));
1473  t->coref=t->type->global_value;
1474  }
1475 }
ptr_psi_term init_value
Definition: def_struct.h:160
void clear_copy()
clear_copy
Definition: copy.c:53
GENERIC * bbbb_3
Definition: def_struct.h:233
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
def_type type_def
Definition: def_struct.h:153
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
#define NULL
Definition: def_const.h:533
void traceline(char *format,...)
traceline
Definition: error.c:186
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
type_ptr type
Definition: def_struct.h:231
ptr_psi_term global_value
Definition: def_struct.h:159
ptr_psi_term coref
Definition: def_struct.h:188
#define STACK_ALLOC(A)
Definition: def_macro.h:21
GENERIC * aaaa_3
Definition: def_struct.h:232
ptr_psi_term eval_copy(ptr_psi_term t, long heap_flag)
eval_copy
Definition: copy.c:196
ptr_definition type
Definition: def_struct.h:181
ptr_stack next
Definition: def_struct.h:234
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
#define psi_term_ptr
values of type_ptr
Definition: def_const.h:383
ptr_psi_term exact_copy ( ptr_psi_term  t,
long  heap_flag 
)

exact_copy

Parameters
t- ptr_psi_term t
heap_flag- long heap_flag

Definition at line 176 of file copy.c.

References copy(), EXACT_FLAG, FALSE, and to_heap.

177 { to_heap=FALSE; return (copy(t, EXACT_FLAG, heap_flag)); }
#define EXACT_FLAG
flag to copy function in copy.c to indicate kind of copy
Definition: def_const.h:1306
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
copy
Definition: copy.c:248
long to_heap
Definition: def_glob.h:905
#define FALSE
Standard boolean.
Definition: def_const.h:275
void exit_if_true ( long  exitflag)

exit_if_true

Parameters
exitflag- long exitflag

Definition at line 55 of file lib.c.

56 {
57  if (exitflag) {
58  printf("\n\n*** Execution is not allowed to continue.\n");
59  /*exit_life(TRUE);*/
60  exit(EXIT_FAILURE);
61  }
62 }
void exit_life ( long  nl_flag)

exit_life

Parameters
nl_flag- long nl_flag

Definition at line 2219 of file built_ins.c.

References garbage_time, life_end, life_start, NOTQUIET, and open_input_file().

2220 {
2221  (void)open_input_file("stdin");
2222  (void)times(&life_end);
2223  if (NOTQUIET) { /* 21.1 */
2224  if (nl_flag) printf("\n");
2225  printf("*** Exiting Wild_Life ");
2226  printf("[%1.3fs cpu, %1.3fs gc (%2.1f%%)]\n",
2227  (life_end.tms_utime-life_start.tms_utime)/60.0,
2228  garbage_time,
2229  garbage_time*100 / ((life_end.tms_utime-life_start.tms_utime)/60.0)
2230  );
2231  }
2232 
2233 #ifdef ARITY /* RM: Mar 29 1993 */
2234  arity_end();
2235 #endif
2236 
2237  exit(EXIT_SUCCESS);
2238 }
struct tms life_end
Definition: def_glob.h:90
float garbage_time
total time on garbage collections - seconds
Definition: def_glob.h:76
#define NOTQUIET
Definition: def_macro.h:15
struct tms life_start
time life started - seconds
Definition: def_glob.h:83
long open_input_file(char *file)
open_input_file
Definition: token.c:594
char * expand_file_name ( char *  s)

expand_file_name

Parameters
s- char *s

EXPAND_FILE_NAME(str) Return the expansion of file name STR. For the time being all this does is replace '~' by the HOME directory if no user is given, or tries to find the user.

Definition at line 537 of file token.c.

References STRLEN.

538 {
539  char *r;
540  char *home; // *getenv();
541  struct passwd *pw;
542  /* char *user="eight character name"; 18.5 */
543  char userbuf[STRLEN];
544  char *user=userbuf;
545  char *t1,*t2;
546 
547  r=s;
548  if (s[0]=='~') {
549  t1=s+1;
550  t2=user;
551  while (*t1!=0 && *t1!='/') {
552  *t2= *t1;
553  *t2++;
554  *t1++;
555  }
556  *t2=0;
557  if ((int)strlen(user)>0) {
558  pw = getpwnam(user);
559  if (pw) {
560  user=pw->pw_dir;
561  r=(char *)malloc(strlen(user)+strlen(t1)+1);
562  sprintf(r,"%s%s",user,t1);
563  }
564  else
565  /* if (warning()) printf("couldn't find user '%s'.\n",user) */;
566  }
567  else {
568  home=getenv("HOME");
569  if (home) {
570  r=(char *)malloc(strlen(home)+strlen(s)+1);
571  sprintf(r,"%s%s",home,s+1);
572  }
573  else
574  /* if (warning()) printf("no HOME directory.\n") */;
575  }
576  }
577 
578  /* printf("*** Using file name: '%s'\n",r); */
579 
580  return r;
581 }
#define STRLEN
Maximum size of file names and input tokens (which includes input strings) (Note: calculated tokens c...
Definition: def_const.h:162
ptr_module extract_module_from_name ( char *  str)

extract_module_from_name

Parameters
str- char *str

EXTRACT_MODULE_FROM_NAME Return the module corresponding to "module#symbol". Return NULL if only "#symbol".

Definition at line 116 of file modules.c.

References create_module(), legal_in_name(), and NULL.

117 {
118  char *s;
119  ptr_module result=NULL;
120 
121  s=str;
122  while(legal_in_name(*s))
123  s++;
124  if(s!=str && *s=='#' /* && *(s+1)!=0 */) {
125  *s=0;
126  result=create_module(str);
127  *s='#';
128  /*
129  printf("Extracted module name '%s' from '%s'\n",result->module_name,str);
130  */
131  }
132 
133  return result;
134 }
long legal_in_name(long c)
legal_in_name
Definition: token.c:980
#define NULL
Definition: def_const.h:533
ptr_module create_module(char *module)
ptr_module create_module(char *module)
Definition: modules.c:72
long f_check_out ( ptr_psi_term  t)

f_check_out

Parameters
t- ptr_psi_term t
  • f_check_out(t) checks out functions too.

Definition at line 1046 of file lefun.c.

References check_func_flag, check_out(), and TRUE.

1048 {
1050  return check_out(t);
1051 }
long check_out(ptr_psi_term t)
Definition: lefun.c:1083
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long check_func_flag
Definition: lefun.c:13
void fail_all ( )

fail_all

FAIL_ALL() This routines provokes a total failure, in case of a bad error (out of memory, abort, etc...). All goals are abandoned.

Definition at line 189 of file memory.c.

References abort_life(), choice_stack, goal_stack, NULL, open_input_file(), output_stream, stdin_cleareof(), TRUE, and undo_stack.

190 {
191  output_stream=stdout;
195  (void)abort_life(TRUE);
196  /* printf("\n*** Abort\n"); */
197  stdin_cleareof();
198  (void)open_input_file("stdin");
199 }
ptr_goal goal_stack
Definition: def_glob.h:1025
#define NULL
Definition: def_const.h:533
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
ptr_stack undo_stack
Definition: def_glob.h:1027
#define TRUE
Standard boolean.
Definition: def_const.h:268
FILE * output_stream
Definition: def_glob.h:1017
void stdin_cleareof()
stdin_cleareof
Definition: token.c:51
long open_input_file(char *file)
open_input_file
Definition: token.c:594
ptr_choice_point choice_stack
Definition: def_glob.h:1026
long featcmp ( char *  str1,
char *  str2 
)

featcmp

Parameters
str1- char *str1
str2- char *str2

FEATCMP(s1,s2) Compares two strings which represent features, for use in FIND or INSERT. This differs from strcmp for those strings that represent integers. These are compared as integers. In addition, all integers are considered to be less than all strings that do not represent integers.

Definition at line 106 of file trees.c.

References is_int().

107 {
108  long len1,len2,sgn1,sgn2;
109  char *s1,*s2;
110 
111  if(str1==str2)
112  return 0;
113 
114  /* if (*str1==0 && *str2==0) return 0; "" bug is unaffected -- PVR 23.2.94 */
115 
116  if(*(str1+1)==0 && *(str2+1)==0)
117  return *str1 - *str2;
118 
119 
120  s1=str1; /* Local copies of the pointers */
121  s2=str2;
122 
123  if (is_int(&s1,&len1,&sgn1)) {
124  if (is_int(&s2,&len2,&sgn2)) {
125  if (sgn1!=sgn2) return (sgn2-sgn1); /* Check signs first */
126  if (len1!=len2) return (len1-len2); /* Then check lengths */
127  return strcmp(s1,s2); /* Use strcmp only if same sign and length */
128  }
129  else
130  return -1;
131  }
132  else {
133  if (is_int(&s2,&len2,&sgn2))
134  return 1;
135  else
136  return strcmp(s1,s2);
137  }
138 }
long is_int(char **s, long *len, long *sgn)
is_int
Definition: trees.c:41
void feature_insert ( char *  keystr,
ptr_node tree,
ptr_psi_term  psi 
)

feature_insert

Parameters
keystr- char *keystr
tree- ptr_node *tree
psi- ptr_psi_term psi

FEATURE_INSERT(keystr,tree,psi) Insert the psi_term psi into the attribute tree. If the feature already exists, create a call to the unification function.

Definition at line 251 of file parser.c.

References FEATCMP, find(), stack_copy_psi_term(), stack_insert_copystr(), and Syntaxerrorline().

252 {
253  ptr_node loc;
254  ptr_psi_term stk_psi;
255 
256  // printf("before find in feature_insert feature=%s\n",keystr);
257  if ((loc=find(FEATCMP,keystr,*tree))) {
258  /* Give an error message if there is a duplicate feature: */
259  Syntaxerrorline("duplicate feature %s\n",keystr);
260  }
261  else {
262  /* If the feature does not exist, insert it. */
263  stk_psi=stack_copy_psi_term(*psi); // 19.8 */
264  stack_insert_copystr(keystr,tree,(GENERIC)stk_psi); /* 10.8 */
265  }
266 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
void Syntaxerrorline(char *format,...)
Syntaxerrorline.
Definition: error.c:557
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
void stack_insert_copystr(char *keystr, ptr_node *tree, GENERIC info)
stack_insert_copystr
Definition: trees.c:301
void fetch_def ( ptr_psi_term  u,
long  allflag 
)

fetch_def

Parameters
u- ptr_psi_term u
allflag- long allflag

FETCH_DEF(psi_term) Fetch the type definition of a psi_term and execute it. That is, get the list of (term,predicate) pairs that define the type. Unify the psi_term with the term, then prove the predicate.

This routine only gets the pairs that are defined in the type itself, not those defined in any types above it. This is the correct behavior for enumerating type disjunctions–all higher constraints have already been checked.

The above is true if allflag==FALSE. If allflag==TRUE then all constraints are executed, not just those defined in the type itself.

Definition at line 1208 of file login.c.

References wl_triple_list::aaaa_4, wl_psi_term::attr_list, wl_triple_list::bbbb_4, wl_triple_list::cccc_4, clear_copy(), DEFRULES, deref_ptr, eval_copy(), i_eval_args(), int_ptr, wl_triple_list::next, NULL, wl_definition::properties, prove, push2_ptr_value(), push_goal(), RMASK, SMASK, STACK, wl_psi_term::status, traceline(), wl_psi_term::type, and unify.

1209 {
1210  ptr_triple_list prop;
1211  ptr_psi_term v,w;
1212  ptr_definition utype;
1213 
1214  /* Uses SMASK because called from check_out */
1216  u->status=(4 & SMASK) | (u->status & RMASK);
1217 
1218  utype=u->type;
1219  prop=u->type->properties;
1220  if (prop) {
1221 
1222  traceline("fetching definition of %P\n",u);
1223 
1224  while (prop) {
1225  if (allflag || prop->cccc_4==utype) {
1226  clear_copy();
1227  v=eval_copy(prop->aaaa_4,STACK);
1228  w=eval_copy(prop->bbbb_4,STACK);
1229 
1231 
1232  deref_ptr(v);
1233  v->status=4;
1235  (void)i_eval_args(v->attr_list);
1236  }
1237  prop=prop->next;
1238  }
1239  }
1240 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
void push2_ptr_value(type_ptr t, GENERIC *p, GENERIC v)
push2_ptr_value
Definition: login.c:573
void clear_copy()
clear_copy
Definition: copy.c:53
void push_goal(goals t, ptr_psi_term aaaa_5, ptr_psi_term bbbb_5, GENERIC cccc_5)
push_goal
Definition: login.c:600
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
ptr_triple_list next
Definition: def_struct.h:215
ptr_definition cccc_4
Definition: def_struct.h:214
void traceline(char *format,...)
traceline
Definition: error.c:186
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
#define RMASK
Bit mask for status field of psi-terms: RMASK is used as a flag to avoid infinite loops when tracing ...
Definition: def_const.h:359
ptr_psi_term bbbb_4
Definition: def_struct.h:213
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long i_eval_args(ptr_node n)
i_eval_args
Definition: lefun.c:874
ptr_psi_term eval_copy(ptr_psi_term t, long heap_flag)
eval_copy
Definition: copy.c:196
ptr_definition type
Definition: def_struct.h:181
ptr_triple_list properties
Definition: def_struct.h:149
#define SMASK
Bit mask for status field of psi-terms: SMASK masks off the status bits. These are used in the 'mark'...
Definition: def_const.h:367
ptr_node attr_list
Definition: def_struct.h:187
ptr_psi_term aaaa_4
Definition: def_struct.h:212
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void fetch_def_lazy ( ptr_psi_term  u,
ptr_definition  old1,
ptr_definition  old2,
ptr_node  old1attr,
ptr_node  old2attr,
long  old1stat,
long  old2stat 
)

fetch_def_lazy

Parameters
u-ptr_psi_term u
old1- ptr_definition old1
old2- ptr_definition old2
old1attr- ptr_node old1attr
old2attr- ptr_node old2attr
old1stat- long old1stat
old2stat- long old2stat

FETCH_DEF_LAZY(psi_term,type1,type2,attr_list1,attr_list2) Fetch the type definition of a psi_term and execute it. That is, get the list of (term,pred) pairs that define the type. 'Term' is one of the type's attributes and 'pred' is a constraint. Unify the psi_term with the term, then prove pred.

Only those (term,pred) pairs are executed whose original type is below both type1 and type2, the types of the two psi-terms whose unification created psi_term. This avoids doing much superfluous work.

The above behavior is correct for a psi_term when always_check==TRUE for that psi_term. If always_check==FALSE for a psi_term, then if it does not have attributes it is not checked, and the addition of an attribute will force checking to occur.

Example:

:: t(a=>one,b=>two,c=> X) | thing(X).

psi_term = A:t (it can be any psi_term of type t) term = t(a=>one,b=>two,c=> X) pred = thing(X)

Definition at line 1276 of file login.c.

References wl_triple_list::aaaa_4, wl_definition::always_check, wl_psi_term::attr_list, wl_triple_list::bbbb_4, wl_triple_list::cccc_4, clear_copy(), DEFRULES, deref_ptr, eval_copy(), FALSE, i_eval_args(), int_ptr, matches(), wl_triple_list::next, NULL, wl_definition::properties, prove, push_goal(), push_ptr_value(), STACK, wl_psi_term::status, traceline(), wl_psi_term::type, and unify.

1277 {
1278  ptr_triple_list prop;
1279  ptr_psi_term v,w;
1280  long checked1, checked2;
1281  long m1, m2;
1282 
1283  if (!u->type->always_check) if (u->attr_list==NULL) return;
1284 
1286  u->status=4;
1287 
1288  prop=u->type->properties;
1289  if (prop) {
1290  traceline("fetching partial definition of %P\n",u);
1291 
1292  checked1 = old1attr || old1->always_check;
1293  checked2 = old2attr || old2->always_check;
1294 
1295  /* checked1 = (old1stat==4); */ /* 18.2.94 */
1296  /* checked2 = (old2stat==4); */
1297 
1298  while (prop) {
1299  /* Only do those constraints that have not yet been done: */
1300  /* In matches, mi is TRUE iff oldi <| prop->cccc_1. */
1301  if (!checked1) m1=FALSE; else (void)matches(old1,prop->cccc_4,&m1);
1302  if (!checked2) m2=FALSE; else (void)matches(old2,prop->cccc_4,&m2);
1303  if (!m1 && !m2) {
1304  /* At this point, prop->cccc_1 is an attribute that has not yet */
1305  /* been checked. */
1306  clear_copy();
1307  v=eval_copy(prop->aaaa_4,STACK);
1308  w=eval_copy(prop->bbbb_4,STACK);
1309 
1311 
1312  deref_ptr(v);
1313  v->status=4;
1315  (void)i_eval_args(v->attr_list);
1316  }
1317  prop=prop->next;
1318  }
1319  }
1320 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
void clear_copy()
clear_copy
Definition: copy.c:53
void push_goal(goals t, ptr_psi_term aaaa_5, ptr_psi_term bbbb_5, GENERIC cccc_5)
push_goal
Definition: login.c:600
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
ptr_triple_list next
Definition: def_struct.h:215
ptr_definition cccc_4
Definition: def_struct.h:214
char always_check
Definition: def_struct.h:154
void traceline(char *format,...)
traceline
Definition: error.c:186
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_psi_term bbbb_4
Definition: def_struct.h:213
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long i_eval_args(ptr_node n)
i_eval_args
Definition: lefun.c:874
ptr_psi_term eval_copy(ptr_psi_term t, long heap_flag)
eval_copy
Definition: copy.c:196
ptr_definition type
Definition: def_struct.h:181
ptr_triple_list properties
Definition: def_struct.h:149
ptr_node attr_list
Definition: def_struct.h:187
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
ptr_psi_term aaaa_4
Definition: def_struct.h:212
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
#define int_ptr
values of type_ptr
Definition: def_const.h:397
long file_exists ( char *  s)

file_exists

Parameters
s- char *s

Definition at line 1711 of file built_ins.c.

References expand_file_name(), FALSE, and TRUE.

1712 {
1713  FILE *f;
1714  char *e;
1715  long success=FALSE;
1716 
1717  e=expand_file_name(s);
1718  if ((f=fopen(e,"r"))) {
1719  (void)fclose(f);
1720  success=TRUE;
1721  }
1722  return success;
1723 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
char * expand_file_name(char *s)
expand_file_name
Definition: token.c:537
ptr_psi_term fileptr2stream ( FILE *  fp,
ptr_definition  typ 
)

fileptr2stream

Parameters
fp- FILE *fp
typ- ptr_definition typ removed * DJD = prior to 2.29

Definition at line 688 of file sys.c.

References BYTEDATA_DATA, FP_NONE, and make_bytedata().

689 {
690  ptr_psi_term result = make_bytedata(typ,sizeof(struct a_stream));
691  ((ptr_stream)BYTEDATA_DATA(result))->fp = fp;
692  ((ptr_stream)BYTEDATA_DATA(result))->op = FP_NONE;
693  return result;
694 }
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:668
#define BYTEDATA_DATA(X)
Definition: sys.c:139
Definition: sys.c:672
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
make_bytedata(
Definition: sys.c:126
ptr_node find ( long  comp,
char *  keystr,
ptr_node  tree 
)

find

Parameters
comp- long comp
keystr- char *keystr
tree- ptr_node tree

FIND(comp,keystr,tree) Return the NODE address corresponding to key KEYSTR in TREE using function COMP to compare keys.

Definition at line 394 of file trees.c.

References Errorline(), FALSE, featcmp(), FEATCMP, intcmp(), INTCMP, wl_node::left, NULL, wl_node::right, STRCMP, and TRUE.

395 {
396  ptr_node result;
397  long cmp;
398  long to_do=TRUE;
399 
400  /*
401  if(comp==strcmp)
402  printf("%s ",keystr);
403  */
404 
405  do {
406  if (tree==NULL) {
407  result=NULL;
408  to_do=FALSE;
409  }
410  else {
411  if (comp == INTCMP)
412  cmp = intcmp((long)keystr,(long) (tree)->key);
413  else if (comp == FEATCMP)
414  cmp = featcmp(keystr,(tree)->key);
415  else if (comp == STRCMP)
416  cmp = strcmp(keystr,(tree)->key);
417  else
418  Errorline("Bad comp in general_insert.\n");
419 
420  if (cmp<0)
421  tree=tree->left;
422  else
423  if (cmp==0) {
424  result=tree;
425  to_do=FALSE;
426  }
427  else
428  tree=tree->right;
429  }
430  } while (to_do);
431 
432 
433  /* RM: Jan 27 1993
434  if(comp==strcmp)
435  printf("Find: '%s' -> %x\n",keystr,result);
436  */
437 
438  return result;
439 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
#define INTCMP
indicates to use intcmp for comparison (in trees.c)
Definition: def_const.h:971
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define STRCMP
indicates to use strcmp for comparison (c function)
Definition: def_const.h:963
#define FALSE
Standard boolean.
Definition: def_const.h:275
long intcmp(long a, long b)
intcmp
Definition: trees.c:21
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
ptr_node right
Definition: def_struct.h:200
void find_adults ( )

find_adults

FIND_ADULTS() Returns the list of all the maximal types (apart from top) in the symbol table. That is, types which have no parents. This routine modifies the global variable 'adults'.

Definition at line 549 of file types.c.

References adults, first_definition, HEAP_ALLOC, wl_int_list::next, wl_definition::next, NULL, wl_definition::parents, wl_definition::type_def, type_it, and wl_int_list::value_1.

551 {
552  ptr_definition d;
553  ptr_int_list l;
554 
555  for(d=first_definition;d;d=d->next)
556  if(d->type_def==(def_type)type_it && d->parents==NULL) {
557  l=HEAP_ALLOC(int_list);
558  l->value_1=(GENERIC)d;
559  l->next=adults;
560  adults=l;
561  }
562 }
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
def_type type_def
Definition: def_struct.h:153
#define NULL
Definition: def_const.h:533
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition next
Definition: def_struct.h:164
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_int_list adults
Definition: def_glob.h:1001
GENERIC value_1
Definition: def_struct.h:85
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_int_list next
Definition: def_struct.h:86
ptr_int_list parents
Definition: def_struct.h:151
ptr_node find_data ( GENERIC  p,
ptr_node  t 
)

find_data

Parameters
p- GENERIC p
t- ptr_node t

FIND_DATA(p,t) Return the node containing the data P in tree T. This is a linear search and can be used to find the key to some data if it is unkown. Return NULL if no key corresponds to data P.

Definition at line 452 of file trees.c.

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

453 {
454  ptr_node r=NULL;
455 
456  if(t)
457  if(t->data==p)
458  r=t;
459  else {
460  r=find_data(p,t->left);
461  if(r==NULL)
462  r=find_data(p,t->right);
463  }
464 
465  return r;
466 }
ptr_node find_data(GENERIC p, ptr_node t)
find_data
Definition: trees.c:452
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
ptr_node right
Definition: def_struct.h:200
ptr_module find_module ( char *  module)

find_module

Parameters
modulechar *module

FIND_MODULE(module) Return a module if it exists.

Definition at line 54 of file modules.c.

References wl_node::data, FEATCMP, find(), and NULL.

55 {
56  ptr_node nodule;
57 
58  nodule=find(FEATCMP,(char *)module,module_table);
59  if(nodule)
60  return (ptr_module)(nodule->data);
61  else
62  return NULL;
63 }
ptr_node module_table
Definition: modules.c:14
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
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 garbage ( )

garbage

GARBAGE() The garbage collector. This routine is called whenever memory is getting low. It returns TRUE if insufficient memory was freed to allow the interpreter to carry on working.

This is a half-space GC, it first explores all known structures, then compresses the heap and the stack, then during the second pass assigns all the new addresses.

Bugs will appear if the collector is called during parsing or other such routines which are 'unsafe'. In order to avoid this problem, before one of these routines is invoked the program will check to see whether there is enough memory available to work, and will call the GC if not (this is a fix, because it is not possible to determine in advance what the size of a psi_term read by the parser will be).

Definition at line 1530 of file memory.c.

References assert, bounds_undo_stack(), check(), clear_copy(), compress(), FALSE, garbage_time, gc_time, heap_pointer, ignore_eff, last_garbage_time, life_time, mem_base, mem_limit, NULL, other_base, other_limit, pass, pointer_names, print_gc_info(), printed_pointers, stack_info(), stack_pointer, TRUE, and verbose.

1531 {
1532  GENERIC addr;
1533  struct tms garbage_start_time,garbage_end_time;
1534  long start_number_cells, end_number_cells;
1535 
1536  start_number_cells = (stack_pointer-mem_base) + (mem_limit-heap_pointer);
1537 
1538  (void)times(&garbage_start_time);
1539 
1540  /* Time elapsed since last garbage collection */
1541  life_time=(garbage_start_time.tms_utime - last_garbage_time.tms_utime)/60.0;
1542 
1543 
1544  if (verbose) {
1545  fprintf(stderr,"*** Garbage Collect "); /* RM: Jan 26 1993 */
1546  fprintf(stderr,"\n*** Begin");
1548  (void)fflush(stderr);
1549  }
1550 
1551  /* reset the other base */
1552  for (addr = other_base; addr < other_limit; addr ++)
1553  *addr = 0;
1554 
1555  pass=1;
1556 
1557  check();
1558 #ifdef GCVERBOSE
1559  fprintf(stderr,"- Done pass 1 ");
1560 #endif
1561 
1563  compress();
1564 #ifdef GCVERBOSE
1565  fprintf(stderr,"- Done compress ");
1566 #endif
1567 
1568  pass=2;
1569 
1570  check();
1572 #ifdef GCVERBOSE
1573  fprintf(stderr,"- Done pass 2\n");
1574 #endif
1575 
1576  clear_copy();
1577 
1580 
1581  (void)times(&garbage_end_time);
1582  gc_time=(garbage_end_time.tms_utime - garbage_start_time.tms_utime)/60.0;
1584 
1585  if (verbose) {
1586  fprintf(stderr,"*** End ");
1587  print_gc_info(TRUE); /* RM: Jan 26 1993 */
1588  stack_info(stderr);
1589  (void)fflush(stderr);
1590  }
1591 
1592  last_garbage_time=garbage_end_time;
1593 
1594  end_number_cells = (stack_pointer-mem_base) + (mem_limit-heap_pointer);
1595  assert(end_number_cells<=start_number_cells);
1596 
1597  ignore_eff=FALSE;
1598 
1599 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
ptr_node printed_pointers
Definition: def_glob.h:1007
float garbage_time
total time on garbage collections - seconds
Definition: def_glob.h:76
static void check()
check
Definition: memory.c:1300
void clear_copy()
clear_copy
Definition: copy.c:53
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
static float gc_time
Definition: memory.c:27
long verbose
Definition: def_glob.h:914
static long pass
Definition: memory.c:21
#define NULL
Definition: def_const.h:533
long ignore_eff
Definition: def_glob.h:677
GENERIC other_limit
only used for the half-space garbage collector
Definition: def_glob.h:104
ptr_node pointer_names
Definition: def_glob.h:1008
void print_gc_info(long timeflag)
print_gc_info
Definition: memory.c:1493
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
GENERIC other_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:98
static float life_time
Definition: memory.c:27
#define FALSE
Standard boolean.
Definition: def_const.h:275
static void compress()
compress
Definition: memory.c:223
void stack_info(FILE *outfile)
stack_info
Definition: error.c:77
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
long bounds_undo_stack()
bounds_undo_stack
Definition: memory.c:143
static struct tms last_garbage_time
Definition: memory.c:26
#define assert(N)
Definition: memory.c:114
ptr_node general_insert ( long  comp,
char *  keystr,
ptr_node tree,
GENERIC  info,
long  heapflag,
long  copystr,
long  bkflag 
)

ptr_node general_insert

Parameters
comp- long comp
keystr- char *keystr
tree- ptr_node *tree
info- GENERIC info
heapflag- long heapflag
copystr- long copystr
bkflag- long bkflag

GENERAL_INSERT(comp,keystr,tree,info,heapflag,copystr,bkflag) General tree insertion routine. comp = comparison routine for insertion. keystr = the insertion key. tree = the tree to insert in. info = the information to insert. heapflag = HEAP or STACK for heap or stack allocation of insertion node. copystr = TRUE iff copy the keystr to the heap on insertion. bkflag = 1 iff the insertion is backtrackable (trailed with trail check). 2 iff the insertion must always be trailed. Returns a pointer to the node containing the pair (keystr,info).

Here KEYSTR can be either a pointer to a string, an integer, or a feature. COMP is the function to call to compare 2 keys so it has three possible values: COMP==strcmp(), COMP==intcmp(), or COMP==featcmp(). COMP(a,b) should return n where: n=0 if a=b; n>0 if a>b; n<0 if a<b.

Definition at line 224 of file trees.c.

References Errorline(), FALSE, featcmp(), FEATCMP, HEAP, HEAP_ALLOC, heap_copy_string(), int_ptr, intcmp(), INTCMP, wl_node::key, NULL, push_ptr_value(), push_ptr_value_global(), STACK_ALLOC, STRCMP, and TRUE.

225 {
226  long cmp;
227  ptr_node result;
228  long to_do=TRUE;
229 
230 
231  do {
232  if (*tree==NULL) {
233  if (bkflag==1) push_ptr_value(int_ptr,(GENERIC *)tree);
234  else if (bkflag==2) push_ptr_value_global(int_ptr,(GENERIC *)tree);
235  *tree = (heapflag==HEAP) ? HEAP_ALLOC(node): STACK_ALLOC(node);
236  result= *tree;
237  (*tree)->key = copystr ? heap_copy_string(keystr) : keystr;
238  (*tree)->left=NULL;
239  (*tree)->right=NULL;
240  (*tree)->data=info;
241  to_do=FALSE;
242  }
243  else {
244  if (comp == INTCMP)
245  cmp = intcmp((long)keystr,(long) (*tree)->key);
246  else if (comp == FEATCMP)
247  cmp = featcmp(keystr,(*tree)->key);
248  else if (comp == STRCMP)
249  cmp = strcmp(keystr,(*tree)->key);
250  else
251  Errorline("Bad comp in general_insert.\n");
252 
253  if (cmp<0)
254  tree=(&((*tree)->left));
255  else
256  if (cmp==0) {
257  if (bkflag)
258  Errorline("attempt to overwrite an existing feature; ignored.\n");
259  else
260  (*tree)->data=info;
261  result= *tree;
262  to_do=FALSE;
263  }
264  else
265  tree=(&((*tree)->right));
266  }
267  } while (to_do);
268 
269  return result;
270 }
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
#define INTCMP
indicates to use intcmp for comparison (in trees.c)
Definition: def_const.h:971
void push_ptr_value_global(type_ptr t, GENERIC *p)
push_ptr_value_global
Definition: login.c:523
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define STRCMP
indicates to use strcmp for comparison (c function)
Definition: def_const.h:963
#define FALSE
Standard boolean.
Definition: def_const.h:275
long intcmp(long a, long b)
intcmp
Definition: trees.c:21
#define STACK_ALLOC(A)
Definition: def_macro.h:21
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
#define int_ptr
values of type_ptr
Definition: def_const.h:397
long get_arg ( ptr_psi_term  g,
ptr_psi_term arg,
char *  number 
)

get_arg

Parameters
g- ptr_psi_term g
arg- ptr_psi_term *arg
number- char *number

GET_ARG assign the argument "number" of the goal "g" in "arg". return FALSE if bad argument.

Definition at line 25 of file templates.c.

References wl_psi_term::attr_list, wl_node::data, FALSE, FEATCMP, find(), and TRUE.

26 {
27  ptr_node n;
28 
29  if ((n = find (FEATCMP, number, g->attr_list)))
30  return (*arg = (ptr_psi_term) n->data) ? TRUE: FALSE;
31  else
32  return FALSE;
33 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
GENERIC data
Definition: def_struct.h:201
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_node attr_list
Definition: def_struct.h:187
GENERIC get_attr ( ptr_psi_term  t,
char *  attrname 
)

get_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname

Get the GENERIC value of a psi-term's attribute

Definition at line 265 of file token.c.

References wl_psi_term::attr_list, wl_node::data, FEATCMP, and find().

266 {
267  ptr_node n=find(FEATCMP,attrname,t->attr_list);
268  return n->data;
269 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
GENERIC data
Definition: def_struct.h:201
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_node attr_list
Definition: def_struct.h:187
int get_module ( ptr_psi_term  psi,
ptr_module module 
)

get_module

Parameters
psi- ptr_psi_term psi
module- ptr_module *module

GET_MODULE(psi,module,resid) Convert a psi-term to a module. The psi-term must be a string.

Definition at line 1226 of file modules.c.

References deref_ptr, Errorline(), FALSE, find_module(), wl_definition::keyword, NULL, overlap_type(), quoted_string, wl_keyword::symbol, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

1227 {
1228  int success=TRUE;
1229  char *s;
1230 
1231  *module=NULL;
1232 
1233  deref_ptr(psi);
1234  if(overlap_type(psi->type,quoted_string) && psi->value_3)
1235  s=(char *)psi->value_3;
1236  else
1237  s=psi->type->keyword->symbol;
1238 
1239  *module=find_module(s);
1240  if(!(*module)) {
1241  Errorline("undefined module \"%s\"\n",s);
1242  success=FALSE;
1243  }
1244 
1245  return success;
1246 }
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
char * symbol
Definition: def_struct.h:118
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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
GENERIC value_3
Definition: def_struct.h:186
ptr_module find_module(char *module)
find_module
Definition: modules.c:54
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
void get_one_arg ( ptr_node  t,
ptr_psi_term a 
)

get_one_arg

Parameters
t- ptr_node t
a- ptr_psi_term *a

GET_ONE_ARG(attr_list,arg1) Get the argument labelled '1' as quickly as possible from the binary tree ATTR_LIST, place it in ARG1. This routine nearly always makes a direct hit.

Definition at line 99 of file login.c.

References wl_node::data, FEATCMP, find(), wl_node::key, NULL, and one.

100 {
101  ptr_node n;
102 
103  *a=NULL;
104  if (t) {
105  if (t->key==one) {
106  *a=(ptr_psi_term)t->data;
107  }
108  else {
109  n=find(FEATCMP,one,t);
110  if (n==NULL)
111  *a=NULL;
112  else
113  *a=(ptr_psi_term)n->data;
114  }
115  }
116 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
char * key
Definition: def_struct.h:198
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
void get_one_arg_addr ( ptr_node  t,
ptr_psi_term **  a 
)

get_one_arg_addr

Parameters
t- ptr_node t
a- ptr_psi_term **a

GET_ONE_ARG_ADDR(attr_list,arg1addr) Get address of slot in the attr_list that points to the argument labelled '1' as quickly as possible from the binary tree ATTR_LIST. This routine nearly always makes a direct hit.

Definition at line 132 of file login.c.

References wl_node::data, FEATCMP, find(), wl_node::key, NULL, and one.

133 {
134  ptr_node n;
135  // ptr_psi_term *b;
136 
137  *a=NULL;
138  if (t) {
139  if (t->key==one)
140  *a= (ptr_psi_term *)(&t->data);
141  else {
142  n=find(FEATCMP,one,t);
143  if (n==NULL)
144  *a=NULL;
145  else
146  *a= (ptr_psi_term *)(&n->data);
147  }
148  }
149 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
char * key
Definition: def_struct.h:198
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
long get_real_value ( ptr_psi_term  t,
REAL v,
long *  n 
)

get_real_value

Parameters
t- ptr_psi_term t
v- REAL *v
n- long *n

GET_REAL_VALUE(t,v,n) Check if psi_term T is a real number. Return N=TRUE iff T <| REAL. If T has a real value then set V to that value. Also force the type of T to REAL if REAL <| T. This is used in all the arithmetic built-in functions to get their arguments.

Definition at line 261 of file built_ins.c.

References def_ptr, FALSE, heap_pointer, i_check_out(), int_ptr, matches(), push_ptr_value(), REAL, real, wl_psi_term::status, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

262 {
263  long success=FALSE;
264  long smaller;
265  if (t) {
266  success=matches(t->type,real,&smaller);
267  if (success) {
268  *n=FALSE;
269  if (smaller) {
270  if (t->value_3) {
271  *v= *(REAL *)t->value_3;
272  *n=TRUE;
273  }
274  }
275  else {
276  if((GENERIC)t<heap_pointer) { /* RM: Jun 8 1993 */
279  t->type=real;
280  t->status=0;
281  (void)i_check_out(t);
282  }
283  }
284  }
285  }
286  return success;
287 }
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
#define def_ptr
values of type_ptr
Definition: def_const.h:404
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
#define int_ptr
values of type_ptr
Definition: def_const.h:397
FILE * get_stream ( ptr_psi_term  t)

get_stream

Parameters
t- ptr_psi_term t

Get the psi-term's STREAM attribute

Definition at line 278 of file token.c.

References get_attr(), and STREAM.

279 {
280  return (FILE *) ((ptr_psi_term)get_attr(t,STREAM))->value_3;
281 }
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define STREAM
feature name
Definition: def_const.h:876
GENERIC get_attr(ptr_psi_term t, char *attrname)
get_attr
Definition: token.c:265
void get_two_args ( ptr_node  t,
ptr_psi_term a,
ptr_psi_term b 
)

get_two_args

Parameters
t- ptr_node t,
a- ptr_psi_term *a
b- ptr_psi_term *b

GET_TWO_ARGS(attr_list,arg1,arg2) Get the arguments labelled '1' and '2' as quickly as possible from the binary tree ATTR_LIST, place them in ARG1 and ARG2. This routine nearly always makes a direct hit.

Definition at line 47 of file login.c.

References wl_node::data, FEATCMP, find(), wl_node::key, NULL, one, wl_node::right, and two.

48 {
49  ptr_node n;
50 
51  *a=NULL;
52  *b=NULL;
53  if (t) {
54  if (t->key==one) {
55  *a=(ptr_psi_term )t->data;
56  n=t->right;
57  if (n)
58  if (n->key==two)
59  *b=(ptr_psi_term )n->data;
60  else {
61  n=find(FEATCMP,two,t);
62  if(n==NULL)
63  *b=NULL;
64  else
65  *b=(ptr_psi_term )n->data;
66  }
67  else
68  *b=NULL;
69  }
70  else {
71  n=find(FEATCMP,one,t);
72  if (n==NULL)
73  *a=NULL;
74  else
75  *a=(ptr_psi_term )n->data;
76  n=find(FEATCMP,two,t);
77  if (n==NULL)
78  *b=NULL;
79  else
80  *b=(ptr_psi_term )n->data;
81  }
82  }
83 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * two
Definition: def_glob.h:892
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
char * key
Definition: def_struct.h:198
char * one
Definition: def_glob.h:891
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_node right
Definition: def_struct.h:200
int GetBoolOption ( char *  name)

GetBoolOption.

Parameters
name- char *name

Definition at line 64 of file memory.c.

References GetStrOption().

65 {
66  char *s;
67  s=GetStrOption(name,"off");
68  return strcmp(s,"off");
69 }
char * name
Definition: def_glob.h:966
char * GetStrOption(char *name, char *def)
GetStrOption.
Definition: memory.c:41
int GetIntOption ( char *  name,
int  def 
)

GetIntOption.

Parameters
name- char *name
def- int def

Definition at line 78 of file memory.c.

References GetStrOption().

79 {
80  char *s;
81  char buffer_loc[40];
82 
83  (void)snprintf(buffer_loc,40,"%d",def);
84  s=GetStrOption(name,buffer_loc);
85  return atof(s);
86 }
char * name
Definition: def_glob.h:966
char * GetStrOption(char *name, char *def)
GetStrOption.
Definition: memory.c:41
char * GetStrOption ( char *  name,
char *  def 
)

GetStrOption.

Parameters
name- char *name
def- char *def

STUFF FOR PARSING COMMAND LINE ARGS

Definition at line 41 of file memory.c.

References arg_c, and arg_v.

42 {
43  int i;
44  char *result=def;
45  int l=strlen(name);
46 
47  for(i=1; i<arg_c; i++)
48  if(arg_v[i][0]=='-' && (int)strlen(arg_v[i])>=l+1)
49  if(!strncmp(arg_v[i]+1,name,l))
50  if(arg_v[i][l+1]=='=')
51  result=arg_v[i]+l+2;
52  else
53  result=arg_v[i]+l+1;
54 
55  return result;
56 }
int arg_c
set from argc in either life.c or lib.c
Definition: def_glob.h:20
char * name
Definition: def_glob.h:966
char * arg_v[ARGNN]
set from argv in either life.c or lib.c
Definition: def_glob.h:27
long glb ( ptr_definition  t1,
ptr_definition  t2,
ptr_definition t3,
ptr_int_list c3 
)

glb

Parameters
t1- ptr_definition t1
t2- ptr_definition t2
t3- ptr_definition *t3
c3- ptr_int_list *c3

GLB(t1,t2,t3) This function returns the Greatest Lower Bound of two types T1 and T2 in T3.

T3 = T1 /\ T2

If T3 is not a simple type then C3 is its code, and T3=NULL.

It also does some type comparing, and returns

0 if T3 = bottom 1 if T1 = T2 2 if T1 <| T2 ( T3 = T1 ) 3 if T1 |> T2 ( T3 = T2 ) 4 otherwise ( T3 strictly <| T1 and T3 strictly <| T2 )

These results are used for knowing when to inherit properties or release residuations. The t3 field is NULL iff a new type is needed to represent the result.

RM: May 7 1993 Fixed bug in when multiple word code

Definition at line 1481 of file types.c.

References wl_definition::code, FALSE, wl_int_list::next, NOT_CODED, nothing, NULL, STACK_ALLOC, top, TRUE, and wl_int_list::value_1.

1482 {
1483  ptr_int_list c1,c2;
1484  long result=0;
1485  unsigned long v1,v2,v3;
1486  int e1,e2,b; /* RM: May 7 1993 */
1487 
1488 
1489 
1490  *c3=NULL;
1491 
1492  if (t1==t2) {
1493  result=1;
1494  *t3= t1;
1495  }
1496  else if (t1==top) {
1497  *t3= t2;
1498  if (t2==top)
1499  result=1;
1500  else
1501  result=3;
1502  }
1503  else if (t2==top) {
1504  result=2;
1505  *t3= t1;
1506  }
1507  else {
1508  /* printf("glb of %s and %s\n",
1509  t1->keyword->combined_name,
1510  t2->keyword->combined_name); */
1511 
1512  c1=t1->code;
1513  c2=t2->code;
1514 
1515  e1=TRUE;e2=TRUE;b=TRUE;
1516 
1517  if (c1!=NOT_CODED && c2!=NOT_CODED) {
1518  result=0;
1519  while (c1 && c2) {
1520 
1521  *c3 = STACK_ALLOC(int_list);
1522  (*c3)->next=NULL;
1523 
1524  v1=(unsigned long)(c1->value_1);
1525  v2=(unsigned long)(c2->value_1);
1526  v3=v1 & v2;
1527 
1528  /* printf("v1=%d, v2=%d, v3=%d\n",v1,v2,v3); */
1529 
1530  (*c3)->value_1=(GENERIC)v3;
1531 
1532  if(v3!=v1) /* RM: May 7 1993 */
1533  e1=FALSE;
1534  if(v3!=v2)
1535  e2=FALSE;
1536  if(v3)
1537  b=FALSE;
1538 
1539  c1=c1->next;
1540  c2=c2->next;
1541  c3= &((*c3)->next);
1542  }
1543  *t3=NULL;
1544 
1545  if(b) /* RM: May 7 1993 */
1546  result=0; /* 0 if T3 = bottom */
1547  else
1548  if(e1)
1549  if(e2)
1550  result=1; /* 1 if T1 = T2 */
1551  else
1552  result=2; /* 2 if T1 <| T2 ( T3 = T1 ) */
1553  else
1554  if(e2)
1555  result=3; /* 3 if T1 |> T2 ( T3 = T2 ) */
1556  else
1557  result=4; /* 4 otherwise */
1558  }
1559  }
1560 
1561  if (!result) *t3=nothing;
1562 
1563  /* printf("result=%d\n\n",result); */
1564 
1565  return result;
1566 }
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_int_list code
Definition: def_struct.h:150
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
long glb_code ( long  f1,
GENERIC  c1,
long  f2,
GENERIC  c2,
long *  f3,
GENERIC c3 
)

glb_code

Parameters
f1- long f1
c1- GENERIC c1
f2- long f2
c2- GENERIC c2
f3- long *f3
c3- GENERIC *c3

GLB_CODE(f1,c1,f2,c2,f3,c3) (21.9) Calculate glb of two type codes C1 and C2, put result in C3. Return a result value (see comments of glb(..)).

Sorts are stored as a 'Variant Record': f1==TRUE: c1 is a ptr_definition (an interned symbol). f1==FALSE: c1 is a ptr_int_list (a sort code). The result (f3,c3) is also in this format. This is needed to correctly handle psi-terms that don't have a sort code (for example, functions, predicates, and singleton sorts). The routine handles a bunch of special cases that keep f3==TRUE. Other than that, it is almost a replica of the inner loop of glb(..).

Definition at line 1351 of file types.c.

References wl_definition::code, FALSE, wl_int_list::next, NOT_CODED, NULL, STACK_ALLOC, top, TRUE, and wl_int_list::value_1.

1352 {
1353  long result=0;
1354  unsigned long v1,v2,v3;
1355  ptr_int_list cd1,cd2,*cd3; /* sort codes */
1356 
1357  /* First, the cases where c1 & c2 are ptr_definitions: */
1358  if (f1 && f2) {
1359  if ((ptr_definition)c1==(ptr_definition)c2) {
1360  *c3=c1;
1361  result=1;
1362  }
1363  else if ((ptr_definition)c1==top) {
1364  *c3=c2;
1365  if ((ptr_definition)c2==top)
1366  result=1;
1367  else
1368  result=3;
1369  }
1370  else if ((ptr_definition)c2==top) {
1371  *c3=c1;
1372  result=2;
1373  }
1374  /* If both inputs are either top or the same ptr_definition */
1375  /* then can return quickly with a ptr_definition. */
1376  if (result) {
1377  *f3=TRUE; /* c3 is ptr_definition (an interned symbol) */
1378  return result;
1379  }
1380  }
1381  /* In the other cases, can't return with a ptr_definition: */
1382  cd1=(ptr_int_list)(f1?(GENERIC)((ptr_definition)c1)->code:c1);
1383  cd2=(ptr_int_list)(f2?(GENERIC)((ptr_definition)c2)->code:c2);
1384  cd3=(ptr_int_list*)c3;
1385  *f3=FALSE; /* cd3 is ptr_int_list (a sort code) */
1386  if (cd1==NOT_CODED) {
1387  if (cd2==NOT_CODED) {
1388  if (c1==c2) {
1389  *cd3=cd1;
1390  result=1;
1391  }
1392  else
1393  result=0;
1394  }
1395  else if (cd2==top->code) {
1396  *cd3=cd1;
1397  result=2;
1398  }
1399  else
1400  result=0;
1401  }
1402  else if (cd1==top->code) {
1403  if (cd2==top->code) {
1404  *cd3=cd1;
1405  result=1;
1406  }
1407  else {
1408  *cd3=cd2;
1409  result=3;
1410  }
1411  }
1412  else if (cd2==NOT_CODED)
1413  result=0;
1414  else if (cd2==top->code) {
1415  *cd3=cd1;
1416  result=2;
1417  }
1418  else while (cd1 && cd2) {
1419  /* Bit operations needed only if c1 & c2 coded & different from top */
1420  *cd3 = STACK_ALLOC(int_list);
1421  (*cd3)->next=NULL;
1422 
1423  v1=(unsigned long)(cd1->value_1);
1424  v2=(unsigned long)(cd2->value_1);
1425  v3=v1 & v2;
1426  (*cd3)->value_1=(GENERIC)v3;
1427 
1428  if (v3) {
1429  if (v3<v1 && v3<v2)
1430  result=4;
1431  else if (result!=4)
1432  if (v1<v2)
1433  result=2;
1434  else if (v1>v2)
1435  result=3;
1436  else
1437  result=1;
1438  }
1439  else if (result)
1440  if (v1 || v2)
1441  result=4;
1442 
1443  cd1=cd1->next;
1444  cd2=cd2->next;
1445  cd3= &((*cd3)->next);
1446  }
1447 
1448  return result;
1449 }
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
struct wl_definition * ptr_definition
Definition: def_struct.h:59
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_int_list code
Definition: def_struct.h:150
GENERIC value_1
Definition: def_struct.h:85
struct wl_int_list * ptr_int_list
Definition: def_struct.h:57
ptr_int_list next
Definition: def_struct.h:86
long glb_value ( long  result,
long  f,
GENERIC  c,
GENERIC  value1,
GENERIC  value2,
GENERIC value 
)

glb_value

Parameters
result- long result
f- long f
c- GENERIC c
value1- GENERIC value1
value2- GENERIC value2
value- GENERIC *value

GLB_VALUE(result,f,c,value1,value2,value) Do the comparison of the value fields of two psi-terms. This is used in conjunction with glb_code to correctly implement completeness for disequality for psi-terms with non-NULL value fields. This must be preceded by a call to glb_code, since it uses the outputs of that call.

result result of preceding glb_code call (non-NULL iff non-empty intersec.) f,c sort intersection (sortflag & code) of preceding glb_code call. value1 value field of first psi-term. value2 value field of second psi-term. value output value field (if any).

Definition at line 1290 of file types.c.

References wl_definition::code, FALSE, NULL, quoted_string, REAL, real, sub_CodeType(), and TRUE.

1291 {
1292  ptr_int_list code;
1293 
1294  if (!result) return FALSE;
1295  if (value1==NULL) {
1296  *value=value2;
1297  return TRUE;
1298  }
1299  if (value2==NULL) {
1300  *value=value1;
1301  return TRUE;
1302  }
1303  /* At this point, both value fields are non-NULL */
1304  /* and must be compared. */
1305 
1306  /* Get a pointer to the sort code */
1307  code = f ? ((ptr_definition)c)->code : (ptr_int_list)c;
1308 
1309  /* This rather time-consuming analysis is necessary if both objects */
1310  /* have non-NULL value fields. Note that only those objects with a */
1311  /* non-NULL value field needed for disentailment are looked at. */
1312  if (sub_CodeType(code,real->code)) {
1313  *value=value1;
1314  return (*(REAL *)value1 == *(REAL *)value2);
1315  }
1316  else if (sub_CodeType(code,quoted_string->code)) {
1317  *value=value1;
1318  return (!strcmp((char *)value1,(char *)value2));
1319  }
1320  else {
1321  /* All other sorts with 'value' fields always return TRUE, that is, */
1322  /* the value field plays no role in disentailment. */
1323  *value=value1;
1324  return TRUE;
1325  }
1326 }
long sub_CodeType(ptr_int_list c1, ptr_int_list c2)
sub_CodeType
Definition: types.c:1618
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
struct wl_definition * ptr_definition
Definition: def_struct.h:59
ptr_int_list code
Definition: def_struct.h:150
struct wl_int_list * ptr_int_list
Definition: def_struct.h:57
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
void global_error_check ( ptr_node  n,
int *  error,
int *  eval_2 
)

global_error_check

Parameters
n- ptr_node n
error- int *error
eval_2- int *eval_2

Definition at line 2591 of file built_ins.c.

References wl_psi_term::attr_list, wl_node::data, deref_eval(), deref_ptr, error_psi_term, Errorline(), FALSE, get_two_args(), global_error_check(), global_it, wl_node::left, leftarrowsym, NULL, wl_node::right, TRUE, wl_psi_term::type, wl_definition::type_def, undef_it, and wl_psi_term::value_3.

2592 {
2593  if (n) {
2594  ptr_psi_term t,a1,a2;
2595  int bad_init=FALSE;
2596  global_error_check(n->left, error, eval_2);
2597 
2598  t=(ptr_psi_term)n->data;
2599  deref_ptr(t);
2600  if (t->type==leftarrowsym) {
2601  get_two_args(t->attr_list,&a1,&a2);
2602  if (a1==NULL || a2==NULL) {
2603  Errorline("%P is an incorrect global variable declaration (%E).\n",t);
2604  *error=TRUE;
2605  bad_init=TRUE;
2606  } else {
2607  deref_ptr(a1);
2608  deref_ptr(a2);
2609  t=a1;
2610  if (deref_eval(a2)) *eval_2=TRUE;
2611  }
2612  }
2613  if (!bad_init && t->type->type_def!=(def_type)undef_it && t->type->type_def!=(def_type)global_it) {
2614  Errorline("%T %P cannot be redeclared as a global variable (%E).\n",
2615  t->type->type_def,
2616  t);
2617  t->type=error_psi_term->type;
2618  t->value_3=NULL; /* RM: Mar 23 1993 */
2619  *error=TRUE;
2620  }
2621 
2622  global_error_check(n->right, error, eval_2);
2623  }
2624 }
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
def_type type_def
Definition: def_struct.h:153
void global_error_check(ptr_node n, int *error, int *eval_2)
global_error_check
Definition: built_ins.c:2591
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#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
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
long deref_eval(ptr_psi_term t)
deref_eval
Definition: lefun.c:1180
ptr_definition leftarrowsym
symbol in syntax module
Definition: def_glob.h:277
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_node right
Definition: def_struct.h:200
void global_one ( ptr_psi_term  t)

global_one

Parameters
t- ptr_psi_term t

Definition at line 2651 of file built_ins.c.

References wl_psi_term::attr_list, clear_copy(), deref_ptr, get_two_args(), global_it, HEAP, wl_definition::init_value, leftarrowsym, quote_copy(), stack_psi_term(), wl_psi_term::type, and wl_definition::type_def.

2652 {
2653  ptr_psi_term u; // ,val;
2654 
2655  if (t->type==leftarrowsym) {
2656  get_two_args(t->attr_list,&t,&u);
2657  deref_ptr(t);
2658  deref_ptr(u);
2659  }
2660  else
2661  u=stack_psi_term(4);
2662 
2663  clear_copy();
2665  t->type->init_value=quote_copy(u,HEAP); /* RM: Mar 23 1993 */
2666 
2667  /* eval_global_var(t); RM: Feb 4 1994 */
2668 
2669  /* RM: Nov 10 1993
2670  val=t->type->global_value;
2671  if (val && (GENERIC)val<heap_pointer) {
2672  deref_ptr(val);
2673  push_psi_ptr_value(val,&(val->coref));
2674  val->coref=u;
2675  } else
2676  t->type->global_value=u;
2677  */
2678 }
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_psi_term init_value
Definition: def_struct.h:160
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
void clear_copy()
clear_copy
Definition: copy.c:53
struct wl_definition * def_type
Definition: def_struct.h:60
def_type type_def
Definition: def_struct.h:153
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
quote_copy
Definition: copy.c:186
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_definition leftarrowsym
symbol in syntax module
Definition: def_glob.h:277
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
void global_tree ( ptr_node  n)

global_tree

Parameters
n- ptr_node n

Definition at line 2631 of file built_ins.c.

References wl_node::data, deref_ptr, global_one(), global_tree(), wl_node::left, and wl_node::right.

2632 {
2633  if (n) {
2634  ptr_psi_term t;
2635  global_tree(n->left);
2636 
2637  t=(ptr_psi_term)n->data;
2638  deref_ptr(t);
2639  global_one(t);
2640 
2641  global_tree(n->right);
2642  }
2643 }
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
void global_tree(ptr_node n)
global_tree
Definition: built_ins.c:2631
void global_one(ptr_psi_term t)
global_one
Definition: built_ins.c:2651
ptr_node right
Definition: def_struct.h:200
int global_unify ( ptr_psi_term  u,
ptr_psi_term  v 
)

global_unify

Parameters
u- ptr_psi_term u
v- ptr_psi_term v

GLOBAL_UNIFY(u,v) Unify two psi-terms, where it is known that V is on the heap (a persistent variable).

This routine really matches U and V, it will only succeed if V is more general than U. U will then be bound to V.

Definition at line 1053 of file modules.c.

References wl_psi_term::attr_list, c_abort(), wl_psi_term::coref, deref_ptr, Errorline(), FALSE, glb(), global_unify_attr(), heap_pointer, overlap_type(), push_psi_ptr_value(), quoted_string, REAL, real, release_resid(), wl_psi_term::resid, traceline(), TRUE, wl_psi_term::type, and wl_psi_term::value_3.

1054 {
1055  int success=TRUE;
1056  int compare;
1057  ptr_definition new_type;
1058  ptr_int_list new_code;
1059 
1060  deref_ptr(u);
1061  deref_ptr(v);
1062 
1063  traceline("match persistent %P with %P\n",u,v);
1064 
1065  /* printf("u=%ld, v=%ld, heap_pointer=%ld\n",u,v,heap_pointer);*/
1066 
1067  /* printf("u=%s, v=%s\n",
1068  u->type->keyword->symbol,
1069  v->type->keyword->symbol); */
1070 
1071  if((GENERIC)u>=heap_pointer) {
1072  Errorline("cannot unify persistent values\n");
1073  return c_abort();
1074  }
1075 
1076  /**** U is on the stack, V is on the heap ****/
1077 
1078  /**** Calculate their Greatest Lower Bound and compare them ****/
1079  compare=glb(u->type,v->type,&new_type,&new_code);
1080 
1081  /* printf("compare=%d\n",compare); */
1082 
1083  if (compare==1 || compare==3) { /* Match only */
1084 
1085  /**** Check for values ****/
1086  if(v->value_3) {
1087  if(u->value_3) {
1088  if(u->value_3!=v->value_3) { /* One never knows */
1089  if (overlap_type(v->type,real))
1090  success=(*((REAL *)u->value_3)==(*((REAL *)v->value_3)));
1091  else if (overlap_type(v->type,quoted_string))
1092  success=(strcmp((char *)u->value_3,(char *)v->value_3)==0);
1093  else
1094  return FALSE; /* Don't unify CUTs and STREAMs and things */
1095  }
1096  }
1097  }
1098  else
1099  if(u->value_3)
1100  return FALSE;
1101 
1102  if(success) {
1103  /**** Bind the two psi-terms ****/
1104  push_psi_ptr_value(u,(GENERIC *)&(u->coref));
1105  u->coref=v;
1106 
1107  /**** Match the attributes ****/
1108  success=global_unify_attr(u->attr_list,v->attr_list);
1109 
1110  /*
1111  if(!success)
1112  warningline("attributes don't unify in %P and %P\n",u,v);
1113  */
1114 
1115  if(success && u->resid)
1116  release_resid(u);
1117  }
1118  }
1119  else
1120  success=FALSE;
1121 
1122  return success;
1123 }
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
long glb(ptr_definition t1, ptr_definition t2, ptr_definition *t3, ptr_int_list *c3)
glb
Definition: types.c:1481
int global_unify_attr(ptr_node, ptr_node)
global_unify_attr
Definition: modules.c:1135
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
long c_abort()
c_abort
Definition: built_ins.c:2247
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
void release_resid(ptr_psi_term t)
release_resid
Definition: lefun.c:445
void traceline(char *format,...)
traceline
Definition: error.c:186
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#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
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term coref
Definition: def_struct.h:188
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
int global_unify_attr ( ptr_node  u,
ptr_node  v 
)

global_unify_attr

Parameters
u- ptr_node u
v- ptr_node v

GLOBAL_UNIFY_ATTR(u,v) Unify the attributes of two terms, one on the heap, one on the stack. This is really matching, so all features of U must appear in V.

Definition at line 1135 of file modules.c.

References wl_node::data, dummy_printf(), FALSE, featcmp(), global_unify(), wl_node::key, wl_node::left, NULL, wl_node::right, and TRUE.

1136 {
1137  int success=TRUE;
1138  ptr_node temp;
1139  long cmp;
1140 
1141  if(u)
1142  if(v) {
1143  /* RM: Feb 16 1993 Avoid C optimiser bug */
1144  (void)dummy_printf("%s %s\n",u->key,v->key);
1145 
1146  cmp=featcmp(u->key,v->key);
1147  if(cmp<0) {
1148  temp=u->right;
1149  u->right=NULL;
1150  success=global_unify_attr(u,v->left) && global_unify_attr(temp,v);
1151  u->right=temp;
1152  }
1153  else
1154  if(cmp>0) {
1155  temp=u->left;
1156  u->left=NULL;
1157  success=global_unify_attr(u,v->right) && global_unify_attr(temp,v);
1158  u->left=temp;
1159  }
1160  else {
1161  success=
1162  global_unify_attr(u->left,v->left) &&
1163  global_unify_attr(u->right,v->right) &&
1165  }
1166  }
1167  else
1168  success=FALSE;
1169 
1170  return success;
1171 }
int global_unify_attr(ptr_node, ptr_node)
global_unify_attr
Definition: modules.c:1135
int global_unify(ptr_psi_term u, ptr_psi_term v)
global_unify
Definition: modules.c:1053
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
int dummy_printf(char *f, char *s, char *t)
dummy_printf
Definition: login.c:2617
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
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
ptr_goal GoalFromPsiTerm ( ptr_psi_term  psiTerm)

GoalFromPsiTerm.

Parameters
psiTerm- ptr_psi_term psiTerm

not used anymore, but interesting

Definition at line 3992 of file xpred.c.

References aim, Errorline(), FALSE, wl_residuation::goal, wl_residuation::next, NULL, and wl_psi_term::resid.

3993 {
3994  ptr_residuation resid;
3995  ptr_goal aim;
3996 
3997  if(psiTerm == NULL)
3998  {
3999  Errorline("X error in GoalFromPsiTerm: psiTerm is null\n");
4000  return FALSE;
4001  }
4002 
4003  if((resid = psiTerm->resid) == NULL)
4004  {
4005  Errorline("X error in GoalFromPsiTerm: psiTerm has no residuating functions\n");
4006  return FALSE;
4007  }
4008 
4009  if(resid->next != NULL)
4010  {
4011  Errorline("X error in GoalFromPsiTerm: psiTerm has more than one residuating function\n");
4012  return FALSE;
4013  }
4014 
4015  if((aim = resid->goal) == NULL)
4016  {
4017  Errorline("X error in GoalFromPsiTerm: psiTerm has no goal\n");
4018  return FALSE;
4019  }
4020 
4021  return aim;
4022 }
ptr_residuation resid
Definition: def_struct.h:189
ptr_goal goal
Definition: def_struct.h:172
ptr_residuation next
Definition: def_struct.h:173
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
char ** group_features ( char **  f,
ptr_node  n 
)

group_features

Parameters
f- char **f
n- ptr_node n

Definition at line 34 of file lib.c.

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

35 {
36  *f=NULL;
37  if(n) {
38  if(n->left)
39  f=group_features(f,n->left);
40  *f=n->key;
41  f++;
42  if(n->right)
43  f=group_features(f,n->right);
44  }
45 
46  return f;
47 }
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
char ** group_features(char **f, ptr_node n)
group_features
Definition: lib.c:34
ptr_node right
Definition: def_struct.h:200
void handle_interrupt ( )

HANDLE_INTERRUPT.

This deals with an eventual interrupt. Return TRUE if execution continues normally, otherwise abort query, toggle trace on or off, or quit Wild_Life (suicide).

Definition at line 52 of file interrupt.c.

References abort_life(), DIGIT, EOLN, exit_life(), FALSE, input_state, interrupted, open_input_file(), prompt, quietflag, read_char(), restore_state(), show_count(), stdin_cleareof(), stepcount, stepflag, steptrace, trace, TRUE, and verbose.

53 {
54  ptr_psi_term old_state_loc;
55  char *old_prompt;
56  int old_quiet; /* 21.1 */
57  long c,d; /* 21.12 (prev. char) */
58  long count;
59 
60  if (interrupted) printf("\n");
62  old_prompt=prompt;
63  old_quiet=quietflag; /* 21.1 */
65 
66  /* new_state(&old_state_loc); */
67  old_state_loc=input_state;
68  (void)open_input_file("stdin");
70 
71  StartAgain:
72  do {
73  printf("*** Command ");
74  prompt="(q,c,a,s,t,h)?";
75  quietflag=FALSE; /* 21.1 */
76 
77  do {
78  c=read_char();
79  } while (c!=EOLN && c>0 && c<=32);
80 
81  d=c;
82  count=0;
83  while (DIGIT(d)) { count=count*10+(d-'0'); d=read_char(); }
84 
85  while (d!=EOLN && d!=EOF) d=read_char();
86 
87  if (c=='h' || c=='?') {
88  printf("*** [Quit (q), Continue (c), Abort (a), Step (s,RETURN), Trace (t), Help (h,?)]\n");
89  }
90 
91  } while (c=='h' || c=='?');
92 
93  prompt=old_prompt;
94  quietflag=old_quiet; /* 21.1 */
95 
96  switch (c) {
97  case 'v':
98  case 'V':
99  verbose=TRUE;
100  break;
101  case 'q':
102  case 'Q':
103  case EOF:
104  if (c==EOF) printf("\n");
105  exit_life(FALSE);
106  break;
107  case 'a':
108  case 'A':
109  (void)abort_life(FALSE);
110  show_count();
111  break;
112  case 'c':
113  case 'C':
114  trace=FALSE;
115  stepflag=FALSE;
116  break;
117  case 't':
118  case 'T':
119  trace=TRUE;
120  stepflag=FALSE;
121  break;
122  case 's':
123  case 'S':
124  case EOLN:
125  trace=TRUE;
126  stepflag=TRUE;
127  break;
128  case '0': case '1': case '2': case '3': case '4':
129  case '5': case '6': case '7': case '8': case '9':
130  trace=TRUE;
131  stepflag=TRUE;
132  if (count>0) {
133  stepcount=count;
134  stepflag=FALSE;
135  }
136  break;
137  default:
138  goto StartAgain;
139  }
140  input_state=old_state_loc;
142 }
void exit_life(long nl_flag)
exit_life
Definition: built_ins.c:2219
long verbose
Definition: def_glob.h:914
#define DIGIT(C)
Definition: def_macro.h:42
long quietflag
Definition: def_glob.h:912
void show_count()
show_count
Definition: login.c:1161
ptr_psi_term input_state
Definition: def_glob.h:856
long steptrace
Definition: def_glob.h:915
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
long trace
Definition: def_glob.h:913
long stepcount
Definition: def_glob.h:916
#define EOLN
End of line.
Definition: def_const.h:309
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long stepflag
Definition: def_glob.h:676
void restore_state(ptr_psi_term t)
restore_state
Definition: token.c:334
char * prompt
Definition: def_glob.h:1018
long read_char()
read_char
Definition: token.c:680
long interrupted
Definition: interrupt.c:12
void stdin_cleareof()
stdin_cleareof
Definition: token.c:51
long open_input_file(char *file)
open_input_file
Definition: token.c:594
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
long has_rules ( ptr_pair_list  r)

has_rules

Parameters
r- ptr_pair_list r

Return TRUE iff there are some rules r This is true for a user-defined function or predicate with a definition, and for a type with constraints.

Definition at line 5101 of file built_ins.c.

References wl_pair_list::aaaa_2, FALSE, wl_pair_list::next, NULL, and TRUE.

5102 {
5103  if (r==NULL) return FALSE;
5104  while (r) {
5105  if (r->aaaa_2!=NULL) return TRUE;
5106  r=r->next;
5107  }
5108  return FALSE;
5109 }
ptr_psi_term aaaa_2
Definition: def_struct.h:205
ptr_pair_list next
Definition: def_struct.h:207
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
int hash_code ( ptr_hash_table  table,
char *  symbol 
)

HASH_CODE.

Parameters
table- ptr_hash_table table
symbol- char *symbol

Return the hash code for a symbol

Definition at line 79 of file hash_table.c.

References rand_array, and wl_hash_table::size.

80 {
81  int n=0;
82 
83  /* printf("code of %s ",symbol); */
84 
85  while(*symbol) {
86  n ^= rand_array[*symbol]+rand_array[n&255];
87  n++;
88  symbol++;
89  }
90 
91  n &= (table->size-1);
92 
93 
94  /* printf("=%d\n",n); */
95 
96  return n;
97 }
long rand_array[256]
Definition: hash_table.c:16
ptr_hash_table hash_create ( int  size)

HASH_CREATE.

Parameters
size- int size

Create a hash-table for max size keywords.

Definition at line 25 of file hash_table.c.

References NULL, and wl_hash_table::size.

26 {
27  ptr_hash_table new;
28  int i;
29 
30  new=(ptr_hash_table)malloc(sizeof(struct wl_hash_table));
31  new->size=size;
32  new->used=0;
33  new->data=(ptr_keyword *)malloc(size*sizeof(ptr_keyword));
34  for(i=0;i<size;i++)
35  new->data[i]=NULL;
36  return new;
37 }
#define NULL
Definition: def_const.h:533
struct wl_hash_table * ptr_hash_table
Definition: def_struct.h:100
void hash_display ( ptr_hash_table  table)

HASH_DISPLAY.

Parameters
table- ptr_hash_table table

Display a symbol table (for debugging).

Definition at line 174 of file hash_table.c.

References hash_code().

175 {
176  int i;
177  int n;
178  char *s;
179  int c=0;
180  int t=0;
181 
182  printf("*** Hash table %lx:\n",(long)table);
183  printf("Size: %d\n",table->size);
184  printf("Used: %d\n",table->used);
185 
186  for(i=0;i<table->size;i++)
187  if(table->data[i]) {
188  t++;
189  s=table->data[i]->symbol;
190  n=hash_code(table,s);
191 
192  printf("%4d %4d %s %s\n",
193  i,
194  n,
195  i==n?"ok ":"*bad*",
196  s);
197 
198  if(i!=n)
199  c++;
200  }
201 
202  printf("Really used: %d\n",t);
203  printf("Collisions: %d = %1.3f%%\n",
204  c,
205  100.0*c/(double)t);
206 }
ptr_keyword * data
Definition: def_struct.h:139
char * symbol
Definition: def_struct.h:118
int hash_code(ptr_hash_table table, char *symbol)
HASH_CODE.
Definition: hash_table.c:79
void hash_expand ( ptr_hash_table  table,
int  new_size 
)

HASH_EXPAND.

Parameters
table- ptr_hash_table table
new_size- int new_size

Allocate a bigger hash table.

Definition at line 47 of file hash_table.c.

References wl_hash_table::data, hash_insert(), NULL, wl_hash_table::size, and wl_hash_table::used.

48 {
49  ptr_keyword *old_data;
50  int old_size;
51  int i;
52 
53 
54  old_data=table->data;
55  old_size=table->size;
56 
57  table->size=new_size; /* Must be power of 2 */
58  table->used=0;
59  table->data=(ptr_keyword *)malloc(new_size*sizeof(ptr_keyword));
60 
61  for(i=0;i<new_size;i++)
62  table->data[i]=NULL;
63 
64  for(i=0;i<old_size;i++)
65  if(old_data[i])
66  hash_insert(table,old_data[i]->symbol,old_data[i]);
67 
68  free(old_data);
69 }
ptr_keyword * data
Definition: def_struct.h:139
#define NULL
Definition: def_const.h:533
void hash_insert(ptr_hash_table table, char *symbol, ptr_keyword keyword)
HASH_INSERT.
Definition: hash_table.c:151
int hash_find ( ptr_hash_table  table,
char *  symbol 
)

hash_find

Parameters
table- ptr_hash_table table
symbol- char *symbol

Definition at line 106 of file hash_table.c.

References wl_hash_table::data, hash_code(), wl_hash_table::size, and wl_keyword::symbol.

107 {
108  int n;
109  int i=1;
110 
111  n=hash_code(table,symbol);
112 
113  while(table->data[n] && strcmp(table->data[n]->symbol,symbol)) {
114  /* Not a direct hit... */
115  n+= i*i;
116  /* i++; */
117  n &= table->size-1;
118  }
119 
120  return n;
121 }
ptr_keyword * data
Definition: def_struct.h:139
char * symbol
Definition: def_struct.h:118
int hash_code(ptr_hash_table table, char *symbol)
HASH_CODE.
Definition: hash_table.c:79
void hash_insert ( ptr_hash_table  table,
char *  symbol,
ptr_keyword  keyword 
)

HASH_INSERT.

Parameters
table- ptr_hash_table table
symbol- char *symbol
keyword- ptr_keyword keyword

Add a symbol and data to a table. Overwrite previous data.

Definition at line 151 of file hash_table.c.

References wl_hash_table::data, hash_expand(), hash_find(), wl_hash_table::size, and wl_hash_table::used.

152 {
153  int n;
154 
155  n=hash_find(table,symbol);
156 
157  /* printf("inserting %s at %d keyword %x\n",symbol,n,keyword); */
158 
159  if(!table->data[n])
160  table->used++;
161  table->data[n]=keyword;
162 
163  if(table->used*2>table->size)
164  hash_expand(table,table->size*2);
165 }
ptr_keyword * data
Definition: def_struct.h:139
int hash_find(ptr_hash_table table, char *symbol)
hash_find
Definition: hash_table.c:106
void hash_expand(ptr_hash_table table, int new_size)
HASH_EXPAND.
Definition: hash_table.c:47
ptr_keyword hash_lookup ( ptr_hash_table  table,
char *  symbol 
)

HASH_LOOKUP.

Parameters
table- ptr_hash_table table
symbol- char *symbol

Look up a symbol in the symbol table.

Definition at line 131 of file hash_table.c.

References wl_hash_table::data, and hash_find().

132 {
133  int n;
134 
135  n=hash_find(table,symbol);
136 
137  /* printf("found %s at %d keyword %x\n",symbol,n,table->data[n]); */
138 
139  return table->data[n];
140 }
ptr_keyword * data
Definition: def_struct.h:139
int hash_find(ptr_hash_table table, char *symbol)
hash_find
Definition: hash_table.c:106
void heap_add_int_attr ( ptr_psi_term  t,
char *  attrname,
long  value 
)

heap_add_int_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
value- long value

Add an attribute whose value is an integer to a psi-term that does not yet contains this attribute.

Definition at line 74 of file token.c.

References wl_psi_term::attr_list, FEATCMP, heap_alloc(), heap_copy_string(), heap_insert(), heap_psi_term(), integer, REAL, wl_psi_term::type, and wl_psi_term::value_3.

75 {
76  ptr_psi_term t1;
77 
78  t1=heap_psi_term(4);
79  t1->type=integer;
80  t1->value_3=heap_alloc(sizeof(REAL));
81  *(REAL *)t1->value_3 = (REAL) value;
82 
83  (void)heap_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list), (GENERIC)t1);
84 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
heap_insert
Definition: trees.c:320
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void heap_add_psi_attr ( ptr_psi_term  t,
char *  attrname,
ptr_psi_term  g 
)

heap_add_psi_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
g- ptr_psi_term g

Attach a psi-term to another as an attribute.

Definition at line 226 of file token.c.

References wl_psi_term::attr_list, FEATCMP, heap_copy_string(), and heap_insert().

227 {
228  (void)heap_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) g);
229 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
heap_insert
Definition: trees.c:320
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
ptr_node attr_list
Definition: def_struct.h:187
void heap_add_str_attr ( ptr_psi_term  t,
char *  attrname,
char *  str 
)

heap_add_str_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
str- char *str

Add an attribute whose value is a string to a psi-term that does not yet contains this attribute.

Definition at line 151 of file token.c.

References wl_psi_term::attr_list, FEATCMP, heap_copy_string(), heap_insert(), heap_psi_term(), quoted_string, wl_psi_term::type, and wl_psi_term::value_3.

152 {
153  ptr_psi_term t1;
154 
155  t1=heap_psi_term(4);
156  t1->type=quoted_string;
157  t1->value_3=(GENERIC)heap_copy_string(str);
158 
159  (void)heap_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) t1);
160 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
heap_insert
Definition: trees.c:320
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
GENERIC heap_alloc ( long  s)

heap_alloc

Parameters
s- long s

HEAP_ALLOC(s) This returns a pointer to S bytes of memory in the heap. Alignment is taken into account in the following manner: the macro ALIGN is supposed to be a power of 2 and the pointer returned is a multiple of ALIGN.

Definition at line 1616 of file memory.c.

References ALIGN, Errorline(), heap_pointer, and stack_pointer.

1617 {
1618  if (s & (ALIGN-1))
1619  s = s - (s & (ALIGN-1))+ALIGN;
1620  /* assert(s % sizeof(*heap_pointer) == 0); */
1621  s /= sizeof (*heap_pointer);
1622 
1623  heap_pointer -= s;
1624 
1626  Errorline("the heap overflowed into the stack.\n");
1627 
1628  return heap_pointer;
1629 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define ALIGN
Definition: def_const.h:66
ptr_psi_term heap_copy_psi_term ( psi_term  t)

heap_copy_psi_term

Parameters
t- psi_term t

HEAP_COPY_PSI_TERM(tok) Return the address of a copy of TOK on the HEAP.

Definition at line 226 of file parser.c.

References global_time_stamp, and HEAP_ALLOC.

227 {
228  ptr_psi_term p;
229 
230  p=HEAP_ALLOC(psi_term);
231  (*p)=t;
232 #ifdef TS
233  p->time_stamp=global_time_stamp; /* 9.6 */
234 #endif
235 
236  return p;
237 }
unsigned long global_time_stamp
Definition: login.c:28
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
char * heap_copy_string ( char *  s)

heap_copy_string

Parameters
s- char *s

HEAP_COPY_STRING(string) Make a copy of the string in the heap, and return a pointer to that. Exceptions: "1" and "2" are unique (and in the heap).

Definition at line 172 of file trees.c.

References heap_ncopy_string().

173 { return heap_ncopy_string(s,strlen(s)); }
char * heap_ncopy_string(char *s, int n)
heap_ncopy_string
Definition: trees.c:150
ptr_node heap_insert ( long  comp,
char *  keystr,
ptr_node tree,
GENERIC  info 
)

heap_insert

Parameters
comp- long comp
keystr- char *keystr
tree- ptr_node *tree
info- GENERIC info

HEAP_INSERT(comp,keystr,tree,info) Insert the pointer INFO under the reference KEYSTR in the binary tree TREE stored in the heap. Return the pointer to the node of KEYSTR.

Definition at line 320 of file trees.c.

References FALSE, general_insert(), and HEAP.

321 {
322 
323  return general_insert(comp,keystr,tree,info,HEAP,FALSE,0L);
324 }
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_node general_insert(long comp, char *keystr, ptr_node *tree, GENERIC info, long heapflag, long copystr, long bkflag)
ptr_node general_insert
Definition: trees.c:224
void heap_insert_copystr ( char *  keystr,
ptr_node tree,
GENERIC  info 
)

heap_insert_copystr

Parameters
keystr- char *keystr
tree- ptr_node *tree
info- GENERIC info

HEAP_INSERT_COPYSTR(keystr,tree,info) Insert the pointer INFO under the reference string KEYSTR (which is a feature name) in the binary tree TREE. KEYSTR is copied to the heap. A potential additional node allocated to TREE is put on the heap.

Definition at line 284 of file trees.c.

References FEATCMP, general_insert(), HEAP, and TRUE.

285 {
286  (void)general_insert(FEATCMP,keystr,tree,info,HEAP,TRUE,0L);
287 }
#define HEAP
Flag to indicate heap allocation.
Definition: def_const.h:324
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_node general_insert(long comp, char *keystr, ptr_node *tree, GENERIC info, long heapflag, long copystr, long bkflag)
ptr_node general_insert
Definition: trees.c:224
void heap_mod_int_attr ( ptr_psi_term  t,
char *  attrname,
long  value 
)

heap_mod_int_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
value- long value

Modify an attribute whose value is an integer to a psi-term that already contains this attribute with another integer value.

Definition at line 116 of file token.c.

References wl_psi_term::attr_list, wl_node::data, FEATCMP, find(), REAL, and wl_psi_term::value_3.

117 {
118  ptr_node n;
119  ptr_psi_term t1;
120 
121  n=find(FEATCMP,attrname,t->attr_list);
122  t1=(ptr_psi_term)n->data;
123  *(REAL *)t1->value_3 = (REAL) value;
124 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
GENERIC value_3
Definition: def_struct.h:186
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_node attr_list
Definition: def_struct.h:187
void heap_mod_str_attr ( ptr_psi_term  t,
char *  attrname,
char *  str 
)

heap_mod_str_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
str- char *str

Modify an attribute whose value is a string to a psi-term that already contains this attribute with another integer value.

Definition at line 191 of file token.c.

References wl_psi_term::attr_list, wl_node::data, FEATCMP, find(), heap_copy_string(), and wl_psi_term::value_3.

192 {
193  ptr_node n;
194  ptr_psi_term t1;
195 
196  n=find(FEATCMP,attrname,t->attr_list);
197  t1=(ptr_psi_term)n->data;
198  t1->value_3=(GENERIC)heap_copy_string(str);
199 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
GENERIC value_3
Definition: def_struct.h:186
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_node attr_list
Definition: def_struct.h:187
char * heap_ncopy_string ( char *  s,
int  n 
)

heap_ncopy_string

Parameters
s- char *s
n- int n

HEAP_NCOPY_STRING(string,length) Make a copy of the string in the heap, and return a pointer to that. Exceptions: "1" and "2" are unique (and in the heap).

Definition at line 150 of file trees.c.

References heap_alloc(), one, and two.

151 {
152  char *p;
153 
154  if (s==one || s==two) return s;
155 
156  p=(char *)heap_alloc(n+1);
157  strncpy(p,s,n);
158  p[n]='\0';
159 
160  return p;
161 }
char * two
Definition: def_glob.h:892
char * one
Definition: def_glob.h:891
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
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
ptr_psi_term heap_psi_term ( long  stat)

heap_psi_term

Parameters
stat- long stat

Create a new psi_term on the heap with value '@' (top) and no attributes.

Definition at line 75 of file lefun.c.

References wl_psi_term::attr_list, wl_psi_term::coref, FALSE, wl_psi_term::flags, global_time_stamp, HEAP_ALLOC, NULL, QUOTED_TRUE, wl_psi_term::resid, wl_psi_term::status, top, wl_psi_term::type, and wl_psi_term::value_3.

76 {
77  ptr_psi_term result;
78 
79  result=HEAP_ALLOC(psi_term);
80  result->type=top;
81  result->status=stat;
82  result->flags=stat?QUOTED_TRUE:FALSE; /* 14.9 */
83  result->attr_list=NULL;
84  result->coref=NULL;
85 #ifdef TS
86  result->time_stamp=global_time_stamp; /* 9.6 */
87 #endif
88  result->resid=NULL;
89  result->value_3=NULL;
90 
91  return result;
92 }
ptr_residuation resid
Definition: def_struct.h:189
#define NULL
Definition: def_const.h:533
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term coref
Definition: def_struct.h:188
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
unsigned long global_time_stamp
Definition: login.c:28
ptr_definition type
Definition: def_struct.h:181
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_node attr_list
Definition: def_struct.h:187
long hidden_type ( ptr_definition  t)

hidden_type

Parameters
t- ptr_definition t

Return TRUE iff T is a type that should not show up as part of the type hierarchy, i.e. it is an internal hidden type.

Definition at line 3672 of file built_ins.c.

References comment, constant, functor, and variable.

3673 {
3674  return (/* (t==conjunction) || 19.8 */
3675  /* (t==disjunction) || RM: Dec 9 1992 */
3676  (t==constant) || (t==variable) ||
3677  (t==comment) || (t==functor));
3678 }
ptr_definition functor
symbol in bi module
Definition: def_glob.h:298
ptr_definition comment
symbol in bi module
Definition: def_glob.h:227
ptr_definition variable
symbol in bi module
Definition: def_glob.h:438
ptr_definition constant
symbol in bi module
Definition: def_glob.h:235
long i_check_out ( ptr_psi_term  t)

i_check_out

Parameters
t- ptr_psi_term t
  • i_check_out(t) checks out everything except functions. When a function is encountered, check_out returns immediately without looking inside it.

Definition at line 1033 of file lefun.c.

References check_func_flag, check_out(), and FALSE.

1034 {
1036  return check_out(t);
1037 }
long check_out(ptr_psi_term t)
Definition: lefun.c:1083
#define FALSE
Standard boolean.
Definition: def_const.h:275
static long check_func_flag
Definition: lefun.c:13
long i_eval_args ( ptr_node  n)

i_eval_args

Parameters
n- ptr_node n

I_EVAL_ARGS(n) N is an attribute tree, the attributes must be examined, if any reveal themselves to need evaluating then return FALSE.

Definition at line 874 of file lefun.c.

References check_func_flag, eval_args(), and FALSE.

875 {
877  return eval_args(n);
878 }
long eval_args(ptr_node n)
eval_args
Definition: lefun.c:889
#define FALSE
Standard boolean.
Definition: def_const.h:275
static long check_func_flag
Definition: lefun.c:13
long in_set ( char *  str,
long  set 
)

in_set

Parameters
str- char *str
set- long set

Return TRUE iff string (considered as number) is in the set This routine only recognizes the strings "1", "2", "3", represented as numbers 1, 2, 4.

Definition at line 1316 of file lefun.c.

References FALSE, featcmp(), and TRUE.

1317 {
1318  if (set&1 && !featcmp(str,"1")) return TRUE;
1319  if (set&2 && !featcmp(str,"2")) return TRUE;
1320  if (set&4 && !featcmp(str,"3")) return TRUE;
1321  if (set&8 && !featcmp(str,"4")) return TRUE;
1322  return FALSE;
1323 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
ptr_psi_term inc_heap_copy ( ptr_psi_term  t)

inc_heap_copy

Parameters
t- ptr_psi_term t

There is a bug in inc_heap_copy

Definition at line 206 of file copy.c.

References copy(), EXACT_FLAG, to_heap, and TRUE.

207 { to_heap=TRUE; return (copy(t, EXACT_FLAG, TRUE)); }
#define EXACT_FLAG
flag to copy function in copy.c to indicate kind of copy
Definition: def_const.h:1306
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
copy
Definition: copy.c:248
long to_heap
Definition: def_glob.h:905
void infoline ( char *  format,
  ... 
)

infoline

Parameters
format- char *format
...

Definition at line 281 of file error.c.

References assert, display_psi(), FALSE, input_file_name, NOTQUIET, parse_ok, perr_i(), perr_s(), print_code(), print_def_type(), print_operator_kind(), and psi_term_line_number.

282 {
283  va_list VarArg;
284  // int l;
285  char buffer_loc[5];
286  char *p;
287  unsigned long lng2;
288  char *cptr;
289  ptr_int_list pil;
290  ptr_psi_term psi;
291  operator kind;
292  def_type t ;
293 
294  va_start(VarArg,format);
295  if (NOTQUIET)
296  {
297 
298  // vinfoline(format, stdout, VarArg);
299  //#define vinfoline(format, outfile, xxxx) {
300  for (p=format;p && *p; p++)
301  {
302  if (*p == '%')
303  {
304  p++;
305  switch (*p)
306  {
307  case 'd':
308  case 'x':
309  buffer_loc[0] = '%';
310  buffer_loc[1] = 'l';
311  buffer_loc[2] = *p;
312  buffer_loc[3] = 0;
313  lng2 = va_arg(VarArg,long);
314  fprintf(stdout, buffer_loc, lng2);
315  break;
316  case 's':
317  buffer_loc[0] = '%';
318  buffer_loc[1] = *p;
319  buffer_loc[2] = 0;
320  cptr = va_arg(VarArg,char *);
321  fprintf(stdout, buffer_loc, cptr);
322  break;
323  case 'C':
324  /* type coding as bin string */
325  pil = va_arg(VarArg,ptr_int_list);
326  print_code(stdout,pil);
327  break;
328  case 'P':
329  psi = va_arg(VarArg,ptr_psi_term);
330  display_psi(stdout,psi);
331  break;
332  case 'O':
333  kind = va_arg(VarArg,operator);
334  print_operator_kind(stdout,kind);
335  break;
336  case 'T':
337  assert(stdout==stderr);
338  t = va_arg(VarArg,def_type);
339  print_def_type(t);
340  break;
341  case 'E':
342  assert(stdout==stderr);
343  perr_i("near line %ld",psi_term_line_number);
344  if (strcmp(input_file_name,"stdin")) {
345  perr_s(" in file 042%s042",input_file_name);
346  }
347  parse_ok=FALSE;
348  break;
349  case '%':
350  (void)putc(*p,stdout);
351  break;
352  default:
353  fprintf(stdout,"<%c follows %% : report bug >", *p);
354  break;
355  }
356  }
357  else
358  (void)putc(*p,stdout);
359  }
360  }
361  va_end(VarArg);
362 }
#define NOTQUIET
Definition: def_macro.h:15
void perr_i(char *str, long i)
perr_i
Definition: error.c:800
long psi_term_line_number
Definition: def_glob.h:909
string input_file_name
Definition: def_glob.h:1016
void display_psi(FILE *s, ptr_psi_term t)
display_psi
Definition: print.c:1579
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
void print_code(FILE *s, ptr_int_list c)
print_code
Definition: print.c:167
void print_def_type(def_type t)
print_def_type
Definition: types.c:24
#define FALSE
Standard boolean.
Definition: def_const.h:275
void print_operator_kind(FILE *s, long kind)
print_operator_kind
Definition: print.c:192
#define assert(N)
Definition: memory.c:114
void inherit_always_check ( )

inherit_always_check

INHERIT_ALWAYS_CHECK() The 'always_check' flag, if false, should be propagated to a sort's children. This routine does a closure on this propagation operation for all declared sorts.

Definition at line 1068 of file types.c.

References FALSE, and one_pass_always_check().

1069 {
1070  long change;
1071 
1072  do {
1073  change=FALSE;
1074  one_pass_always_check(&change);
1075  } while (change);
1076 }
void one_pass_always_check(long *ch)
one_pass_always_check
Definition: types.c:1049
#define FALSE
Standard boolean.
Definition: def_const.h:275
void init_built_in_types ( )

init_built_in_types

INIT_BUILT_IN_TYPES Initialise the symbol tree with the built-in types. Declare all built-in predicates and functions. Initialise system type variables. Declare all standard operators.

Called by life.c

Definition at line 6155 of file built_ins.c.

References aborthooksym, abortsym, add_module1, add_module2, add_module3, alist, all_public_symbols(), and, apply, bi_module, boolpredsym, built_in, c_abort(), c_alias(), c_and(), c_append_file(), c_apply(), c_args(), c_ascii(), c_assert_first(), c_assert_last(), c_bk_assign(), c_boolpred(), c_char(), c_chdir(), c_clause(), c_close(), c_combined_name(), c_concatenate(), c_cond(), c_copy_pointer(), c_copy_term(), c_current_module(), c_declaration(), c_delay_check(), c_deref_length(), c_diff(), c_diff_address(), c_disj(), c_display_modules(), c_display_persistent(), c_dynamic(), c_equal(), c_eval(), c_eval_disjunction(), c_eval_inplace(), c_exist_feature(), c_exists(), c_exists_choice(), c_fail(), c_feature_values(), c_features(), c_get(), c_get_choice(), c_global(), c_global_assign(), c_gt(), c_gtoe(), c_halt(), c_implies(), c_initrandom(), c_int2string(), c_is_function(), c_is_predicate(), c_is_sort(), c_listing(), c_load(), c_lt(), c_ltoe(), c_module_name(), c_non_strict(), c_nonvar(), c_not(), c_not_implemented(), c_op(), c_open_in(), c_open_module(), c_open_out(), c_ops(), c_or(), c_page_width(), c_parse(), c_persistent(), c_print_codes(), c_print_depth(), c_print_variables(), c_private(), c_private_feature(), c_project(), c_psi2string(), c_public(), c_put(), c_put_err(), c_pwrite(), c_pwriteq(), c_random(), c_read_psi(), c_read_token(), c_repeat(), c_replace(), c_retract(), c_rootsort(), c_same_address(), c_set_choice(), c_set_input(), c_set_module(), c_set_output(), c_setq(), c_split_double(), c_static(), c_string2psi(), c_string_address(), c_string_length(), c_strip(), c_sub_string(), c_succeed(), c_such_that(), c_trace_input(), c_undo(), c_unify_func(), c_unify_pred(), c_var(), c_write(), c_write_canonical(), c_write_err(), c_writeq(), c_writeq_err(), c_xor(), call_handlersym, calloncesym, wl_definition::code, colonsym, commasym, comment, constant, cut, day_attr, delay_checksym, disj_nil, disjunction, dynamicsym, encodesym, eof, eqsym, error_psi_term, eval_argsym, final_dot, final_question, funcsym, function_it, functor, fx_sym, fy_sym, hash_lookup(), heap_psi_term(), hour_attr, iff, inputfilesym, insert_math_builtins(), insert_sys_builtins(), insert_system_builtins(), insert_type_builtins(), integer, wl_definition::keyword, leftarrowsym, lf_false, lf_true, life_or, listingsym, loadsym, minus_symbol, minute_attr, month_attr, new_built_in(), nil, no_module, NOT_CODED, nothing, null_psi_term, nullsym, one, opsym, predicate_it, predsym, wl_keyword::public, quote, quoted_string, real, second_attr, set_current_module(), staticsym, stream, succeed, such_that, wl_keyword::symbol, wl_module::symbol_table, syntax_module, three, timesym, top, tracesym, TRUE, two, wl_psi_term::type, wl_definition::type_def, type_it, typesym, update_symbol(), variable, weekday_attr, xf_sym, xfx_sym, xfy_sym, year_attr, yf_sym, and yfx_sym.

6156 {
6157  ptr_definition t;
6158 
6159  /* symbol_table=NULL; RM: Feb 3 1993 */
6160 
6161 
6162 
6163  /* RM: Jan 13 1993 */
6164  /* Initialize the minimum syntactic symbols */
6165  (void)set_current_module(syntax_module); /* RM: Feb 3 1993 */
6167  (void)update_symbol(syntax_module,"[");
6168  (void)update_symbol(syntax_module,"]");
6169  (void)update_symbol(syntax_module,"(");
6170  (void)update_symbol(syntax_module,")");
6171  (void)update_symbol(syntax_module,"{");
6172  (void)update_symbol(syntax_module,"}");
6173  (void)update_symbol(syntax_module,".");
6174  (void)update_symbol(syntax_module,"?");
6175 
6176 
6181  eof =update_symbol(syntax_module,"end_of_file");
6185  life_or =update_symbol(syntax_module,";");/* RM: Apr 6 1993 */
6186  minus_symbol =update_symbol(syntax_module,"-");/* RM: Jun 21 1993 */
6192 
6193  /* RM: Jul 7 1993 */
6196 
6197 
6198 
6199  /* RM: Feb 3 1993 */
6201  error_psi_term=heap_psi_term(4); /* 8.10 */
6202  error_psi_term->type=update_symbol(bi_module,"*** ERROR ***");
6204 
6205  apply =update_symbol(bi_module,"apply");
6206  boolean =update_symbol(bi_module,"bool");
6207  boolpredsym =update_symbol(bi_module,"bool_pred");
6208  built_in =update_symbol(bi_module,"built_in");
6209  calloncesym =update_symbol(bi_module,"call_once");
6210  /* colon sym */
6211  /* comma sym */
6212  comment =update_symbol(bi_module,"comment");
6213 
6214 
6215  /* RM: Dec 11 1992 conjunctions have been totally scrapped it seems */
6216  /* conjunction=update_symbol("*conjunction*"); 19.8 */
6217 
6218  constant =update_symbol(bi_module,"*constant*");
6219  disjunction =update_symbol(bi_module,"disj");/*RM:9 Dec 92*/
6220  lf_false =update_symbol(bi_module,"false");
6221  functor =update_symbol(bi_module,"functor");
6222  iff =update_symbol(bi_module,"cond");
6224  alist =update_symbol(bi_module,"cons");/*RM:9 Dec 92*/
6225  nothing =update_symbol(bi_module,"bottom");
6226  nil =update_symbol(bi_module,"nil");/*RM:9 Dec 92*/
6228  real =update_symbol(bi_module,"real");
6229  stream =update_symbol(bi_module,"stream");
6230  succeed =update_symbol(bi_module,"succeed");
6231  lf_true =update_symbol(bi_module,"true");
6232  timesym =update_symbol(bi_module,"time");
6233  variable =update_symbol(bi_module,"*variable*");
6234  opsym =update_symbol(bi_module,"op");
6235  loadsym =update_symbol(bi_module,"load");
6236  dynamicsym =update_symbol(bi_module,"dynamic");
6237  staticsym =update_symbol(bi_module,"static");
6238  encodesym =update_symbol(bi_module,"encode");
6239  listingsym =update_symbol(bi_module,"c_listing");
6240  /* provesym =update_symbol(bi_module,"prove"); */
6241  delay_checksym =update_symbol(bi_module,"delay_check");
6242  eval_argsym =update_symbol(bi_module,"non_strict");
6243  inputfilesym =update_symbol(bi_module,"input_file");
6244  call_handlersym =update_symbol(bi_module,"call_handler");
6252  nullsym =update_symbol(bi_module,"<NULL PSI TERM>");
6255 
6256 
6257  (void)set_current_module(no_module); /* RM: Feb 3 1993 */
6258  t=update_symbol(no_module,"1");
6259  one=t->keyword->symbol;
6260  t=update_symbol(no_module,"2");
6261  two=t->keyword->symbol;
6262  t=update_symbol(no_module,"3");
6263  three=t->keyword->symbol;
6264  (void)set_current_module(bi_module); /* RM: Feb 3 1993 */
6265  t=update_symbol(bi_module,"year");
6266  year_attr=t->keyword->symbol;
6267  t=update_symbol(bi_module,"month");
6269  t=update_symbol(bi_module,"day");
6270  day_attr=t->keyword->symbol;
6271  t=update_symbol(bi_module,"hour");
6272  hour_attr=t->keyword->symbol;
6273  t=update_symbol(bi_module,"minute");
6275  t=update_symbol(bi_module,"second");
6277  t=update_symbol(bi_module,"weekday");
6279 
6282 
6283  /* Built-in routines */
6284  // bi_list = fopen("bi_list.txt","w");
6285 
6286  /* Program database */
6296 
6297  /* File I/O */
6309 
6310  /* Term I/O */
6322  new_built_in(bi_module,"c_op",(def_type)predicate_it,c_op); /* RM: Jan 13 1993 */
6326 
6327  /* Type checks */
6333 
6338 
6339  /* RM: Dec 16 1992 So the symbol can be changed easily */
6340 
6341 
6342  /* Arithmetic */
6344 
6345  /* Comparison */
6357 
6358  /* RM: Nov 22 1993 */
6360 
6361  /* Psi-term navigation */
6363  new_built_in(bi_module,"feature_values",(def_type)function_it,c_feature_values); /* RM: Mar 3 1994 */
6364 
6365  /* RM: Jul 20 1993 */
6366 
6367  new_built_in(syntax_module,".",(def_type)function_it,c_project);/* RM: Jul 7 1993 */
6370  new_built_in(bi_module,"copy_pointer",(def_type)function_it,c_copy_pointer); /* PVR: Dec 17 1992 */
6371  new_built_in(bi_module,"has_feature",(def_type)function_it,c_exist_feature); /* PVR: Dec 17 1992 */
6372 
6373  /* Unification and assignment */
6375  /* new_built_in(syntax_module,"<<-",(def_type)predicate_it,c_assign); RM: Feb 24 1993 */
6376 
6377  /* RM: Feb 24 1993 */
6379  /* new_built_in(syntax_module,"<<<-",(def_type)predicate_it,c_global_assign); */
6380 
6381  /* RM: Feb 8 1993 */
6382  new_built_in(syntax_module,"{}",(def_type)function_it,c_fail); /* RM: Feb 16 1993 */
6386  /* UNI new_built_in(syntax_module,":",(def_type)function_it,c_unify_func); */
6387 
6388  /* Type hierarchy navigation */
6390 
6391  /* String and character utilities */
6397 
6398  /* Control */
6404  /* new_built_in(bi_module,"quote",(def_type)function_it,c_quote); */
6405  /*new_built_in(bi_module,"call_once",(def_type)function_it,c_call_once);*/ /* DENYS: Jan 25 1995 */
6406  /* new_built_in(bi_module,"call",(def_type)function_it,c_call); */
6407  /* new_built_in(bi_module,"undefined",(def_type)function_it,c_fail); */ /* RM: Jan 13 1993 */
6414 
6417  /* new_built_in(syntax_module,"::",(def_type)predicate_it,c_declaration); */
6428  /* new_built_in(bi_module,"freeze",(def_type)predicate_it,c_freeze); PVR 16.9.93 */
6433 
6434  /* System */
6436 
6443 
6444  /* RM: Jan 8 1993 */
6455  /* new_built_in(bi_module,"#",(def_type)function_it,c_module_access); */
6456 
6457  /* Hack so '.set_up' doesn't issue a Warning message */
6458  /* RM: Feb 3 1993 */
6459  hash_lookup(bi_module->symbol_table,"set_module")->public=TRUE;
6461 
6462  /* RM: Jan 29 1993 */
6463  abortsym=update_symbol(bi_module,"abort"); /* 26.1 */
6464  aborthooksym=update_symbol(bi_module,"aborthook"); /* 26.1 */
6465  tracesym=update_symbol(bi_module,"trace"); /* 26.1 */
6466 
6467 
6468  /* RM: Feb 9 1993 */
6473 
6474  /* RM: Mar 11 1993 */
6476  add_module1=update_symbol(bi_module,"features");
6477  add_module2=update_symbol(bi_module,"str2psi");
6478  add_module3=update_symbol(bi_module,"feature_values"); /* RM: Mar 3 1994 */
6479 
6480  /* RM: Jun 29 1993 */
6483 
6484  /* RM: Jul 15 1993 */
6486 
6487 
6488  /* RM: Sep 20 1993 */
6490 
6491  /* RM: Jan 28 1994 */
6493 
6494 #ifdef CLIFE
6495  life_reals();
6496 #endif /* CLIFE */
6497 
6499  // fclose(bi_list);
6500 }
static long c_diff()
c_diff
Definition: built_ins.c:1308
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
static long c_get()
c_get
Definition: built_ins.c:2992
static long c_listing()
c_listing
Definition: built_ins.c:5172
static long c_char()
c_char
Definition: built_ins.c:4731
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
void insert_math_builtins()
insert math builtins into table
Definition: bi_math.c:1346
static long c_is_sort()
c_is_sort
Definition: built_ins.c:1570
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
long c_initrandom()
c_initrandom
Definition: built_ins.c:6032
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
ptr_definition succeed
symbol in bi module
Definition: def_glob.h:389
static long c_exists()
c_exists
Definition: built_ins.c:1732
static long c_combined_name()
c_combined_name
Definition: built_ins.c:5693
static long c_exists_choice()
c_exists_choice
Definition: built_ins.c:1910
static long c_static()
c_static
Definition: built_ins.c:1642
ptr_definition xf_sym
symbol in bi module
Definition: def_glob.h:515
static long c_write()
c_write
Definition: built_ins.c:3177
static long c_pwriteq()
c_pwriteq
Definition: built_ins.c:3253
static long c_unify_func()
c_unify_func
Definition: built_ins.c:4425
static long c_clause()
c_clause
Definition: built_ins.c:2519
ptr_definition apply
symbol in bi module
Definition: def_glob.h:178
struct wl_definition * def_type
Definition: def_struct.h:60
static long c_declaration()
c_declaration
Definition: built_ins.c:2313
long c_random()
c_random
Definition: built_ins.c:5966
void insert_type_builtins()
void insert_type_builtins
Definition: bi_type.c:817
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
long c_public()
c_public
Definition: modules.c:687
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_definition eqsym
symbol in syntax module
Definition: def_glob.h:270
ptr_definition functor
symbol in bi module
Definition: def_glob.h:298
static long c_pwrite()
c_pwrite
Definition: built_ins.c:3235
ptr_definition quote
symbol in syntax module
Definition: def_glob.h:361
static long c_ascii()
c_ascii
Definition: built_ins.c:4781
static long c_retract()
c_retract
Definition: built_ins.c:2538
long c_display_modules()
c_display_modules
Definition: modules.c:739
static long c_features()
c_features
Definition: built_ins.c:3564
ptr_definition final_question
symbol in syntax module
Definition: def_glob.h:615
static long c_delay_check()
static long c_delay_check()
Definition: built_ins.c:1661
static long c_fail()
c_fail
Definition: built_ins.c:1388
static long c_exist_feature()
c_exist_feature
Definition: built_ins.c:3499
static long c_rootsort()
c_rootsort
Definition: built_ins.c:3355
static long c_persistent()
c_persistent
Definition: built_ins.c:2687
long c_deref_length()
c_deref_length
Definition: built_ins.c:6087
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
ptr_definition calloncesym
symbol in bi module
Definition: def_glob.h:206
ptr_definition delay_checksym
symbol in bi module
Definition: def_glob.h:487
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
char * two
Definition: def_glob.h:892
ptr_definition iff
symbol in bi module
Definition: def_glob.h:305
static long c_project()
c_project
Definition: built_ins.c:1207
static long c_int2string()
c_int2string
Definition: built_ins.c:4943
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
static long c_same_address()
c_same_address
Definition: built_ins.c:3857
static long c_xor()
c_xor
Definition: built_ins.c:1080
ptr_definition timesym
symbol in bi module
Definition: def_glob.h:417
ptr_module syntax_module
Module for minimal Prolog syntax.
Definition: def_glob.h:715
ptr_definition comment
symbol in bi module
Definition: def_glob.h:227
def_type type_def
Definition: def_struct.h:153
static long c_unify_pred()
c_unify_pred
Definition: built_ins.c:4454
static long c_cond()
c_cond
Definition: built_ins.c:3422
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
long c_set_module()
c_set_module
Definition: modules.c:488
long c_append_file()
c_append_file
Definition: built_ins.c:5890
ptr_definition listingsym
symbol in bi module
Definition: def_glob.h:480
static long c_string2psi()
c_string2psi
Definition: built_ins.c:4831
static long c_read_psi()
c_read_psi
Definition: built_ins.c:2097
ptr_definition fx_sym
symbol in bi module
Definition: def_glob.h:522
static long c_lt()
c_lt C_LT Less than.
Definition: built_ins.c:633
long c_abort()
c_abort
Definition: built_ins.c:2247
static long c_boolpred()
c_boolpred
Definition: built_ins.c:838
static long c_diff_address()
c_diff_address
Definition: built_ins.c:3901
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
static long c_open_out()
c_open_out
Definition: built_ins.c:2819
static long c_print_codes()
c_print_codes
Definition: built_ins.c:5285
ptr_definition call_handlersym
symbol in bi module
Definition: def_glob.h:508
long c_args()
c_args
Definition: built_ins.c:6123
ptr_hash_table symbol_table
Definition: def_struct.h:110
ptr_keyword keyword
Definition: def_struct.h:147
ptr_definition dynamicsym
symbol in bi module
Definition: def_glob.h:459
ptr_definition opsym
symbol in bi module
Definition: def_glob.h:445
ptr_definition add_module3
symbol in bi module for feature_values
Definition: def_glob.h:157
static long c_string_address()
c_string_address
Definition: built_ins.c:4099
ptr_definition add_module2
symbol in bi module for str2psi
Definition: def_glob.h:150
static long c_op()
c_op
Definition: built_ins.c:1697
static long c_ltoe()
c_ltoe
Definition: built_ins.c:769
long c_open_module()
c_open_module
Definition: modules.c:519
char * three
Definition: def_glob.h:893
char * symbol
Definition: def_struct.h:118
ptr_definition funcsym
symbol in syntax module
Definition: def_glob.h:291
ptr_definition eval_argsym
symbol in bi module
Definition: def_glob.h:494
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
static long c_parse()
c_parse
Definition: built_ins.c:2012
void insert_system_builtins()
insert_system_builtins
Definition: bi_sys.c:746
ptr_definition and
symbol in syntax module
Definition: def_glob.h:171
static long c_page_width()
c_page_width
Definition: built_ins.c:3271
static long c_gtoe()
c_gtoe
Definition: built_ins.c:701
ptr_psi_term null_psi_term
Used to represent an empty parse token.
Definition: def_glob.h:656
ptr_definition built_in
symbol in bi module
Definition: def_glob.h:199
static long c_psi2string()
c_psi2string
Definition: built_ins.c:4898
static long c_repeat()
c_repeat
Definition: built_ins.c:1416
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
long c_display_persistent()
c_display_persistent
Definition: modules.c:775
static long c_global_assign()
c_global_assign
Definition: built_ins.c:4383
static long c_split_double()
c_split_double
Definition: built_ins.c:4034
ptr_definition inputfilesym
symbol in bi module
Definition: def_glob.h:501
ptr_definition yf_sym
symbol in bi module
Definition: def_glob.h:529
static long c_write_err()
c_write_err
Definition: built_ins.c:3138
static long c_apply()
c_apply
Definition: built_ins.c:1160
ptr_definition variable
symbol in bi module
Definition: def_glob.h:438
static long c_writeq_err()
c_writeq_err
Definition: built_ins.c:3158
static long c_global()
c_global
Definition: built_ins.c:2561
static long c_get_choice()
c_get_choice
Definition: built_ins.c:1814
ptr_definition final_dot
symbol in syntax module
Definition: def_glob.h:608
void insert_sys_builtins()
insert_sys_builtins
Definition: sys.c:2209
ptr_definition colonsym
symbol in syntax module
Definition: def_glob.h:213
static long c_writeq()
c_writeq
Definition: built_ins.c:3197
long c_sub_string()
c_sub_string
Definition: built_ins.c:5781
#define TRUE
Standard boolean.
Definition: def_const.h:268
long all_public_symbols()
all_public_symbols
Definition: modules.c:1363
static long c_open_in()
c_open_in
Definition: built_ins.c:2773
ptr_definition minus_symbol
symbol in syntax module
Definition: def_glob.h:333
static long c_dynamic()
c_dynamic
Definition: built_ins.c:1625
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
long c_string_length()
c_string_length
Definition: built_ins.c:5726
ptr_definition constant
symbol in bi module
Definition: def_glob.h:235
static long c_non_strict()
c_non_strict
Definition: built_ins.c:1680
static long c_copy_term()
c_copy_term
Definition: built_ins.c:4514
static long c_undo()
c_undo
Definition: built_ins.c:4552
static long c_eval()
c_eval
Definition: built_ins.c:3945
static long c_nonvar()
c_nonvar
Definition: built_ins.c:1467
ptr_definition abortsym
symbol in bi module
Definition: def_glob.h:126
ptr_definition add_module1
symbol in bi module for features
Definition: def_glob.h:143
ptr_definition staticsym
symbol in bi module
Definition: def_glob.h:466
long c_halt()
c_halt
Definition: built_ins.c:2208
static long c_disj()
c_disj
Definition: built_ins.c:3391
static long c_eval_disjunction()
c_eval_disjunction
Definition: built_ins.c:589
ptr_definition such_that
symbol in syntax module
Definition: def_glob.h:396
ptr_definition typesym
symbol in syntax module
Definition: def_glob.h:431
ptr_definition nil
symbol in bi module
Definition: def_glob.h:340
ptr_definition xfy_sym
symbol in bi module
Definition: def_glob.h:550
long c_current_module()
c_current_module
Definition: modules.c:974
static long c_succeed()
c_succeed
Definition: built_ins.c:1400
static long c_and()
c_and
Definition: built_ins.c:1000
ptr_definition disj_nil
symbol in syntax module
Definition: def_glob.h:256
static long c_implies()
c_implies
Definition: built_ins.c:4718
char * weekday_attr
Definition: def_glob.h:900
static long c_strip()
c_strip
Definition: built_ins.c:3828
char * one
Definition: def_glob.h:891
static long c_put_err()
c_put_err
Definition: built_ins.c:3065
long c_private_feature()
c_private_feature
Definition: modules.c:1302
ptr_definition commasym
symbol in syntax module
Definition: def_glob.h:220
static long c_or()
c_or
Definition: built_ins.c:1013
static long c_assert_last()
c_assert_last
Definition: built_ins.c:2416
static long c_close()
c_close
Definition: built_ins.c:2936
static long c_read_token()
c_read_token
Definition: built_ins.c:2107
static long c_not()
c_not
Definition: built_ins.c:1026
long c_trace_input()
c_trace_input
Definition: modules.c:810
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
static long c_is_predicate()
c_is_predicate
Definition: built_ins.c:1536
static long c_var()
static long c_var()
Definition: built_ins.c:1433
long c_alias()
c_alias
Definition: modules.c:1180
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
long c_concatenate()
c_concatenate
Definition: built_ins.c:5577
ptr_definition yfx_sym
symbol in bi module
Definition: def_glob.h:557
static long c_is_function()
c_is_function
Definition: built_ins.c:1501
static long c_put()
c_put
Definition: built_ins.c:3049
static long c_eval_inplace()
c_eval_inplace
Definition: built_ins.c:3977
ptr_definition loadsym
symbol in bi module
Definition: def_glob.h:452
long c_private()
c_private
Definition: modules.c:714
char * minute_attr
Definition: def_glob.h:898
static long c_not_implemented()
c_not_implemented
Definition: built_ins.c:2296
ptr_definition leftarrowsym
symbol in syntax module
Definition: def_glob.h:277
ptr_definition nullsym
symbol in bi module
Definition: def_glob.h:564
long c_replace()
c_replace
Definition: modules.c:936
ptr_module no_module
???
Definition: def_glob.h:701
static long c_chdir()
c_chdir
Definition: built_ins.c:4152
char * year_attr
Definition: def_glob.h:894
ptr_definition encodesym
symbol in bi module
Definition: def_glob.h:473
ptr_definition fy_sym
symbol in bi module
Definition: def_glob.h:536
static long c_bk_assign()
c_bk_assign
Definition: built_ins.c:4287
ptr_int_list code
Definition: def_struct.h:150
char * second_attr
Definition: def_glob.h:899
char * day_attr
Definition: def_glob.h:896
static long c_ops()
c_ops
Definition: built_ins.c:3784
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
static long c_set_input()
c_set_input
Definition: built_ins.c:2868
static long c_equal()
static long c_equal()
Definition: built_ins.c:507
ptr_definition type
Definition: def_struct.h:181
char * hour_attr
Definition: def_glob.h:897
ptr_definition aborthooksym
symbol in bi module
Definition: def_glob.h:133
ptr_definition boolpredsym
symbol in bi module
Definition: def_glob.h:192
static long c_setq()
c_setq
Definition: built_ins.c:2336
static long c_module_name()
c_module_name
Definition: built_ins.c:5660
static long c_write_canonical()
c_write_canonical
Definition: built_ins.c:3217
static long c_gt()
c_gt
Definition: built_ins.c:439
ptr_definition xfx_sym
symbol in bi module
Definition: def_glob.h:543
static long c_load()
c_load
Definition: built_ins.c:1774
static long c_print_depth()
c_print_depth
Definition: built_ins.c:3311
static long c_copy_pointer()
c_copy_pointer
Definition: built_ins.c:4482
static long c_feature_values()
c_feature_values
Definition: built_ins.c:3618
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
static long c_assert_first()
c_assert_first
Definition: built_ins.c:2386
static long c_print_variables()
c_print_variables
Definition: built_ins.c:1967
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_set_choice()
c_set_choice
Definition: built_ins.c:1853
static long c_set_output()
c_set_output
Definition: built_ins.c:2905
ptr_definition predsym
symbol in syntax module
Definition: def_glob.h:354
char * month_attr
Definition: def_glob.h:895
static long c_such_that()
c_such_that
Definition: built_ins.c:5011
ptr_definition tracesym
symbol in bi module
Definition: def_glob.h:424
ptr_definition life_or
symbol in syntax module
Definition: def_glob.h:326
void init_copy ( )

init_copy

INIT_COPY() Execute once upon startup of Wild_Life.

Definition at line 32 of file copy.c.

References HASHSIZE, hashtable, hashtime, numbuckets, and NUMBUCKETS.

33 {
34  long i;
35 
36  /* for(i=0; i<HASHSTATS; i++) hashstats[i]=0; 20.8 */
37 
38  for(i=0; i<HASHSIZE; i++) hashtable[i].timestamp = 0;
39  hashtime = 0;
41  hashbuckets = (struct hashbucket *)
42  malloc(NUMBUCKETS * sizeof(struct hashbucket));
43 }
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:16
#define NUMBUCKETS
Total number of buckets in initial hash table;.
Definition: def_const.h:1292
static long numbuckets
Definition: copy.c:20
static long hashtime
Definition: copy.c:18
static struct hashbucket * hashbuckets
Definition: copy.c:17
#define HASHSIZE
Size of hash table; must be a power of 2.
Definition: def_const.h:1284
void init_global_vars ( )

init_global_vars

INIT_GLOBAL_VARS() Initialize all non-persistent global variables.

Definition at line 1484 of file lefun.c.

References first_definition, wl_definition::global_value, heap_pointer, wl_definition::next, and NULL.

1486 {
1487  ptr_definition def;
1488 
1489  /* printf("initializing global vars...\n"); */
1490 
1491  /*
1492  for(def=first_definition;def;def=def->next) {
1493  if(def->type==global_it && ((GENERIC)def->global_value<heap_pointer)) {
1494  clear_copy();
1495  def->global_value=eval_copy(def->init_value,STACK);
1496  }
1497  }
1498  */
1499 
1500  for(def=first_definition;def;def=def->next)
1502  def->global_value=NULL;
1503 }
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
#define NULL
Definition: def_const.h:533
ptr_definition next
Definition: def_struct.h:164
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_psi_term global_value
Definition: def_struct.h:159
void init_interrupt ( )

INIT_INTERRUPT.

This initialises interrupts by trapping the interrupt signal and sending it to INTERRUPT.

Definition at line 36 of file interrupt.c.

References interrupt().

37 {
38  void (*f)(); /* RM: Apr 7 1993 Weird problem in GCC and C89 */
39  f=interrupt;
40  if (signal(SIGINT,SIG_IGN)!=SIG_IGN)
41  (void)signal(SIGINT,f);
42 }
void interrupt()
INTERRUPT()
Definition: interrupt.c:21
void init_io ( )

void init_io

I/O initialization

Definition at line 69 of file lib.c.

References input_state, NULL, output_stream, stdin_state, stdin_terminal, and TRUE.

70 {
74  output_stream=stdout;
75 }
ptr_psi_term stdin_state
Definition: def_glob.h:857
#define NULL
Definition: def_const.h:533
ptr_psi_term input_state
Definition: def_glob.h:856
#define TRUE
Standard boolean.
Definition: def_const.h:268
long stdin_terminal
set in init_io in lib.c to true - never changed - used in token.c
Definition: def_glob.h:832
FILE * output_stream
Definition: def_glob.h:1017
void init_memory ( )

init_memory ()

INIT_MEMORY() Get two big blocks of memory to work in. The second is only used for the half-space garbage collector. The start and end addresses of the blocks are re-aligned correctly. to allocate.

Definition at line 1671 of file memory.c.

References ALIGNUP, ALLOC_WORDS, alloc_words, buffer, delta, Errorline(), GetIntOption(), heap_pointer, mem_base, mem_limit, mem_size, other_base, other_limit, other_pointer, PRINT_BUFFER, stack_pointer, and WORD.

1672 {
1675 
1676  mem_base = (GENERIC) malloc(mem_size);
1677  other_base = (GENERIC) malloc(mem_size);
1678 
1679  if (mem_base && other_base) {
1680  /* Rewrote some rather poor code... RM: Mar 1 1994 */
1681  ALIGNUP(mem_base);
1683 
1685  ALIGNUP(mem_limit);
1687 
1690 
1691  other_limit=other_base+alloc_words-2;
1693 
1695  buffer = (char *) malloc (PRINT_BUFFER); /* The printing buffer */
1696 
1697  /* RM: Oct 22 1993 */
1698  /* Fill the memory with rubbish data */
1699  /*
1700  {
1701  int i;
1702 
1703  for(i=0;i<alloc_words;i++) {
1704  mem_base[i]= -1234;
1705  other_base[i]= -1234;
1706  }
1707  }
1708  */
1709  }
1710  else
1711  Errorline("Wild_life could not allocate sufficient memory to run.\n\n");
1712 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
#define WORD
Memory Word Size.
Definition: def_const.h:63
#define ALLOC_WORDS
number of words to allocate if -memory=nnnnn not on command line
Definition: def_config.h:26
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
int alloc_words
number of words to allocate - from either command lind or ALLOC_WORDS define
Definition: def_glob.h:34
static long delta
Definition: memory.c:12
GENERIC other_limit
only used for the half-space garbage collector
Definition: def_glob.h:104
GENERIC other_pointer
NOT USED - according to comment.
Definition: def_glob.h:111
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
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 ALIGNUP(X)
Definition: def_macro.h:299
#define PRINT_BUFFER
Size of print buffer.
Definition: def_const.h:211
GENERIC other_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:98
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
int mem_size
number of words from memory = alloc_words * sizeof word
Definition: def_glob.h:41
int GetIntOption(char *name, int def)
GetIntOption.
Definition: memory.c:78
void init_modules ( )

init_modules

INIT_MODULES() Initialize the module system.

Definition at line 34 of file modules.c.

References create_module(), and set_current_module().

35 {
36  bi_module=create_module("built_ins");
37  no_module=create_module("no_module");
39  syntax_module=create_module("syntax");
40  user_module=create_module("user"); /* RM: Jan 27 1993 */
42 
44 }
ptr_module user_module
Definition: modules.c:22
ptr_module sys_module
Definition: modules.c:19
ptr_module bi_module
Definition: modules.c:17
ptr_module create_module(char *module)
ptr_module create_module(char *module)
Definition: modules.c:72
ptr_module x_module
Definition: modules.c:23
ptr_module no_module
Definition: modules.c:16
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
ptr_module syntax_module
Definition: modules.c:18
void init_parse_state ( )

init_parse_state

Initialize the parser/tokenizer state variables.

Definition at line 464 of file token.c.

References eof_flag, FALSE, line_count, NULL, old_saved_char, old_saved_psi_term, saved_char, saved_psi_term, start_of_line, stringparse, and TRUE.

465 {
466  line_count=0;
468  saved_char=0;
469  old_saved_char=0;
472  eof_flag=FALSE;
474 }
long eof_flag
Definition: def_glob.h:853
long old_saved_char
Definition: def_glob.h:850
#define NULL
Definition: def_const.h:533
long saved_char
Definition: def_glob.h:849
long line_count
Definition: def_glob.h:1015
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long start_of_line
???
Definition: def_glob.h:846
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
long stringparse
Definition: def_glob.h:859
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
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 init_system ( )

init_system

Initial state of system to begin a query

Definition at line 83 of file lib.c.

References choice_stack, current_module, exit_if_true(), FALSE, goal_stack, init_global_vars(), mem_base, memory_check(), wl_module::module_name, NULL, PROMPT, prompt, PROMPT_BUFFER, prompt_buffer, resid_aim, stack_nil(), stack_pointer, undo_stack, user_module, var_tree, x_window_creation, and xevent_list.

84 {
85 #ifdef X11
87 #endif
91  undo_stack=NULL; /* 7.8 */
92  var_tree=NULL;
93 
94  /* RM: Oct 13 1993 */
96  prompt=PROMPT;
97  else {
100  }
101 
102  resid_aim=NULL;
104 
105 #ifdef X11
106  /* RM: Dec 15 1992 */
108 #endif
109 
110  init_global_vars(); /* RM: Feb 15 1993 */
111 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
ptr_module user_module
Default module for user input.
Definition: def_glob.h:694
ptr_goal goal_stack
Definition: def_glob.h:1025
char prompt_buffer[PROMPT_BUFFER]
Definition: def_glob.h:878
ptr_psi_term xevent_list
Definition: def_glob.h:1037
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
#define PROMPT
Head of prompt.
Definition: def_const.h:218
ptr_goal resid_aim
Definition: def_glob.h:865
long x_window_creation
Definition: def_glob.h:1046
ptr_stack undo_stack
Definition: def_glob.h:1027
void exit_if_true(long exitflag)
exit_if_true
Definition: lib.c:55
void init_global_vars()
init_global_vars
Definition: lefun.c:1484
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
char * module_name
Definition: def_struct.h:106
#define PROMPT_BUFFER
Size of prompt buffer.
Definition: def_const.h:225
char * prompt
Definition: def_glob.h:1018
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
long memory_check()
memory_check
Definition: memory.c:1723
ptr_choice_point choice_stack
Definition: def_glob.h:1026
void init_trace ( )

init_trace

Initialize all tracing variables

Definition at line 651 of file error.c.

References FALSE, stepcount, stepflag, and trace.

652 {
653  trace=FALSE;
654  stepflag=FALSE;
655  stepcount=0;
656 }
#define FALSE
Standard boolean.
Definition: def_const.h:275
long stepcount
Definition: error.c:25
long trace
Definition: error.c:21
long stepflag
Definition: error.c:23
void insert_dbm_builtins ( )
void insert_math_builtins ( )

insert math builtins into table

insert functions into table

Definition at line 1346 of file bi_math.c.

References bi_module, c_add(), c_bit_and(), c_bit_not(), c_bit_or(), c_ceiling(), c_cos(), c_div(), c_exp(), c_floor(), c_intdiv(), c_log(), c_mod(), c_mult(), c_shift_left(), c_shift_right(), c_sin(), c_sqrt(), c_sub(), c_tan(), function_it, new_built_in(), and syntax_module.

1347 {
1353  new_built_in(syntax_module,"mod",(def_type)function_it,c_mod); /* PVR 24.2.94 */
1367 }
static long c_mult()
multiplication
Definition: bi_math.c:28
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
static long c_shift_right()
Definition: bi_math.c:864
static long c_log()
natural logarithm
Definition: bi_math.c:1238
static long c_shift_left()
bitwise shift left
Definition: bi_math.c:853
static long c_sub()
subtraction
Definition: bi_math.c:1132
static long c_bit_not()
bitwise not
Definition: bi_math.c:649
ptr_module syntax_module
Module for minimal Prolog syntax.
Definition: def_glob.h:715
static long c_div()
division
Definition: bi_math.c:138
static long c_floor()
floor
Definition: bi_math.c:479
static long c_intdiv()
integer division
Definition: bi_math.c:264
static long c_bit_or()
bitwise or
Definition: bi_math.c:785
static long c_bit_and()
bitwise and
Definition: bi_math.c:703
static long c_ceiling()
ceiling
Definition: bi_math.c:490
static long c_exp()
exponential
Definition: bi_math.c:1295
static long c_cos()
cosine
Definition: bi_math.c:617
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
static long c_sin()
sin Return the sine of the argument
Definition: bi_math.c:627
static long c_add()
addition
Definition: bi_math.c:1016
static long c_sqrt()
square root
Definition: bi_math.c:501
static long c_tan()
tangent
Definition: bi_math.c:638
static long c_mod()
modulo
Definition: bi_math.c:945
void insert_own_prop ( ptr_definition  d)

insert_own_prop

Parameters
d- ptr_definition d

INSERT_OWN_PROP(definition) Append a type's "rules" (i.e. its own attr. & constr.) to its property list. The property list also contains the type's code. A type's attributes and constraints are stored in the 'rule' field of the definition.

Definition at line 575 of file types.c.

References wl_pair_list::aaaa_2, wl_pair_list::bbbb_2, children, FALSE, HEAP_ALLOC, wl_int_list::next, wl_definition::next, wl_pair_list::next, NULL, wl_definition::properties, wl_definition::rule, TRUE, and wl_int_list::value_1.

576 {
577  ptr_int_list l;
578  ptr_pair_list rule;
579  ptr_triple_list *t;
580  long flag;
581 
582  l=HEAP_ALLOC(int_list);
583  l->value_1=(GENERIC)d;
584  l->next=children;
585  children=l;
586 
587  rule = d->rule;
588  while (rule) {
589  t= &(d->properties);
590  flag=TRUE;
591 
592  while (flag) {
593  if (*t)
594  if ((*t)->aaaa_4==rule->aaaa_2 && (*t)->bbbb_4==rule->bbbb_2 && (*t)->cccc_4==d)
595  flag=FALSE;
596  else
597  t= &((*t)->next);
598  else {
599  *t = HEAP_ALLOC(triple_list);
600  (*t)->aaaa_4=rule->aaaa_2;
601  (*t)->bbbb_4=rule->bbbb_2;
602  (*t)->cccc_4=d;
603  (*t)->next=NULL;
604  flag=FALSE;
605  }
606  }
607  rule=rule->next;
608  }
609 }
ptr_psi_term aaaa_2
Definition: def_struct.h:205
ptr_pair_list next
Definition: def_struct.h:207
#define NULL
Definition: def_const.h:533
ptr_definition next
Definition: def_struct.h:164
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term bbbb_2
Definition: def_struct.h:206
ptr_int_list children
Definition: def_glob.h:1001
GENERIC value_1
Definition: def_struct.h:85
ptr_triple_list properties
Definition: def_struct.h:149
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_int_list next
Definition: def_struct.h:86
void insert_prop ( ptr_definition  d,
ptr_triple_list  prop 
)

insert_prop

Parameters
d- ptr_definition d
prop- ptr_triple_list prop

INSERT_PROP(definition,prop) Append the properties to the definition if they aren't already present.

Definition at line 620 of file types.c.

References wl_triple_list::aaaa_4, wl_triple_list::bbbb_4, wl_triple_list::cccc_4, children, FALSE, HEAP_ALLOC, wl_int_list::next, wl_definition::next, wl_triple_list::next, NULL, wl_definition::properties, TRUE, and wl_int_list::value_1.

621 {
622  ptr_int_list l;
623  ptr_triple_list *t;
624  long flag;
625 
626  l=HEAP_ALLOC(int_list);
627  l->value_1=(GENERIC)d;
628  l->next=children;
629  children=l;
630 
631  while (prop) {
632  t= &(d->properties);
633  flag=TRUE;
634 
635  while (flag) {
636  if (*t)
637  if ((*t)->aaaa_4==prop->aaaa_4 && (*t)->bbbb_4==prop->bbbb_4 && (*t)->cccc_4==prop->cccc_4)
638  flag=FALSE;
639  else
640  t= &((*t)->next);
641  else {
642  *t = HEAP_ALLOC(triple_list);
643  (*t)->aaaa_4=prop->aaaa_4;
644  (*t)->bbbb_4=prop->bbbb_4;
645  (*t)->cccc_4=prop->cccc_4;
646  (*t)->next=NULL;
647  flag=FALSE;
648  }
649  }
650  prop=prop->next;
651  }
652 }
#define NULL
Definition: def_const.h:533
ptr_triple_list next
Definition: def_struct.h:215
ptr_definition cccc_4
Definition: def_struct.h:214
ptr_definition next
Definition: def_struct.h:164
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term bbbb_4
Definition: def_struct.h:213
ptr_int_list children
Definition: def_glob.h:1001
GENERIC value_1
Definition: def_struct.h:85
ptr_triple_list properties
Definition: def_struct.h:149
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_psi_term aaaa_4
Definition: def_struct.h:212
ptr_int_list next
Definition: def_struct.h:86
void insert_sys_builtins ( )

insert_sys_builtins

Definition at line 2209 of file sys.c.

References bi_module, c_accept(), c_apply1(), c_bind(), c_bitvector_and(), c_bitvector_clear(), c_bitvector_count(), c_bitvector_get(), c_bitvector_not(), c_bitvector_or(), c_bitvector_set(), c_bitvector_xor(), c_call_once(), c_connect(), c_cuserid(), c_errmsg(), c_errno(), c_fclose(), c_fflush(), c_fopen(), c_fork(), c_fseek(), c_ftell(), c_fwrite(), c_get_buffer(), c_get_code(), c_get_record(), c_gethostname(), c_getpid(), c_import_symbol(), c_int2stream(), c_kill(), c_lazy_project(), c_listen(), c_make_bitvector(), c_my_wait_on_feature(), c_regexp_compile(), c_regexp_execute(), c_socket(), c_stream2sys_stream(), c_sys_stream2stream(), c_wait(), c_wait_on_feature(), c_waitpid(), current_module, function_it, insert_dbm_builtins(), new_built_in(), predicate_it, set_current_module(), sys_bitvector, sys_bytedata, sys_file_stream, sys_module, sys_process_continued, sys_process_exited, sys_process_no_children, sys_process_signaled, sys_process_stopped, sys_regexp, sys_socket_stream, sys_stream, and update_symbol().

2210 {
2211  ptr_module curmod = current_module;
2213 
2214  sys_bytedata =update_symbol(sys_module,"bytedata"); /* DENYS: BYTEDATA */
2215  sys_bitvector =update_symbol(sys_module,"bitvector");
2216  sys_regexp =update_symbol(sys_module,"regexp");
2217  sys_stream =update_symbol(sys_module,"stream");
2218  sys_file_stream =update_symbol(sys_module,"file_stream");
2219  sys_socket_stream =update_symbol(sys_module,"socket_stream");
2220  sys_process_no_children=update_symbol(sys_module,"process_no_children");
2221  sys_process_exited =update_symbol(sys_module,"process_exited");
2222  sys_process_signaled =update_symbol(sys_module,"process_signaled");
2223  sys_process_stopped =update_symbol(sys_module,"process_stopped");
2224  sys_process_continued =update_symbol(sys_module,"process_continued");
2225 
2226  /* DENYS: BYTEDATA */
2227  /* purely for illustration
2228  new_built_in(sys_module,"string_to_bytedata",(def_type)function_it,c_string_to_bytedata);
2229  new_built_in(sys_module,"bytedata_to_string",(def_type)function_it,c_bytedata_to_string);
2230  */
2273 #ifdef LIFE_DBM
2275 #endif
2276 #ifdef LIFE_NDBM
2277  insert_ndbm_builtins();
2278 #endif
2281  (void)set_current_module(curmod);
2282 }
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
static long c_make_bitvector()
c_make_bitvector
Definition: sys.c:174
static long c_bitvector_not()
c_bitvector_not
Definition: sys.c:366
static long c_wait()
c_wait
Definition: sys.c:1782
static long c_accept()
c_accept
Definition: sys.c:1503
static long c_fwrite()
c_fwrite
Definition: sys.c:819
static long c_call_once()
c_call_once
Definition: sys.c:2084
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
static long c_stream2sys_stream()
c_stream2sys_stream
Definition: sys.c:1214
static long c_ftell()
c_ftell
Definition: sys.c:1144
static long c_regexp_compile()
c_regexp_compile
Definition: sys.c:554
ptr_definition sys_regexp
symbol in sys module
Definition: def_glob.h:578
static long c_int2stream()
c_int2stream
Definition: sys.c:723
ptr_definition sys_process_continued
symbol in sys module
Definition: def_glob.h:650
static long c_kill()
c_kill
Definition: sys.c:1835
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
static long c_fseek()
c_fseek
Definition: sys.c:1185
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
static long c_get_record()
c_get_record
Definition: sys.c:1083
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
static long c_getpid()
c_getpid
Definition: sys.c:2157
static long c_get_code()
c_get_code
Definition: sys.c:1113
static long c_bitvector_set()
c_bitvector_set
Definition: sys.c:472
static long c_fclose()
c_fclose
Definition: sys.c:787
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
static long c_apply1()
c_apply1()
Definition: sys.c:2130
ptr_definition sys_process_no_children
symbol in sys module
Definition: def_glob.h:622
static long c_bitvector_xor()
c_bitvector_xor
Definition: sys.c:281
static long c_fflush()
c_fflush
Definition: sys.c:849
static long c_fopen()
c_fopen
Definition: sys.c:758
static long c_connect()
c_connect
Definition: sys.c:1434
static long c_listen()
c_listen
Definition: sys.c:1460
static long c_import_symbol()
c_import_symbol
Definition: sys.c:1624
static long c_waitpid()
c_waitpid
Definition: sys.c:1808
static long c_fork()
c_fork
Definition: sys.c:1655
static long c_bitvector_count()
c_bitvector_count
Definition: sys.c:376
void insert_dbm_builtins()
static long c_wait_on_feature()
c_wait_on_feature
Definition: sys.c:1995
static long c_bind()
c_bind
Definition: sys.c:1419
static long c_errno()
c_errno
Definition: sys.c:1532
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
static long c_regexp_execute()
c_regexp_execute
Definition: sys.c:648
ptr_module sys_module
Definition: def_glob.h:735
static long c_cuserid()
c_cuserid
Definition: sys.c:1869
static long c_bitvector_or()
c_bitvector_or
Definition: sys.c:271
static long c_socket()
c_socket
Definition: sys.c:1319
ptr_definition sys_process_signaled
symbol in sys module
Definition: def_glob.h:636
static long c_bitvector_and()
c_bitvector_and
Definition: sys.c:261
static long c_lazy_project()
c_lazy_project
Definition: sys.c:1947
static long c_my_wait_on_feature()
c_my_wait_on_feature
Definition: sys.c:2043
static long c_bitvector_get()
c_bitvector_get
Definition: sys.c:462
static long c_bitvector_clear()
c_bitvector_clear
Definition: sys.c:482
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
ptr_definition sys_process_exited
symbol in sys module
Definition: def_glob.h:629
static long c_sys_stream2stream()
c_sys_stream2stream
Definition: sys.c:1244
static long c_gethostname()
c_gethostname
Definition: sys.c:1901
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
static long c_get_buffer()
c_get_buffer
Definition: sys.c:885
static long c_errmsg()
c_errmsg
Definition: sys.c:1564
ptr_definition sys_process_stopped
symbol in sys module
Definition: def_glob.h:643
void insert_system_builtins ( )

insert_system_builtins

Definition at line 746 of file bi_sys.c.

References bi_module, c_cputime(), c_encode(), c_garbage(), c_getenv(), c_localtime(), c_maxint(), c_mresiduate(), c_quiet(), c_realtime(), c_residList(), c_residuate(), c_statistics(), c_step(), c_system(), c_tprove(), c_trace(), c_verbose(), c_warning(), function_it, new_built_in(), and predicate_it.

747 {
754  new_built_in(bi_module,"quiet",(def_type)function_it,c_quiet); /* 21.1 */
766 }
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
static long c_mresiduate()
c_mresiduate
Definition: bi_sys.c:698
static long c_garbage()
c_garbage
Definition: bi_sys.c:343
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
static long c_step()
c_step
Definition: bi_sys.c:98
static long c_realtime()
c_realtime
Definition: bi_sys.c:236
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
static long c_verbose()
c_verbose
Definition: bi_sys.c:115
static long c_residuate()
c_residuate
Definition: bi_sys.c:664
static long c_getenv()
c_getenv
Definition: bi_sys.c:360
long c_trace()
trace
Definition: bi_sys.c:30
static long c_warning()
c_warning
Definition: bi_sys.c:136
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
static long c_system()
c_system
Definition: bi_sys.c:400
static long c_cputime()
c_cputime
Definition: bi_sys.c:207
static long c_residList()
c_residList()
Definition: bi_sys.c:612
static long c_encode()
c_encode
Definition: bi_sys.c:449
static long c_localtime()
localtime
Definition: bi_sys.c:269
static long c_maxint()
c_maxint
Definition: bi_sys.c:157
static long c_statistics()
c_statistics
Definition: bi_sys.c:306
long c_tprove()
c_tprove
Definition: bi_sys.c:81
long c_quiet()
c_quiet
Definition: bi_sys.c:186
void insert_translation ( ptr_psi_term  a,
ptr_psi_term  b,
long  info 
)

insert_translation

void insert_translation(ptr_psi_term a,ptr_psi_term b,long info) INSERT_TRANSLATION(a,b,info) Add the translation of address A to address B in the translation table. Also add an info field.

Definition at line 67 of file copy.c.

References hashentry::bucketindex, HASH, hashbuckets, HASHEND, hashfree, hashtable, hashtime, hashbucket::info, hashbucket::new_value, hashbucket::next, numbuckets, hashbucket::old_value, hashentry::timestamp, and traceline().

68 {
69  long index;
70  long lastbucket;
71 
72  /* Ensure there are free buckets by doubling their number if necessary */
73  if (hashfree >= numbuckets) {
74  numbuckets *= 2;
75  hashbuckets = (struct hashbucket *)
76  realloc((void *) hashbuckets, numbuckets * sizeof(struct hashbucket));
77  /* *** Do error handling here *** */
78  traceline("doubled the number of hashbuckets to %d\n", numbuckets);
79  }
80 
81  /* Add a bucket to the beginning of the list */
82  index = HASH(a);
83  if (hashtable[index].timestamp == hashtime)
84  lastbucket = hashtable[index].bucketindex;
85  else {
86  lastbucket = HASHEND;
87  hashtable[index].timestamp = hashtime;
88  }
93  hashbuckets[hashfree].next = lastbucket;
94  hashfree++;
95 }
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:16
static long hashfree
Definition: copy.c:19
static long numbuckets
Definition: copy.c:20
#define HASHEND
Tail of hash bucket.
Definition: def_const.h:1299
ptr_psi_term old_value
Definition: def_struct.h:385
static long hashtime
Definition: copy.c:18
void traceline(char *format,...)
traceline
Definition: error.c:186
ptr_psi_term new_value
Definition: def_struct.h:386
long timestamp
Definition: def_struct.h:392
static struct hashbucket * hashbuckets
Definition: copy.c:17
long bucketindex
Definition: def_struct.h:393
#define HASH(A)
Definition: def_macro.h:278
void insert_type_builtins ( )

void insert_type_builtins

Definition at line 817 of file bi_type.c.

References bi_module, c_children(), c_glb(), c_is_function(), c_is_number(), c_is_persistent(), c_is_predicate(), c_is_sort(), c_is_value(), c_isa_cmp(), c_isa_eq(), c_isa_ge(), c_isa_gt(), c_isa_le(), c_isa_lt(), c_isa_ncmp(), c_isa_neq(), c_isa_nge(), c_isa_ngt(), c_isa_nle(), c_isa_nlt(), c_isa_subsort(), c_lub(), c_parents(), c_smallest(), function_it, new_built_in(), predicate_it, and syntax_module.

818 {
819  /* Sort comparisons */
832 
833  /* Type checks */
840 
841  /* Sort hierarchy maneuvering */
848 }
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
static long c_isa_cmp()
c_isa_cmp
Definition: bi_type.c:480
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
static long c_smallest()
c_smallest
Definition: bi_type.c:159
long c_lub()
long c_lub
Definition: bi_type.c:773
static long c_is_number()
static long c_is_number
Definition: bi_type.c:636
static long c_is_predicate()
c_is_predicate
Definition: bi_type.c:556
static long c_isa_lt()
c_isa_lt
Definition: bi_type.c:343
static long c_isa_ncmp()
c_isa_ncmp
Definition: bi_type.c:489
long c_glb()
long c_glb
Definition: bi_type.c:709
ptr_module syntax_module
Module for minimal Prolog syntax.
Definition: def_glob.h:715
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
static long c_children()
c_children
Definition: bi_type.c:30
static long c_isa_nle()
c_isa_nle
Definition: bi_type.c:407
static long c_isa_ge()
c_isa_ge
Definition: bi_type.c:359
long c_isa_subsort()
long c_isa_subsort
Definition: bi_type.c:664
static long c_isa_nlt()
c_isa_nlt
Definition: bi_type.c:423
static long c_isa_ngt()
c_isa_ngt
Definition: bi_type.c:455
static long c_isa_gt()
c_isa_gt
Definition: bi_type.c:375
static long c_is_value()
c_is_value
Definition: bi_type.c:610
static long c_isa_nge()
c_isa_nge
Definition: bi_type.c:439
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
static long c_parents()
c_parents
Definition: bi_type.c:96
static long c_is_sort()
c_is_sort
Definition: bi_type.c:582
static long c_is_function()
c_is_function
Definition: bi_type.c:500
static long c_isa_eq()
c_isa_eq
Definition: bi_type.c:391
static long c_isa_le()
c_isa_le
Definition: bi_type.c:327
static long c_is_persistent()
c_is_persistent
Definition: bi_type.c:526
static long c_isa_neq()
c_isa_neq
Definition: bi_type.c:471
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 int_div_warning ( ptr_psi_term  arg,
REAL  val 
)

int_div_warning

Parameters
arg- ptr_psi_term arg
val- REAL val

Definition at line 1028 of file error.c.

References nonint_warning().

1029 {
1030  return nonint_warning(arg,val,"of integer division is not an integer");
1031 }
long nonint_warning(ptr_psi_term arg, REAL val, char *msg)
nonint_warning
Definition: error.c:974
long intcmp ( long  a,
long  b 
)

intcmp

Parameters
a- long a
b- long b

INTCMP(a,b) Compares two integers, for use in FIND or INSERT.

Definition at line 21 of file trees.c.

22 {
23 #ifdef CMPDBG
24  printf("intcmp a = %ld b = %ld a - b = %ld\n", a ,b , a - b);
25 #endif
26  return a - b;
27 }
void interrupt ( )

INTERRUPT()

This routine is called whenever the user types CONTROL C which generates an interrupt. The interrupt is dealt with later, when convenient, or ignored.

Definition at line 21 of file interrupt.c.

References interrupted, and TRUE.

22 {
23  void (*f)(); /* RM: Apr 7 1993 Weird problem in GCC and C89 */
24 
26  f=interrupt;
27  (void)signal(SIGINT,f);/* RM: Feb 15 1993 */
28 }
void interrupt()
INTERRUPT()
Definition: interrupt.c:21
#define TRUE
Standard boolean.
Definition: def_const.h:268
long interrupted
Definition: interrupt.c:12
GENERIC intListNext ( ptr_int_list  p)

intListNext

Parameters
p- ptr_int_list p

not sure purpose (DJD ???)

Definition at line 515 of file bi_sys.c.

References wl_int_list::next.

516 {
517  return (GENERIC )(p->next);
518 }
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_int_list next
Definition: def_struct.h:86
ptr_psi_term intListValue ( ptr_int_list  p)

ptr_psi_term intListValue

Parameters
p- ptr_int_list p

not sure purpose (DJD ???)

Definition at line 503 of file bi_sys.c.

References makePsiTerm(), and wl_int_list::value_1.

504 {
505  return makePsiTerm((void *)p->value_1);
506 }
ptr_psi_term makePsiTerm(ptr_definition x)
ptr_psi_term makePsiTerm
Definition: bi_sys.c:573
GENERIC value_1
Definition: def_struct.h:85
long is_built_in ( ptr_pair_list  r)

is_built_in

Parameters
r- ptr_pair_list r

Return TRUE if rules r are for a built-in

Definition at line 5118 of file built_ins.c.

References MAX_BUILT_INS.

5119 {
5120  return ((unsigned long)r>0 && (unsigned long)r<MAX_BUILT_INS);
5121 }
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
long is_int ( char **  s,
long *  len,
long *  sgn 
)

is_int

Parameters
s= char **s
len- long *len
sgn- long *sgn

Return TRUE iff the string s represents an integer. Modify s to point to first non-zero digit. Return number of significant digits in the integer and its sign.

Definition at line 41 of file trees.c.

References FALSE, and TRUE.

42 {
43  char *sint; /* Ptr to first non-zero digit */
44  char *stmp; /* Scratchpad for string ptr */
45 #ifdef CMPDBG
46  printf("is_int *s = %s\n",*s);
47 #endif
48  /*
49  { register char *p= *s;
50  register char c= *p;
51  if(c>'0' && c<='9' && *(p+1)==0) return TRUE;
52  }
53  */
54 
55  stmp=(*s);
56  if ((*sgn=(*stmp=='-'))) {
57  stmp++;
58  if (!*stmp)
59  {
60 #ifdef CMPDBG
61  printf("is_int = FALSE\n");
62 #endif
63  return FALSE;
64  }
65  }
66  if (!*stmp)
67  {
68 #ifdef CMPDBG
69  printf("is_int = FALSE\n");
70 #endif
71  return FALSE; /* 6.10 */
72  }
73  while (*stmp=='0') stmp++;
74  sint=stmp;
75  while (*stmp) {
76  if (*stmp<'0' || *stmp>'9')
77  {
78 #ifdef CMPDBG
79  printf("is_int = FALSE\n");
80 #endif
81  return FALSE;
82  }
83  stmp++;
84  }
85  *len=stmp-sint;
86  *s=sint;
87 #ifdef CMPDBG
88  printf("is_int = TRUE *len = %ld *sgn = %ld *s = %s\n",*len,*sgn,*s);
89 #endif
90  return TRUE;
91 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
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
int is_ipaddr ( char *  s)

is_ipaddr

Parameters
s- char *s

Definition at line 1333 of file sys.c.

References NULL.

1334 {
1335  if (s==NULL) return 0;
1336  while (*s)
1337  if (!isdigit(*s) && *s!='.') return 0;
1338  else s++;
1339  return 1;
1340 }
#define NULL
Definition: def_const.h:533
int isSubTypeValue ( ptr_psi_term  arg1,
ptr_psi_term  arg2 
)

isSubTypeValue

Parameters
arg1- ptr_psi_term arg1
arg2- ptr_psi_term arg2

Definition at line 180 of file bi_type.c.

References FALSE, integer, quoted_string, REAL, real, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

181 {
182  long ans=TRUE;
183 
184  /* we already know that either arg1->type == arg2->type or that at both
185  * of the two are either long or real
186  */
187 
188  if (arg2->value_3) {
189  if (arg1->value_3) {
190  if (arg1->type==real || arg1->type==integer) {
191  ans=( *(REAL *)arg1->value_3 == *(REAL *)arg2->value_3);
192  }
193  else if (arg1->type==quoted_string) {
194  ans=(strcmp((char *)arg1->value_3,(char *)arg2->value_3)==0);
195  }
196  }
197  else
198  ans=FALSE;
199  }
200  else {
201  if (arg1->value_3 && (arg1->type==real || arg1->type==integer)) {
202  if (arg2->type==integer)
203  ans=(*(REAL *)arg1->value_3 == floor(*(REAL *)arg1->value_3));
204  else
205  ans=TRUE;
206  }
207  }
208  return ans;
209 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
long isValue ( ptr_psi_term  p)

isValue(p)

Parameters
p- ptr_psi_term p

Definition at line 694 of file bi_type.c.

References NULL, and wl_psi_term::value_3.

695 {
696  return (p->value_3 != NULL);
697 }
#define NULL
Definition: def_const.h:533
GENERIC value_3
Definition: def_struct.h:186
void least_sorts ( )

void least_sorts()

LEAST_SORTS() Build the list of terminals (i.e. sorts with no children) in nothing->parents.

Definition at line 743 of file types.c.

References wl_definition::children, cons(), first_definition, wl_definition::next, nothing, NULL, wl_definition::parents, wl_definition::type_def, and type_it.

744 {
745  ptr_definition d;
746 
747  for(d=first_definition;d;d=d->next)
748  if (d->type_def==(def_type)type_it && d->children==NULL && d!=nothing)
750 }
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
def_type type_def
Definition: def_struct.h:153
ptr_int_list cons(GENERIC v, ptr_int_list l)
cons
Definition: types.c:179
#define NULL
Definition: def_const.h:533
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition next
Definition: def_struct.h:164
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_int_list children
Definition: def_struct.h:152
ptr_int_list parents
Definition: def_struct.h:151
long legal_in_name ( long  c)

legal_in_name

Parameters
c- long c

LEGAL_IN_NAME(character) Tests if character is legal in a name or a variable (see macros).

Definition at line 980 of file token.c.

References DIGIT, LOWER, and UPPER.

981 {
982  return
983  UPPER(c) ||
984  LOWER(c) ||
985  DIGIT(c);
986 
987  /* || c=='\'' RM: Dec 16 1992 */ ;
988 }
#define UPPER(C)
Definition: def_macro.h:44
#define DIGIT(C)
Definition: def_macro.h:42
#define LOWER(C)
Definition: def_macro.h:46
void List_Append ( RefListHeader  header,
Ref  atom 
)

void List_Append

Parameters
header- RefListHeader header
atom- Ref atom

Definition at line 71 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, wl_ListHeader::Last, and NULL.

72 {
73  RefListGetLinksProc getLinks = header->GetLinks;
74 
75  /* Link to the end of list */
76 
77  if (header->Last != NULL)
78  (*getLinks)(header->Last)->Next = atom;
79 
80  else /* The list is empty */
81  header->First = atom;
82 
83  /* Update links of atom to insert */
84 
85  (*getLinks)(atom)->Prev = header->Last;
86  (*getLinks)(atom)->Next = NULL;
87 
88  /* Update last element of header */
89 
90  header->Last = atom;
91 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
#define NULL
Definition: def_const.h:533
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.h:275
long List_Card ( RefListHeader  header)

List_Card.

Parameters
header- RefListHeader header

Definition at line 461 of file list.c.

References List_CountAtom(), and List_Enum().

462 {
463  long n = 0;
464 
465  (void)List_Enum (header,(RefListEnumProc) List_CountAtom, &n);
466  return n;
467 }
int(* RefListEnumProc)()
Definition: def_struct.h:276
static long List_CountAtom(Ref p, Ref nbR)
List_CountAtom.
Definition: list.c:446
long List_Enum(RefListHeader header, RefListEnumProc proc, Ref closure)
List_Enum.
Definition: list.c:379
void List_Concat ( RefListHeader  header1,
RefListHeader  header2 
)

List_Concat.

Parameters
header1- RefListHeader header1
header2- RefListHeader header2

Definition at line 308 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, wl_ListHeader::Last, and NULL.

309 {
310  RefListGetLinksProc getLinks = header1->GetLinks;
311 
312  if (header1->GetLinks == header2->GetLinks)
313  {
314 #ifdef prlDEBUG
315  OS_PrintMessage ("List_Concat: ERROR concat different lists\n");
316 #endif
317  return;
318  }
319 
320  /* Concatenate only if the second list is not empty */
321 
322  if (header2->First != NULL)
323  {
324  /* Obvious concatenate when the first list is empty */
325 
326  if (header1->First == NULL)
327  header1->First = header2->First;
328 
329  else /* Concatenate the two non empty lists */
330  {
331  (*getLinks)(header1->Last)->Next = header2->First;
332  (*getLinks)(header2->First)->Prev = header1->Last;
333  }
334  header1->Last = header2->Last;
335  }
336 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
#define NULL
Definition: def_const.h:533
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.h:275
void List_Cut ( RefListHeader  header,
Ref  atom,
RefListHeader  newHeader 
)

List_Cut.

Parameters
header- RefListHeader header
atom- Ref atom
newHeader- RefListHeader newHeader

Definition at line 488 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, wl_ListHeader::Last, List_Last, List_Next, and NULL.

489 {
490  RefListGetLinksProc getLinks = header->GetLinks;
491 
492  if (atom != List_Last (header))
493  {
494  newHeader->First = List_Next (header, atom);
495  newHeader->Last = header->Last;
496 
497  header->Last = atom;
498 
499  /* Update the links */
500  (*getLinks)(atom)->Next = NULL;
501  (*getLinks)(newHeader->First)->Prev = NULL;
502  }
503 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
#define NULL
Definition: def_const.h:533
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.h:275
#define List_Next(header, RefAtom)
Definition: def_macro.h:161
#define List_Last(header)
Definition: def_macro.h:160
long List_Enum ( RefListHeader  header,
RefListEnumProc  proc,
Ref  closure 
)

List_Enum.

Parameters
header- RefListHeader header
proc- RefListEnumProc proc
closure- Ref closure

Definition at line 379 of file list.c.

References wl_ListHeader::First, and List_EnumFrom().

388 {
389  return (List_EnumFrom (header, header->First, proc, closure));
390 }
long List_EnumFrom(RefListHeader header, Ref atom, RefListEnumProc proc, Ref closure)
List_EnumFrom.
Definition: list.c:347
long List_EnumBack ( RefListHeader  header,
RefListEnumProc  proc,
Ref  closure 
)

List_EnumBack.

Parameters
header- RefListHeader header
proc- RefListEnumProc proc
closure- Ref closure

Definition at line 433 of file list.c.

References wl_ListHeader::Last, and List_EnumBackFrom().

434 {
435  return (List_EnumBackFrom (header, header->Last, proc, closure));
436 }
long List_EnumBackFrom(RefListHeader header, Ref atom, RefListEnumProc proc, Ref closure)
List_EnumBackFrom.
Definition: list.c:401
long List_EnumBackFrom ( RefListHeader  header,
Ref  atom,
RefListEnumProc  proc,
Ref  closure 
)

List_EnumBackFrom.

Parameters
header- RefListHeader header
atom- Ref atom
proc- RefListEnumProc proc
closure- Ref closure)

Definition at line 401 of file list.c.

References List_Prev, NULL, and TRUE.

402 {
403  Ref cur, prev;
404  int notInterrupted = TRUE;
405 
406 #ifdef prlDEBUG
407  header->Lock += 1;
408 #endif
409 
410  cur = atom;
411  while (cur != NULL && notInterrupted)
412  {
413  prev = List_Prev (header, cur);
414  notInterrupted = (*proc)(cur, closure);
415  cur = prev;
416  }
417 
418 #ifdef prlDEBUG
419  header->Lock -=1;
420 #endif
421 
422  return (notInterrupted);
423 }
#define List_Prev(header, RefAtom)
Definition: def_macro.h:162
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
void * Ref
Definition: def_struct.h:272
long List_EnumFrom ( RefListHeader  header,
Ref  atom,
RefListEnumProc  proc,
Ref  closure 
)

List_EnumFrom.

Parameters
header- RefListHeader header
atom- Ref atom
proc- RefListEnumProc proc
closure- Ref closure

Definition at line 347 of file list.c.

References List_Next, text_buffer::next, NULL, and TRUE.

348 {
349  Ref cur, next;
350  int notInterrupted = TRUE;
351 
352 #ifdef prlDEBUG
353  header->Lock += 1;
354 #endif
355 
356  cur = atom;
357  while (cur != NULL && notInterrupted)
358  {
359  next = List_Next (header, cur);
360  notInterrupted = (*proc)(cur, closure);
361  cur = next;
362  }
363 
364 #ifdef prlDEBUG
365  header->Lock -=1;
366 #endif
367 
368  return (notInterrupted);
369 }
#define NULL
Definition: def_const.h:533
#define List_Next(header, RefAtom)
Definition: def_macro.h:161
#define TRUE
Standard boolean.
Definition: def_const.h:268
void * Ref
Definition: def_struct.h:272
void List_InsertAfter ( RefListHeader  header,
Ref  atom,
Ref  mark 
)

List_InsertAfter.

Parameters
header- RefListHeader header
atom- Ref atom
mark- Ref mark)

Definition at line 134 of file list.c.

References wl_ListHeader::GetLinks, wl_ListHeader::Last, List_InsertAhead(), and NULL.

135 {
136  RefListGetLinksProc getLinks = header->GetLinks;
137 
138 #ifdef prlDEBUG
139  if (header->Lock > 1)
140  OS_PrintMessage ("List_InsertAfter: Warning insert after on recursive List_Enum call !!\n");
141 #endif
142 
143  if (mark != NULL)
144  {
145  (*getLinks)(atom)->Prev = mark;
146 
147  if (mark != header->Last)
148  {
149  (*getLinks)(atom)->Next = (*getLinks)(mark)->Next;
150  (*getLinks)((*getLinks)(mark)->Next)->Prev = atom;
151  }
152  else /* Insert at the end of the list */
153  {
154  (*getLinks)(atom)->Next = NULL;
155  header->Last = atom;
156  }
157 
158  (*getLinks)(mark)->Next = atom;
159  }
160  else /* Insert ahead the list */
161  List_InsertAhead (header, atom);
162 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
#define NULL
Definition: def_const.h:533
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.h:275
void List_InsertAhead(RefListHeader header, Ref atom)
List_InsertAhead.
Definition: list.c:44
void List_InsertAhead ( RefListHeader  header,
Ref  atom 
)

List_InsertAhead.

Parameters
header- RefListHeader header
atom- Ref atom

List functions

Definition at line 44 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, wl_ListHeader::Last, and NULL.

45 {
46  RefListGetLinksProc getLinks = header->GetLinks;
47 
48  /* Update links of atom to insert */
49 
50  (*getLinks)(atom)->Next = header->First;
51  (*getLinks)(atom)->Prev = NULL;
52 
53  /* Link to the head of list */
54 
55  if (header->First != NULL)
56  (*getLinks)(header->First)->Prev = atom;
57 
58  else /* The list is empty */
59  header->Last = atom;
60 
61  header->First = atom;
62 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
#define NULL
Definition: def_const.h:533
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.h:275
void List_InsertBefore ( RefListHeader  header,
Ref  atom,
Ref  mark 
)

List_InsertBefore.

Parameters
header- RefListHeader header
atom- Ref atom
mark- Ref mark

Definition at line 101 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, List_Append(), and NULL.

102 {
103  RefListGetLinksProc getLinks = header->GetLinks;
104 
105  if (mark != NULL)
106  {
107  (*getLinks)(atom)->Next = mark;
108 
109  if (mark != header->First)
110  {
111  (*getLinks)(atom)->Prev = (*getLinks)(mark)->Prev;
112  (*getLinks)((*getLinks)(mark)->Prev)->Next = atom;
113  }
114  else /* Insert ahead the list */
115  {
116  (*getLinks)(atom)->Prev = NULL;
117  header->First = atom;
118  }
119 
120  (*getLinks)(mark)->Prev = atom;
121  }
122  else /* Append to the list */
123  List_Append (header, atom);
124 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
#define NULL
Definition: def_const.h:533
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.h:275
void List_Append(RefListHeader header, Ref atom)
void List_Append
Definition: list.c:71
long List_IsUnlink ( RefListLinks  links)

List_IsUnlink.

Parameters
links- RefListLinks links

Definition at line 475 of file list.c.

References wl_ListLinks::Next, NULL, and wl_ListLinks::Prev.

476 {
477  return (links->Next == NULL && links->Prev == NULL);
478 }
#define NULL
Definition: def_const.h:533
psi_term list_nil ( ptr_definition  type)

list_nil

Parameters
type- ptr_definition type

LIST_NIL(type) Returns the atom NIL to mark the end of a list.

Definition at line 278 of file parser.c.

References wl_psi_term::attr_list, wl_psi_term::coref, disj_nil, disjunction, FALSE, wl_psi_term::flags, nil, NULL, wl_psi_term::resid, wl_psi_term::status, wl_psi_term::type, and wl_psi_term::value_3.

279 {
280  psi_term nihil;
281 
282  if(type==disjunction) /* RM: Feb 1 1993 */
283  nihil.type=disj_nil;
284  else
285  nihil.type=nil;
286 
287  nihil.status=0;
288  nihil.flags=FALSE; /* 14.9 */
289  nihil.attr_list=NULL;
290  nihil.resid=NULL;
291  nihil.value_3=NULL;
292  nihil.coref=NULL;
293 
294  return nihil;
295 }
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
ptr_residuation resid
Definition: def_struct.h:189
#define NULL
Definition: def_const.h:533
#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
ptr_psi_term coref
Definition: def_struct.h:188
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
void List_Remove ( RefListHeader  header,
Ref  atom 
)

List_Remove.

Parameters
header- RefListHeader header
atom- Ref atom)

Definition at line 258 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, wl_ListHeader::Last, and NULL.

259 {
260 /*-----------------------------------------------------------------------------
261 
262 WARNING
263  - The container is 'updated' two times if the first and last atom
264  of list is the only one to remove.
265 
266 -----------------------------------------------------------------------------*/
267 
268  RefListGetLinksProc getLinks = header->GetLinks;
269 
270 #ifdef prlDEBUG
271  if (header->Lock > 1)
272  OS_PrintMessage ("List_Remove: Warning remove on recursive List_Enum call !!\n");
273 #endif
274 
275  /* Update the DownStream links */
276 
277  if ((*getLinks)(atom)->Prev != NULL)
278  {
279  (*getLinks)((*getLinks)(atom)->Prev)->Next =
280  (*getLinks)(atom)->Next;
281  }
282  else /* Atom is the first of list */
283  header->First = (*getLinks)(atom)->Next;
284 
285  /* Update the UpStream links */
286 
287  if ((*getLinks)(atom)->Next != NULL)
288  {
289  (*getLinks)((*getLinks)(atom)->Next)->Prev =
290  (*getLinks)(atom)->Prev;
291  }
292  else /* Atom is the last of list */
293  header->Last = (*getLinks)(atom)->Prev;
294 
295  /* Reset the atom links */
296 
297  (*getLinks)(atom)->Prev = NULL;
298  (*getLinks)(atom)->Next = NULL;
299 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
#define NULL
Definition: def_const.h:533
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.h:275
void List_Reverse ( RefListHeader  header)

List_Reverse.

Parameters
header- RefListHeader header

Definition at line 230 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, wl_ListHeader::Last, List_SwapLinks(), text_buffer::next, and NULL.

231 {
232  Ref cur, next;
233  RefListGetLinksProc getLinks = header->GetLinks;
234 
235  /* This traverse cannot be done with function List_Enum() */
236 
237  cur = header->First;
238 
239  /* Swap the headers */
240  header->First = header->Last;
241  header->Last = cur;
242 
243  while (cur != NULL)
244  {
245  next = (*getLinks)(cur)->Next;
246  (void)List_SwapLinks (header, cur);
247  cur = next;
248  }
249 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
static long List_SwapLinks(RefListHeader header, Ref atom)
List_SwapLinks.
Definition: list.c:213
#define NULL
Definition: def_const.h:533
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.h:275
void * Ref
Definition: def_struct.h:272
void List_SetLinkProc ( RefListHeader  header,
RefListGetLinksProc  getLinks 
)

List_SetLinkProc.

Parameters
header- RefListHeader header
getLinks- RefListGetLinksProc getLinks

Set functions

Definition at line 24 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, wl_ListHeader::Last, and NULL.

25 {
26  header->First = NULL;
27  header->Last = NULL;
28 
29 #ifdef prlDEBUG
30  header->Lock = 0;
31 #endif
32 
33  header->GetLinks = getLinks;
34 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
#define NULL
Definition: def_const.h:533
void list_special ( ptr_psi_term  t)

list_special

Parameters
t- ptr_psi_term t

List the characteristics (delay_check, dynamic/static, non_strict) in such a way that they can be immediately read in.

Definition at line 5131 of file built_ins.c.

References wl_definition::always_check, display_psi_stream(), wl_definition::evaluate_args, FALSE, is_built_in(), output_stream, wl_definition::protected, wl_definition::rule, TRUE, wl_psi_term::type, wl_definition::type_def, and type_it.

5132 {
5133  ptr_definition d = t->type;
5134  ptr_pair_list r = t->type->rule;
5135  long prflag=FALSE;
5136 
5137  if (t->type->type_def==(def_type)type_it) {
5138  if (!d->always_check) {
5139  if (is_built_in(r)) fprintf(output_stream,"%% ");
5140  fprintf(output_stream,"delay_check(");
5141  display_psi_stream(t);
5142  fprintf(output_stream,")?\n");
5143  prflag=TRUE;
5144  }
5145  } else {
5146  if (!d->protected) {
5147  if (is_built_in(r)) fprintf(output_stream,"%% ");
5148  fprintf(output_stream,"%s(",(d->protected?"static":"dynamic"));
5149  display_psi_stream(t);
5150  fprintf(output_stream,")?\n");
5151  prflag=TRUE;
5152  }
5153  }
5154  if (!d->evaluate_args) {
5155  if (is_built_in(r)) fprintf(output_stream,"%% ");
5156  fprintf(output_stream,"non_strict(");
5157  display_psi_stream(t);
5158  fprintf(output_stream,")?\n");
5159  prflag=TRUE;
5160  }
5161  /* if (prflag) fprintf(output_stream,"\n"); */
5162 }
char evaluate_args
Definition: def_struct.h:156
void display_psi_stream(ptr_psi_term t)
display_psi_stream
Definition: print.c:1564
def_type type_def
Definition: def_struct.h:153
char always_check
Definition: def_struct.h:154
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
long is_built_in(ptr_pair_list r)
is_built_in
Definition: built_ins.c:5118
FILE * output_stream
Definition: def_glob.h:1017
ptr_definition type
Definition: def_struct.h:181
void List_Swap ( RefListHeader  header,
Ref  first,
Ref  second 
)

List_Swap.

Parameters
header- RefListHeader header
first- Ref first
second- Ref second)

Definition at line 172 of file list.c.

References wl_ListHeader::First, wl_ListHeader::GetLinks, and wl_ListHeader::Last.

173 {
174  RefListGetLinksProc getLinks = header->GetLinks;
175 
176  /* Don't swap if the input is wrong */
177 
178  if ((*getLinks)(first)->Next != second)
179  {
180 #ifdef prlDEBUG
181  OS_PrintMessage ("List_Swap: WARNING wrong input data, swap not done..\n");
182 #endif
183  return;
184  }
185 
186  /* Special Cases */
187 
188  if (header->First == first)
189  header->First = second;
190  else
191  (*getLinks)((*getLinks)(first)->Prev)->Next = second;
192 
193  if (header->Last == second)
194  header->Last = first;
195  else
196  (*getLinks)((*getLinks)(second)->Next)->Prev = first;
197 
198  /* Swap the atoms */
199 
200  (*getLinks)(second)->Prev = (*getLinks)(first)->Prev;
201  (*getLinks)(first)->Next = (*getLinks)(second)->Next;
202  (*getLinks)(first)->Prev = second;
203  (*getLinks)(second)->Next = first;
204 }
RefListGetLinksProc GetLinks
Definition: def_struct.h:297
RefListLinks(* RefListGetLinksProc)()
Definition: def_struct.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
long load_aim ( )

load_aim

LOAD_AIM() Continue loading a file from the current psi-term up to the next query. Files are loaded in blocks of assertions that end with a query. Such a chunk is loaded by a 'load' goal on the goal_stack. This goal contains the input file state information. This guarantees that all queries in the input file are executed in the order they are encountered (which includes load operations).

Definition at line 2232 of file login.c.

References wl_goal::aaaa_1, abort_life(), aim, assert_clause(), assert_first, wl_goal::bbbb_1, wl_goal::cccc_1, choice_stack, CURRENT_MODULE, DEFRULES, encode_types(), eof, FACT, FALSE, file_date, find_module(), general_cut, get_attr(), input_state, input_stream, load, noisy, NULL, open_input_file(), parse(), prove, push_choice_point(), push_goal(), QUERY, restore_state(), save_state(), set_current_module(), stack_copy_psi_term(), TRUE, wl_psi_term::type, var_occurred, and var_tree.

2233 {
2234  long success=TRUE,exitloop;
2235  ptr_psi_term s;
2236  long sort;
2237  char *fn;
2238  long old_noisy,old_file_date;
2239  ptr_node old_var_tree;
2240  ptr_choice_point cutpt;
2241  long old_var_occurred; /* 18.8 */
2242  int end_of_file=FALSE; /* RM: Jan 27 1993 */
2243 
2244 
2248  old_file_date=file_date;
2249  file_date=(unsigned long)aim->bbbb_1;
2250  old_noisy=noisy;
2251  noisy=FALSE;
2252  fn=(char*)aim->cccc_1;
2253  exitloop=FALSE;
2254 
2255  do {
2256  /* Variables in queries in files are *completely independent* of top- */
2257  /* level variables. I.e.: top-level variables are *not* recognized */
2258  /* while loading files and variables in file queries are *not* added. */
2259  old_var_occurred=var_occurred; /* 18.8 */
2260  old_var_tree=var_tree;
2261  var_tree=NULL;
2262  s=stack_copy_psi_term(parse(&sort));
2263  var_tree=old_var_tree;
2264  var_occurred=old_var_occurred; /* 18.8 */
2265 
2266  if (s->type==eof) {
2267  encode_types();
2268  if (input_stream!=stdin) (void)fclose(input_stream);
2269  exitloop=TRUE;
2270  end_of_file=TRUE; /* RM: Jan 27 1993 */
2271  }
2272  else if (sort==FACT) {
2274  assert_clause(s);
2275  }
2276  else if (sort==QUERY) {
2277  encode_types();
2279  /* Handle both successful and failing queries correctly. */
2280  cutpt=choice_stack;
2285  exitloop=TRUE;
2286  }
2287  else {
2288  /* fprintf(stderr,"*** Error: in input file %c%s%c.\n",34,fn,34); */
2289  /* success=FALSE; */
2290  /* fail_all(); */
2291  if (input_stream!=stdin) (void)fclose(input_stream);
2292  (void)abort_life(TRUE);
2293  /* printf("\n*** Abort\n"); */
2294  /* main_loop_ok=FALSE; */
2295  }
2296  } while (success && !exitloop);
2297 
2298 
2299  /* RM: Jan 27 1993 */
2300  if(end_of_file || !success) {
2301  /*
2302  printf("END OF FILE %s, setting module to %s\n",
2303  ((ptr_psi_term)get_attr(input_state,
2304  INPUT_FILE_NAME))->value,
2305  ((ptr_psi_term)get_attr(input_state,
2306  CURRENT_MODULE))->value);
2307  */
2308 
2309  (void)set_current_module(
2310  find_module((char *)((ptr_psi_term)get_attr(input_state,
2311  CURRENT_MODULE))->value_3));
2312  }
2313 
2314 
2315  noisy=old_noisy;
2316  file_date=old_file_date;
2317  (void)open_input_file("stdin");
2318 
2319 
2320  return success;
2321 }
void assert_clause(ptr_psi_term t)
assert_clause
Definition: login.c:287
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
long assert_first
Definition: def_glob.h:1032
psi_term parse(long *q)
parse
Definition: parser.c:907
void push_goal(goals t, ptr_psi_term aaaa_5, ptr_psi_term bbbb_5, GENERIC cccc_5)
push_goal
Definition: login.c:600
GENERIC cccc_1
Definition: def_struct.h:241
#define general_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1114
long file_date
Definition: def_glob.h:1034
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define CURRENT_MODULE
feature name
Definition: def_const.h:939
#define FACT
Fact Kind of user input.
Definition: def_const.h:338
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
ptr_psi_term input_state
Definition: def_glob.h:856
#define QUERY
Query Kind of user input.
Definition: def_const.h:345
long noisy
Definition: def_glob.h:1011
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
#define FALSE
Standard boolean.
Definition: def_const.h:275
FILE * input_stream
Definition: def_glob.h:1014
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
void restore_state(ptr_psi_term t)
restore_state
Definition: token.c:334
#define load
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1156
void encode_types()
encode_types
Definition: types.c:1091
void save_state(ptr_psi_term t)
save_state
Definition: token.c:293
GENERIC get_attr(ptr_psi_term t, char *attrname)
get_attr
Definition: token.c:265
ptr_module find_module(char *module)
find_module
Definition: modules.c:54
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
long var_occurred
???
Definition: def_glob.h:839
long open_input_file(char *file)
open_input_file
Definition: token.c:594
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
void push_choice_point(goals t, ptr_psi_term aaaa_6, ptr_psi_term bbbb_6, GENERIC cccc_6)
push_choice_point
Definition: login.c:638
ptr_choice_point choice_stack
Definition: def_glob.h:1026
long look ( )

look

LOOK() This function returns the precedence of the stack top.

Definition at line 163 of file parser.c.

References int_stack, and parser_stack_index.

164 {
166 }
long parser_stack_index
index to parser stack
Definition: def_glob.h:164
long int_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:959
ptr_int_list lub ( ptr_psi_term  a,
ptr_psi_term  b,
ptr_psi_term pp 
)

Definition at line 173 of file lub.c.

References bfs(), wl_definition::code, copyTypeCode(), decode(), isSubTypeValue(), isValue(), makeUnitList(), NULL, or_codes(), stack_alloc(), sub_type(), top, wl_psi_term::type, and type_count.

174 {
175  ptr_definition ta; /* type of psi term a */
176  ptr_definition tb; /* type of psi term b */
177  long *flags; /* set to 1 if this type has been checked in
178  * the lub search.
179  */
180  ptr_int_list ans;
181  ptr_int_list pattern;
182  long found;
183 
184  ta = a->type;
185  tb = b->type;
186 
187  /* special cases first */
188 
189  if (isValue(a) && isValue(b) && sub_type(ta,tb) && sub_type(tb,ta))
190  {
191  /* special case of two values being of same type. Check that they
192  * might actually be same value before returning the type
193  */
194  if (isSubTypeValue(a, b))
195  {
196  /* since we alreadyuu know they are both values, isSubTypeValue
197  * returns TRUE if they are same value, else false
198  */
199 
200  *pp = a;
201  return NULL;
202  }
203  }
204 
205  if (sub_type(ta, tb)) return makeUnitList(tb);
206  if (sub_type(tb, ta)) return makeUnitList(ta);
207 
208  /* ta has the lub of tb&ta without the high bit set, search upwards for a
209  * type that has the same lower bits as ta
210  */
211 
212  /* get the pattern to search for */
213 
214  pattern = copyTypeCode(ta->code);
215  or_codes(pattern, tb->code); /* pattern to search for */
216  ans = copyTypeCode(pattern); /* resulting pattern */
217 
218  /* initialize the table to be non-searched */
219 
220  flags = (long *)stack_alloc(sizeof(unsigned long) * type_count);
221  memset(flags, 0, sizeof(unsigned long) * type_count);
222 
223  /* now do a breadth first search for each of arg1 and arg2 */
224 
225  found = bfs(ta, ans, pattern, flags);
226  found += bfs(tb, ans, pattern, flags);
227 
228  if (found)
229  ans = decode(ans);
230  else
231  ans = makeUnitList(top);
232 
233  return ans;
234 }
int isSubTypeValue(ptr_psi_term arg1, ptr_psi_term arg2)
isSubTypeValue
Definition: bi_type.c:180
long type_count
Definition: def_glob.h:1021
ptr_int_list decode(ptr_int_list c)
decode
Definition: types.c:1784
static long bfs(ptr_definition p, ptr_int_list ans, ptr_int_list pattern, long *flags)
bfs
Definition: lub.c:88
void or_codes(ptr_int_list u, ptr_int_list v)
or_codes
Definition: types.c:831
#define NULL
Definition: def_const.h:533
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_int_list copyTypeCode(ptr_int_list u)
copyTypeCode
Definition: types.c:808
ptr_int_list code
Definition: def_struct.h:150
long isValue(ptr_psi_term p)
isValue(p)
Definition: bi_type.c:694
ptr_definition type
Definition: def_struct.h:181
static ptr_int_list makeUnitList(ptr_definition x)
makeUnitList
Definition: lub.c:152
GENERIC stack_alloc(long s)
stack_alloc
Definition: memory.c:1642
int main ( int  argc,
char *  argv[] 
)

main

int main(int argc,char *argv[])

Parameters
argc- int argc
argv- char *argv[]

MAIN(argc,argv) This routine contains the Read-Solve-Print loop.

Definition at line 34 of file life.c.

References arg_c, arg_v, assert, assert_clause(), assert_first, assert_ok, begin_terminal_io(), DEFRULES, encode_types(), end_terminal_io(), env, eof, Errorline(), exit_if_true(), exit_life(), FACT, FALSE, file_date, GetBoolOption(), goal_count, heap_copy_string(), ignore_eff, infoline(), init_built_in_types(), init_copy(), init_interrupt(), init_io(), init_memory(), init_modules(), init_print(), init_system(), init_trace(), input_state, life_start, load, main_prove(), mem_base, noisy, NULL, open_input_file(), other_base, parse(), prove, push_goal(), put_back_char(), QUERY, quietflag, rand_array, read_char(), reset_step(), set_current_module(), stack_copy_psi_term(), stack_pointer, start_chrono(), stdin_cleareof(), title(), TRUE, wl_psi_term::type, undo(), undo_stack, user_module, var_occurred, what_next, and x_setup_builtins().

35 {
36  ptr_psi_term s;
37  ptr_stack save_undo_stack;
38  long sort,exitflag;
39  long c; /* 21.12 (prev. char) */
40 
41  int i;
42 #ifdef SOLARIS
43  for(i=0;i<256;i++)
44  rand_array[i]=rand_r(&lifeseed);
45 #else
46  for(i=0;i<256;i++)
47  rand_array[i]=random();
48 #endif
49 
50 
51  arg_c=argc;
52  if (argc < 10)
53  {
54  for (i = 0; i < argc;i++)
55  {
56  arg_v[i]=argv[i];
57  }
58  }
59  else
60  Errorline("Too many command line arguments\n");
61 
62  // arg_v=argv;
63  quietflag = GetBoolOption("q");
64  init_io();
65  init_memory();
67  assert(stack_pointer==mem_base); /* 8.10 */
68  init_copy();
69  assert(stack_pointer==mem_base); /* 8.10 */
70  init_print();
71  assert(stack_pointer==mem_base); /* 8.10 */
72 
73  /* Timekeeping initialization */
74  tzset();
75  (void)times(&life_start);
76  assert(stack_pointer==mem_base); /* 8.10 */
77 
78  init_modules(); /* RM: Jan 8 1993 */
79 
81  assert(stack_pointer==mem_base); /* 8.10 */
82 #ifdef X11
84  assert(stack_pointer==mem_base); /* 8.10 */
85 #endif
87 
88  assert(stack_pointer==mem_base); /* 8.10 */
89  title();
90  assert(stack_pointer==mem_base); /* 8.10 */
91  init_trace();
92  noisy=FALSE;
93 
94  assert(stack_pointer==mem_base); /* 8.10 */
95 
96 
97  (void)set_current_module(user_module); /* RM: Jan 27 1993 */
98 
99  /* Read in the .set_up file */
100  init_system();
101 
102 #ifdef ARITY /* RM: Mar 29 1993 */
103  arity_init();
104 #endif
105 
106 
107  (void)open_input_file("+SETUP+");
109  file_date+=2;
110  main_prove();
111 
112 
113  /* Main loop of interpreter */
114  do {
115  (void)setjmp(env);
116  /* printf("%ld\n",(long)(stack_pointer-mem_base)); */ /* 8.10 */
117  init_system();
118  init_trace();
119 
122  save_undo_stack=undo_stack;
123  stdin_cleareof();
124  c=read_char();
125  /* Wait until an EOF or a good character */
126  while (c!=EOF && !(c>32 && c!='.' && c!=';')) c=read_char();
127  if (c==EOF)
128  exitflag=TRUE;
129  else {
130  put_back_char(c);
131  s=stack_copy_psi_term(parse(&sort));
132  exitflag=(s->type==eof);
133  }
134  end_terminal_io();
135 
136  if (!exitflag) {
137  if (sort==QUERY) {
138 
139  // clear_already_loaded(symbol_table); RM: Feb 3 1993
140 
142 
144  goal_count=0;
146  reset_step();
147  start_chrono();
148  main_prove();
149  /* assert(goal_stack==NULL); */
150  /* assert(choice_stack==NULL); */
151  if (undo_stack) {
152  undo(NULL);
153  Errorline("non-NULL undo stack.\n");
154  }
155  /* assert(undo_stack==NULL); */
156  }
157  else if (sort==FACT) {
159  assert_clause(s);
160  undo(save_undo_stack); /* 17.8 */
161  var_occurred=FALSE; /* 18.8 */
162  encode_types();
163 
164  infoline(assert_ok?"\n*** Yes\n":"\n*** No\n"); /* 21.1 */
165  }
166  }
167  } while (!exitflag);
168 
169  /* hash_display(x_module->symbol_table); */
170 
171  exit_life(TRUE);
172  return 0;
173 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
void init_trace()
init_trace
Definition: error.c:651
void undo(ptr_stack limit)
undo
Definition: login.c:691
long assert_first
Definition: def_glob.h:1032
void put_back_char(long c)
put_back_char
Definition: token.c:729
void exit_life(long nl_flag)
exit_life
Definition: built_ins.c:2219
void exit_if_true(long exitflag)
exit_if_true
Definition: lib.c:55
ptr_module user_module
Default module for user input.
Definition: def_glob.h:694
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
psi_term parse(long *q)
parse
Definition: parser.c:907
void init_system()
init_system
Definition: lib.c:83
void reset_step()
reset_step
Definition: error.c:665
long file_date
Definition: def_glob.h:1034
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define FACT
Fact Kind of user input.
Definition: def_const.h:338
long quietflag
Definition: def_glob.h:912
#define NULL
Definition: def_const.h:533
ptr_psi_term input_state
Definition: def_glob.h:856
long ignore_eff
Definition: def_glob.h:677
#define QUERY
Query Kind of user input.
Definition: def_const.h:345
long noisy
Definition: def_glob.h:1011
long assert_ok
Definition: def_glob.h:1033
void init_io()
void init_io
Definition: lib.c:69
struct tms life_start
time life started - seconds
Definition: def_glob.h:83
ptr_stack undo_stack
Definition: def_glob.h:1027
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
void end_terminal_io()
end_terminal_io
Definition: token.c:516
long goal_count
Definition: def_glob.h:678
void infoline(char *format,...)
infoline
Definition: error.c:281
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
void begin_terminal_io()
begin_terminal_io
Definition: token.c:493
int arg_c
set from argc in either life.c or lib.c
Definition: def_glob.h:20
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
#define what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1079
GENERIC other_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:98
void start_chrono()
start_chrono
Definition: login.c:349
#define FALSE
Standard boolean.
Definition: def_const.h:275
void init_print()
init_print
Definition: print.c:52
void init_memory()
init_memory ()
Definition: memory.c:1671
char * arg_v[ARGNN]
set from argv in either life.c or lib.c
Definition: def_glob.h:27
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
#define load
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1156
long rand_array[256]
Definition: def_glob.h:920
void encode_types()
encode_types
Definition: types.c:1091
jmp_buf env
Definition: def_glob.h:877
void main_prove()
main_prove
Definition: login.c:2333
void x_setup_builtins()
x_setup_builtins
Definition: xpred.c:3374
void init_built_in_types()
init_built_in_types
Definition: built_ins.c:6155
long read_char()
read_char
Definition: token.c:680
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
void init_modules()
init_modules
Definition: modules.c:34
ptr_definition type
Definition: def_struct.h:181
void stdin_cleareof()
stdin_cleareof
Definition: token.c:51
void title()
TITLE.
Definition: info.c:39
void init_copy()
init_copy
Definition: copy.c:32
long var_occurred
???
Definition: def_glob.h:839
long open_input_file(char *file)
open_input_file
Definition: token.c:594
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
void assert_clause(ptr_psi_term t)
assert_clause
Definition: login.c:287
void init_interrupt()
INIT_INTERRUPT.
Definition: interrupt.c:36
int GetBoolOption(char *name)
GetBoolOption.
Definition: memory.c:64
#define assert(N)
Definition: memory.c:114
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 main_prove ( )

main_prove

MAIN_PROVE() This is the inference engine. It distributes sub-goals to the appropriate routines. It deals with backtracking. It fails if there is not enough memory available or if there is an interrupt that causes the current query to be aborted.

Definition at line 2333 of file login.c.

References wl_goal::aaaa_1, aim, backtrack(), wl_goal::bbbb_1, c_what_next, wl_goal::cccc_1, choice_stack, clause, clause_aim(), clean_trail(), curried, cut_to, del_clause, disj, disjunct_aim(), do_currying(), do_residuation_user(), Errorline(), eval, eval_aim(), eval_cut, fail, FALSE, freeze_cut, function_it, GC_THRESHOLD, general_cut, goal_count, goal_stack, handle_interrupt(), heap_pointer, i_check_out(), implies_cut, infoline(), interrupted, load, load_aim(), main_loop_ok, match, match_aim(), memory_check(), wl_goal::next, NULL, prove, prove_aim(), release_resid(), resid_aim, resid_vars, restore_resid(), retract, show_count(), stack_pointer, stepcount, stepflag, steptrace, traceline(), TRUE, wl_goal::type, type_disj, type_disj_aim(), undo(), unify, unify_aim(), unify_aim_noeval(), unify_noeval, warningline(), what_next, what_next_aim(), x_exist_event(), xcount, xevent_existing, XEVENTDELAY, and xeventdelay.

2334 {
2335  long success=TRUE;
2336  ptr_pair_list *p;
2337  ptr_psi_term unused_match_date; /* 13.6 */
2338 
2339  xcount=0;
2343 
2344  while (main_loop_ok && goal_stack) {
2345 
2346  /* RM: Oct 28 1993 For debugging a horrible mess.
2347  {
2348  ptr_choice_point c=choice_stack;
2349  while(c) {
2350  if((ptr_psi_term)stack_pointer<(ptr_psi_term)c) {
2351  printf("########### Choice stack corrupted! %x\n",c);
2352  trace=TRUE;
2353  c=NULL;
2354  }
2355  else
2356  c=c->next;
2357  }
2358  }
2359  */
2360 
2361 
2362  aim=goal_stack;
2363  switch(aim->type) {
2364 
2365  case unify:
2366  goal_stack=aim->next;
2367  goal_count++;
2368  success=unify_aim();
2369  break;
2370 
2371  /* Same as above, but do not evaluate top level */
2372  /* Used to bind with unbound variables */
2373  case unify_noeval:
2374  goal_stack=aim->next;
2375  goal_count++;
2376  success=unify_aim_noeval();
2377  break;
2378 
2379  case prove:
2380  success=prove_aim();
2381  break;
2382 
2383  case eval:
2384  goal_stack=aim->next;
2385  goal_count++;
2386  success=eval_aim();
2387  break;
2388 
2389  case load:
2390  goal_stack=aim->next;
2391  goal_count++;
2392  success=load_aim();
2393  break;
2394 
2395  case match:
2396  goal_stack=aim->next;
2397  goal_count++;
2398  success=match_aim();
2399  break;
2400 
2401  case disj:
2402  goal_stack=aim->next;
2403  goal_count++;
2404  success=disjunct_aim();
2405  break;
2406 
2407  case general_cut:
2408  goal_stack=aim->next;
2409  goal_count++;
2410  /* assert((ptr_choice_point)aim->aaaa_1 <= choice_stack); 12.7 */
2411  /* choice_stack=(ptr_choice_point)aim->aaaa_1; */
2412  cut_to(aim->aaaa_1); /* 12.7 */
2413 #ifdef CLEAN_TRAIL
2415 #endif
2416 #ifdef TS
2417  /* RESTORE_TIME_STAMP; */ /* 9.6 */
2418 #endif
2419  break;
2420 
2421  case eval_cut:
2422  /* RESID */ restore_resid((ptr_resid_block)aim->cccc_1, &unused_match_date);
2423  if (curried)
2424  do_currying();
2425  else if (resid_vars) {
2426  success=do_residuation_user(); /* 21.9 */ /* PVR 9.2.94 */
2427  } else {
2428  if (resid_aim)
2429  traceline("result of %P is %P\n", resid_aim->aaaa_1, aim->aaaa_1);
2430  goal_stack=aim->next;
2431  goal_count++;
2432  /* resid_aim=NULL; 21.9 */
2433  /* PVR 5.11 choice_stack=(ptr_choice_point)aim->bbbb_1; */
2434  (void)i_check_out(aim->aaaa_1);
2435  }
2436  resid_aim=NULL; /* 21.9 */
2437  resid_vars=NULL; /* 22.9 */
2438  /* assert((ptr_choice_point)aim->bbbb_1<=choice_stack); 12.7 */
2439  /* PVR 5.11 */ /* choice_stack=(ptr_choice_point)aim->bbbb_1; */
2440  if (success) { /* 21.9 */
2441  cut_to(aim->bbbb_1); /* 12.7 */
2442 #ifdef CLEAN_TRAIL
2444 #endif
2445  /* match_date=NULL; */ /* 13.6 */
2446 #ifdef TS
2447  /* RESTORE_TIME_STAMP; */ /* 9.6 */
2448 #endif
2449  }
2450  break;
2451 
2452  case freeze_cut:
2453  /* RESID */ restore_resid((ptr_resid_block)aim->cccc_1, &unused_match_date);
2454  if (curried) {
2455  warningline("frozen goal has a missing parameter '%P' and fails.\n",aim->aaaa_1);
2456  success=FALSE;
2457  }
2458  else if (resid_vars) {
2459  success=do_residuation_user(); /* 21.9 */ /* PVR 9.2.94 */
2460  } else {
2461  if (resid_aim) traceline("releasing frozen goal: %P\n", aim->aaaa_1);
2462  /* resid_aim=NULL; 21.9 */
2463  /* PVR 5.12 choice_stack=(ptr_choice_point)aim->bbbb_1; */
2464  goal_stack=aim->next;
2465  goal_count++;
2466  }
2467  resid_aim=NULL; /* 21.9 */
2468  resid_vars=NULL; /* 22.9 */
2469  if (success) { /* 21.9 */
2470  /* assert((ptr_choice_point)aim->bbbb_1<=choice_stack); 12.7 */
2471  /* PVR 5.12 */ /* choice_stack=(ptr_choice_point)aim->bbbb_1; */
2472  cut_to(aim->bbbb_1); /* 12.7 */
2473 #ifdef CLEAN_TRAIL
2475 #endif
2476  /* match_date=NULL; */ /* 13.6 */
2477 #ifdef TS
2478  /* RESTORE_TIME_STAMP; */ /* 9.6 */
2479 #endif
2480  }
2481  break;
2482 
2483  case implies_cut: /* 12.10 */
2484  /* This 'cut' is actually more like a no-op! */
2485  restore_resid((ptr_resid_block)aim->cccc_1, &unused_match_date);
2486  if (curried) {
2487  warningline("implied goal has a missing parameter '%P' and fails.\n",aim->aaaa_1);
2488  success=FALSE;
2489  }
2490  else if (resid_vars)
2491  success=FALSE;
2492  else {
2493  if (resid_aim) traceline("executing implied goal: %P\n", aim->aaaa_1);
2494  goal_stack=aim->next;
2495  goal_count++;
2496  }
2497  resid_aim=NULL; /* 21.9 */
2498  resid_vars=NULL; /* 22.9 */
2499  break;
2500 
2501  case fail:
2502  goal_stack=aim->next;
2503  success=FALSE;
2504  break;
2505 
2506  case what_next:
2507  goal_stack=aim->next;
2508  success=what_next_aim();
2509  break;
2510 
2511  case type_disj:
2512  goal_stack=aim->next;
2513  goal_count++;
2514  type_disj_aim();
2515  break;
2516 
2517  case clause:
2518  goal_stack=aim->next;
2519  goal_count++;
2520  success=clause_aim(0);
2521  break;
2522 
2523  case del_clause:
2524  goal_stack=aim->next;
2525  goal_count++;
2526  success=clause_aim(1);
2527  break;
2528 
2529  case retract:
2530  goal_stack=aim->next;
2531  goal_count++;
2532  p=(ptr_pair_list*)aim->aaaa_1;
2533  traceline("deleting clause (%P%s%P)\n",
2534  (*p)->aaaa_2,((*p)->aaaa_2->type->type_def==(def_type)function_it?"->":":-"),(*p)->bbbb_2);
2535  (*p)->aaaa_2=NULL;
2536  (*p)->bbbb_2=NULL;
2537  (*p)=(*p)->next; /* Remove retracted element from pairlist */
2538  break;
2539 
2540  case c_what_next: /* RM: Mar 31 1993 */
2541  main_loop_ok=FALSE; /* Exit the main loop */
2542  break;
2543 
2544  default:
2545  Errorline("bad goal on stack %d.\n",goal_stack->type);
2546  goal_stack=aim->next;
2547  }
2548 
2549  if (main_loop_ok) {
2550 
2551  if (success) {
2552 
2553 #ifdef X11
2554  /* Polling on external events */
2555  if (xcount<=0 && aim->type==prove) {
2556  if (x_exist_event()) {
2557  /* printf("At event, xeventdelay = %ld.\n",xeventdelay); */
2558  xeventdelay=0;
2560  } else {
2562  /* If XEVENTDELAY=1000 it takes 90000 goals to get back */
2563  /* from 100 at the pace of 1%. */
2564  xeventdelay=(xeventdelay*101)/100+2;
2565  else
2567  }
2569  }
2570  else
2571  xcount--;
2572 #endif
2573 
2574  }
2575  else {
2576  if (choice_stack) {
2577  backtrack();
2578  traceline("backtracking\n");
2579  success=TRUE;
2580  }
2581  else /* if (goal_stack) */ {
2582  undo(NULL); /* 8.10 */
2583  infoline("\n*** No");
2584  /* printf("\n*** No (in main_prove)."); */
2585  show_count();
2586 #ifdef TS
2587  /* global_time_stamp=INIT_TIME_STAMP; */ /* 9.6 */
2588 #endif
2590  }
2591  }
2592 
2594  (void)memory_check();
2595 
2596  if (interrupted || (stepflag && steptrace))
2597  handle_interrupt();
2598  else if (stepcount>0) {
2599  stepcount--;
2600  if (stepcount==0 && !stepflag) {
2601  stepflag=TRUE;
2602  handle_interrupt();
2603  }
2604  }
2605  }
2606  }
2607 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
long x_exist_event()
x_exist_event
Definition: xpred.c:3787
ptr_psi_term aaaa_1
Definition: def_struct.h:239
long load_aim()
load_aim
Definition: login.c:2232
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
long main_loop_ok
Definition: def_glob.h:1023
long do_residuation_user()
do_residuation_user()
Definition: lefun.c:324
void restore_resid(ptr_resid_block rb, ptr_psi_term *match_date)
restore_resid
Definition: lefun.c:1417
void show_count()
show_count
Definition: login.c:1161
ptr_goal goal_stack
Definition: def_glob.h:1025
void undo(ptr_stack limit)
undo
Definition: login.c:691
long unify_aim()
unify_aim
Definition: login.c:1344
GENERIC cccc_1
Definition: def_struct.h:241
#define general_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1114
#define implies_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1107
#define XEVENTDELAY
Maximum number of goals executed between event polling.
Definition: def_const.h:240
#define NULL
Definition: def_const.h:533
long steptrace
Definition: def_glob.h:915
void type_disj_aim()
type_disj_aim
Definition: login.c:1845
ptr_goal resid_aim
Definition: def_glob.h:865
#define c_what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1163
ptr_resid_list resid_vars
Definition: def_glob.h:866
#define eval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1086
void release_resid(ptr_psi_term t)
release_resid
Definition: lefun.c:445
void traceline(char *format,...)
traceline
Definition: error.c:186
long stepcount
Definition: def_glob.h:916
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
long clause_aim(long r)
clause_aim
Definition: login.c:1879
long goal_count
Definition: def_glob.h:678
void infoline(char *format,...)
infoline
Definition: error.c:281
goals type
Definition: def_struct.h:238
void do_currying()
do_currying
Definition: lefun.c:383
#define freeze_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1100
#define TRUE
Standard boolean.
Definition: def_const.h:268
static void clean_trail(ptr_choice_point cutpt)
clean_trail
Definition: login.c:810
#define what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1079
#define match
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1121
#define FALSE
Standard boolean.
Definition: def_const.h:275
long unify_aim_noeval()
unify_aim_noeval
Definition: login.c:1354
#define clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1135
long stepflag
Definition: def_glob.h:676
#define cut_to(C)
Definition: def_macro.h:85
#define fail
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1044
ptr_goal aim
Definition: def_glob.h:1024
#define retract
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1149
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long xeventdelay
Definition: def_glob.h:941
long eval_aim()
eval_aim
Definition: lefun.c:497
#define load
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1156
long prove_aim()
prove_aim
Definition: login.c:1645
#define unify_noeval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1065
long curried
Definition: def_glob.h:868
#define del_clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1142
#define eval_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1093
long disjunct_aim()
disjunct_aim
Definition: login.c:1621
void handle_interrupt()
HANDLE_INTERRUPT.
Definition: interrupt.c:52
void backtrack()
backtrack
Definition: login.c:772
#define GC_THRESHOLD
Garbage collection threshold (1/8 of MEM_SIZE is reasonable).
Definition: def_const.h:117
#define disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1072
#define type_disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1128
long interrupted
used in handling user using ctrl-c
Definition: def_glob.h:672
void warningline(char *format,...)
warningline
Definition: error.c:371
long memory_check()
memory_check
Definition: memory.c:1723
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_psi_term xevent_existing
Definition: def_glob.h:1037
long xcount
Definition: def_glob.h:942
long match_aim()
match_aim
Definition: lefun.c:770
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
ptr_choice_point choice_stack
Definition: def_glob.h:1026
long what_next_aim()
what_next_aim
Definition: login.c:2068
ptr_goal next
Definition: def_struct.h:242
ptr_psi_term make_feature_list ( ptr_node  tree,
ptr_psi_term  tail,
ptr_module  module,
int  val 
)

make_feature_list

Parameters
tree- ptr_node tree
tail- ptr_psi_term tail
module- ptr_module module
val- int val

Definition at line 175 of file built_ins.c.

References wl_node::data, heap_alloc(), integer, wl_node::key, wl_node::left, make_feature_list(), REAL, real, wl_node::right, stack_cons(), stack_psi_term(), str_to_int(), and update_feature().

176 {
177  ptr_psi_term new;
178  ptr_definition def;
179  double d; // strtod();
180 
181 
182  if(tree) {
183  if(tree->right)
184  tail=make_feature_list(tree->right,tail,module,val);
185 
186  /* Insert the feature name into the list */
187 
188  d=str_to_int(tree->key);
189  if (d== -1) { /* Feature is not a number */
190  def=update_feature(module,tree->key); /* Extract module RM: Feb 3 1993 */
191  if(def) {
192  if(val) /* RM: Mar 3 1994 Distinguish between features & values */
193  tail=stack_cons((ptr_psi_term)tree->data,(ptr_psi_term)tail);
194  else {
195  new=stack_psi_term(4);
196  new->type=def;
197  tail=stack_cons((ptr_psi_term)new,(ptr_psi_term)tail);
198  }
199  }
200  }
201  else { /* Feature is a number */
202  if(val) /* RM: Mar 3 1994 Distinguish between features & values */
203  tail=stack_cons((ptr_psi_term)tree->data,(ptr_psi_term)tail);
204  else {
205  new=stack_psi_term(4);
206  new->type=(d==floor(d))?integer:real;
207  new->value_3=heap_alloc(sizeof(REAL));
208  *(REAL *)new->value_3=(REAL)d;
209  tail=stack_cons((ptr_psi_term)new,(ptr_psi_term)tail);
210  }
211  }
212 
213  if(tree->left)
214  tail=make_feature_list(tree->left,tail,module,val);
215  }
216 
217  return tail;
218 }
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
GENERIC data
Definition: def_struct.h:201
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_node left
Definition: def_struct.h:199
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
char * key
Definition: def_struct.h:198
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
long str_to_int(char *s)
str_to_int
Definition: print.c:118
ptr_psi_term make_feature_list(ptr_node tree, ptr_psi_term tail, ptr_module module, int val)
make_feature_list
Definition: built_ins.c:175
ptr_definition update_feature(ptr_module module, char *feature)
update_feature
Definition: modules.c:1331
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
ptr_node right
Definition: def_struct.h:200
int make_feature_private ( ptr_psi_term  term)

make_feature_private

Parameters
term- ptr_psi_term term

MAKE_FEATURE_PRIVATE(feature) Make a feature private.

Definition at line 1256 of file modules.c.

References wl_keyword::combined_name, wl_keyword::definition, deref_ptr, hash_lookup(), wl_definition::keyword, wl_keyword::private_feature, wl_keyword::public, wl_keyword::symbol, wl_module::symbol_table, TRUE, wl_psi_term::type, update_symbol(), and warningline().

1257 {
1258  int ok=TRUE;
1259  ptr_keyword key;
1260  ptr_definition def;
1261 
1262  deref_ptr(term);
1263 
1265 
1266  if(key) {
1267  /*
1268  if(key->definition->keyword->module!=current_module) {
1269  warningline("local definition of '%s' overrides '%s'\n",
1270  key->definition->keyword->symbol,
1271  key->definition->keyword->combined_name);
1272 
1273  new_definition(key);
1274  }
1275  */
1276 
1277  key->private_feature=TRUE;
1278  def=key->definition;
1279  }
1280  else {
1283  }
1284 
1285 
1286  if(ok && def->keyword->public) {
1287  warningline("feature '%s' is now private, but was also declared public\n",
1288  def->keyword->combined_name);
1289  }
1290 
1291  return ok;
1292 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
char * combined_name
Definition: def_struct.h:119
ptr_definition definition
Definition: def_struct.h:122
ptr_hash_table symbol_table
Definition: def_struct.h:110
ptr_keyword keyword
Definition: def_struct.h:147
ptr_module current_module
Definition: modules.c:15
char * symbol
Definition: def_struct.h:118
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
int private_feature
Definition: def_struct.h:121
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
psi_term make_life_form ( ptr_psi_term  tok,
ptr_psi_term  arg1,
ptr_psi_term  arg2 
)

make_life_form

Parameters
tok- ptr_psi_term tok
arg1- ptr_psi_term arg1
arg2- ptr_psi_term arg2

MAKE_LIFE_FORM(tok,arg1,arg2) This routine inserts ARG1 and ARG2 as the first and second attributes of psi_term TOK, thus creating the term TOK(1=>arg1,2=>arg2).

If TOK is ':' then a conjunction is created if necessary. Example: a:V:b:5:long => V: <a,b,5,int> (= conjunction list).

Definition at line 571 of file parser.c.

References wl_psi_term::attr_list, wl_psi_term::coref, deref_ptr, equ_tokch, error_psi_term, FEATCMP, heap_alloc(), integer, minus_symbol, NULL, one, push_psi_ptr_value(), REAL, real, wl_psi_term::resid, stack_copy_psi_term(), stack_insert(), Syntaxerrorline(), top, two, wl_psi_term::type, and wl_psi_term::value_3.

572 {
573  ptr_psi_term a1,a2;
574 
575  deref_ptr(tok);
576  tok->attr_list=NULL;
577  tok->resid=NULL;
578 
579  /* Here beginneth a terrible FIX,
580  I will have to rewrite the tokeniser and the parser to handle
581  POINTERS to psi-terms instead of PSI_TERMS !!!
582  */
583 
584  a1=arg1;
585  a2=arg2;
586 
587  if (a1)
588  deref_ptr(a1);
589  if (a2)
590  deref_ptr(a2);
591 
592  /* End of extremely ugly fix. */
593 
594  if (/* UNI FALSE */ equ_tokch((*tok),':') && arg1 && arg2) {
595 
596  if (a1!=a2) {
597  if (a1->type==top &&
598  !a1->attr_list &&
599  !a1->resid) {
600  if (a1!=arg1)
601  /* push_ptr_value(psi_term_ptr,&(a1->coref)); 9.6 */
602  push_psi_ptr_value(a1,(GENERIC *)&(a1->coref));
603  a1->coref=stack_copy_psi_term(*arg2);
604  tok=arg1;
605  }
606  else
607  if(a2->type==top &&
608  !a2->attr_list &&
609  !a2->resid) {
610  if(a2!=arg2)
611  /* push_ptr_value(psi_term_ptr,&(a2->coref)); 9.6 */
612  push_psi_ptr_value(a2,(GENERIC *)&(a2->coref));
613  a2->coref=stack_copy_psi_term(*arg1);
614  tok=arg2;
615  }
616  else { /* RM: Feb 22 1993 Now reports an error */
617  Syntaxerrorline("':' occurs where '&' required (%E)\n");
618  *tok= *error_psi_term;
619  /* make_unify_pair(tok,arg1,arg2); Old code */
620  }
621  }
622  else
623  tok=arg1;
624  }
625  else {
626 
627  /* RM: Jun 21 1993 */
628  /* And now for another nasty hack: reading negative numbers */
629  if(tok->type==minus_symbol &&
630  a1 &&
631  !a2 &&
632  a1->value_3 &&
633  (a1->type==integer || a1->type==real)) {
634 
635  tok->type=a1->type;
636  tok->value_3=(GENERIC)heap_alloc(sizeof(REAL));
637  *(REAL *)tok->value_3 = - *(REAL *)a1->value_3;
638 
639  return *tok;
640  }
641  /* End of other nasty hack */
642 
644  if (arg2)
646  }
647 
648  return *tok;
649 }
ptr_residuation resid
Definition: def_struct.h:189
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
char * two
Definition: def_glob.h:892
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
#define deref_ptr(P)
Definition: def_macro.h:100
void Syntaxerrorline(char *format,...)
Syntaxerrorline.
Definition: error.c:557
ptr_definition minus_symbol
symbol in syntax module
Definition: def_glob.h:333
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
ptr_psi_term coref
Definition: def_struct.h:188
char * one
Definition: def_glob.h:891
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
#define equ_tokch(A, B)
Definition: def_macro.h:71
char * make_module_token ( ptr_module  module,
char *  str 
)

make_module_token

Parameters
module- ptr_module module
str- char *str

MAKE_MODULE_TOKEN(module,string) Write 'module::string' in module_buffer. If string is a qualified reference to a given module, then modify the calling module variable to reflect this.

The result must be immediately stored in a newly allocated string.

Definition at line 191 of file modules.c.

References extract_module_from_name(), module_buffer, and wl_module::module_name.

192 {
193  ptr_module explicit;
194 
195 
196  /* Check if the string already contains a module */
197  explicit=extract_module_from_name(str);
198  if(explicit)
199  strcpy(module_buffer,str);
200  else
201  if(module!=no_module) {
202  strcpy(module_buffer,module->module_name);
203  strcat(module_buffer,"#");
204  strcat(module_buffer,str);
205  }
206  else
207  strcpy(module_buffer,str);
208 
209  return module_buffer;
210 }
string module_buffer
Definition: def_glob.h:953
char * module_name
Definition: def_struct.h:106
ptr_module no_module
Definition: modules.c:16
ptr_module extract_module_from_name(char *str)
extract_module_from_name
Definition: modules.c:116
long make_public ( ptr_psi_term  term,
long  bool 
)

make_public

Parameters
term- ptr_psi_term term
bool- long bool

MAKE_PUBLIC(term,bool) Make a term public.

Definition at line 613 of file modules.c.

References wl_keyword::combined_name, wl_keyword::definition, deref_ptr, hash_lookup(), wl_definition::keyword, wl_keyword::module, new_definition(), wl_keyword::public, wl_keyword::symbol, wl_module::symbol_table, TRUE, wl_psi_term::type, update_symbol(), and warningline().

614 {
615  int ok=TRUE;
616  ptr_keyword key;
617  ptr_definition def;
618 
619  deref_ptr(term);
620 
622  if(key) {
623 
624  if(key->definition->keyword->module!=current_module && !bool) {
625  warningline("local definition of '%s' overrides '%s'\n",
626  key->definition->keyword->symbol,
628 
629  (void)new_definition(key);
630  }
631 
632  key->public=bool;
633  }
634  else {
636  def->keyword->public=bool;
637  }
638 
639  return ok;
640 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
char * combined_name
Definition: def_struct.h:119
ptr_definition new_definition(ptr_keyword key)
new_definition
Definition: modules.c:220
ptr_definition definition
Definition: def_struct.h:122
ptr_hash_table symbol_table
Definition: def_struct.h:110
ptr_keyword keyword
Definition: def_struct.h:147
ptr_module current_module
Definition: modules.c:15
char * symbol
Definition: def_struct.h:118
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_module module
Definition: def_struct.h:117
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
void make_sys_type_links ( )

make_sys_type_links

INITIALIZATION FUNCTIONS

Definition at line 2168 of file sys.c.

References built_in, make_type_link(), sys_bitvector, sys_bytedata, sys_file_stream, sys_regexp, sys_socket_stream, and sys_stream.

2169 {
2170 #ifdef LIFE_NDBM
2171  make_ndbm_type_links();
2172 #endif
2178  make_type_link(sys_bytedata ,built_in); /* DENYS: BYTEDATA */
2179 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
ptr_definition sys_regexp
symbol in sys module
Definition: def_glob.h:578
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
ptr_definition built_in
symbol in bi module
Definition: def_glob.h:199
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
void make_type_link(ptr_definition t1, ptr_definition t2)
make_type_link
Definition: types.c:901
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
void make_type_link ( ptr_definition  t1,
ptr_definition  t2 
)

make_type_link

Parameters
t1- ptr_definition t1
t2- ptr_definition t2

MAKE_TYPE_LINK(t1,t2) Assert that T1 <| T2, this is used to initialise the built_in type relations so that nothing really horrible happens if the user modifies built-in types such as INT or LIST. This routine also makes sure that top has no links.

Definition at line 901 of file types.c.

References wl_definition::children, cons(), wl_definition::parents, top, and type_member().

902 {
903  if (t2!=top && !type_member(t2,t1->parents))
904  t1->parents=cons((GENERIC)t2,t1->parents);
905  if (t2!=top && !type_member(t1,t2->children))
906  t2->children=cons((GENERIC)t1,t2->children);
907 }
ptr_int_list cons(GENERIC v, ptr_int_list l)
cons
Definition: types.c:179
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_int_list children
Definition: def_struct.h:152
long type_member(ptr_definition t, ptr_int_list tlst)
type_member
Definition: types.c:918
ptr_int_list parents
Definition: def_struct.h:151
ptr_goal makeGoal ( ptr_psi_term  p)

makeGoal

Parameters
p- ptr_psi_term p

Definition at line 646 of file bi_sys.c.

References DEFRULES, goal_stack, wl_goal::next, NULL, prove, and push_goal().

647 {
648  ptr_goal old = goal_stack;
649  ptr_goal g;
650 
652  g = goal_stack;
653  g->next=NULL;
654  goal_stack = old;
655  return g;
656 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_goal goal_stack
Definition: def_glob.h:1025
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_goal next
Definition: def_struct.h:242
ptr_psi_term makePsiList ( GENERIC  head,
ptr_psi_term(*)()  valueFunc,
GENERIC(*)()  nextFunc 
)

makePsiList

Parameters
head- GENERIC head
*valueFunc- ptr_psi_term (*valueFunc)()
nextFunc- GENERIC (*nextFunc)()

Definition at line 590 of file bi_sys.c.

References stack_cons(), and stack_nil().

591 {
592  ptr_psi_term result;
593 
594 
595  /* RM: Dec 14 1992: Added the new list representation */
596  result=stack_nil();
597 
598  while (head) {
599  result=stack_cons((*valueFunc)(head),result);
600  head=(*nextFunc)(head);
601  }
602  return result;
603 }
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
stack_cons
Definition: built_ins.c:46
ptr_psi_term stack_nil()
stack_nil
Definition: built_ins.c:26
ptr_psi_term makePsiTerm ( ptr_definition  x)

ptr_psi_term makePsiTerm

Parameters
x- ptr_definition x

Definition at line 573 of file bi_sys.c.

References stack_psi_term(), and wl_psi_term::type.

574 {
575  ptr_psi_term p;
576 
577  p = stack_psi_term(4);
578  p->type = x;
579  return p;
580 }
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_definition type
Definition: def_struct.h:181
void mark_ancestors ( ptr_definition  def,
long *  flags 
)

mark_ancestors

Parameters
def- ptr_definition def
flags- long *flags

Set flags bit for all ancestors (i.e., higher up) of head

Definition at line 60 of file lub.c.

References bit_length(), wl_definition::code, wl_int_list::next, wl_definition::parents, and wl_int_list::value_1.

61 {
62  ptr_int_list par;
63 
64  par=def->parents;
65  while (par) {
67  long len;
68 
69  p=(ptr_definition)par->value_1;
70  len=bit_length(p->code);
71  if (!flags[len]) {
72  flags[len]=1;
73  mark_ancestors(p, flags);
74  }
75  par=par->next;
76  }
77 }
long bit_length(ptr_int_list c)
bit_length
Definition: types.c:1753
void mark_ancestors(ptr_definition def, long *flags)
mark_ancestors
Definition: lub.c:60
struct wl_definition * ptr_definition
Definition: def_struct.h:59
ptr_int_list code
Definition: def_struct.h:150
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
ptr_int_list parents
Definition: def_struct.h:151
void mark_eval ( ptr_psi_term  t)

mark_eval

Parameters
t- ptr_psi_term t

A (possibly) correct mark_eval and its companion mark_quote.

The translation table is used to record whether a subgraph has already been quoted or not. Mark a psi-term as to be evaluated (i.e. strict), except for arguments of a nonstrict term, which are marked quoted. Set status correctly and propagate zero status upwards. Avoid doing superfluous work: non-shared terms are traversed once; shared terms are traversed at most twice (this only occurs if the first occurrence encountered is strict and a later occurrence is nonstrict). The translation table is used to indicate (1) whether a term has already been traversed, and if so, (2) whether there was a nonstrict traversal (in that case, the info field is FALSE).

Definition at line 498 of file copy.c.

References clear_copy(), FALSE, mark_eval_new(), and mark_nonstrict_flag.

499 {
500  clear_copy();
502  mark_eval_new(t);
503 }
void mark_eval_new(ptr_psi_term t)
mark_eval_new
Definition: copy.c:540
void clear_copy()
clear_copy
Definition: copy.c:53
#define FALSE
Standard boolean.
Definition: def_const.h:275
static long mark_nonstrict_flag
Definition: copy.c:479
void mark_eval_new ( ptr_psi_term  t)

mark_eval_new

Parameters
t- ptr_psi_term t

Definition at line 540 of file copy.c.

References wl_psi_term::attr_list, curr_status, deref_ptr, wl_definition::evaluate_args, FALSE, wl_psi_term::flags, function_it, global_it, insert_translation(), mark_eval_tree_new(), mark_nonstrict_flag, mark_quote_new(), mark_quote_tree_new(), wl_definition::properties, QUOTED_TRUE, wl_psi_term::status, translate(), TRUE, wl_psi_term::type, wl_definition::type_def, and type_it.

541 {
542  long *infoptr,flag;
543  ptr_psi_term u;
544  long old_status;
545 
546  if (t) {
547  deref_ptr(t);
548  flag = t->type->evaluate_args;
549  u=translate(t,&infoptr);
550  if (u) {
551  /* Quote the subgraph if it was already copied as to be evaluated. */
552  if (!flag && *infoptr) {
553  mark_quote_new(t);
554  *infoptr=FALSE;
555  }
556  /* If any subterm has zero curr_status (i.e., if t->status==0),
557  then so does the whole term: PVR 14.2.94 */
558  old_status=curr_status;
559  curr_status=(long)t->status;
560  if (curr_status) curr_status=old_status;
561  }
562  else {
564  old_status=curr_status;
565  curr_status=4;
566 
567  if (flag) /* 16.9 */
569  else
571 
572  switch((long)t->type->type_def) {
573  case type_it:
574  if (t->type->properties)
575  curr_status=0;
576  break;
577 
578  case function_it:
579  curr_status=0;
580  break;
581 
582  case global_it: /* RM: Feb 8 1993 */
583  curr_status=0;
584  break;
585 
586  default:
587  break;
588  }
589  if (mark_nonstrict_flag) { /* 25.8 */
590  if (curr_status) {
591  /* Only increase the status, never decrease it: */
592  t->status=curr_status;
593  }
594  }
595  else {
596  t->status=curr_status;
597  t->flags=curr_status?QUOTED_TRUE:FALSE; /* 14.9 */
598  }
599  /* If any subterm has zero curr_status, then so does the whole term: */
600  if (curr_status) curr_status=old_status;
601  }
602  }
603 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
translate
Definition: copy.c:108
char evaluate_args
Definition: def_struct.h:156
def_type type_def
Definition: def_struct.h:153
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
insert_translation
Definition: copy.c:67
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
void mark_eval_tree_new(ptr_node n)
mark_eval_tree_new
Definition: copy.c:611
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
void mark_quote_tree_new(ptr_node n)
mark_quote_tree_new
Definition: copy.c:653
static long curr_status
Definition: copy.c:209
#define FALSE
Standard boolean.
Definition: def_const.h:275
void mark_quote_new(ptr_psi_term t)
mark_quote_new
Definition: copy.c:626
static long mark_nonstrict_flag
Definition: copy.c:479
ptr_definition type
Definition: def_struct.h:181
ptr_triple_list properties
Definition: def_struct.h:149
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
void mark_eval_tree_new ( ptr_node  n)

mark_eval_tree_new

Parameters
n- ptr_node n

Definition at line 611 of file copy.c.

References wl_node::data, wl_node::left, mark_eval_new(), mark_eval_tree_new(), and wl_node::right.

612 {
613  if (n) {
617  }
618 }
void mark_eval_new(ptr_psi_term t)
mark_eval_new
Definition: copy.c:540
GENERIC data
Definition: def_struct.h:201
void mark_eval_tree_new(ptr_node n)
mark_eval_tree_new
Definition: copy.c:611
ptr_node left
Definition: def_struct.h:199
ptr_node right
Definition: def_struct.h:200
void mark_nonstrict ( ptr_psi_term  t)

mark_nonstrict

Parameters
t- ptr_psi_term t

Same as above, except that the status is only changed from 0 to 4 when needed; it is never changed from 4 to 0.

Definition at line 513 of file copy.c.

References clear_copy(), mark_eval_new(), mark_nonstrict_flag, and TRUE.

514 {
515  clear_copy();
517  mark_eval_new(t);
518 }
void mark_eval_new(ptr_psi_term t)
mark_eval_new
Definition: copy.c:540
void clear_copy()
clear_copy
Definition: copy.c:53
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long mark_nonstrict_flag
Definition: copy.c:479
void mark_quote ( ptr_psi_term  t)

mark_quote

Parameters
t- ptr_psi_term t

A more efficient version of mark_quote This version avoids using the translation table by setting a 'visited' in the status field. Mark a psi-term as completely evaluated.

Definition at line 674 of file copy.c.

References wl_psi_term::attr_list, wl_psi_term::coref, wl_psi_term::flags, mark_quote(), mark_quote_tree(), QUOTED_TRUE, RMASK, and wl_psi_term::status.

675 {
676  if (t && !(t->status&RMASK)) {
677  t->status = 4;
678  t->flags=QUOTED_TRUE; /* 14.9 */
679  t->status |= RMASK;
680  mark_quote(t->coref);
682  t->status &= ~RMASK;
683  }
684 }
#define RMASK
Bit mask for status field of psi-terms: RMASK is used as a flag to avoid infinite loops when tracing ...
Definition: def_const.h:359
ptr_psi_term coref
Definition: def_struct.h:188
void mark_quote(ptr_psi_term t)
mark_quote
Definition: copy.c:674
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
void mark_quote_tree()
void mark_quote_c ( ptr_psi_term  t,
long  heap_flag 
)

mark_quote_c

Parameters
t- ptr_psi_term t
heap_flag- long heap_flag

The new mark_quote to be used from copy.

Meaning of the info field in the translation table: With u=translate(t,&infoptr): If infoptr==QUOTE_FLAG then the whole subgraph from u is quoted. If infoptr==EVAL_FLAG then anything is possible. If infoptr==QUOTE_STUB then the term does not exist yet, e.g., there is a cycle in the term & copy(...) has not created it yet, for example X:s(L,t(X),R), where non_strict(t), in which R does not exist when the call to mark_quote_c is done. When the term is later created, it must be created as quoted.

Mark a psi-term u (which is a copy of t) as completely evaluated. Only t is given as the argument. Assumes the psi-term is a copy of another psi-term t, which is made through eval_copy. Therefore the copy is accessible through the translation table. Assumes all translation table entries already exist. The infoptr field is updated so that each subgraph is only traversed once. This routine is called only from the main copy routine.

Definition at line 434 of file copy.c.

References wl_psi_term::attr_list, deref_ptr, EVAL_FLAG, wl_psi_term::flags, insert_translation(), mark_quote_tree_c(), NEW, QUOTE_FLAG, QUOTE_STUB, QUOTED_TRUE, wl_psi_term::status, and translate().

435 {
436  // ptr_list l;
437  long *infoptr;
438  ptr_psi_term u;
439 
440  if (t) {
441  deref_ptr(t);
442  u=translate(t,&infoptr);
443  /* assert(u!=NULL); 15.9 */
444  if (u) {
445  if (*infoptr==EVAL_FLAG) {
446  *infoptr=QUOTE_FLAG;
447  u->status=4;
448  u->flags=QUOTED_TRUE; /* 14.9 */
449  mark_quote_tree_c(t->attr_list,heap_flag);
450  }
451  }
452  else { /* u does not exist yet */ /* 15.9 */
453  /* Create a stub & mark it as to-be-quoted. */
454  u=NEW(t,psi_term);
456  }
457  }
458 }
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
translate
Definition: copy.c:108
void mark_quote_tree_c(ptr_node n, long heap_flag)
mark_quote_tree_c
Definition: copy.c:467
#define QUOTE_STUB
flag having to do with copying in copy.c
Definition: def_const.h:1328
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
insert_translation
Definition: copy.c:67
#define NEW(A, TYPE)
Definition: def_macro.h:284
#define EVAL_FLAG
flag to copy function in copy.c to indicate kind of copy
Definition: def_const.h:1320
#define deref_ptr(P)
Definition: def_macro.h:100
#define QUOTE_FLAG
flag to copy function in copy.c to indicate kind of copy
Definition: def_const.h:1313
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
void mark_quote_new ( ptr_psi_term  t)

mark_quote_new

Parameters
t- ptr_psi_term t

Definition at line 626 of file copy.c.

References wl_psi_term::attr_list, deref_ptr, FALSE, wl_psi_term::flags, insert_translation(), mark_quote_tree_new(), QUOTED_TRUE, wl_psi_term::status, translate(), and TRUE.

627 {
628  long *infoptr;
629  ptr_psi_term u;
630 
631  if (t) {
632  deref_ptr(t);
633  u=translate(t,&infoptr);
634 
635  /* Return if the subgraph is already quoted. */
636  if (u && !*infoptr) return;
637 
638  /* Otherwise quote the subgraph */
640  else *infoptr = FALSE; /* sanjay */
641  t->status= 4;
642  t->flags=QUOTED_TRUE; /* 14.9 */
644  }
645 }
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
translate
Definition: copy.c:108
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
insert_translation
Definition: copy.c:67
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
void mark_quote_tree_new(ptr_node n)
mark_quote_tree_new
Definition: copy.c:653
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
void mark_quote_new2 ( ptr_psi_term  t)

mark_quote_new2

Parameters
t- ptr_psi_term t

Mark a term as quoted.

Definition at line 527 of file copy.c.

References clear_copy(), FALSE, mark_nonstrict_flag, and mark_quote_new().

528 {
529  clear_copy();
531  mark_quote_new(t);
532 }
void clear_copy()
clear_copy
Definition: copy.c:53
#define FALSE
Standard boolean.
Definition: def_const.h:275
void mark_quote_new(ptr_psi_term t)
mark_quote_new
Definition: copy.c:626
static long mark_nonstrict_flag
Definition: copy.c:479
void mark_quote_tree ( ptr_node  t)

mark_quote_tree

Parameters
t- ptr_node t

Definition at line 692 of file copy.c.

References wl_node::data, wl_node::left, mark_quote(), mark_quote_tree(), and wl_node::right.

693 {
694  if (t) {
695  mark_quote_tree(t->left);
696  mark_quote((ptr_psi_term) (t->data));
698  }
699 }
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
void mark_quote(ptr_psi_term t)
mark_quote
Definition: copy.c:674
void mark_quote_tree()
ptr_node right
Definition: def_struct.h:200
void mark_quote_tree_c ( ptr_node  n,
long  heap_flag 
)

mark_quote_tree_c

Parameters
n- ptr_node n
heap_flag- long heap_flag

Definition at line 467 of file copy.c.

References wl_node::data, wl_node::left, mark_quote_c(), mark_quote_tree_c(), and wl_node::right.

468 {
469  if (n) {
470  mark_quote_tree_c(n->left,heap_flag);
471  mark_quote_c((ptr_psi_term) (n->data),heap_flag);
472  mark_quote_tree_c(n->right,heap_flag);
473  }
474 }
void mark_quote_tree_c(ptr_node n, long heap_flag)
mark_quote_tree_c
Definition: copy.c:467
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
void mark_quote_c(ptr_psi_term t, long heap_flag)
mark_quote_c
Definition: copy.c:434
ptr_node right
Definition: def_struct.h:200
void mark_quote_tree_new ( ptr_node  n)

mark_quote_tree_new

void mark_quote_tree_new(ptr_node n)

Parameters
n- ptr_node n

Definition at line 653 of file copy.c.

References wl_node::data, wl_node::left, mark_quote_new(), mark_quote_tree_new(), and wl_node::right.

654 {
655  if (n) {
659  }
660 }
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
void mark_quote_tree_new(ptr_node n)
mark_quote_tree_new
Definition: copy.c:653
void mark_quote_new(ptr_psi_term t)
mark_quote_new
Definition: copy.c:626
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
long match_aim ( )

match_aim

long match_aim() MATCH_AIM() This is very similar to UNIFY_AIM, only matching cannot modify the calling psi_term. The first argument is the calling term (which may not be changed) and the second argument is the function definition (which may be changed). Residuate the expression if the calling term is more general than the function definition.

Definition at line 770 of file lefun.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, attr_missing, wl_goal::bbbb_1, can_curry, wl_goal::cccc_1, wl_psi_term::coref, curried, cut, deref_ptr, FALSE, FUNC_ARG, integer, match_attr(), matches(), NULL, overlap_type(), quoted_string, REAL, real, resid_aim, residuate_double(), restore_resid(), save_resid(), sys_bytedata, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

771 {
772  long success=TRUE;
773  ptr_psi_term u,v; // ,tmp;
774  REAL r;
775  long /* less, */ lesseq;
776  ptr_resid_block rb;
777  ptr_psi_term match_date;
778 
779  u=(ptr_psi_term )aim->aaaa_1;
780  v=(ptr_psi_term )aim->bbbb_1;
781  deref_ptr(u);
782  deref_ptr(v);
784  restore_resid(rb,&match_date);
785 
786  if (u!=v) {
787  if ((success=matches(u->type,v->type,&lesseq))) {
788  if (lesseq) {
789  if (u->type!=cut || v->type!=cut) { /* Ignore value field for cut! */
790  if (v->value_3) {
791  if (u->value_3) {
792  if (overlap_type(v->type,real))
793  success=(*((REAL *)u->value_3)==(*((REAL *)v->value_3)));
794  else if (overlap_type(v->type,quoted_string))
795  success=(strcmp((char *)u->value_3,(char *)v->value_3)==0);
796  /* DENYS: BYTEDATA */
797  else if (overlap_type(v->type,sys_bytedata)) {
798  unsigned long ulen = *((unsigned long *) u->value_3);
799  unsigned long vlen = *((unsigned long *) v->value_3);
800  success=(ulen==vlen && bcmp((char *)u->value_3,(char *)v->value_3,ulen)==0);
801  }
802  }
803  else
804  residuate_double(u,v);
805  }
806  }
807  }
808  else if (u->value_3) {
809  /* Here we have U <| V but U and V have values which cannot match. */
810  success=TRUE;
811 
812  if (v->value_3) {
813  if (overlap_type(v->type,real))
814  success=(*((REAL *)u->value_3)==(*((REAL *)v->value_3)));
815  }
816  else if (overlap_type(u->type,integer)) {
817  r= *((REAL *)u->value_3);
818  success=(r==floor(r));
819  }
820 
821  if (success) residuate_double(u,v);
822  }
823  else
824  residuate_double(u,v);
825 
826  if (success) {
827  if (FUNC_ARG(u) && FUNC_ARG(v)) { /* RM: Feb 10 1993 */
828  /* residuate2(u,v); 21.9 */
829  residuate_double(u,v); /* 21.9 */
830  residuate_double(v,u); /* 21.9 */
831  }
832  else if (FUNC_ARG(v)) { /* RM: Feb 10 1993 */
833  residuate_double(v,u); /* 21.9 */
834  }
835  else {
836  v->coref=u;
837  } /* 21.9 */
839  match_attr(&(u->attr_list),v->attr_list,rb);
840  if (attr_missing) {
841  if (can_curry)
842  curried=TRUE;
843  else
844  residuate_double(u,v);
845  }
846  /* } 21.9 */
847  }
848  }
849  }
850 
852  save_resid(rb,match_date); /* updated resid_block */
853  /* This should be a useless statement: */
854  resid_aim = NULL;
855 
856  return success;
857 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
struct wl_resid_block * ptr_resid_block
Definition: def_struct.h:259
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
static long attr_missing
Definition: lefun.c:12
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
GENERIC cccc_1
Definition: def_struct.h:241
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_goal resid_aim
Definition: def_glob.h:865
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
void residuate_double(ptr_psi_term t, ptr_psi_term u)
residuate_double
Definition: lefun.c:107
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#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
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
long can_curry
Definition: def_glob.h:869
#define FUNC_ARG(t)
Definition: def_macro.h:31
long curried
Definition: def_glob.h:868
void save_resid(ptr_resid_block rb, ptr_psi_term match_date)
save_resid
Definition: lefun.c:1398
void match_attr(ptr_node *u, ptr_node v, ptr_resid_block rb)
match_attr
Definition: lefun.c:752
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
void restore_resid(ptr_resid_block rb, ptr_psi_term *match_date)
restore_resid
Definition: lefun.c:1417
void match_attr ( ptr_node u,
ptr_node  v,
ptr_resid_block  rb 
)

match_attr

Parameters
u- ptr_node *u
v- ptr_node v
rb- ptr_resid_block rb

MATCH_ATTR(u,v) Match the attribute trees of psi_terms U and V. If V has an attribute that U doesn't then curry. U is the calling term, V is the definition. This routine is careful to push nested eval and match goals in descending order of feature names.

Definition at line 752 of file lefun.c.

References match_attr1(), match_attr2(), and match_attr3().

753 {
754  match_attr1(u,v,rb); /* Match corresponding arguments (third) */
755  match_attr2(u,v,rb); /* Evaluate lone arguments (second) */
756  match_attr3(u,v,rb); /* Evaluate corresponding arguments (first) */
757 }
void match_attr2(ptr_node *u, ptr_node v, ptr_resid_block rb)
match_attr2
Definition: lefun.c:644
void match_attr1(ptr_node *u, ptr_node v, ptr_resid_block rb)
void match_attr1
Definition: lefun.c:599
void match_attr3(ptr_node *u, ptr_node v, ptr_resid_block rb)
match_attr3
Definition: lefun.c:700
void match_attr1 ( ptr_node u,
ptr_node  v,
ptr_resid_block  rb 
)

void match_attr1

Parameters
u- ptr_node *u
v- ptr_node v
rb- ptr_resid_block rb

Match the corresponding arguments

Definition at line 599 of file lefun.c.

References attr_missing, wl_node::data, featcmp(), wl_node::key, wl_node::left, match, NULL, push_goal(), wl_node::right, and TRUE.

600 {
601  long cmp;
602  ptr_node temp;
603 
604  if (v) {
605  if (*u==NULL)
607  else {
608  cmp=featcmp((*u)->key,v->key);
609  if(cmp==0) {
610  ptr_psi_term t;
611  /* RESID */ match_attr1(&((*u)->right),v->right,rb);
612  t = (ptr_psi_term) (*u)->data;
613  /* RESID */ push_goal(match,(ptr_psi_term)(*u)->data,(ptr_psi_term)v->data,(GENERIC)rb);
614  /* deref2_eval(t); */
615  /* RESID */ match_attr1(&((*u)->left),v->left,rb);
616  }
617  else if (cmp>0) {
618  temp=v->right;
619  v->right=NULL;
620  /* RESID */ match_attr1(u,temp,rb);
621  /* RESID */ match_attr1(&((*u)->left),v,rb);
622  v->right=temp;
623  }
624  else {
625  temp=v->left;
626  v->left=NULL;
627  /* RESID */ match_attr1(&((*u)->right),v,rb);
628  /* RESID */ match_attr1(u,temp,rb);
629  v->left=temp;
630  }
631  }
632  }
633 }
static long attr_missing
Definition: lefun.c:12
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define match
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1121
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
void match_attr1(ptr_node *u, ptr_node v, ptr_resid_block rb)
void match_attr1
Definition: lefun.c:599
ptr_node right
Definition: def_struct.h:200
void match_attr2 ( ptr_node u,
ptr_node  v,
ptr_resid_block  rb 
)

match_attr2

Parameters
u- ptr_node *u
v- ptr_node v
rb- ptr_resid_block rb

Evaluate the lone arguments (for lazy failure + eager success)

Definition at line 644 of file lefun.c.

References wl_node::data, deref2_rec_eval(), featcmp(), wl_node::key, wl_node::left, match_attr1(), NULL, and wl_node::right.

645 {
646  long cmp;
647  ptr_node temp;
648 
649  if (v) {
650  if (*u==NULL) { /* PVR 12.03 */
651  ptr_psi_term t;
652  match_attr1(u,v->right,rb);
653  t = (ptr_psi_term) v->data;
654  deref2_rec_eval(t);
655  match_attr1(u,v->left,rb);
656  }
657  else {
658  cmp=featcmp((*u)->key,v->key);
659  if(cmp==0) {
660  /* RESID */ match_attr2(&((*u)->right),v->right,rb);
661  /* RESID */ match_attr2(&((*u)->left),v->left,rb);
662  }
663  else if (cmp>0) {
664  temp=v->right;
665  v->right=NULL;
666  /* RESID */ match_attr2(u,temp,rb);
667  /* RESID */ match_attr2(&((*u)->left),v,rb);
668  v->right=temp;
669  }
670  else {
671  temp=v->left;
672  v->left=NULL;
673  /* RESID */ match_attr2(&((*u)->right),v,rb);
674  /* RESID */ match_attr2(u,temp,rb);
675  v->left=temp;
676  }
677  }
678  }
679  else if (*u!=NULL) {
680  ptr_psi_term t /* , empty */ ;
681  match_attr1(&((*u)->right),v,rb);
682  t = (ptr_psi_term) (*u)->data;
683  /* Create a new psi-term to put the (useless) result: */
684  /* This is needed so that *all* arguments of a function call */
685  /* are evaluated, which avoids incorrect 'Yes' answers. */
686  deref2_rec_eval(t); /* Assumes goal_stack is already restored. */
687  match_attr1(&((*u)->left),v,rb);
688  }
689 }
void match_attr2(ptr_node *u, ptr_node v, ptr_resid_block rb)
match_attr2
Definition: lefun.c:644
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
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
void match_attr1(ptr_node *u, ptr_node v, ptr_resid_block rb)
void match_attr1
Definition: lefun.c:599
void deref2_rec_eval(ptr_psi_term t)
deref2_rec_eval
Definition: lefun.c:1382
ptr_node right
Definition: def_struct.h:200
void match_attr3 ( ptr_node u,
ptr_node  v,
ptr_resid_block  rb 
)

match_attr3

Parameters
u- ptr_node *u
v- ptr_node v
rb- ptr_resid_block rb

Evaluate the corresponding arguments

Definition at line 700 of file lefun.c.

References attr_missing, wl_node::data, deref2_eval(), featcmp(), wl_node::key, wl_node::left, NULL, wl_node::right, and TRUE.

701 {
702  long cmp;
703  ptr_node temp;
704 
705  if (v) {
706  if (*u==NULL)
708  else {
709  cmp=featcmp((*u)->key,v->key);
710  if(cmp==0) {
711  ptr_psi_term t1,t2;
712  /* RESID */ match_attr3(&((*u)->right),v->right,rb);
713  t1 = (ptr_psi_term) (*u)->data;
714  t2 = (ptr_psi_term) v->data;
715  /* RESID */ /* push_goal(match,(*u)->data,v->data,rb); */
716  deref2_eval(t1); /* Assumes goal_stack is already restored. */
717  deref2_eval(t2); /* PVR 12.03 */
718  /* RESID */ match_attr3(&((*u)->left),v->left,rb);
719  }
720  else if (cmp>0) {
721  temp=v->right;
722  v->right=NULL;
723  /* RESID */ match_attr3(u,temp,rb);
724  /* RESID */ match_attr3(&((*u)->left),v,rb);
725  v->right=temp;
726  }
727  else {
728  temp=v->left;
729  v->left=NULL;
730  /* RESID */ match_attr3(&((*u)->right),v,rb);
731  /* RESID */ match_attr3(u,temp,rb);
732  v->left=temp;
733  }
734  }
735  }
736 }
void deref2_eval(ptr_psi_term t)
deref2_eval
Definition: lefun.c:1356
static long attr_missing
Definition: lefun.c:12
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
void match_attr3(ptr_node *u, ptr_node v, ptr_resid_block rb)
match_attr3
Definition: lefun.c:700
ptr_node right
Definition: def_struct.h:200
long matches ( ptr_definition  t1,
ptr_definition  t2,
long *  smaller 
)

matches

Parameters
t1- ptr_definition t1
t2- ptr_definition t2
smaller- long *smaller

MATCHES(t1,t2,s) Returns TRUE if GLB(t1,t2)!=bottom. Sets S to TRUE if type T1 is <| than type T2, that is if T1 matches T2.

Definition at line 1666 of file types.c.

References wl_definition::code, FALSE, wl_int_list::next, NOT_CODED, top, TRUE, and wl_int_list::value_1.

1667 {
1668  ptr_int_list c1,c2;
1669  long result=TRUE;
1670 
1671  *smaller=TRUE;
1672 
1673  if (t1!=t2)
1674  if (t2!=top)
1675  if (t1==top)
1676  *smaller=FALSE;
1677  else {
1678  c1=t1->code;
1679  c2=t2->code;
1680  result=FALSE;
1681 
1682  if (c1!=NOT_CODED && c2!=NOT_CODED) {
1683  while (c1 && c2) {
1684  if ((unsigned long)c1->value_1 & (unsigned long)c2->value_1) result=TRUE;
1685  if ((unsigned long)c1->value_1 & ~(unsigned long)c2->value_1) *smaller=FALSE;
1686  c1=c1->next;
1687  c2=c2->next;
1688  }
1689  }
1690  else
1691  *smaller=FALSE;
1692  }
1693 
1694  return result;
1695 }
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_int_list code
Definition: def_struct.h:150
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
long memory_check ( )

memory_check

MEMORY_CHECK() This function tests to see whether enough memory is available to allow execution to continue. It causes a garbage collection if not, and if that fails to release enough memory it returns FALSE.

Definition at line 1723 of file memory.c.

References fail_all(), FALSE, garbage(), GC_THRESHOLD, heap_pointer, stack_pointer, TRUE, and verbose.

1724 {
1725  long success=TRUE;
1726 
1728  if(verbose) fprintf(stderr,"\n"); /* RM: Feb 1 1993 */
1729  garbage();
1730  /* Abort if didn't recover at least GC_THRESHOLD/10 of memory */
1732  fprintf(stderr,"*********************\n");
1733  fprintf(stderr,"*** OUT OF MEMORY ***\n");
1734  fprintf(stderr,"*********************\n");
1735  fail_all();
1736  success=FALSE;
1737  }
1738  }
1739  return success;
1740 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
void fail_all()
fail_all
Definition: memory.c:189
long verbose
Definition: def_glob.h:914
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
void garbage()
garbage
Definition: memory.c:1530
#define GC_THRESHOLD
Garbage collection threshold (1/8 of MEM_SIZE is reasonable).
Definition: def_const.h:117
void merge ( ptr_node u,
ptr_node  v 
)

merge

Parameters
u- ptr_node *u
v- ptr_node v

MERGE(u,v) U and V are two binary trees containing the attributes fields of psi-terms. U and V are merged together, that is U becomes the union of U and V: For each label L in V and L->Vpsi_term: If L is in U Then With L->Upsi_term Do unify(Upsi_term,Vpsi_term) Else merge L->Vpsi_term in U. Unification is simply done by appending the 2 psi_terms to the unification stack. All effects must be recorded in the trail so that they can be undone on backtracking.

Definition at line 1131 of file login.c.

References merge1(), merge2(), and merge3().

1132 {
1133  merge1(u,v); /* Unify corresponding arguments */
1134  merge2(u,v); /* Evaluate lone arguments (lazy failure + eager success) */
1135  merge3(u,v); /* Merge v's loners into u & evaluate corresponding arguments */
1136 }
void merge2(ptr_node *u, ptr_node v)
merge2
Definition: login.c:949
void merge3(ptr_node *u, ptr_node v)
merge3
Definition: login.c:1004
void merge1(ptr_node *u, ptr_node v)
merge1
Definition: login.c:893
void merge1 ( ptr_node u,
ptr_node  v 
)

merge1

Parameters
u- ptr_node *u
v- ptr_node v

Unify the corresponding arguments

Definition at line 893 of file login.c.

References wl_node::data, featcmp(), wl_node::key, wl_node::left, NULL, push_goal(), wl_node::right, and unify.

894 {
895  long cmp;
896  ptr_node temp;
897 
898  if (v) {
899  if (*u==NULL) {
900  /* push_ptr_value(int_ptr,u); */
901  /* (*u)=STACK_ALLOC(node); */
902  /* **u= *v; */
903  /* more_v_attr=TRUE; */
904  }
905  else {
906  cmp=featcmp((*u)->key,v->key);
907  if (cmp==0) {
908  if (v->right)
909  merge1(&((*u)->right),v->right);
910 
912 
913  if (v->left)
914  merge1(&((*u)->left),v->left);
915  }
916  else if (cmp>0) {
917  temp=v->right;
918  v->right=NULL;
919  merge1(&((*u)->left),v);
920  merge1(u,temp);
921  v->right=temp;
922  }
923  else {
924  temp=v->left;
925  v->left=NULL;
926  merge1(&((*u)->right),v);
927  merge1(u,temp);
928  v->left=temp;
929  }
930  }
931  }
932  else if (*u!=NULL) {
933  /* more_u_attr=TRUE; */
934  }
935 }
void push_goal(goals t, ptr_psi_term aaaa_5, ptr_psi_term bbbb_5, GENERIC cccc_5)
push_goal
Definition: login.c:600
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
ptr_node right
Definition: def_struct.h:200
void merge1(ptr_node *u, ptr_node v)
merge1
Definition: login.c:893
merge2 ( ptr_node u,
ptr_node  v 
)

merge2

Parameters
u- ptr_node *u
v- ptr_node v

Evaluate the lone arguments (For LAZY failure + EAGER success) Evaluate low numbered lone arguments first. For each lone argument in either u or v, create a new psi-term to put the (useless) result: This is needed so that all arguments of a uni- unified psi-term are evaluated, which avoids incorrect 'Yes' answers.

Definition at line 949 of file login.c.

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

950 {
951  long cmp;
952  ptr_node temp;
953 
954  if (v) {
955  if (*u==NULL) {
956  ptr_psi_term t;
957  merge2(u,v->right);
958  t = (ptr_psi_term) v->data;
959  deref2_rec_eval(t); /* Assumes goal_stack is already restored. */
960  merge2(u,v->left);
961  }
962  else {
963  cmp=featcmp((*u)->key,v->key);
964  if (cmp==0) {
965  /* if (v->right) */
966  merge2(&((*u)->right),v->right);
967 
968  /* if (v->left) */
969  merge2(&((*u)->left),v->left);
970  }
971  else if (cmp>0) {
972  temp=v->right;
973  v->right=NULL;
974  merge2(&((*u)->left),v);
975  merge2(u,temp);
976  v->right=temp;
977  }
978  else {
979  temp=v->left;
980  v->left=NULL;
981  merge2(&((*u)->right),v);
982  merge2(u,temp);
983  v->left=temp;
984  }
985  }
986  }
987  else if (*u!=NULL) {
988  ptr_psi_term t;
989  merge2(&((*u)->right),v);
990  t = (ptr_psi_term) (*u)->data;
991  deref2_rec_eval(t); /* Assumes goal_stack is already restored. */
992  merge2(&((*u)->left),v);
993  }
994 }
void deref2_rec_eval(ptr_psi_term t)
deref2_rec_eval
Definition: lefun.c:1382
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
void merge2(ptr_node *u, ptr_node v)
merge2
Definition: login.c:949
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
ptr_node right
Definition: def_struct.h:200
void merge3 ( ptr_node u,
ptr_node  v 
)

merge3

Parameters
u- ptr_node *u
v- ptr_node v

Merge v's loners into u and evaluate the corresponding arguments

Definition at line 1004 of file login.c.

References deref2_eval(), featcmp(), int_ptr, wl_node::key, wl_node::left, more_u_attr, more_v_attr, NULL, push_ptr_value(), wl_node::right, STACK_ALLOC, and TRUE.

1005 {
1006  long cmp;
1007  ptr_node temp;
1008 
1009  if (v) {
1010  if (*u==NULL) {
1012  (*u)=STACK_ALLOC(node);
1013  **u= *v;
1014  more_v_attr=TRUE;
1015  }
1016  else {
1017  ptr_psi_term t1; // ,t2;
1018 
1019  cmp=featcmp((*u)->key,v->key);
1020  if (cmp==0) {
1021  if (v->right)
1022  merge3(&((*u)->right),v->right);
1023 
1024  t1 = (ptr_psi_term) (*u)->data;
1025  /* t2 = (ptr_psi_term) v->data; */
1026  deref2_eval(t1);
1027  /* deref2_eval(t2); */
1028  /* push_goal(unify,(ptr_psi_term)(*u)->data,(ptr_psi_term)v->data,NULL); */
1029 
1030  if (v->left)
1031  merge3(&((*u)->left),v->left);
1032  }
1033  else if (cmp>0) {
1034  temp=v->right;
1035  v->right=NULL;
1036  merge3(&((*u)->left),v);
1037  merge3(u,temp);
1038  v->right=temp;
1039  }
1040  else {
1041  temp=v->left;
1042  v->left=NULL;
1043  merge3(&((*u)->right),v);
1044  merge3(u,temp);
1045  v->left=temp;
1046  }
1047  }
1048  }
1049  else if (*u!=NULL) {
1050  more_u_attr=TRUE;
1051  }
1052 }
long more_u_attr
Definition: def_glob.h:944
void deref2_eval(ptr_psi_term t)
deref2_eval
Definition: lefun.c:1356
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
void merge3(ptr_node *u, ptr_node v)
merge3
Definition: login.c:1004
#define STACK_ALLOC(A)
Definition: def_macro.h:21
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
long more_v_attr
Definition: def_glob.h:945
ptr_node right
Definition: def_struct.h:200
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void merge_unify ( ptr_node u,
ptr_node  v 
)

merge_unify

Parameters
u- ptr_node *u
v- ptr_node v

For built-ins.c

Definition at line 1146 of file login.c.

References merge1(), and merge3().

1147 {
1148  merge1(u,v); /* Unify corresponding arguments */
1149  merge3(u,v); /* Merge v's loners into u & evaluate corresponding arguments */
1150 }
void merge3(ptr_node *u, ptr_node v)
merge3
Definition: login.c:1004
void merge1(ptr_node *u, ptr_node v)
merge1
Definition: login.c:893
long mod_warning ( ptr_psi_term  arg,
REAL  val,
int  zero 
)

mod_warning

Parameters
arg- ptr_psi_term arg
val- REAL val
zero- int zero

Definition at line 1041 of file error.c.

References Errorline(), nonint_warning(), and TRUE.

1042 {
1043  int err;
1044 
1045  err=nonint_warning(arg,val,"of modulo operation is not an integer");
1046  if(!err && zero && val==0) {
1047  Errorline("division by 0 in modulo operation\n");
1048  err=TRUE;
1049  }
1050  return err;
1051 }
long nonint_warning(ptr_psi_term arg, REAL val, char *msg)
nonint_warning
Definition: error.c:974
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define TRUE
Standard boolean.
Definition: def_const.h:268
void new_built_in ( ptr_module  m,
char *  s,
def_type  t,
long(*)()  r 
)

new_built_in

Parameters
m- ptr_module m
s- char *s
t- def_type t
r- long (*r)()

NEW_BUILT_IN(m,s,t,r) Add a new built-in predicate or function. Used also in x_pred.c

M=module. S=string. T=type (function or predicate). R=address of C routine to call.

Definition at line 5375 of file built_ins.c.

References built_in_index, c_rule, current_module, MAX_BUILT_INS, wl_definition::rule, set_current_module(), wl_definition::type_def, and update_symbol().

5376 {
5377  ptr_definition d;
5378  if (built_in_index >= MAX_BUILT_INS) {
5379  fprintf(stderr,"Too many primitives, increase MAX_BUILT_INS in extern.h\n");
5380  exit(EXIT_FAILURE);
5381  }
5382 
5383  if(m!=current_module) /* RM: Jan 13 1993 */
5384  (void)set_current_module(m);
5385 
5386  d=update_symbol(m,s); /* RM: Jan 8 1993 */
5387  d->type_def=t;
5388  built_in_index++;
5391 }
static long built_in_index
Definition: built_ins.c:16
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
long(* c_rule[MAX_BUILT_INS])()
Definition: def_glob.h:888
def_type type_def
Definition: def_struct.h:153
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
ptr_pair_list rule
Definition: def_struct.h:148
struct wl_pair_list * ptr_pair_list
Definition: def_struct.h:64
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
ptr_definition new_definition ( ptr_keyword  key)

new_definition

Parameters
key- ptr_keyword key

NEW_DEFINITION(key) Create a definition for a key.

Definition at line 220 of file modules.c.

References wl_definition::already_loaded, wl_definition::always_check, wl_definition::children, wl_definition::code, wl_definition::date, wl_keyword::definition, wl_definition::evaluate_args, FALSE, first_definition, wl_definition::global_value, HEAP_ALLOC, wl_definition::init_value, wl_definition::keyword, wl_definition::next, NOT_CODED, NULL, wl_definition::op_data, wl_definition::parents, wl_definition::properties, wl_definition::protected, wl_definition::rule, TRUE, wl_definition::type_def, and undef_it.

221 {
222  ptr_definition result;
223 
224 
225  /* printf("*** New definition: %s\n",key->combined_name); */
226 
227  /* Create a new definition */
228  result=HEAP_ALLOC(struct wl_definition);
229 
230  /* RM: Feb 3 1993 */
231  result->next=first_definition; /* Linked list of all definitions */
232  first_definition=result;
233 
234  result->keyword=key;
235  result->rule=NULL;
236  result->properties=NULL;
237  result->date=0;
238  result->type_def=(def_type)undef_it;
239  result->always_check=TRUE;
240  result->protected=TRUE;
241  result->evaluate_args=TRUE;
242  result->already_loaded=FALSE;
243  result->children=NULL;
244  result->parents=NULL;
245  result->code=NOT_CODED;
246  result->op_data=NULL;
247  result->global_value=NULL; /* RM: Feb 8 1993 */
248  result->init_value=NULL; /* RM: Mar 23 1993 */
249  key->definition=result;
250 
251  return result;
252 }
char already_loaded
Definition: def_struct.h:157
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
ptr_psi_term init_value
Definition: def_struct.h:160
struct wl_definition * def_type
Definition: def_struct.h:60
char evaluate_args
Definition: def_struct.h:156
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
ptr_definition definition
Definition: def_struct.h:122
def_type type_def
Definition: def_struct.h:153
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
char always_check
Definition: def_struct.h:154
ptr_definition next
Definition: def_struct.h:164
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
ptr_psi_term global_value
Definition: def_struct.h:159
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_int_list code
Definition: def_struct.h:150
ptr_triple_list properties
Definition: def_struct.h:149
ptr_int_list children
Definition: def_struct.h:152
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_operator_data op_data
Definition: def_struct.h:158
ptr_int_list parents
Definition: def_struct.h:151
ptr_psi_term new_psi_term ( long  numargs,
ptr_definition  typ,
ptr_psi_term **  a1,
ptr_psi_term **  a2 
)

new_psi_term

Parameters
numargs- long numargs
typ- ptr_definition typ
a1- ptr_psi_term **a1
a2- ptr_psi_term **a2

Return a psi term with one or two args, and the addresses of the args

Definition at line 5064 of file built_ins.c.

References wl_psi_term::attr_list, wl_node::data, wl_node::key, wl_node::left, NULL, one, wl_node::right, STACK_ALLOC, stack_psi_term(), two, and wl_psi_term::type.

5065 {
5066  ptr_psi_term t;
5067  ptr_node n1, n2;
5068 
5069  if (numargs==2) {
5070  n2 = STACK_ALLOC(node);
5071  n2->key = two;
5072  *a2 = (ptr_psi_term *) &(n2->data);
5073  n2->left = NULL;
5074  n2->right = NULL;
5075  }
5076  else
5077  n2=NULL;
5078 
5079  n1 = STACK_ALLOC(node);
5080  n1->key = one;
5081  *a1 = (ptr_psi_term *) &(n1->data);
5082  n1->left = NULL;
5083  n1->right = n2;
5084 
5085  t=stack_psi_term(4);
5086  t->type = typ;
5087  t->attr_list = n1;
5088 
5089  return t;
5090 }
char * two
Definition: def_glob.h:892
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
char * one
Definition: def_glob.h:891
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_node right
Definition: def_struct.h:200
void new_state ( ptr_psi_term t)

new_state

Parameters
t- ptr_psi_term *t

Create a new file state psi-term that reflects the current global state

Definition at line 372 of file token.c.

References current_module, CURRENT_MODULE, eof_flag, EOF_FLAG, heap_add_int_attr(), heap_add_psi_attr(), heap_add_str_attr(), heap_psi_term(), INPUT_FILE_NAME, input_file_name, input_stream, inputfilesym, lf_false, lf_true, LINE_COUNT, line_count, wl_module::module_name, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, stream, STREAM, wl_psi_term::type, and wl_psi_term::value_3.

373 {
374  ptr_psi_term t1;
375 
376  *t=heap_psi_term(4);
377  (*t)->type=inputfilesym;
378 
379  t1=heap_psi_term(4);
380  t1->type=stream;
382  heap_add_psi_attr(*t,STREAM,t1);
383 
384  /* RM: Jan 27 1993 */
386 
387  /*
388  printf("Creating new state for file '%s', module '%s'\n",
389  input_file_name,
390  current_module->module_name);
391  */
392 
397 
400 
403 
404  t1=heap_psi_term(4);
407 
408  t1=heap_psi_term(4);
411 }
#define LINE_COUNT
feature name
Definition: def_const.h:890
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
long eof_flag
Definition: def_glob.h:853
string input_file_name
Definition: def_glob.h:1016
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
#define SAVED_PSI_TERM
feature name
Definition: def_const.h:918
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
#define OLD_SAVED_CHAR
feature name
Definition: def_const.h:911
#define CURRENT_MODULE
feature name
Definition: def_const.h:939
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
long old_saved_char
Definition: def_glob.h:850
long saved_char
Definition: def_glob.h:849
ptr_psi_term null_psi_term
Used to represent an empty parse token.
Definition: def_glob.h:656
ptr_definition inputfilesym
symbol in bi module
Definition: def_glob.h:501
long line_count
Definition: def_glob.h:1015
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define STREAM
feature name
Definition: def_const.h:876
#define START_OF_LINE
feature name
Definition: def_const.h:897
void heap_add_str_attr(ptr_psi_term t, char *attrname, char *str)
heap_add_str_attr
Definition: token.c:151
void heap_add_psi_attr(ptr_psi_term t, char *attrname, ptr_psi_term g)
heap_add_psi_attr
Definition: token.c:226
FILE * input_stream
Definition: def_glob.h:1014
GENERIC value_3
Definition: def_struct.h:186
long start_of_line
???
Definition: def_glob.h:846
#define INPUT_FILE_NAME
feature name
Definition: def_const.h:883
char * module_name
Definition: def_struct.h:106
#define OLD_SAVED_PSI_TERM
feature name
Definition: def_const.h:925
void heap_add_int_attr(ptr_psi_term t, char *attrname, long value)
heap_add_int_attr
Definition: token.c:74
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
#define EOF_FLAG
feature name
Definition: def_const.h:932
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
#define SAVED_CHAR
feature name
Definition: def_const.h:904
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
void new_step ( long  newstep)

new_step

long newstep

Definition at line 713 of file error.c.

References FALSE, new_trace(), stepflag, and steptrace.

714 {
715  stepflag = newstep;
716  printf("*** Single stepping is turned ");
717  printf(stepflag?"on.\n":"off.\n");
720 }
long steptrace
Definition: error.c:24
void new_trace(long newtrace)
new_trace
Definition: error.c:698
#define FALSE
Standard boolean.
Definition: def_const.h:275
long stepflag
Definition: error.c:23
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
void new_trace ( long  newtrace)

new_trace

Parameters
newtrace- long newtrace

Definition at line 698 of file error.c.

References trace.

699 {
700  trace = newtrace;
701  printf("*** Tracing is turned ");
702  printf(trace?"on.":"off.");
703  if (trace == 2) printf(" Only for Proves");
704  printf("\n");
705 }
long trace
Definition: error.c:21
long no_choices ( )

no_choices

Return TRUE iff the top choice point is a what_next choice point or if there are no choice points.

Definition at line 1945 of file login.c.

References choice_stack, wl_choice_point::goal_stack, NULL, wl_goal::type, and what_next.

1946 {
1948 }
#define NULL
Definition: def_const.h:533
goals type
Definition: def_struct.h:238
#define what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1079
ptr_goal goal_stack
Definition: def_struct.h:249
ptr_choice_point choice_stack
Definition: def_glob.h:1026
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 nonint_warning ( ptr_psi_term  arg,
REAL  val,
char *  msg 
)

nonint_warning

Parameters
arg- ptr_psi_term arg
val- REAL val
msg- char *msg

Definition at line 974 of file error.c.

References FALSE, report_warning2(), and TRUE.

975 {
976  long err=FALSE;
977 
978  if (val!=floor(val)) {
979  report_warning2(arg, msg);
980  err=TRUE;
981  }
982  return err;
983 }
void report_warning2(ptr_psi_term g, char *s)
report_warning2
Definition: error.c:938
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
void nonnum_warning ( ptr_psi_term  t,
ptr_psi_term  arg1,
ptr_psi_term  arg2 
)

nonnum_warning

Parameters
t- ptr_psi_term t
arg1- ptr_psi_term arg1
arg2- ptr_psi_term arg2

Give error message if there is an argument which cannot unify with/ a real number.

Definition at line 953 of file error.c.

References curried, overlap_type(), real, report_warning(), and wl_psi_term::type.

954 {
955  if (!curried && /* PVR 15.9.93 */
956  ((arg1 && !overlap_type(arg1->type,real)) ||
957  (arg2 && !overlap_type(arg2->type,real)))) {
958  report_warning(t,"non-numeric argument(s)");
959  }
960 }
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
long curried
Definition: def_glob.h:868
ptr_definition type
Definition: def_struct.h:181
void report_warning(ptr_psi_term g, char *s)
report_warning
Definition: error.c:890
long num_choices ( )

num_choices

Return the number of choice points on the choice point stack

Definition at line 1956 of file login.c.

References choice_stack, and wl_choice_point::next.

1957 {
1958  long num;
1959  ptr_choice_point cp;
1960 
1961  num=0;
1962  cp=choice_stack;
1963  while (cp) {
1964  num++;
1965  cp=cp->next;
1966  }
1967  return num;
1968 }
ptr_choice_point next
Definition: def_struct.h:250
ptr_choice_point choice_stack
Definition: def_glob.h:1026
long num_vars ( ptr_node  vt)

num_vars

Parameters
vt- ptr_node vt

Return the number of variables in the variable tree.

Definition at line 1976 of file login.c.

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

1977 {
1978  return (vt?(num_vars(vt->left)+1+num_vars(vt->right)):0);
1979 }
long num_vars(ptr_node vt)
num_vars
Definition: login.c:1976
ptr_node left
Definition: def_struct.h:199
ptr_node right
Definition: def_struct.h:200
ptr_node one_attr ( )

one_attr

Return an attr_list with one argument

Definition at line 5042 of file built_ins.c.

References wl_node::data, wl_node::key, wl_node::left, NULL, one, wl_node::right, and STACK_ALLOC.

5043 {
5044  ptr_node n;
5045 
5046  n = STACK_ALLOC(node);
5047  n->key = one;
5048  n->data = NULL; /* To be filled in later */
5049  n->left = NULL;
5050  n->right = NULL;
5051 
5052  return n;
5053 }
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
char * one
Definition: def_glob.h:891
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_node right
Definition: def_struct.h:200
void one_pass_always_check ( long *  ch)

one_pass_always_check

Parameters
ch- long *ch
    ONE_PASS_ALWAYS_CHECK(ch)
Go through the symbol table & propagate all FALSE always_check flags of all sorts to their children. Return a TRUE flag if a change was made somewhere (for the closure calculation).

Definition at line 1049 of file types.c.

References wl_definition::always_check, first_definition, wl_definition::next, propagate_always_check(), wl_definition::type_def, and type_it.

1050 {
1051  ptr_definition d;
1052 
1053 
1054  for(d=first_definition;d;d=d->next)
1055  if (d->type_def==(def_type)type_it && !d->always_check)
1056  propagate_always_check(d,ch);
1057 }
ptr_definition first_definition
All definition are stores in a linked list starting at first_definition.
Definition: def_glob.h:13
def_type type_def
Definition: def_struct.h:153
char always_check
Definition: def_struct.h:154
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_definition next
Definition: def_struct.h:164
void propagate_always_check(ptr_definition d, long *ch)
propagate_always_check
Definition: types.c:1022
long only_arg1 ( ptr_psi_term  t,
ptr_psi_term arg1 
)

only_arg1

Parameters
t- ptr_psi_term t
arg1- ptr_psi_term * arg1

Return TRUE iff t has only argument "1", and return the argument.

Definition at line 1605 of file built_ins.c.

References wl_psi_term::attr_list, wl_node::data, FALSE, featcmp(), wl_node::key, wl_node::left, NULL, one, wl_node::right, and TRUE.

1606 {
1607  ptr_node n=t->attr_list;
1608 
1609  if (n && n->left==NULL && n->right==NULL && !featcmp(n->key,one)) {
1610  *arg1=(ptr_psi_term)n->data;
1611  return TRUE;
1612  }
1613  else
1614  return FALSE;
1615 }
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node left
Definition: def_struct.h:199
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
char * one
Definition: def_glob.h:891
long featcmp(char *str1, char *str2)
featcmp
Definition: trees.c:106
ptr_node attr_list
Definition: def_struct.h:187
ptr_node right
Definition: def_struct.h:200
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
long open_input_file ( char *  file)

open_input_file

Parameters
file- char *file

OPEN_INPUT_FILE(file) Open the input file specified by the string FILE. If the file is "stdin", restore the stdin state. Otherwise, open the file and create a new global state for it. If the file can't be opened, print an error and open "stdin" instead.

Definition at line 594 of file token.c.

References Errorline(), expand_file_name(), FALSE, init_parse_state(), input_file_name, input_state, input_stream, new_state(), noisy, NULL, restore_state(), save_state(), stdin_state, and TRUE.

595 {
596  long ok=TRUE;
597  long stdin_flag;
598 
599  /* Save global input file state */
601 
602  file=expand_file_name(file);
603 
604  if ((stdin_flag=(!strcmp(file,"stdin")))) {
605  input_stream=stdin;
606  noisy=TRUE;
607  }
608  else {
609  input_stream=fopen(file,"r");
610  noisy=FALSE;
611  }
612 
613  if (input_stream==NULL) {
614  Errorline("file '%s' does not exist.\n",file);
615  file="stdin";
616  input_stream=stdin;
617  noisy=TRUE;
618  ok=FALSE;
619  }
620 
621  if (!stdin_flag || stdin_state==NULL) {
622  /* Initialize a new global input file state */
623  strcpy(input_file_name,file);
625  /* Create a new state containing the new global values */
627  if (stdin_flag) stdin_state=input_state;
628  }
629  else {
632  }
633 
634  return ok;
635 }
void init_parse_state()
init_parse_state
Definition: token.c:464
ptr_psi_term stdin_state
Definition: def_glob.h:857
string input_file_name
Definition: def_glob.h:1016
void save_state(ptr_psi_term t)
save_state
Definition: token.c:293
#define NULL
Definition: def_const.h:533
ptr_psi_term input_state
Definition: def_glob.h:856
long noisy
Definition: def_glob.h:1011
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
void restore_state(ptr_psi_term t)
restore_state
Definition: token.c:334
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
FILE * input_stream
Definition: def_glob.h:1014
char * expand_file_name(char *s)
expand_file_name
Definition: token.c:537
void new_state(ptr_psi_term *t)
new_state
Definition: token.c:372
void open_module_one ( ptr_psi_term  t,
int *  onefailed 
)

open_module_one

Parameters
t= ptr_psi_term t
onefailed- int *onefailed

Definition at line 562 of file modules.c.

References wl_keyword::combined_name, wl_keyword::definition, Errorline(), FALSE, find_module(), hash_lookup(), HEAP_ALLOC, wl_int_list::next, wl_module::open_modules, wl_keyword::public, string_val(), wl_keyword::symbol, wl_module::symbol_table, TRUE, and wl_int_list::value_1.

563 {
564  ptr_module open_module;
565  ptr_int_list opens;
566  ptr_keyword key1,key2;
567  int i;
568  int found=FALSE;
569 
570  open_module=find_module(string_val(t));
571  if (open_module) {
572 
573  for (opens=current_module->open_modules;opens;opens=opens->next)
574  if (opens->value_1 == (GENERIC)open_module) {
575  /* warningline("module \"%s\" is already open\n",
576  open_module->module_name); */ /* RM: Jan 27 1993 */
577  found=TRUE;
578  }
579 
580  if (!found) {
581  opens=HEAP_ALLOC(struct wl_int_list);
582  opens->value_1=(GENERIC)open_module;
585 
586  /* Check for name conflicts */
587  /* RM: Feb 23 1993 */
588  for (i=0;i<open_module->symbol_table->size;i++)
589  if ((key1=open_module->symbol_table->data[i]) && key1->public) {
591  if (key2 && key1->definition!=key2->definition)
592  Errorline("symbol clash '%s' and '%s'\n",
593  key1->combined_name,
594  key2->combined_name);
595  }
596  }
597  }
598  else {
599  Errorline("module \"%s\" not found\n",string_val(t));
600  *onefailed=TRUE;
601  }
602 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
char * combined_name
Definition: def_struct.h:119
ptr_definition definition
Definition: def_struct.h:122
ptr_hash_table symbol_table
Definition: def_struct.h:110
ptr_module current_module
Definition: modules.c:15
char * symbol
Definition: def_struct.h:118
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_int_list open_modules
Definition: def_struct.h:108
char * string_val(ptr_psi_term term)
string_val
Definition: modules.c:169
ptr_module find_module(char *module)
find_module
Definition: modules.c:54
GENERIC value_1
Definition: def_struct.h:85
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_int_list next
Definition: def_struct.h:86
void open_module_tree ( ptr_node  n,
int *  onefailed 
)

open_module_tree

Parameters
n- ptr_node n
onefailed- int *onefailed

Definition at line 542 of file modules.c.

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

543 {
544  if (n) {
545  ptr_psi_term t;
546  open_module_tree(n->left,onefailed);
547 
548  t=(ptr_psi_term)n->data;
549  open_module_one(t,onefailed);
550 
551  open_module_tree(n->right,onefailed);
552  }
553 }
void open_module_tree(ptr_node n, int *onefailed)
open_module_tree
Definition: modules.c:542
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void open_module_one(ptr_psi_term t, int *onefailed)
open_module_one
Definition: modules.c:562
ptr_node left
Definition: def_struct.h:199
ptr_node right
Definition: def_struct.h:200
long open_output_file ( char *  file)
void or_codes ( ptr_int_list  u,
ptr_int_list  v 
)

or_codes

Parameters
u- ptr_int_list u
v- ptr_int_list v

OR_CODES(code1,code2) Performs CODE1 := CODE1 or CODE2, 'or' being the binary logical operator on bits.

Definition at line 831 of file types.c.

References HEAP_ALLOC, wl_int_list::next, NULL, and wl_int_list::value_1.

832 {
833  while (v) {
834  u->value_1= (GENERIC)(((unsigned long)(u->value_1)) | ((unsigned long)(v->value_1)));
835  v=v->next;
836  if (u->next==NULL && v) {
838  u=u->next;
839  u->value_1=0;
840  u->next=NULL;
841  }
842  else
843  u=u->next;
844  }
845 }
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
GENERIC value_1
Definition: def_struct.h:85
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_int_list next
Definition: def_struct.h:86
void outputline ( char *  format,
  ... 
)

void outputline(char *format,...)

outputline

Parameters
format- char *format
...

Definition at line 101 of file error.c.

References assert, display_psi(), FALSE, input_file_name, output_stream, parse_ok, perr_i(), perr_s(), print_code(), print_def_type(), print_operator_kind(), and psi_term_line_number.

102 {
103  va_list VarArg;
104  // int l;
105  char buffer_loc[5];
106  char *p;
107  unsigned long lng2;
108  char *cptr;
109  ptr_int_list pil;
110  ptr_psi_term psi;
111  operator kind;
112  def_type t ;
113  va_start(VarArg,format);
114  // vinfoline(format,output_stream, VarArg);
115  // #define vinfoline(format, outfile, xxxx) {
116  for (p=format;p && *p; p++)
117  {
118  if (*p == '%')
119  {
120  p++;
121  switch (*p)
122  {
123  case 'd':
124  case 'x':
125  buffer_loc[0] = '%';
126  buffer_loc[1] = 'l';
127  buffer_loc[2] = *p;
128  buffer_loc[3] = 0;
129  lng2 = va_arg(VarArg, long);
130  fprintf(output_stream, buffer_loc, lng2);
131  break;
132  case 's':
133  buffer_loc[0] = '%';
134  buffer_loc[1] = *p;
135  buffer_loc[2] = 0;
136  cptr = va_arg(VarArg,char *);
137  fprintf(output_stream, buffer_loc, cptr);
138  break;
139  case 'C':
140  /* type coding as bin string */
141  pil = va_arg(VarArg,ptr_int_list);
143  break;
144  case 'P':
145  psi = va_arg(VarArg,ptr_psi_term);
147  break;
148  case 'O':
149  kind = va_arg(VarArg,operator);
151  break;
152  case 'T':
153  assert(output_stream==stderr);
154  t = va_arg(VarArg,def_type);
155  print_def_type(t);
156  break;
157  case 'E':
158  assert(output_stream==stderr);
159  perr_i("near line %ld",psi_term_line_number);
160  if (strcmp(input_file_name,"stdin")) {
161  perr_s(" in file \042%s\042",input_file_name);
162  }
163  parse_ok=FALSE;
164  break;
165  case '%':
166  (void)putc(*p,output_stream);
167  break;
168  default:
169  fprintf(output_stream,"<%c follows %% : report bug >", *p);
170  break;
171  }
172  }
173  else
174  (void)putc(*p,output_stream);
175  }
176  va_end(VarArg);
177 }
void perr_i(char *str, long i)
perr_i
Definition: error.c:800
long psi_term_line_number
Definition: def_glob.h:909
string input_file_name
Definition: def_glob.h:1016
void display_psi(FILE *s, ptr_psi_term t)
display_psi
Definition: print.c:1579
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
void print_code(FILE *s, ptr_int_list c)
print_code
Definition: print.c:167
void print_def_type(def_type t)
print_def_type
Definition: types.c:24
#define FALSE
Standard boolean.
Definition: def_const.h:275
FILE * output_stream
Definition: def_glob.h:1017
void print_operator_kind(FILE *s, long kind)
print_operator_kind
Definition: print.c:192
#define assert(N)
Definition: memory.c:114
long overlap_type ( ptr_definition  t1,
ptr_definition  t2 
)

overlap_type

Parameters
t1- ptr_definition t1
t2- ptr_definition t2

OVERLAP_TYPE(t1,t2) This function returns TRUE if GLB(t1,t2)!=bottom. This is essentially the same thing as GLB, only it's faster 'cause we don't care about the resulting code.

Definition at line 1579 of file types.c.

References wl_definition::code, FALSE, wl_int_list::next, NOT_CODED, top, TRUE, and wl_int_list::value_1.

1580 {
1581  ptr_int_list c1,c2;
1582  long result=TRUE;
1583 
1584  if (t1!=t2 && t1!=top && t2!=top) {
1585 
1586  c1=t1->code;
1587  c2=t2->code;
1588  result=FALSE;
1589 
1590  if (c1!=NOT_CODED && c2!=NOT_CODED) {
1591  while (!result && c1 && c2) {
1592  result=(((unsigned long)(c1->value_1)) & ((unsigned long)(c2->value_1)));
1593  c1=c1->next;
1594  c2=c2->next;
1595  }
1596  }
1597  }
1598 
1599  /*
1600  printf("overlap_type(%s,%s) => %ld\n",t1->def->keyword->symbol,t2->def->keyword->symbol,result);
1601  */
1602 
1603  return result;
1604 }
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_int_list code
Definition: def_struct.h:150
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
psi_term parse ( long *  q)

parse

Parameters
q- long *q

PARSE(is_it_a_clause) This returns one clause or query from the input stream. It also indicates the type psi-term read, that is whether it was a clause or a query in the IS_IT_A_CLAUSE variable. This is the top level of the parser.

The whole parser is, rather like the psi_termiser, not too well written. It handles psi_terms rather than pointers which causes a lot of messy code and is somewhat slower.

Definition at line 907 of file parser.c.

References eof, EOLN, ERROR, FACT, FALSE, final_dot, final_question, mark_nonstrict(), NULL, parse_ok, parser_stack_index, prompt, put_back_char(), QUERY, read_char(), read_life_form(), read_token(), saved_char, saved_psi_term, stringparse, Syntaxerrorline(), TRUE, and wl_psi_term::type.

908 {
909  psi_term s,t,u;
910  long c;
911 
913  parse_ok=TRUE;
914 
915  /*s=read_life_form('.','?');*/
916  s=read_life_form(0,0);
917 
918  if (parse_ok) {
919  if (s.type!=eof) {
920  read_token(&t);
921 
922  /*
923  if (equ_tokch(t,'?'))
924  *q=QUERY;
925  else if (equ_tokch(t,'.'))
926  *q=FACT;
927  */
928 
929  /* RM: Jul 7 1993 */
930  if (t.type==final_question)
931  {
932  *q=QUERY;
933  }
934  else if (t.type==final_dot)
935  {
936  *q=FACT;
937  }
938  else
939  {
941  else {
942 
943  /*
944  perr("*** Syntax error ");psi_term_error();perr(": ");
945  display_psi_stderr(&t);
946  perr(".\n");
947  */
948 
949  /* RM: Feb 1 1993 */
950  Syntaxerrorline("'%P' (%E)\n",&t);
951 
952  }
953  *q=ERROR;
954  }
955  }
956  }
957 
958 
959  if (!parse_ok) {
960 
961  while (saved_psi_term!=NULL) read_token(&u);
962 
963  prompt="error>";
964  while((c=read_char()) && c!=EOF && c!='.' && c!='?' && c!=EOLN) {}
965 
966  *q=ERROR;
967  }
968  else if (saved_char)
969  do {
970  c=read_char();
971  if (c==EOLN)
972  c=0;
973  else if (c<0 || c>32) {
974  put_back_char(c);
975  c=0;
976  }
977  } while(c && c!=EOF);
978 
979  /* Make sure arguments of nonstrict terms are marked quoted. */
980  if (parse_ok) mark_nonstrict(&s); /* 25.8 */
981 
982  /* mark_eval(&s); 24.8 XXX */
983 
984  /* Mark all the psi-terms corresponding to variables in the var_tree as */
985  /* quoted. This is needed for correct parsing of inputs; otherwise vars */
986  /* that occur in an increment of a query are marked to be evaluated again! */
987  /* mark_quote_tree(var_tree); 24.8 XXX */
988 
989 
990  return s;
991 }
void put_back_char(long c)
put_back_char
Definition: token.c:729
void read_token(ptr_psi_term tok)
read_token
Definition: token.c:1186
ptr_definition final_question
symbol in syntax module
Definition: def_glob.h:615
#define FACT
Fact Kind of user input.
Definition: def_const.h:338
void mark_nonstrict(ptr_psi_term t)
mark_nonstrict
Definition: copy.c:513
#define NULL
Definition: def_const.h:533
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
long saved_char
Definition: def_glob.h:849
#define QUERY
Query Kind of user input.
Definition: def_const.h:345
#define ERROR
Error Kind of user input.
Definition: def_const.h:352
psi_term read_life_form(char ch1, char ch2)
read_life_form
Definition: parser.c:728
#define EOLN
End of line.
Definition: def_const.h:309
ptr_definition final_dot
symbol in syntax module
Definition: def_glob.h:608
void Syntaxerrorline(char *format,...)
Syntaxerrorline.
Definition: error.c:557
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
char * prompt
Definition: def_glob.h:1018
long read_char()
read_char
Definition: token.c:680
long parser_stack_index
index to parser stack
Definition: def_glob.h:164
long stringparse
Definition: def_glob.h:859
ptr_definition type
Definition: def_struct.h:181
psi_term parse_list ( ptr_definition  typ,
char  e,
char  s 
)

parse_list

Parameters
typ- ptr_definition typ
e- char e
s- char s

PARSE_LIST(type,end,separator)

This function provides a replacement for the function 'read_list'. It does not create the old (slightly more compact and a lot more complicated) list structure, but instead creates a generic psi-term with 2 features. The list is terminated by the atom 'nil'.

Example:

[a,b,c|d] -> cons(a,cons(b,cons(c,d))). [] -> nil {a;b;c} -> disj(a,disj(b,disj(c,{}))). {} -> {} = bottom

Example: TYP=disjunction, END="}", SEPARATOR=";" will read in disjunctions.

Example: TYP=list, END="]", SEPARATOR="," will read lists such as [1,2,a,b,c|d]

Definition at line 329 of file parser.c.

References wl_psi_term::attr_list, display_psi_stderr(), equ_tokc, equ_tokch, FALSE, FEATCMP, list_nil(), NULL, one, parse_ok, perr(), psi_term_error(), put_back_token(), read_life_form(), read_token(), stack_copy_psi_term(), stack_insert(), stringparse, two, and wl_psi_term::type.

330 {
331  ptr_psi_term car=NULL;
332  ptr_psi_term cdr=NULL;
333  psi_term result;
334  psi_term t;
335  char a;
336 
337  result=list_nil(typ); /* RM: Feb 1 1993 */
338 
339  if (parse_ok) {
340 
341  /* Character used for building cons pairs */
342  a='|'; /* RM: Jan 11 1993 */
343 
344 
345  read_token(&t);
346 
347  if(!equ_tokc(t,e)) {
348 
349  /* Read the CAR of the list */
350  put_back_token(t);
352 
353  /* Read the CDR of the list */
354  read_token(&t);
355  if(equ_tokch(t,s))
356  cdr=stack_copy_psi_term(parse_list(typ,e,s));
357  else if(equ_tokch(t,e))
358  cdr=stack_copy_psi_term(list_nil(typ));
359  else if(equ_tokch(t,'|')) {
361  read_token(&t);
362  if(!equ_tokch(t,e)) {
364  else {
365  perr("*** Syntax error ");psi_term_error();
366  perr(": bad symbol for end of list '");
367  display_psi_stderr(&t);
368  perr("'.\n");
369  put_back_token(t);
370  }
371  }
372  }
373  else
375  else {
376  perr("*** Syntax error ");psi_term_error();
377  perr(": bad symbol in list '");
378  display_psi_stderr(&t);
379  perr("'.\n");
380  put_back_token(t);
381  }
382 
383  result.type=typ;
384  if(car)
385  (void)stack_insert(FEATCMP,one,&(result.attr_list),(GENERIC)car);
386  if(cdr)
387  (void)stack_insert(FEATCMP,two,&(result.attr_list),(GENERIC)cdr);
388  }
389  }
390 
391  return result;
392 }
void psi_term_error()
psi_term_error
Definition: token.c:761
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void perr(char *str)
perr
Definition: error.c:763
#define equ_tokc(A, B)
Definition: def_macro.h:76
void read_token(ptr_psi_term tok)
read_token
Definition: token.c:1186
char * two
Definition: def_glob.h:892
#define NULL
Definition: def_const.h:533
psi_term parse_list(ptr_definition typ, char e, char s)
parse_list
Definition: parser.c:329
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
void display_psi_stderr(ptr_psi_term t)
display_psi_stderr
Definition: print.c:1550
void put_back_token(psi_term t)
put_back_token
Definition: token.c:746
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
psi_term read_life_form(char ch1, char ch2)
read_life_form
Definition: parser.c:728
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
char * one
Definition: def_glob.h:891
psi_term list_nil(ptr_definition type)
list_nil
Definition: parser.c:278
long stringparse
Definition: def_glob.h:859
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
#define equ_tokch(A, B)
Definition: def_macro.h:71
void pchoices ( )

pchoices

for debugging

Definition at line 94 of file memory.c.

References choice_stack, wl_choice_point::next, stack_pointer, and wl_choice_point::stack_top.

95 {
97  printf("stack pointer is: %lx\n",(unsigned long)stack_pointer);
98  for(c=choice_stack;c;c=c->next)
99  printf("\tc=%lx\ts=%lx\tg=%lx\tu=%lx\n",(unsigned long)c,(unsigned long)c->stack_top,(unsigned long)c->goal_stack,(unsigned long)c->undo_point);
100 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
GENERIC stack_top
Definition: def_struct.h:251
ptr_choice_point next
Definition: def_struct.h:250
ptr_choice_point choice_stack
Definition: def_glob.h:1026
void perr ( char *  str)

perr

Parameters
str- char *str

Definition at line 763 of file error.c.

764 {
765  (void)fputs(str, stderr);
766 }
void perr_i ( char *  str,
long  i 
)

perr_i

Parameters
str- char *str
i- long i

Definition at line 800 of file error.c.

801 {
802  fprintf(stderr,str,i);
803 }
void perr_s ( char *  s1,
char *  s2 
)

perr_s

Parameters
s1- char *s1
s2- char *s2

Definition at line 775 of file error.c.

776 {
777  fprintf(stderr,s1,s2);
778 }
void perr_s2 ( char *  s1,
char *  s2,
char *  s3 
)

perr_s2

Parameters
s1- char *s1
s2- char *s2
s3- char *s3

Definition at line 788 of file error.c.

789 {
790  fprintf(stderr,s1,s2,s3);
791 }
void perr_sort ( ptr_definition  d)

perr_sort

Parameters
d- ptr_definition d

Definition at line 933 of file types.c.

References wl_definition::keyword, perr_s(), and wl_keyword::symbol.

934 {
935  perr_s("%s",d->keyword->symbol);
936 }
ptr_keyword keyword
Definition: def_struct.h:147
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
char * symbol
Definition: def_struct.h:118
void perr_sort_cycle ( ptr_int_list  anc)

perr_sort_cycle

Parameters
anc- ptr_int_list anc

Definition at line 959 of file types.c.

References perr(), perr_sort(), perr_sort_list(), and wl_int_list::value_1.

960 {
962  perr(" <| ");
963  perr_sort_list(anc);
964 }
void perr(char *str)
perr
Definition: error.c:763
void perr_sort_list(ptr_int_list anc)
perr_sort_list
Definition: types.c:944
void perr_sort(ptr_definition d)
perr_sort
Definition: types.c:933
GENERIC value_1
Definition: def_struct.h:85
void perr_sort_list ( ptr_int_list  anc)

perr_sort_list

Parameters
anc- ptr_int_list anc

Definition at line 944 of file types.c.

References wl_int_list::next, perr(), perr_sort(), and wl_int_list::value_1.

945 {
946  if (anc) {
947  perr_sort_list(anc->next);
948  if (anc->next) perr(" <| ");
950  }
951 }
void perr(char *str)
perr
Definition: error.c:763
void perr_sort_list(ptr_int_list anc)
perr_sort_list
Definition: types.c:944
void perr_sort(ptr_definition d)
perr_sort
Definition: types.c:933
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
void persistent_error_check ( ptr_node  n,
int *  error 
)

persistent_error_check

Parameters
n- ptr_node n
error- int *error

Definition at line 2714 of file built_ins.c.

References wl_node::data, deref_ptr, error_psi_term, Errorline(), global_it, wl_node::left, persistent_error_check(), wl_node::right, TRUE, wl_psi_term::type, wl_definition::type_def, and undef_it.

2715 {
2716  if (n) {
2717  ptr_psi_term t;
2718  persistent_error_check(n->left, error);
2719 
2720  t=(ptr_psi_term)n->data;
2721  deref_ptr(t);
2723  Errorline("%T %P cannot be redeclared persistent (%E).\n",
2724  t->type->type_def,
2725  t);
2726  t->type=error_psi_term->type;
2727  *error=TRUE;
2728  }
2729 
2730  persistent_error_check(n->right, error);
2731  }
2732 }
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
struct wl_definition * def_type
Definition: def_struct.h:60
void persistent_error_check(ptr_node n, int *error)
persistent_error_check
Definition: built_ins.c:2714
def_type type_def
Definition: def_struct.h:153
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
GENERIC data
Definition: def_struct.h:201
ptr_node left
Definition: def_struct.h:199
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
ptr_definition type
Definition: def_struct.h:181
ptr_node right
Definition: def_struct.h:200
void persistent_one ( ptr_psi_term  t)

persistent_one

Parameters
t- ptr_psi_term t

Definition at line 2759 of file built_ins.c.

References global_it, wl_definition::global_value, heap_pointer, heap_psi_term(), wl_psi_term::type, and wl_definition::type_def.

2760 {
2764 }
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
struct wl_definition * def_type
Definition: def_struct.h:60
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
def_type type_def
Definition: def_struct.h:153
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_psi_term global_value
Definition: def_struct.h:159
ptr_definition type
Definition: def_struct.h:181
void persistent_tree ( ptr_node  n)

persistent_tree

Parameters
n- ptr_node n

Definition at line 2739 of file built_ins.c.

References wl_node::data, deref_ptr, wl_node::left, persistent_one(), persistent_tree(), and wl_node::right.

2740 {
2741  if (n) {
2742  ptr_psi_term t;
2743  persistent_tree(n->left);
2744 
2745  t=(ptr_psi_term)n->data;
2746  deref_ptr(t);
2747  persistent_one(t);
2748 
2749  persistent_tree(n->right);
2750  }
2751 }
void persistent_tree(ptr_node n)
persistent_tree
Definition: built_ins.c:2739
void persistent_one(ptr_psi_term t)
persistent_one
Definition: built_ins.c:2759
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
ptr_node right
Definition: def_struct.h:200
long pop ( ptr_psi_term  tok,
long *  op 
)

pop

Parameters
tok- ptr_psi_term tok
op- long *op

POP(psi_term,op); This function pops PSI_TERM and OP off the parser stack and returns its precedence.

Definition at line 132 of file parser.c.

References error_psi_term, FALSE, int_stack, parse_ok, parser_stack_index, and psi_term_stack.

133 {
134  long r=0;
135 
136  if (parser_stack_index==0) {
137  /*
138  perr("*** Parser error ");
139  psi_term_error();
140  perr(": stack empty.\n");
141  */
142 
143  (*tok)= *error_psi_term;
144  parse_ok=FALSE;
145  }
146  else {
148  (*op)=op_stack[parser_stack_index];
151  }
152 
153  return r;
154 }
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
long parser_stack_index
index to parser stack
Definition: def_glob.h:164
long int_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:959
psi_term psi_term_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:958
long precedence ( psi_term  tok,
long  typ 
)

precedence

Parameters
tok- psi_term tok
typ- long typ

PRECEDENCE(tok,typ) This function returns the precedence of TOK if it is an operator of type TYP where TYP is FX XFX XF etc... Note that this allows both a binary and unary minus. The result is NOP if tok is not an operator.

Definition at line 180 of file parser.c.

References wl_operator_data::next, NOP, wl_definition::op_data, wl_operator_data::precedence, and wl_psi_term::type.

181 {
182  long r=NOP;
184 
185  o=tok.type->op_data;
186  while(o && r==NOP) {
187  if(typ==o->type)
188  r=o->precedence;
189  else
190  o=o->next;
191  }
192 
193  return r;
194 }
ptr_operator_data next
Definition: def_struct.h:76
#define NOP
returned by precedence if token is not an operator
Definition: def_const.h:1337
ptr_definition type
Definition: def_struct.h:181
ptr_operator_data op_data
Definition: def_struct.h:158
long pred_clause ( ptr_psi_term  t,
long  r,
ptr_psi_term  g 
)

pred_clause

Parameters
t- ptr_psi_term t
r- long r
g- ptr_psi_term g

PRED_CLAUSE(ptr_psi_term t,long r,ptr_psi_term g) Set about finding a clause that unifies with psi_term T. This routine is used both for CLAUSE and RETRACT. If R==TRUE then delete the first clause which unifies with T.

Definition at line 2451 of file built_ins.c.

References wl_psi_term::attr_list, bk_mark_quote(), clause, del_clause, deref_ptr, Errorline(), FALSE, function_it, get_two_args(), wl_definition::keyword, predicate_it, push_goal(), redefine(), wl_definition::rule, stack_psi_term(), succeed, wl_keyword::symbol, TRUE, wl_psi_term::type, wl_definition::type_def, and undef_it.

2452 {
2453  long success=FALSE;
2454  ptr_psi_term head,body;
2455 
2456  bk_mark_quote(g); /* RM: Apr 7 1993 */
2457  if (t) {
2458  deref_ptr(t);
2459 
2460  if (!strcmp(t->type->keyword->symbol,"->")) {
2461  get_two_args(t->attr_list,&head,&body);
2462  if (head) {
2463  deref_ptr(head);
2464  if (head && body &&
2466  success=TRUE;
2467  }
2468  }
2469  else if (!strcmp(t->type->keyword->symbol,":-")) {
2470  get_two_args(t->attr_list,&head,&body);
2471  if (head) {
2472  deref_ptr(head);
2473  if (head &&
2474  (head->type->type_def==(def_type)predicate_it || head->type->type_def==(def_type)undef_it)) {
2475  success=TRUE;
2476  if (!body) {
2477  body=stack_psi_term(4);
2478  body->type=succeed;
2479  }
2480  }
2481  }
2482  }
2483  /* There is no body, so t is a fact */
2484  else if (t->type->type_def==(def_type)predicate_it || t->type->type_def==(def_type)undef_it) {
2485  head=t;
2486  body=stack_psi_term(4);
2487  body->type=succeed;
2488  success=TRUE;
2489  }
2490  }
2491 
2492  if (success) {
2493  if (r) {
2494  if (redefine(head))
2495  push_goal(del_clause,head,body,(GENERIC)&(head->type->rule));
2496  else
2497  success=FALSE;
2498  }
2499  else
2500  push_goal(clause,head,body,(GENERIC)&(head->type->rule));
2501  }
2502  else
2503  Errorline("bad argument in %s.\n", (r?"retract":"clause"));
2504 
2505  return success;
2506 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
ptr_definition succeed
symbol in bi module
Definition: def_glob.h:389
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
long redefine(ptr_psi_term t)
redefine
Definition: types.c:104
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
void bk_mark_quote(ptr_psi_term t)
bk_mark_quote
Definition: copy.c:708
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1135
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
#define del_clause
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1142
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
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_quote_symbol ( ptr_keyword  k)

pretty_quote_symbol

Parameters
k- ptr_keyword k

PRETTY_QUOTE_SYMBOL(k) Prints the string to be used to display keyword K, with quotes if required.

Definition at line 470 of file modules.c.

References wl_keyword::definition, display_modules, wl_definition::keyword, wl_keyword::module, wl_module::module_name, prettyf(), prettyf_quote(), and wl_keyword::symbol.

471 {
472  k=k->definition->keyword;
473  if(display_modules) {
475  prettyf("#");
476  }
477  prettyf_quote(k->symbol);
478 }
long display_modules
Definition: modules.c:25
ptr_definition definition
Definition: def_struct.h:122
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
char * module_name
Definition: def_struct.h:106
ptr_module module
Definition: def_struct.h:117
void prettyf(char *s)
prettyf
Definition: print.c:496
void prettyf_quote(char *s)
prettyf_quote
Definition: print.c:529
void pretty_symbol ( ptr_keyword  k)

pretty_symbol

Parameters
k- ptr_keyword k

PRETTY_SYMBOL(k) Prints the string to be used to display keyword K.

Definition at line 452 of file modules.c.

References wl_keyword::definition, display_modules, wl_definition::keyword, wl_keyword::module, wl_module::module_name, prettyf(), and wl_keyword::symbol.

453 {
454  k=k->definition->keyword;
455  if(display_modules) {
457  prettyf("#");
458  }
459  prettyf(k->symbol);
460 }
long display_modules
Definition: modules.c:25
ptr_definition definition
Definition: def_struct.h:122
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
char * module_name
Definition: def_struct.h:106
ptr_module module
Definition: def_struct.h:117
void prettyf(char *s)
prettyf
Definition: print.c:496
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_codes ( )

print_codes

PRINT_CODES() Print all the codes.

Definition at line 1256 of file types.c.

References outputline(), and type_count.

1257 {
1258  long i;
1259 
1260  for (i=0; i<type_count; i++) {
1261  outputline("%C = %s\n",
1262  gamma_table[i]->code,
1263  gamma_table[i]->keyword->combined_name);
1264  }
1265 }
ptr_definition * gamma_table
Definition: types.c:14
long type_count
Definition: def_glob.h:1021
void outputline(char *format,...)
void outputline(char *format,...)
Definition: error.c:101
void print_def_type ( def_type  t)

print_def_type

Parameters
t- def_type t

PRINT_DEF_TYPE(t) This prints type T to stderr, where T=predicate, function or type.

Definition at line 24 of file types.c.

References function_it, global_it, perr(), predicate_it, and type_it.

25 {
26  switch ((long)t) {
27  case (long)predicate_it:
28  perr("predicate");
29  break;
30  case (long)function_it:
31  perr("function");
32  break;
33  case (long)type_it:
34  perr("sort");
35  break;
36  case (long)global_it: /* RM: Feb 8 1993 */
37  perr("global variable");
38  break;
39  default:
40  perr("undefined");
41  }
42 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
void perr(char *str)
perr
Definition: error.c:763
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
#define global_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1422
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
void print_gc_info ( long  timeflag)

print_gc_info

Parameters
timeflag- long timeflag

Definition at line 1493 of file memory.c.

References gc_time, heap_pointer, life_time, mem_base, mem_limit, mem_size, and stack_pointer.

1494 {
1495  fprintf(stderr," [%ld%% free (%ldK), %ld%% heap, %ld%% stack",
1496  (100*((unsigned long)heap_pointer-(unsigned long)stack_pointer)+mem_size/2)/mem_size,
1497  ((unsigned long)heap_pointer-(unsigned long)stack_pointer+512)/1024,
1498  (100*((unsigned long)mem_limit-(unsigned long)heap_pointer)+mem_size/2)/mem_size,
1499  (100*((unsigned long)stack_pointer-(unsigned long)mem_base)+mem_size/2)/mem_size);
1500  if (timeflag) {
1501  fprintf(stderr,", %1.3fs cpu (%ld%%)",
1502  gc_time,
1503  (unsigned long)(0.5+100*gc_time/(life_time+gc_time)));
1504  }
1505  fprintf(stderr,"]\n");
1506 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
static float gc_time
Definition: memory.c:27
static float life_time
Definition: memory.c:27
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
int mem_size
number of words from memory = alloc_words * sizeof word
Definition: def_glob.h:41
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
char * print_symbol ( ptr_keyword  k)

print_symbol

OBSOLETE ptr_psi_term get_function_value(module,symbol)

ptr_module module; char *symbol;

{ ptr_node n; ptr_definition def; ptr_psi_term result=NULL; ptr_pair_list rule;

n=find(STRCMP,make_module_token(module,symbol),symbol_table); if(n) def=(ptr_definition)n->data; if(def && def->type==function) { rule=def->rule; while (rule && (!rule->aaaa_1 || !rule->bbbb_1)) rule=rule->next; if(rule) { result=(ptr_psi_term)rule->bbbb_1; deref_ptr(result); } } }

if(!result) Errorline("error in definition of '%s'\n",module_buffer);

return result; }

Parameters
k- ptr_keyword k

PRINT_SYMBOL(k) Returns the string to be used to display keyword K.

Definition at line 435 of file modules.c.

References wl_keyword::combined_name, wl_keyword::definition, display_modules, wl_definition::keyword, and wl_keyword::symbol.

436 {
437  k=k->definition->keyword;
438  if(display_modules)
439  return k->combined_name;
440  else
441  return k->symbol;
442 }
long display_modules
Definition: modules.c:25
char * combined_name
Definition: def_struct.h:119
ptr_definition definition
Definition: def_struct.h:122
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
void print_undo_stack ( )

print_undo_stack

Definition at line 122 of file memory.c.

References wl_stack::aaaa_3, wl_stack::bbbb_3, mem_base, mem_limit, wl_stack::next, wl_stack::type, and undo_stack.

123 {
125 
126  while (u) {
127  if ((GENERIC)u->aaaa_3<mem_base || (GENERIC)u->aaaa_3>mem_limit ||
128  (GENERIC)u->next<mem_base || (GENERIC)u->next>mem_limit) {
129  printf("UNDO: type:%ld a:%lx b:%lx next:%lx\n",u->type,(unsigned long)u->aaaa_3,(unsigned long)u->bbbb_3,(unsigned long)u->next);
130  (void)fflush(stdout);
131  }
132  u=u->next;
133  }
134 }
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
GENERIC * bbbb_3
Definition: def_struct.h:233
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
type_ptr type
Definition: def_struct.h:231
GENERIC * aaaa_3
Definition: def_struct.h:232
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
ptr_stack next
Definition: def_struct.h:234
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
void propagate_always_check ( ptr_definition  d,
long *  ch 
)

propagate_always_check

Parameters
d- ptr_definition d
ch- long *ch

PROPAGATE_ALWAYS_CHECK(d,ch) Recursively set the always_check flag to 'FALSE' for all d's children. Continue until encountering only 'FALSE' values. Return a TRUE flag if a change was made somewhere (for the closure calculation).

Definition at line 1022 of file types.c.

References wl_definition::always_check, wl_definition::children, FALSE, wl_int_list::next, TRUE, and wl_int_list::value_1.

1023 {
1024  ptr_int_list child_list;
1025  ptr_definition child;
1026 
1027  child_list = d->children;
1028  while (child_list) {
1029  child = (ptr_definition)child_list->value_1;
1030  if (child->always_check) {
1031  child->always_check = FALSE;
1032  *ch = TRUE;
1033  propagate_always_check(child,ch);
1034  }
1035  child_list = child_list->next;
1036  }
1037 }
char always_check
Definition: def_struct.h:154
#define TRUE
Standard boolean.
Definition: def_const.h:268
void propagate_always_check(ptr_definition d, long *ch)
propagate_always_check
Definition: types.c:1022
#define FALSE
Standard boolean.
Definition: def_const.h:275
struct wl_definition * ptr_definition
Definition: def_struct.h:59
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list children
Definition: def_struct.h:152
ptr_int_list next
Definition: def_struct.h:86
void propagate_definitions ( )

propagate_definitions

PROPAGATE_DEFINITIONS() This routine propagates the definition (attributes,predicates) of a type to all its sons.

Definition at line 662 of file types.c.

References adults, wl_definition::children, children, find_adults(), insert_own_prop(), insert_prop(), wl_int_list::next, NULL, wl_definition::properties, and wl_int_list::value_1.

663 {
664  ptr_int_list kids;
665  ptr_definition d;
666 
667  adults=NULL;
668  find_adults();
669 
670  while (adults) {
671 
672  children=NULL;
673 
674  while (adults) {
676 
677  insert_own_prop(d);
679 
680  kids=d->children;
681 
682  while(kids) {
684  /* if (d->always_check && kids->value_1)
685  ((ptr_definition)kids->value_1)->always_check=TRUE; */
686  kids=kids->next;
687  }
688  adults=adults->next;
689  }
691  }
692 }
void find_adults()
find_adults
Definition: types.c:549
#define NULL
Definition: def_const.h:533
void insert_prop(ptr_definition d, ptr_triple_list prop)
insert_prop
Definition: types.c:620
struct wl_definition * ptr_definition
Definition: def_struct.h:59
void insert_own_prop(ptr_definition d)
insert_own_prop
Definition: types.c:575
ptr_int_list children
Definition: def_glob.h:1001
ptr_int_list adults
Definition: def_glob.h:1001
GENERIC value_1
Definition: def_struct.h:85
ptr_triple_list properties
Definition: def_struct.h:149
ptr_int_list children
Definition: def_struct.h:152
ptr_int_list next
Definition: def_struct.h:86
long prove_aim ( )

prove_aim

PROVE_AIM() This is the proving routine. It performs one proof step, that is: finding the definition to use to prove AIM, and unifying the HEAD with the GOAL before proving. It all works by pushing sub-goals onto the goal_stack. Special cases are CUT and AND (","). Built-in predicates written in C are called.

Definition at line 1645 of file login.c.

References wl_goal::aaaa_1, wl_pair_list::aaaa_2, aim, and, wl_psi_term::attr_list, wl_goal::bbbb_1, wl_pair_list::bbbb_2, boolpredsym, c_rule, call_handlersym, can_curry, choice_stack, clean_trail(), clear_copy(), wl_psi_term::coref, curried, cut, cut_to, wl_node::data, DEFRULES, deref_args, deref_ptr, do_currying(), do_residuation_user(), eval_copy(), FALSE, function_it, get_two_args(), goal_count, goal_stack, i_check_out(), i_eval_args(), wl_node::key, wl_node::left, lf_false, lf_true, life_or, MAX_BUILT_INS, merge(), wl_pair_list::next, wl_goal::next, NULL, one, predicate_it, wl_definition::protected, prove, push_choice_point(), push_goal(), push_psi_ptr_value(), quote_copy(), resid_aim, resid_vars, wl_node::right, wl_definition::rule, set_empty, STACK, stack_add_psi_attr(), STACK_ALLOC, stack_psi_term(), wl_psi_term::status, sub_type(), succeed, traceline(), tracesym, TRUE, wl_psi_term::type, wl_definition::type_def, type_it, undef_it, and wl_psi_term::value_3.

1646 {
1647  long success=TRUE;
1648  ptr_psi_term thegoal,head,body,arg1,arg2;
1649  ptr_pair_list rule;
1650 
1651  thegoal=(ptr_psi_term )aim->aaaa_1;
1652  rule=(ptr_pair_list )aim->bbbb_1;
1653 
1654  if (thegoal && rule) {
1655 
1656  deref_ptr(thegoal); /* Evaluation is explicitly handled later. */
1657 
1658  if (thegoal->type!=and) {
1659  if (thegoal->type!=cut)
1660  if(thegoal->type!=life_or) {
1661  /* User-defined predicates with unevaluated arguments */
1662  /* Built-ins do this themselves (see built_ins.c). */
1663  /* if (!thegoal->type->evaluate_args) mark_quote(thegoal); 24.8 25.8 */
1664 
1665  if(i_check_out(thegoal)) { /* RM: Apr 6 1993 */
1666 
1667  goal_stack=aim->next;
1668  goal_count++;
1669 
1670  if ((unsigned long)rule==DEFRULES) {
1671  rule=(ptr_pair_list)thegoal->type->rule;
1672  if (thegoal->type->type_def==(def_type)predicate_it) {
1673  if (!rule) /* This can happen when RETRACT is used */
1674  success=FALSE;
1675  }
1676  else if ( thegoal->type->type_def==(def_type)function_it
1677  || ( thegoal->type->type_def==(def_type)type_it
1678  && sub_type(boolean,thegoal->type)
1679  )
1680  ) {
1681  if (thegoal->type->type_def==(def_type)function_it && !rule)
1682  /* This can happen when RETRACT is used */
1683  success=FALSE;
1684  else {
1685  ptr_psi_term bool_pred;
1686  ptr_node a;
1687  /* A function F in pred. position is called as */
1688  /* '*bool_pred*'(F), which succeeds if F returns true */
1689  /* and fails if it returns false. It can residuate too. */
1690  bool_pred=stack_psi_term(0);
1691  bool_pred->type=boolpredsym;
1692  bool_pred->attr_list=(a=STACK_ALLOC(node));
1693  a->key=one;
1694  a->left=a->right=NULL;
1695  a->data=(GENERIC) thegoal;
1697  return success; /* We're done! */
1698  }
1699  }
1700  else if (!thegoal->type->protected && thegoal->type->type_def==(def_type)undef_it) {
1701  /* Don't give an error message for undefined dynamic objects */
1702  /* that do not yet have a definition */
1703  success=FALSE;
1704  }
1705  else if (thegoal->type==lf_true || thegoal->type==lf_false) {
1706  /* What if the 'lf_true' or 'lf_false' have arguments? */
1707  success=(thegoal->type==lf_true);
1708  return success; /* We're done! */
1709  }
1710  else {
1711  /* Error: undefined predicate. */
1712  /* Call the call_handler (which may do an auto-load). */
1713  ptr_psi_term call_handler;
1714  /* mark_quote(thegoal); */
1715 
1716  /* RM: Jan 27 1993 */
1717  /* warningline("call handler invoked for %P\n",thegoal); */
1718 
1719  call_handler=stack_psi_term(0);
1720  call_handler->type=call_handlersym;
1721  stack_add_psi_attr(call_handler,"1",thegoal);
1723  return success; /* We're done! */
1724  }
1725  }
1726 
1727  if (success) {
1728 
1729  if ((unsigned long)rule<=MAX_BUILT_INS) {
1730 
1731  /* For residuation (RESPRED) */
1732  curried=FALSE;
1733  can_curry=TRUE;
1734  resid_vars=NULL;
1735  /* resid_limit=(ptr_goal )stack_pointer; 12.6 */
1736 
1737  if (thegoal->type!=tracesym) /* 26.1 */
1738  traceline("prove built-in %P\n", thegoal);
1739 
1740  /* RESPRED */ resid_aim=aim;
1741  /* Residuated predicate must return success=TRUE */
1742  success=c_rule[(unsigned long)rule]();
1743 
1744  /* RESPRED */ if (curried)
1745  /* RESPRED */ do_currying();
1746  /* RESPRED */ else if (resid_vars)
1747  /* RESPRED */ success=do_residuation_user(); /* 21.9 */ /* PVR 9.2.94 */
1748  }
1749  else {
1750 
1751  /* Evaluate arguments of a predicate call before the call. */
1752  deref_args(thegoal,set_empty);
1753 
1754  traceline("prove %P\n", thegoal);
1755 
1756  /* For residuation (RESPRED) */
1757  curried=FALSE;
1758  can_curry=TRUE;
1759  resid_vars=NULL;
1760  /* resid_limit=(ptr_goal )stack_pointer; 12.6 */
1761 
1762  while (rule && (rule->aaaa_2==NULL || rule->bbbb_2==NULL)) {
1763  rule=rule->next;
1764  traceline("alternative clause has been retracted\n");
1765  }
1766  if (rule) {
1767 
1768  clear_copy();
1769  if (TRUE) /* 8.9 */
1770  /* if (thegoal->type->evaluate_args) 8.9 */
1771  head=eval_copy(rule->aaaa_2,STACK);
1772  else
1773  head=quote_copy(rule->aaaa_2,STACK);
1774 
1775  body=eval_copy(rule->bbbb_2,STACK);
1776 
1777  /* What does this do?? */
1778  /* if (body->type==built_in) */
1779  /* body->coref=head; */
1780 
1781  if (rule->next)
1782  push_choice_point(prove,thegoal,(ptr_psi_term)rule->next,NULL);
1783 
1784  if (body->type!=succeed)
1786 
1787  /* push_ptr_value(psi_term_ptr,&(head->coref)); 9.6 */
1788  push_psi_ptr_value(head,(GENERIC *)&(head->coref));
1789  head->coref=thegoal;
1790  merge(&(thegoal->attr_list),head->attr_list);
1791  if (!head->status) {
1792  (void)i_eval_args(head->attr_list);
1793  }
1794  }
1795  else {
1796  success=FALSE;
1797  }
1798  }
1799  }
1800  }
1801  }
1802  else { /* ';' built-in */
1803  /* RM: Apr 6 1993 */
1804  goal_stack=aim->next;
1805  goal_count++;
1806  get_two_args(thegoal->attr_list,&arg1,&arg2);
1809  }
1810  else { /* 'Cut' built-in*/
1811  goal_stack=aim->next;
1812  goal_count++;
1813  /* assert((ptr_choice_point)(thegoal->value)<=choice_stack); 12.7 */
1814  cut_to(thegoal->value_3); /* 12.7 */
1815 #ifdef CLEAN_TRAIL
1817 #endif
1818  traceline("cut all choice points back to %x\n",choice_stack);
1819  }
1820  }
1821  else { /* 'And' built-in */
1822  goal_stack=aim->next;
1823  goal_count++;
1824  get_two_args(thegoal->attr_list,&arg1,&arg2);
1827  }
1828  }
1829  else
1830  success=FALSE;
1831 
1832  /* RESPRED */ resid_aim=NULL;
1833  return success;
1834 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_psi_term aaaa_2
Definition: def_struct.h:205
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
ptr_definition succeed
symbol in bi module
Definition: def_glob.h:389
void clear_copy()
clear_copy
Definition: copy.c:53
struct wl_definition * def_type
Definition: def_struct.h:60
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
long do_residuation_user()
do_residuation_user()
Definition: lefun.c:324
ptr_goal goal_stack
Definition: def_glob.h:1025
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
ptr_pair_list next
Definition: def_struct.h:207
void push_goal(goals t, ptr_psi_term aaaa_5, ptr_psi_term bbbb_5, GENERIC cccc_5)
push_goal
Definition: login.c:600
long(* c_rule[MAX_BUILT_INS])()
Definition: def_glob.h:888
def_type type_def
Definition: def_struct.h:153
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
#define set_empty
Set constants for deref_args in lefun.c.
Definition: def_const.h:493
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
ptr_definition call_handlersym
symbol in bi module
Definition: def_glob.h:508
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
void merge(ptr_node *u, ptr_node v)
merge
Definition: login.c:1131
ptr_definition and
symbol in syntax module
Definition: def_glob.h:171
ptr_resid_list resid_vars
Definition: def_glob.h:866
void stack_add_psi_attr(ptr_psi_term t, char *attrname, ptr_psi_term g)
stack_add_psi_attr
Definition: token.c:239
ptr_node left
Definition: def_struct.h:199
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void traceline(char *format,...)
traceline
Definition: error.c:186
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
ptr_psi_term quote_copy(ptr_psi_term t, long heap_flag)
quote_copy
Definition: copy.c:186
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
long goal_count
Definition: def_glob.h:678
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
#define deref_ptr(P)
Definition: def_macro.h:100
void do_currying()
do_currying
Definition: lefun.c:383
char * key
Definition: def_struct.h:198
#define TRUE
Standard boolean.
Definition: def_const.h:268
static void clean_trail(ptr_choice_point cutpt)
clean_trail
Definition: login.c:810
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
struct wl_pair_list * ptr_pair_list
Definition: def_struct.h:64
#define cut_to(C)
Definition: def_macro.h:85
ptr_psi_term bbbb_2
Definition: def_struct.h:206
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
Definition: login.c:47
char * one
Definition: def_glob.h:891
#define STACK_ALLOC(A)
Definition: def_macro.h:21
long can_curry
Definition: def_glob.h:869
long i_eval_args(ptr_node n)
i_eval_args
Definition: lefun.c:874
long curried
Definition: def_glob.h:868
#define deref_args(P, S)
Definition: def_macro.h:150
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
ptr_psi_term eval_copy(ptr_psi_term t, long heap_flag)
eval_copy
Definition: copy.c:196
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_definition boolpredsym
symbol in bi module
Definition: def_glob.h:192
ptr_node attr_list
Definition: def_struct.h:187
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
void push_choice_point(goals t, ptr_psi_term aaaa_6, ptr_psi_term bbbb_6, GENERIC cccc_6)
push_choice_point
Definition: login.c:638
ptr_choice_point choice_stack
Definition: def_glob.h:1026
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
ptr_node right
Definition: def_struct.h:200
ptr_definition tracesym
symbol in bi module
Definition: def_glob.h:424
ptr_definition life_or
symbol in syntax module
Definition: def_glob.h:326
ptr_goal next
Definition: def_struct.h:242
void psi_term_error ( )

psi_term_error

PSI_TERM_ERROR Print the line number at which the current psi_term started.

Definition at line 761 of file token.c.

References FALSE, input_file_name, parse_ok, perr_i(), perr_s(), and psi_term_line_number.

762 {
763  perr_i("near line %ld",psi_term_line_number);
764  if (strcmp(input_file_name,"stdin")) {
765  perr_s(" in file \042%s\042",input_file_name);
766  }
767  /* prompt="error>"; 20.8 */
768  parse_ok=FALSE;
769 }
long psi_term_line_number
Definition: def_glob.h:909
string input_file_name
Definition: def_glob.h:1016
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
#define FALSE
Standard boolean.
Definition: def_const.h:275
void perr_i(char *str, long i)
perr_i
Definition: error.c:800
long psi_to_string ( ptr_psi_term  t,
char **  fn 
)

psi_to_string

Parameters
t- ptr_psi_term t
fn- char ** fn

PSI_TO_STRING(t,fn) Get the value of a Life string, or the name of a non-string psi-term. Return TRUE iff a valid string is found.

Definition at line 146 of file built_ins.c.

References equal_types, wl_definition::keyword, quoted_string, wl_keyword::symbol, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

147 {
148  if (equal_types(t->type,quoted_string)) {
149  if (t->value_3) {
150  *fn = (char *) t->value_3;
151  return TRUE;
152  }
153  else {
154  *fn = quoted_string->keyword->symbol;
155  return TRUE;
156  }
157  }
158  else {
159  *fn = t->type->keyword->symbol;
160  return TRUE;
161  }
162 }
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
#define TRUE
Standard boolean.
Definition: def_const.h:268
GENERIC value_3
Definition: def_struct.h:186
#define equal_types(A, B)
Definition: def_macro.h:111
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
void push ( psi_term  tok,
long  prec,
long  op 
)

push

Parameters
tok- psi_term tok
prec- long prec
op- long op

PUSH(tok,prec,op) Push psi_term and precedence and operator onto parser stack.

Definition at line 107 of file parser.c.

References int_stack, parser_stack_index, PARSER_STACK_SIZE, perr(), psi_term_error(), and psi_term_stack.

108 {
110  perr("*** Parser error ");
111  psi_term_error();
112  perr(": stack full.\n");
113  }
114  else {
118  op_stack[parser_stack_index]=op;
119  }
120 }
void psi_term_error()
psi_term_error
Definition: token.c:761
void perr(char *str)
perr
Definition: error.c:763
#define PARSER_STACK_SIZE
Maximum depth of the parser stack.
Definition: def_const.h:198
long parser_stack_index
index to parser stack
Definition: def_glob.h:164
long int_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:959
psi_term psi_term_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:958
void push2_ptr_value ( type_ptr  t,
GENERIC p,
GENERIC  v 
)

push2_ptr_value

Parameters
t- type_ptr t
p- GENERIC *p
v- GENERIC v

PUSH2_PTR_VALUE(t,*p,v) Push the pair (P,V) onto the stack of things to be undone (trail). It needn't be done if P is greater than the latest choice point because in that case memory is reclaimed.

Definition at line 573 of file login.c.

References wl_stack::aaaa_3, wl_stack::bbbb_3, choice_stack, wl_stack::next, STACK_ALLOC, stack_pointer, wl_stack::type, and undo_stack.

574 {
575  ptr_stack n;
576 
577  if (p<(GENERIC *)choice_stack || p>(GENERIC *)stack_pointer) {
578  n=STACK_ALLOC(stack);
579  n->type=t;
580  n->aaaa_3= (GENERIC *)p;
581  n->bbbb_3= (GENERIC *)v;
582  n->next=undo_stack;
583  undo_stack=n;
584  }
585 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
GENERIC * bbbb_3
Definition: def_struct.h:233
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
type_ptr type
Definition: def_struct.h:231
#define STACK_ALLOC(A)
Definition: def_macro.h:21
GENERIC * aaaa_3
Definition: def_struct.h:232
ptr_stack next
Definition: def_struct.h:234
ptr_choice_point choice_stack
Definition: def_glob.h:1026
void push_choice_point ( goals  t,
ptr_psi_term  aaaa_6,
ptr_psi_term  bbbb_6,
GENERIC  cccc_6 
)

push_choice_point

Parameters
t- goals t
aaaa_6ptr_psi_term aaaa_6
bbbb_6ptr_psi_term bbbb_6
cccc_6GENERIC cccc_6

PUSH_CHOICE_POINT(t,a,b,c) T,A,B,C is an alternative goal to try. T is the type of the goal: unify or prove.

If T=prove then a=goal to prove b=definition to use if b=DEFRULES then that means it's a first call.

If T=unify then a and b are the terms to unify.

etc...

Definition at line 638 of file login.c.

References wl_goal::aaaa_1, wl_goal::bbbb_1, wl_goal::cccc_1, choice_stack, FALSE, global_time_stamp, wl_choice_point::goal_stack, goal_stack, wl_goal::next, wl_choice_point::next, wl_goal::pending, STACK_ALLOC, stack_pointer, wl_choice_point::stack_top, wl_choice_point::time_stamp, wl_goal::type, wl_choice_point::undo_point, and undo_stack.

639 {
640  ptr_goal alternative;
641  ptr_choice_point choice;
642  GENERIC top_loc;
643 
644  alternative=STACK_ALLOC(goal);
645 
646  alternative->type=t;
647  alternative->aaaa_1=aaaa_6;
648  alternative->bbbb_1=bbbb_6;
649  alternative->cccc_1=cccc_6;
650  alternative->next=goal_stack;
651  alternative->pending=FALSE;
652 
653  top_loc=stack_pointer;
654 
655  choice=STACK_ALLOC(choice_point);
656 
657  choice->undo_point=undo_stack;
658  choice->goal_stack=alternative;
659  choice->next=choice_stack;
660  choice->stack_top=top_loc;
661 
662 #ifdef TS
663  choice->time_stamp=global_time_stamp; /* 9.6 */
664  global_time_stamp++; /* 9.6 */
665 #endif
666 
667  choice_stack=choice;
668 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_goal goal_stack
Definition: def_glob.h:1025
GENERIC cccc_1
Definition: def_struct.h:241
ptr_stack undo_point
Definition: def_struct.h:248
GENERIC stack_top
Definition: def_struct.h:251
unsigned long time_stamp
Definition: def_struct.h:247
ptr_choice_point next
Definition: def_struct.h:250
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
goals type
Definition: def_struct.h:238
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_goal goal_stack
Definition: def_struct.h:249
unsigned long global_time_stamp
Definition: login.c:28
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_definition pending
Definition: def_struct.h:243
ptr_choice_point choice_stack
Definition: def_glob.h:1026
ptr_goal next
Definition: def_struct.h:242
void push_def_ptr_value ( ptr_psi_term  q,
GENERIC p 
)

push_def_ptr_value

Parameters
q- ptr_psi_term q
p- GENERIC *p

PUSH_DEF_PTR_VALUE(q,p) (9.6) Same as push_ptr_value, but only for psi-terms whose definition field is being modified. (If another field is modified, use push_ptr_value.) This routine implements the time-stamp technique of only trailing once between choice point creations, even on multiple bindings. q is address of psi-term, p is address of field inside psi-term that is modified. Both the definition and the time_stamp must be trailed.

Definition at line 416 of file login.c.

References wl_stack::aaaa_3, assert, wl_stack::bbbb_3, choice_stack, def_ptr, global_time_stamp, heap_pointer, int_ptr, wl_stack::next, push_ptr_value(), STACK_ALLOC, stack_pointer, trail_condition(), wl_stack::type, undo_stack, and VALID_ADDRESS.

417 {
418  ptr_stack m,n;
419 
420  assert(VALID_ADDRESS(q));
421  assert(VALID_ADDRESS(p));
422 #ifdef TS
423  if (trail_condition(q) &&
424  /* (q->time_stamp != global_time_stamp) && */
425  (p < (GENERIC *)choice_stack || p > (GENERIC *)stack_pointer))
426  {
427 #define TRAIL_TS
428 #ifdef TRAIL_TS
429 
430  assert((GENERIC)q<heap_pointer); /* RM: Feb 15 1993 */
431 
432  m=STACK_ALLOC(stack); /* Trail time_stamp */
433  m->type=int_ptr;
434  m->aaaa_3= (GENERIC *) &(q->time_stamp);
435  m->bbbb_3= (GENERIC *) (q->time_stamp);
436  m->next=undo_stack;
437  n=STACK_ALLOC(stack); /* Trail definition field (top of undo_stack) */
438  n->type=def_ptr;
439  n->aaaa_3= p;
440  n->bbbb_3= (GENERIC *)*p;
441  n->next=m;
442  undo_stack=n;
443 #else
444  n=STACK_ALLOC(stack); /* Trail definition field (top of undo_stack) */
445  n->type=def_ptr;
446  n->aaaa_3= p;
447  n->bbbb_3= (GENERIC *) *p;
448  n->next=undo_stack;
449  undo_stack=n;
450 #endif
451  q->time_stamp=global_time_stamp;
452  }
453 #else
455 #endif
456 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
#define VALID_ADDRESS(A)
Definition: def_macro.h:137
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
#define def_ptr
values of type_ptr
Definition: def_const.h:404
GENERIC * bbbb_3
Definition: def_struct.h:233
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
long trail_condition(psi_term *Q)
trail_condition
Definition: login.c:2630
type_ptr type
Definition: def_struct.h:231
#define STACK_ALLOC(A)
Definition: def_macro.h:21
GENERIC * aaaa_3
Definition: def_struct.h:232
unsigned long global_time_stamp
Definition: login.c:28
ptr_stack next
Definition: def_struct.h:234
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
ptr_choice_point choice_stack
Definition: def_glob.h:1026
#define assert(N)
Definition: memory.c:114
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void push_goal ( goals  t,
ptr_psi_term  aaaa_5,
ptr_psi_term  bbbb_5,
GENERIC  cccc_5 
)

push_goal

Parameters
t- goals t
aaaa_5ptr_psi_term aaaa_5
bbbb_5ptr_psi_term bbbb_5
cccc_5GENERIC cccc_5

PUSH_GOAL(t,a,b,c) Push a goal onto the goal stack. T is the type of the goal, A,B and C are various parameters. See PUSH_CHOICE_POINT(t,a,b,c).

Definition at line 600 of file login.c.

References wl_goal::aaaa_1, wl_goal::bbbb_1, wl_goal::cccc_1, FALSE, goal_stack, wl_goal::next, wl_goal::pending, STACK_ALLOC, and wl_goal::type.

601 {
602  ptr_goal thegoal;
603 
604  thegoal=STACK_ALLOC(goal);
605 
606  thegoal->type=t;
607  thegoal->aaaa_1=aaaa_5;
608  thegoal->bbbb_1=bbbb_5;
609  thegoal->cccc_1=cccc_5;
610  thegoal->next=goal_stack;
611  thegoal->pending=FALSE;
612 
613  goal_stack=thegoal;
614 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_goal goal_stack
Definition: def_glob.h:1025
GENERIC cccc_1
Definition: def_struct.h:241
goals type
Definition: def_struct.h:238
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_definition pending
Definition: def_struct.h:243
ptr_goal next
Definition: def_struct.h:242
void push_psi_ptr_value ( ptr_psi_term  q,
GENERIC p 
)

push_psi_ptr_value

Parameters
q- ptr_psi_term q
p- GENERIC *p

PUSH_PSI_PTR_VALUE(q,p) (9.6) Same as push_ptr_value, but only for psi-terms whose coref field is being modified. (If another field is modified, use push_ptr_value.) This routine implements the time-stamp technique of only trailing once between choice point creations, even on multiple bindings. q is address of psi-term, p is address of field inside psi-term that is modified. Both the coref and the time_stamp must be trailed.

Definition at line 474 of file login.c.

References wl_stack::aaaa_3, assert, wl_stack::bbbb_3, choice_stack, global_time_stamp, int_ptr, wl_stack::next, psi_term_ptr, push_ptr_value(), STACK_ALLOC, stack_pointer, trail_condition(), wl_stack::type, undo_stack, and VALID_ADDRESS.

475 {
476  ptr_stack m,n;
477 
478  assert(VALID_ADDRESS(q));
479  assert(VALID_ADDRESS(p));
480 #ifdef TS
481  if (trail_condition(q) &&
482  /* (q->time_stamp != global_time_stamp) && */
483  (p < (GENERIC *)choice_stack || p > (GENERIC *)stack_pointer))
484  {
485 #define TRAIL_TS
486 #ifdef TRAIL_TS
487  m=STACK_ALLOC(stack); /* Trail time_stamp */
488  m->type=int_ptr;
489  m->aaaa_3= (GENERIC *) &(q->time_stamp);
490  m->bbbb_3= (GENERIC *) (q->time_stamp);
491  m->next=undo_stack;
492  n=STACK_ALLOC(stack); /* Trail coref field (top of undo_stack) */
493  n->type=psi_term_ptr;
494  n->aaaa_3= (GENERIC *) p;
495  n->bbbb_3= (GENERIC *) *p;
496  n->next=m;
497  undo_stack=n;
498 #else
499  n=STACK_ALLOC(stack); /* Trail coref field (top of undo_stack) */
500  n->type=psi_term_ptr;
501  n->aaaa_3= (ptr_psi_term)p;
502  n->bbbb_3= *p;
503  n->next=undo_stack;
504  undo_stack=n;
505 #endif
506  q->time_stamp=global_time_stamp;
507  }
508 #else
510 #endif
511 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
#define VALID_ADDRESS(A)
Definition: def_macro.h:137
GENERIC * bbbb_3
Definition: def_struct.h:233
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
long trail_condition(psi_term *Q)
trail_condition
Definition: login.c:2630
type_ptr type
Definition: def_struct.h:231
#define STACK_ALLOC(A)
Definition: def_macro.h:21
GENERIC * aaaa_3
Definition: def_struct.h:232
unsigned long global_time_stamp
Definition: login.c:28
ptr_stack next
Definition: def_struct.h:234
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
ptr_choice_point choice_stack
Definition: def_glob.h:1026
#define assert(N)
Definition: memory.c:114
#define psi_term_ptr
values of type_ptr
Definition: def_const.h:383
#define int_ptr
values of type_ptr
Definition: def_const.h:397
push_ptr_value ( type_ptr  t,
GENERIC p 
)

push_ptr_value

Parameters
t- type_ptr t
p- GENERIC *p

PUSH_PTR_VALUE(t,*p) Push the pair (P,*P) onto the stack of things to be undone (trail). It needn't be done if P is greater than the latest choice point because in that case memory is reclaimed.

Definition at line 383 of file login.c.

References wl_stack::aaaa_3, assert, wl_stack::bbbb_3, choice_stack, heap_pointer, wl_stack::next, STACK_ALLOC, stack_pointer, wl_stack::type, undo_stack, and VALID_ADDRESS.

384 {
385  ptr_stack n;
386 
387  assert(p<(GENERIC *)heap_pointer); /* RM: Feb 15 1993 */
388 
389  assert(VALID_ADDRESS(p));
390  if (p < (GENERIC *)choice_stack || p > (GENERIC *)stack_pointer)
391  {
392  n=STACK_ALLOC(stack);
393  n->type=t;
394  n->aaaa_3= (GENERIC *) p;
395  n->bbbb_3= (GENERIC *) *p;
396  n->next=undo_stack;
397  undo_stack=n;
398  }
399 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
#define VALID_ADDRESS(A)
Definition: def_macro.h:137
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
GENERIC * bbbb_3
Definition: def_struct.h:233
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
type_ptr type
Definition: def_struct.h:231
#define STACK_ALLOC(A)
Definition: def_macro.h:21
GENERIC * aaaa_3
Definition: def_struct.h:232
ptr_stack next
Definition: def_struct.h:234
ptr_choice_point choice_stack
Definition: def_glob.h:1026
#define assert(N)
Definition: memory.c:114
void push_ptr_value_global ( type_ptr  t,
GENERIC p 
)

push_ptr_value_global

Parameters
t- type_ptr t
p- GENERIC *p

Same as push_ptr_value, but for objects that must always be trailed. This includes objects outside of the Life data space and entries in the var_tree.

Definition at line 523 of file login.c.

References wl_stack::aaaa_3, assert, wl_stack::bbbb_3, wl_stack::next, STACK_ALLOC, wl_stack::type, undo_stack, and VALID_ADDRESS.

524 {
525  ptr_stack n;
526 
527  assert(VALID_ADDRESS(p)); /* 17.8 */
528  n=STACK_ALLOC(stack);
529  n->type=t;
530  n->aaaa_3= (GENERIC *) p;
531  n->bbbb_3= (GENERIC *) *p;
532  n->next=undo_stack;
533  undo_stack=n;
534 }
#define VALID_ADDRESS(A)
Definition: def_macro.h:137
GENERIC * bbbb_3
Definition: def_struct.h:233
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
type_ptr type
Definition: def_struct.h:231
#define STACK_ALLOC(A)
Definition: def_macro.h:21
GENERIC * aaaa_3
Definition: def_struct.h:232
ptr_stack next
Definition: def_struct.h:234
#define assert(N)
Definition: memory.c:114
void push_window ( long  type,
long  disp,
long  wind 
)

push_window

Parameters
type- long type
disp- long disp
wind- long wind

PUSH_WINDOW(type,disp,wind) Push the window information (operation, display and window identifiers) on the undo_stack (trail) so that the window can be destroyed, redrawn, or hidden on backtracking.

Definition at line 548 of file login.c.

References wl_stack::aaaa_3, assert, wl_stack::bbbb_3, wl_stack::next, STACK_ALLOC, wl_stack::type, undo_action, and undo_stack.

549 {
550  ptr_stack n;
551 
552  assert(type & undo_action);
553  n=STACK_ALLOC(stack);
554  n->type=type;
555  n->aaaa_3=(GENERIC *)disp;
556  n->bbbb_3=(GENERIC *)wind;
557  n->next=undo_stack;
558  undo_stack=n;
559 }
GENERIC * bbbb_3
Definition: def_struct.h:233
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
type_ptr type
Definition: def_struct.h:231
#define STACK_ALLOC(A)
Definition: def_macro.h:21
GENERIC * aaaa_3
Definition: def_struct.h:232
#define undo_action
Fast checking for an undo action.
Definition: def_const.h:484
ptr_stack next
Definition: def_struct.h:234
#define assert(N)
Definition: memory.c:114
void put_back_char ( long  c)

put_back_char

Parameters
c- long c

PUT_BACK_CHAR Put back one character, if there already are 2 saved characters then report an error (= bug).

Definition at line 729 of file token.c.

References Errorline(), old_saved_char, and saved_char.

730 {
731  if (old_saved_char)
732  Errorline("in tokenizer, put_back_char three times (last=%d).\n",c);
734  saved_char=c;
735 }
long old_saved_char
Definition: def_glob.h:850
long saved_char
Definition: def_glob.h:849
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
void put_back_token ( psi_term  t)

put_back_token

Parameters
t- psi_term t

PUT_BACK_TOKEN Put back a psi_term, if there already are two saved then report an error (= bug).

Definition at line 746 of file token.c.

References Errorline(), NULL, old_saved_psi_term, saved_psi_term, and stack_copy_psi_term().

747 {
749  Errorline("in parser, put_back_token three times (last=%P).\n",t);
752 }
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
ptr_psi_term quote_copy ( ptr_psi_term  t,
long  heap_flag 
)

quote_copy

Parameters
t- ptr_psi_term t
heap_flag- long heap_flag

Definition at line 186 of file copy.c.

References copy(), FALSE, QUOTE_FLAG, and to_heap.

187 { to_heap=FALSE; return (copy(t, QUOTE_FLAG, heap_flag)); }
ptr_psi_term copy(ptr_psi_term t, long copy_flag, long heap_flag)
copy
Definition: copy.c:248
long to_heap
Definition: def_glob.h:905
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define QUOTE_FLAG
flag to copy function in copy.c to indicate kind of copy
Definition: def_const.h:1313
ptr_psi_term quotedStackCopy ( psi_term  p)

Definition at line 528 of file bi_sys.c.

References mark_quote(), and stack_copy_psi_term().

529 {
530  ptr_psi_term q;
531 
533  mark_quote(q);
534  return q;
535 }
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
void mark_quote(ptr_psi_term t)
mark_quote
Definition: copy.c:674
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
void raw_setup_builtins ( )

raw_setup_builtins

set up the built-ins for the mode raw

Definition at line 303 of file raw.c.

References bi_module, c_begin_raw(), c_end_raw(), c_get_raw(), c_in_raw(), c_put_raw(), c_reset_window_flag(), c_window_flag(), function_it, and new_built_in().

304 {
305 #ifndef NORAW
306  new_built_in(bi_module,"begin_raw", predicate, c_begin_raw);
307  new_built_in(bi_module,"get_raw", predicate, c_get_raw);
308  new_built_in(bi_module,"put_raw", predicate, c_put_raw);
309  new_built_in(bi_module,"end_raw", predicate, c_end_raw);
312  new_built_in(bi_module,"reset_window_flag", predicate, c_reset_window_flag);
313 #endif
314 }
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
long c_end_raw()
long c_in_raw()
long c_reset_window_flag()
long c_put_raw()
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
long c_get_raw()
long c_window_flag()
long c_begin_raw()
long read_char ( )

read_char

READ_CHAR Return the char read from the input stream, if end of file reached then return EOF. If stringparse==TRUE then read characters from the input string instead of from a file.

Definition at line 680 of file token.c.

References EOLN, FALSE, infoline(), input_stream, line_count, NULL, old_saved_char, prompt, saved_char, start_of_line, stringinput, stringparse, trace_input, and TRUE.

681 {
682  int c=0;
683 
684  if ((c=saved_char)) {
686  old_saved_char=0;
687  }
688  else if (stringparse) {
689  if ((c=(*stringinput)))
690  stringinput++;
691  else
692  c=EOF;
693  }
694  else if (input_stream == NULL || feof(input_stream))
695  c=EOF;
696  else {
697  if (start_of_line) {
699  line_count++;
700  if (input_stream==stdin) infoline("%s",prompt); /* 21.1 */
701  }
702 
703  c=fgetc(input_stream);
704 
705  if(trace_input) /* RM: Jan 13 1993 */
706  if(c!=EOF)
707  printf("%c",c);
708  else
709  printf(" <EOF>\n");
710 
711  if (c==EOLN)
713  }
714 
715  /* printf("%c\n",c); RM: Jan 5 1993 Just to trace the parser */
716 
717  return c;
718 }
long old_saved_char
Definition: def_glob.h:850
#define NULL
Definition: def_const.h:533
long saved_char
Definition: def_glob.h:849
long trace_input
Definition: token.c:12
long line_count
Definition: def_glob.h:1015
#define EOLN
End of line.
Definition: def_const.h:309
void infoline(char *format,...)
infoline
Definition: error.c:281
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
FILE * input_stream
Definition: def_glob.h:1014
long start_of_line
???
Definition: def_glob.h:846
char * prompt
Definition: def_glob.h:1018
long stringparse
Definition: def_glob.h:859
char * stringinput
Definition: def_glob.h:860
void read_comment ( ptr_psi_term  tok)

read_comment

Parameters
tok- ptr_psi_term tok

READ_COMMENT Read a comment starting with '' to the end of the line.

Definition at line 779 of file token.c.

References comment, EOLN, read_char(), and wl_psi_term::type.

780 {
781  long c;
782 
783  do {
784  c=read_char();
785  } while (c!=EOF && c!=EOLN);
786 
787  tok->type=comment;
788 }
ptr_definition comment
symbol in bi module
Definition: def_glob.h:227
#define EOLN
End of line.
Definition: def_const.h:309
ptr_definition type
Definition: def_struct.h:181
long read_char()
read_char
Definition: token.c:680
psi_term read_life_form ( char  ch1,
char  ch2 
)

read_life_form

Parameters
ch1- char ch1
ch2- char ch2

READ_LIFE_FORM(str1,str2) This reads in one life-form from the input stream which finishes with the psi_term whose name is STR1 or STR2, typically if we're reading a list [A,4*5,b-4!] then STR1="," and STR2="|" . It would be incorrect if "," were taken as an operator.

This routine implements the two state expression parser as described in the implementation guide. It deals with all the various types of operators, precedence is dealt with by the CRUNCH function. Each time an opening parenthesis is encountered a new expression is started.

Definition at line 728 of file parser.c.

References wl_psi_term::attr_list, bad_psi_term(), crunch(), equ_tokc, equ_tokch, error_psi_term, FALSE, fx, fy, line_count, MAX_PRECEDENCE, nop, NOP, parse_ok, parser_stack_index, pop(), precedence(), push(), put_back_token(), read_psi_term(), read_token(), stringparse, Syntaxerrorline(), TRUE, xf, xfx, xfy, yf, and yfx.

729 {
730  psi_term t,t2;
731  long limit,pr_op,pr_1,pr_2,start=0;
732  long fin=FALSE;
733  long state=0;
734  long prec=0;
735 
736  long op;
737 
738  limit=parser_stack_index+1;
739 
740  if (parse_ok)
741  do {
742  if (state)
743  read_token(&t);
744  else
745  t=read_psi_term();
746 
747  if (!start)
748  start=line_count;
749 
750  if (!fin)
751  if (state) {
752  if (equ_tokc(t,ch1) || equ_tokc(t,ch2)) {
753  fin=TRUE;
754  put_back_token(t);
755  }
756  else {
757  pr_op=precedence(t,xf);
758  pr_1=pr_op-1;
759 
760  if(pr_op==NOP) {
761  pr_op=precedence(t,yf);
762  pr_1=pr_op;
763  }
764 
765  if(pr_op==NOP) {
766 
767  pr_op=precedence(t,xfx);
768  pr_1=pr_op-1;
769  pr_2=pr_op-1;
770 
771  if(pr_op==NOP) {
772  pr_op=precedence(t,xfy);
773  pr_1=pr_op-1;
774  pr_2=pr_op;
775  }
776 
777  if(pr_op==NOP) {
778  pr_op=precedence(t,yfx);
779  pr_1=pr_op;
780  pr_2=pr_op-1;
781  }
782 
783  /* if(pr_op==NOP) {
784  pr_op=precedence(t,yfy);
785  pr_1=pr_op;
786  pr_2=pr_op-1;
787  }
788  */
789 
790  if(pr_op==NOP) {
791  fin=TRUE;
792  put_back_token(t);
793  }
794  else
795  {
796  crunch(pr_1,limit);
797  push(t,pr_2,xfx);
798  prec=pr_2;
799  state=0;
800  }
801  }
802  else {
803  crunch(pr_1,limit);
804  push(t,pr_1,xf);
805  prec=pr_1;
806  }
807  }
808  }
809  else {
810 
811  if(t.attr_list)
812  pr_op=NOP;
813  else {
814  pr_op=precedence(t,fx);
815  pr_2=pr_op-1;
816 
817  if(pr_op==NOP) {
818  pr_op=precedence(t,fy);
819  pr_2=pr_op;
820  }
821  }
822 
823  if(pr_op==NOP) {
824  if(equ_tokch(t,'(')) {
825  t2=read_life_form(')',0);
826  if(parse_ok) {
827  push(t2,prec,nop);
828  read_token(&t2);
829  if(!equ_tokch(t2,')')) {
831  else {
832  /*
833  perr("*** Syntax error ");psi_term_error();
834  perr(": ')' missing.\n");
835  */
836 
837  /* RM: Feb 1 1993 */
838  Syntaxerrorline("')' missing (%E)\n");
839 
840  put_back_token(t2);
841  }
842  }
843  state=1;
844  }
845  }
846  else
847  if(bad_psi_term(&t)) {
848  put_back_token(t);
849  /* psi_term_error(); */
850  fin=TRUE;
851  }
852  else {
853  push(t,prec,nop);
854  state=1;
855  }
856  }
857  else {
858  push(t,pr_2,fx);
859  prec=pr_2;
860  }
861 
862  }
863 
864  } while (!fin && parse_ok);
865 
866  if (state)
867  crunch(MAX_PRECEDENCE,limit);
868 
869  if (parse_ok && parser_stack_index!=limit) {
871  else {
872  /*
873  perr("*** Syntax error ");psi_term_error();
874  perr(": bad expression.\n");
875  */
876 
877  /* RM: Feb 1 1993 */
878  Syntaxerrorline("bad expression (%E)\n");
879  }
880  }
881  else
882  (void)pop(&t,&op);
883 
884  if (!parse_ok)
885  t= *error_psi_term;
886 
887  parser_stack_index=limit-1;
888 
889  return t;
890 }
#define yfx
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1037
#define equ_tokc(A, B)
Definition: def_macro.h:76
void read_token(ptr_psi_term tok)
read_token
Definition: token.c:1186
#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 NOP
returned by precedence if token is not an operator
Definition: def_const.h:1337
void push(psi_term tok, long prec, long op)
push
Definition: parser.c:107
long precedence(psi_term tok, long typ)
precedence
Definition: parser.c:180
#define xfy
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:1030
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
#define nop
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:986
void put_back_token(psi_term t)
put_back_token
Definition: token.c:746
long line_count
Definition: def_glob.h:1015
psi_term read_life_form(char ch1, char ch2)
read_life_form
Definition: parser.c:728
void Syntaxerrorline(char *format,...)
Syntaxerrorline.
Definition: error.c:557
#define TRUE
Standard boolean.
Definition: def_const.h:268
long pop(ptr_psi_term tok, long *op)
pop
Definition: parser.c:132
void crunch(long prec, long limit)
crunch
Definition: parser.c:662
int bad_psi_term(ptr_psi_term t)
bad_psi_term
Definition: parser.c:31
#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
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
#define MAX_PRECEDENCE
Maximum operator precedence.
Definition: def_const.h:205
long parser_stack_index
index to parser stack
Definition: def_glob.h:164
long stringparse
Definition: def_glob.h:859
psi_term read_psi_term()
read_psi_term
Definition: parser.c:421
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
#define equ_tokch(A, B)
Definition: def_macro.h:71
void read_name ( ptr_psi_term  tok,
long  ch,
long(*)()  f,
ptr_definition  typ 
)
void read_number ( ptr_psi_term  tok,
long  c 
)

read_number

Parameters
tok- ptr_psi_term tok
c- long c

READ_NUMBER(c) Read in the number whose first character is c. Accepted syntax: digit+ [ . digit+ ] [ {e|E} {+|-|empty} digit* ] Negative numbers are dealt with in the parser.

Definition at line 1110 of file token.c.

References DIGIT, heap_alloc(), integer, put_back_char(), read_char(), REAL, real, wl_psi_term::type, and wl_psi_term::value_3.

1111 {
1112  long c2;
1113  REAL f,p;
1114  long /* sgn, */ pwr,posflag;
1115 
1116  /* if (sgn=(c=='-')) c=read_char(); */
1117 
1118  /* tok->type=integer; RM: Mar 8 1993 */
1119 
1120  f=0.0;
1121  do { f=f*10.0+(c-'0'); c=read_char(); } while (DIGIT(c));
1122 
1123  if (c=='.') {
1124  c2=read_char();
1125  if DIGIT(c2) {
1126  /* tok->type=real; RM: Mar 8 1993 */
1127  p=10.0;
1128  while (DIGIT(c2)) { f=f+(c2-'0')/p; p=p*10.0; c2=read_char(); }
1129  put_back_char(c2);
1130  }
1131  else {
1132  put_back_char(c2);
1133  put_back_char(c);
1134  }
1135  }
1136  else
1137  put_back_char(c);
1138 
1139  c=read_char();
1140  if (c=='e' || c=='E') {
1141  c2=read_char();
1142  if (c2=='+' || c2=='-' || DIGIT(c2)) {
1143  tok->type=real;
1144  posflag = (c2=='+' || DIGIT(c2));
1145  if (!DIGIT(c2)) c2=read_char();
1146  pwr=0;
1147  while (DIGIT(c2)) { pwr=pwr*10+(c2-'0'); c2=read_char(); }
1148  put_back_char(c2);
1149  p=1.0;
1150  while (pwr>=100) { pwr-=100; if (posflag) p*=1e100; else p/=1e100; }
1151  while (pwr>=10 ) { pwr-=10; if (posflag) p*=1e10; else p/=1e10; }
1152  while (pwr>0 ) { pwr-=1; if (posflag) p*=1e1; else p/=1e1; }
1153  f*=p;
1154  }
1155  else {
1156  put_back_char(c2);
1157  put_back_char(c);
1158  }
1159  }
1160  else
1161  put_back_char(c);
1162 
1163  /* if (sgn) f = -f; */
1164  tok->value_3=heap_alloc(sizeof(REAL)); /* 12.5 */
1165  *(REAL *)tok->value_3=f;
1166 
1167  /* RM: Mar 8 1993 */
1168  if(f==floor(f))
1169  tok->type=integer;
1170  else
1171  tok->type=real;
1172 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define DIGIT(C)
Definition: def_macro.h:42
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
long read_char()
read_char
Definition: token.c:680
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void put_back_char(long c)
put_back_char
Definition: token.c:729
psi_term read_psi_term ( )

read_psi_term

READ_PSI_TERM() This reads in a complex object from the input stream, that is, a whole psi-term.

Examples:

[A,B,C]

{0;1;2+A}

<a,b,c> death(victim => V,murderer => M)

which(x,y,z)

A:g(f)

I have allowed mixing labelled with unlabelled attributes.

Example:

f(x=>A,B,y=>K,"hklk",D) is parsed as f(1=>B,2=>"hklk",3=>D,x=>A,y=>K).

Definition at line 421 of file parser.c.

References add_module1, add_module2, add_module3, alist, apply, wl_psi_term::attr_list, bad_psi_term(), wl_keyword::combined_name, wl_psi_term::coref, current_module, disjunction, eof, equ_tok, equ_tokch, equal_types, error_psi_term, FALSE, FEATCMP, feature_insert(), find(), functor, heap_copy_string(), integer, wl_definition::keyword, wl_module::module_name, NULL, parse_list(), parse_ok, wl_keyword::private_feature, put_back_token(), quoted_string, read_life_form(), read_token(), REAL, wl_psi_term::resid, stack_copy_psi_term(), stack_insert(), stack_psi_term(), stringparse, wl_keyword::symbol, Syntaxerrorline(), TRUE, two, wl_psi_term::type, wl_psi_term::value_3, variable, and wl_const_3.

422 {
423  psi_term t,t2,t3;
424  char s[10];
425  long count=0,f=TRUE,f2,v;
426  ptr_psi_term module;
427 
428  if(parse_ok) {
429 
430  read_token(&t);
431 
432  if(equ_tokch(t,'['))
433  t=parse_list(alist,']',','); /*** RICHARD Nov_4 ***/
434  else
435  if(equ_tokch(t,'{'))
436  t=parse_list(disjunction,'}',';'); /*** RICHARD Nov_4 ***/
437 
438  /* The syntax <a,b,c> for conjunctions has been abandoned.
439  else
440  if(equ_tokch(t,'<'))
441  t=parse_list(conjunction,'>',',');
442  */
443 
444  if(parse_ok
445  && t.type!=eof
446  && !bad_psi_term(&t)
447  /* && (precedence(t,fx)==NOP)
448  && (precedence(t,fy)==NOP) */
449  ) {
450  read_token(&t2);
451  if(equ_tokch(t2,'(')) {
452 
453  do {
454 
455  f2=TRUE;
456  read_token(&t2);
457 
458  if(wl_const_3(t2) && !bad_psi_term(&t2)) {
459  read_token(&t3);
460  if(equ_tok(t3,"=>")) {
461  t3=read_life_form(',',')');
462 
463  if(t2.type->keyword->private_feature) /* RM: Mar 11 1993 */
465  /* RM: Jan 13 1993 */
466  &(t.attr_list),
467  &t3);
468  else
470  /* RM: Jan 13 1993 */
471  &(t.attr_list),
472  &t3);
473 
474  f2=FALSE;
475  }
476  else
477  put_back_token(t3);
478  }
479 
480  if(parse_ok && equal_types(t2.type,integer)) {
481  read_token(&t3);
482  if(equ_tok(t3,"=>")) {
483  t3=read_life_form(',',')');
484  v= *(REAL *)t2.value_3;
485  (void)snprintf(s,10,"%ld",v);
486  feature_insert(s,&(t.attr_list),&t3);
487  f2=FALSE;
488  }
489  else
490  put_back_token(t3);
491  }
492 
493  if(f2) {
494  put_back_token(t2);
495  t2=read_life_form(',',')');
496  ++count;
497  (void)snprintf(s,10,"%ld",count);
498  feature_insert(s,&(t.attr_list),&t2);
499  }
500 
501  read_token(&t2);
502 
503  if(equ_tokch(t2,')'))
504  f=FALSE;
505  else
506  if(!equ_tokch(t2,',')) {
508  else {
509  /*
510  perr("*** Syntax error ");psi_term_error();
511  perr(": ',' expected in argument list.\n");
512  */
513 
514  /* RM: Feb 1 1993 */
515  Syntaxerrorline("',' expected in argument list (%E)\n");
516 
517  f=FALSE;
518  }
519  }
520 
521  } while(f && parse_ok);
522  }
523  else
524  put_back_token(t2);
525  }
526  }
527  else
528  t= *error_psi_term;
529 
530  if(t.type==variable && t.attr_list) {
531  t2=t;
532  t.type=apply;
533  t.value_3=NULL;
534  t.coref=NULL;
535  t.resid=NULL;
536  (void)stack_insert(FEATCMP,(char *)functor->keyword->symbol,
537  &(t.attr_list),
539  }
540 
541 
542  /* RM: Mar 12 1993 Nasty hack for Bruno's features in modules */
543  if((t.type==add_module1 || t.type==add_module2 || t.type==add_module3) &&
544  !find(FEATCMP,two,t.attr_list)) {
545 
546  module=stack_psi_term(4);
547  module->type=quoted_string;
549 
550  (void)stack_insert(FEATCMP,two,&(t.attr_list),(GENERIC)module);
551  }
552 
553  return t;
554 }
ptr_definition disjunction
symbol in bi module
Definition: def_glob.h:249
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
ptr_residuation resid
Definition: def_struct.h:189
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition apply
symbol in bi module
Definition: def_glob.h:178
void read_token(ptr_psi_term tok)
read_token
Definition: token.c:1186
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
ptr_definition functor
symbol in bi module
Definition: def_glob.h:298
char * combined_name
Definition: def_struct.h:119
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
char * two
Definition: def_glob.h:892
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
ptr_definition add_module3
symbol in bi module for feature_values
Definition: def_glob.h:157
ptr_definition add_module2
symbol in bi module for str2psi
Definition: def_glob.h:150
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
psi_term parse_list(ptr_definition typ, char e, char s)
parse_list
Definition: parser.c:329
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
char * symbol
Definition: def_struct.h:118
void put_back_token(psi_term t)
put_back_token
Definition: token.c:746
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
psi_term read_life_form(char ch1, char ch2)
read_life_form
Definition: parser.c:728
void feature_insert(char *keystr, ptr_node *tree, ptr_psi_term psi)
feature_insert
Definition: parser.c:251
ptr_definition variable
symbol in bi module
Definition: def_glob.h:438
#define wl_const_3(S)
Definition: def_macro.h:109
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
void Syntaxerrorline(char *format,...)
Syntaxerrorline.
Definition: error.c:557
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
int bad_psi_term(ptr_psi_term t)
bad_psi_term
Definition: parser.c:31
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition add_module1
symbol in bi module for features
Definition: def_glob.h:143
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
char * module_name
Definition: def_struct.h:106
ptr_psi_term coref
Definition: def_struct.h:188
#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
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
int private_feature
Definition: def_struct.h:121
#define equ_tok(A, B)
Definition: def_macro.h:67
long stringparse
Definition: def_glob.h:859
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
#define equ_tokch(A, B)
Definition: def_macro.h:71
void read_string ( ptr_psi_term  tok,
long  e 
)

read_string

Parameters
tok- ptr_psi_term tok
e- long e

READ_STRING(e) Read a string ending with character E, where E=" or '. Transform a double occurrence into a single one so that 'ab""cd' is the string 'ab"cd'.

Definition at line 859 of file token.c.

References base2int(), FALSE, heap_copy_string(), isoctal, NULL, put_back_char(), read_char(), read_string_error(), STRLEN, TOKEN_ERROR(), TRUE, wl_psi_term::type, update_symbol(), wl_psi_term::value_3, and warningline().

860 {
861  long c;
862  string str;
863  long len=0;
864  long store=TRUE;
865  long flag=TRUE;
866 
867  str[len]=0;
868 
869  do {
870  c=read_char();
871  if (c==EOF) {
872  store=FALSE;
873  flag=FALSE;
875  }
876  else if (e=='"' && c=='\\') {
877  c=read_char();
878  if (c==EOF) {
879  store=FALSE;
880  flag=FALSE;
881  put_back_char('\\');
883  }
884  else {
885  switch (c) {
886  case 'a': c='\a'; break;
887  case 'b': c='\b'; break;
888  case 'f': c='\f'; break;
889  case 'n': c='\n'; break;
890  case 'r': c='\r'; break;
891  case 't': c='\t'; break;
892  case 'v': c='\v'; break;
893  /* missing \ooo and \xhh */
894  case 'x':
895  {
896  int n;
897  c=read_char();
898  if (c==EOF) {
899  store=flag=FALSE;
901  break;
902  }
903  else if (!isxdigit(c)) {
904  store=flag=FALSE;
906  break;
907  }
908  else {
909  n = base2int(c);
910  }
911  c=read_char();
912  if (isxdigit(c)) n = 16*n+base2int(c);
913  else put_back_char(c);
914  c=n;
915  break;
916  }
917  default:
918  if (isoctal(c)) {
919  int n,i;
920  for(i=n=0;i<3&&isoctal(c);i++,c=read_char())
921  n = n*8 + base2int(c);
922  if (c!=EOF) put_back_char(c);
923  c=n;
924  break;
925  }
926  else break;
927  }
928  }
929  }
930  else
931  if (c==e) {
932  c=read_char();
933  if (c!=e) {
934  store=FALSE;
935  flag=FALSE;
936  put_back_char(c);
937  }
938  }
939  if (store)
940  if (len==STRLEN) {
941  warningline("string too long, extra ignored (%E).\n");
942  store=FALSE;
943  }
944  else {
945  str[len++]=c;
946  str[len]=0;
947  }
948  } while(flag);
949 
950  if (e=='"')
951  tok->value_3=(GENERIC)heap_copy_string(str);
952  else {
953  tok->type=update_symbol(NULL,str); /* Maybe no_module would be better */
954  tok->value_3=NULL;
955  TOKEN_ERROR(tok); /* RM: Feb 1 1993 */
956  }
957 }
int base2int(int n)
base2int
Definition: token.c:816
#define NULL
Definition: def_const.h:533
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
void read_string_error(int n)
read_string_error
Definition: token.c:796
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
#define isoctal(c)
Definition: token.c:847
#define STRLEN
Maximum size of file names and input tokens (which includes input strings) (Note: calculated tokens c...
Definition: def_const.h:162
void TOKEN_ERROR(ptr_psi_term p)
TOKEN_ERROR.
Definition: token.c:38
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
long read_char()
read_char
Definition: token.c:680
void put_back_char(long c)
put_back_char
Definition: token.c:729
void read_string_error ( int  n)

read_string_error

Parameters
n- int n

Definition at line 796 of file token.c.

References FALSE, parse_ok, stringparse, and Syntaxerrorline().

797 {
799  else
800  switch (n) {
801  case 0:
802  Syntaxerrorline("end of file reached before end of string (%E).\n");
803  break;
804  case 1:
805  Syntaxerrorline("Hexadecimal digit expected (%E).\n");
806  break;
807  }
808 }
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
void Syntaxerrorline(char *format,...)
Syntaxerrorline.
Definition: error.c:557
#define FALSE
Standard boolean.
Definition: def_const.h:275
long stringparse
Definition: def_glob.h:859
void read_token ( ptr_psi_term  tok)

read_token

Parameters
tok- ptr_psi_term tok

READ_TOKEN Read in one token from the input stream, represented as a psi_term. Return the psi_term 'end_of_file' if that is the case.

Used in the parser Set prompt to the 'partial input' prompt

Definition at line 1186 of file token.c.

References read_token_main(), and TRUE.

1187 { read_token_main(tok, TRUE); }
void read_token_main(ptr_psi_term tok, long for_parser)
read_token_main
Definition: token.c:1207
#define TRUE
Standard boolean.
Definition: def_const.h:268
void read_token_b ( ptr_psi_term  tok)

read_token_b

Parameters
tok- ptr_psi_term tok

Used as a built-in Prompt is unchanged

Definition at line 1197 of file token.c.

References FALSE, and read_token_main().

1198 { read_token_main(tok, FALSE); }
void read_token_main(ptr_psi_term tok, long for_parser)
read_token_main
Definition: token.c:1207
#define FALSE
Standard boolean.
Definition: def_const.h:275
void read_token_main ( ptr_psi_term  tok,
long  for_parser 
)

read_token_main

Parameters
tok- ptr_psi_term tok
for_parser- long for_parser

Definition at line 1207 of file token.c.

References wl_psi_term::attr_list, bk2_stack_insert(), choice_stack, comment, constant, wl_psi_term::coref, current_module, cut, wl_node::data, DIGIT, eof, EOLN, Errorline(), FALSE, final_dot, final_question, find(), wl_psi_term::flags, legal_in_name(), line_count, LOWER, nothing, NULL, old_saved_psi_term, prompt, psi_term_line_number, put_back_char(), quoted_string, read_char(), read_comment(), read_name(), read_number(), read_string(), read_token(), wl_psi_term::resid, saved_psi_term, SINGLE, stack_psi_term(), wl_psi_term::status, STRCMP, SYMBOL, symbolic(), TOKEN_ERROR(), TRUE, wl_psi_term::type, update_symbol(), UPPER, wl_psi_term::value_3, var_occurred, var_tree, and variable.

1208 {
1209  long c, c2;
1210  ptr_node n;
1211  char p[2];
1212 
1213  if (for_parser && (saved_psi_term!=NULL)) {
1214  *tok= *saved_psi_term;
1217  }
1218  else {
1219  tok->type=nothing;
1220 
1221  do {
1222  c=read_char();
1223  } while(c!=EOF && (c<=32));
1224 
1225  if (for_parser) psi_term_line_number=line_count;
1226 
1227  switch(c) {
1228  case EOF:
1229  tok->type=eof;
1230  tok->value_3=NULL;
1231  break;
1232  case '%':
1233  read_comment(tok);
1234  break;
1235  case '"':
1236  read_string(tok,c);
1237  tok->type=quoted_string;
1238  break;
1239  case 39: /* The quote symbol "'" */
1240  read_string(tok,c);
1241  break;
1242 
1243  default:
1244 
1245  /* Adding this results in problems with terms like (N-1) */
1246  /* if (c=='-' && (c2=read_char()) && DIGIT(c2)) {
1247  put_back_char(c2);
1248  read_number(tok,c);
1249  }
1250  else */
1251 
1252  if(c=='.' || c=='?') { /* RM: Jul 7 1993 */
1253  c2=read_char();
1254  put_back_char(c2);
1255  /*printf("c2=%d\n",c2);*/
1256  if(c2<=' ' || c2==EOF) {
1257  if(c=='.')
1258  tok->type=final_dot;
1259  else
1260  tok->type=final_question;
1261 
1262  tok->value_3=NULL;
1263  }
1264  else
1265  read_name(tok,c,symbolic,constant);
1266  }
1267  else
1268  if DIGIT(c)
1269  read_number(tok,c);
1270  else
1271  if UPPER(c) {
1273  }
1274  else
1275  if LOWER(c) {
1277  }
1278  else
1279  if SYMBOL(c) {
1280  read_name(tok,c,symbolic,constant);
1281  }
1282  else /* RM: Jul 7 1993 Moved this */
1283  if SINGLE(c) {
1284  p[0]=c; p[1]=0;
1286  tok->value_3=NULL;
1287  TOKEN_ERROR(tok); /* RM: Feb 1 1993 */
1288  }
1289  else {
1290  Errorline("illegal character %d in input (%E).\n",c);
1291  }
1292  }
1293 
1294  if (tok->type==variable) {
1295  if (tok->value_3) {
1296  /* If the variable read in has name "_", then it becomes 'top' */
1297  /* and is no longer a variable whose name must be remembered. */
1298  /* As a result, '@' and '_' are synonyms in the program input. */
1299  if (!strcmp((char *)tok->value_3,"_")) {
1300  p[0]='@'; p[1]=0;
1302  tok->value_3=NULL;
1303  TOKEN_ERROR(tok); /* RM: Feb 1 1993 */
1304  }
1305  else {
1306  /* Insert into variable tree, create 'top' value if need be. */
1308  n=find(STRCMP,(char *)tok->value_3,var_tree);
1309  if (n==NULL) {
1311  /* The change is always trailed. */
1312  (void)bk2_stack_insert(STRCMP,(char *)tok->value_3,&var_tree,(GENERIC)t); /* 17.8 */
1313  tok->coref=t;
1314  }
1315  else
1316  tok->coref=(ptr_psi_term)n->data;
1317  }
1318  }
1319  /* else do nothing */
1320  }
1321  }
1322 
1323  if (tok->type==comment)
1324  read_token(tok);
1325 
1326  if (tok->type!=variable)
1327  tok->coref=NULL;
1328 
1329  tok->attr_list=NULL;
1330  tok->status=0;
1331  tok->flags=FALSE; /* 14.9 */
1332  tok->resid=NULL;
1333 
1334  if (tok->type==cut) /* 12.7 */
1336 
1337  do {
1338  c=read_char();
1339  if (c==EOLN) {
1340  if (for_parser) put_back_char(c);
1341  c=0;
1342  }
1343  else if (c<0 || c>32) {
1344  put_back_char(c);
1345  c=0;
1346  }
1347  } while(c && c!=EOF);
1348 
1349  if (for_parser) prompt="| ";
1350 }
ptr_residuation resid
Definition: def_struct.h:189
ptr_definition nothing
symbol in bi module
Definition: def_glob.h:347
ptr_definition final_question
symbol in syntax module
Definition: def_glob.h:615
#define UPPER(C)
Definition: def_macro.h:44
long psi_term_line_number
Definition: def_glob.h:909
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
ptr_definition comment
symbol in bi module
Definition: def_glob.h:227
#define DIGIT(C)
Definition: def_macro.h:42
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
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 bk2_stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
bk2_stack_insert
Definition: trees.c:377
void read_name(ptr_psi_term tok, long ch, long(*f)(long), ptr_definition typ)
read_name
Definition: token.c:1002
void read_string(ptr_psi_term tok, long e)
read_string
Definition: token.c:859
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
#define LOWER(C)
Definition: def_macro.h:46
#define SYMBOL(C)
Definition: def_macro.h:57
long line_count
Definition: def_glob.h:1015
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define EOLN
End of line.
Definition: def_const.h:309
ptr_definition variable
symbol in bi module
Definition: def_glob.h:438
void read_number(ptr_psi_term tok, long c)
read_number
Definition: token.c:1110
ptr_definition final_dot
symbol in syntax module
Definition: def_glob.h:608
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define STRCMP
indicates to use strcmp for comparison (c function)
Definition: def_const.h:963
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
ptr_definition constant
symbol in bi module
Definition: def_glob.h:235
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term coref
Definition: def_struct.h:188
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
long legal_in_name(long c)
legal_in_name
Definition: token.c:980
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
void read_comment(ptr_psi_term tok)
read_comment
Definition: token.c:779
char * prompt
Definition: def_glob.h:1018
long symbolic(long c)
symbolic
Definition: token.c:967
#define SINGLE(C)
Definition: def_macro.h:52
void TOKEN_ERROR(ptr_psi_term p)
TOKEN_ERROR.
Definition: token.c:38
ptr_definition type
Definition: def_struct.h:181
long read_char()
read_char
Definition: token.c:680
long var_occurred
???
Definition: def_glob.h:839
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
ptr_choice_point choice_stack
Definition: def_glob.h:1026
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
void read_token(ptr_psi_term tok)
read_token
Definition: token.c:1186
void put_back_char(long c)
put_back_char
Definition: token.c:729
ptr_psi_term real_stack_psi_term ( long  stat,
REAL  thereal 
)

real_stack_psi_term

Parameters
stat- long stat
thereal- REAL thereal

Create a new psi_term on the stack with a real number value.

Definition at line 48 of file lefun.c.

References wl_psi_term::attr_list, wl_psi_term::coref, FALSE, wl_psi_term::flags, global_time_stamp, heap_alloc(), integer, NULL, QUOTED_TRUE, REAL, real, wl_psi_term::resid, STACK_ALLOC, wl_psi_term::status, wl_psi_term::type, and wl_psi_term::value_3.

49 {
50  ptr_psi_term result;
51 
52  result=STACK_ALLOC(psi_term);
53  result->type = (thereal==floor(thereal)) ? integer : real;
54  result->status=stat;
55  result->flags=stat?QUOTED_TRUE:FALSE; /* 14.9 */
56  result->attr_list=NULL;
57  result->coref=NULL;
58 #ifdef TS
59  result->time_stamp=global_time_stamp; /* 9.6 */
60 #endif
61  result->resid=NULL;
62  result->value_3=heap_alloc(sizeof(REAL));
63  (* (REAL *)(result->value_3)) = thereal;
64 
65  return result;
66 }
ptr_residuation resid
Definition: def_struct.h:189
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term coref
Definition: def_struct.h:188
#define STACK_ALLOC(A)
Definition: def_macro.h:21
unsigned long global_time_stamp
Definition: login.c:28
ptr_definition type
Definition: def_struct.h:181
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void rec_replace ( ptr_definition  old,
ptr_definition  new,
ptr_psi_term  term 
)

rec_replace

Parameters
old- ptr_definition old
new- ptr_definition new
term- ptr_psi_term term

Definition at line 865 of file modules.c.

References wl_psi_term::attr_list, def_ptr, deref_ptr, insert_translation(), int_ptr, NULL, push_ptr_value(), replace_attr(), translate(), wl_psi_term::type, and wl_psi_term::value_3.

866 {
867  ptr_psi_term done;
868  long *info; // some trouble w this - don't see
869  ptr_node old_attr;
870 
871  deref_ptr(term);
872  done=translate(term,&info);
873  if(!done) {
874  insert_translation(term,term,0);
875 
876  if(term->type==old && !term->value_3) {
877  push_ptr_value(def_ptr,(GENERIC *)&(term->type));
878  term->type=new;
879  }
880  old_attr=term->attr_list;
881  if(old_attr) {
883  term->attr_list=NULL;
884  replace_attr(old_attr,term,old,new);
885  }
886  }
887 }
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
ptr_psi_term translate(ptr_psi_term a, long **infoptr)
translate
Definition: copy.c:108
#define def_ptr
values of type_ptr
Definition: def_const.h:404
void replace_attr(ptr_node, ptr_psi_term, ptr_definition, ptr_definition)
replace_attr
Definition: modules.c:898
void insert_translation(ptr_psi_term a, ptr_psi_term b, long info)
insert_translation
Definition: copy.c:67
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define deref_ptr(P)
Definition: def_macro.h:100
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
#define int_ptr
values of type_ptr
Definition: def_const.h:397
long redefine ( ptr_psi_term  t)

redefine

Parameters
t- ptr_psi_term t

REDEFINE(t) This decides whether a definition (a sort, function, or predicate) may be extended or not.

Definition at line 104 of file types.c.

References wl_definition::children, wl_keyword::combined_name, wl_definition::date, deref_ptr, Errorline(), FALSE, file_date, wl_definition::keyword, MAX_BUILT_INS, wl_definition::parents, wl_definition::protected, remove_cycles(), wl_definition::rule, wl_keyword::symbol, TRUE, wl_psi_term::type, wl_definition::type_def, type_it, undef_it, warningflag, warningline(), and yes_or_no().

105 {
106  ptr_definition d; // ,d2;
107  // ptr_int_list l,*l2;
108  long success=TRUE;
109 
110  deref_ptr(t);
111  d=t->type;
112  if (d->date<file_date) {
113  if (d->type_def==(def_type)type_it) {
114  /* Except for top, sorts are always unprotected, with a warning. */
115  if (FALSE /*d==top*/) {
116  Errorline("the top sort '@' may not be extended.\n");
117  success=FALSE;
118  }
119  /* RM: Mar 25 1993
120  else if (d!=top)
121  warningline("extending definition of sort '%s'.\n",d->keyword->symbol);
122  */
123  }
124  else if (d->protected && d->type_def!=(def_type)undef_it) {
125  if (d->date>0) {
126  /* The term was entered in a previous file, and therefore */
127  /* cannot be altered. */
128  Errorline("the %T '%s' may not be changed.\n", /* RM: Jan 27 1993 */
129  d->type_def, d->keyword->combined_name);
130  success=FALSE;
131  }
132  else {
133  if (d->rule && (unsigned long)d->rule<=MAX_BUILT_INS /*&& input_stream==stdin*/) {
134  /* d is a built-in, and therefore cannot be altered. */
135  Errorline("the built-in %T '%s' may not be extended.\n",
136  d->type_def, d->keyword->symbol);
137  success=FALSE;
138  }
139  else {
140  /* d is not a built-in, and therefore can be altered. */
141  warningline("extending the %T '%s'.\n",d->type_def,d->keyword->symbol);
142  if (warningflag) if (!yes_or_no()) success=FALSE;
143  }
144  }
145  }
146 
147  if (success) {
148  if (d->type_def==(def_type)type_it) { /* d is an already existing type */
149  /* Remove cycles in the type hierarchy of d */
150  /* This is done by Richard's version, and I don't know why. */
151  /* It seems to be a no-op. */
152  remove_cycles(d, &(d->children));
153  remove_cycles(d, &(d->parents));
154  /* d->rule=NULL; */ /* Types must keep their rules! */
155  /* d->properties=NULL; */ /* Types get new properties from encode */
156  }
157  if (d->date==0) d->date=file_date;
158  /* d->type=undef_it; */ /* Objects keep their type! */
159  /* d->always_check=TRUE; */
160  /* d->protected=TRUE; */
161  /* d->children=NULL; */
162  /* d->parents=NULL; */
163  /* d->code=NOT_CODED; */
164  }
165  }
166 
167  return success;
168 }
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
char * combined_name
Definition: def_struct.h:119
def_type type_def
Definition: def_struct.h:153
long file_date
Definition: def_glob.h:1034
ptr_keyword keyword
Definition: def_struct.h:147
void remove_cycles(ptr_definition d, ptr_int_list *dl)
remove_cycles
Definition: types.c:85
long warningflag
Definition: def_glob.h:911
char * symbol
Definition: def_struct.h:118
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_pair_list rule
Definition: def_struct.h:148
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define MAX_BUILT_INS
Maximum number of built_ins.
Definition: def_const.h:154
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
ptr_int_list children
Definition: def_struct.h:152
long yes_or_no()
yes_or_no
Definition: types.c:50
ptr_int_list parents
Definition: def_struct.h:151
void release_resid ( ptr_psi_term  t)

release_resid

Parameters
t- ptr_psi_term t

Definition at line 445 of file lefun.c.

References release_resid_main(), and TRUE.

446 {
448 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
void release_resid_main(ptr_psi_term t, long trailflag)
release_resid_main
Definition: lefun.c:411
void release_resid_main ( ptr_psi_term  t,
long  trailflag 
)

release_resid_main

Parameters
t- ptr_psi_term t
trailflag- long trailflag

Release the residuations pending on the Residuation Variable T. This is done by simply pushing the residuated goals onto the goal-stack. A goal is not added if already present on the stack. Two versions of this routine exist: one which trails t and one which never trails t.

Definition at line 411 of file lefun.c.

References wl_goal::aaaa_1, FALSE, wl_residuation::goal, goal_ptr, goal_stack, int_ptr, wl_residuation::next, wl_goal::next, NULL, wl_goal::pending, push_ptr_value(), wl_psi_term::resid, resid_ptr, and traceline().

412 {
413  ptr_goal g;
414  ptr_residuation r;
415 
416  if ((r=t->resid)) {
417  if (trailflag) push_ptr_value(resid_ptr,(GENERIC *)&(t->resid));
418  t->resid=NULL;
419 
420  while (r) {
421  g=r->goal;
422  if (g->pending) {
423 
425  g->pending=FALSE;
426 
428 
429  g->next=goal_stack;
430  goal_stack=g;
431 
432  traceline("releasing %P\n",g->aaaa_1);
433  }
434  r=r->next;
435  }
436  }
437 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_residuation resid
Definition: def_struct.h:189
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
ptr_goal goal_stack
Definition: def_glob.h:1025
ptr_goal goal
Definition: def_struct.h:172
ptr_residuation next
Definition: def_struct.h:173
#define NULL
Definition: def_const.h:533
void traceline(char *format,...)
traceline
Definition: error.c:186
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define resid_ptr
values of type_ptr
Definition: def_const.h:390
#define goal_ptr
values of type_ptr
Definition: def_const.h:418
ptr_definition pending
Definition: def_struct.h:243
ptr_goal next
Definition: def_struct.h:242
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void release_resid_notrail ( ptr_psi_term  t)

release_resid_notrail

Parameters
t- ptr_psi_term t

Definition at line 456 of file lefun.c.

References FALSE, and release_resid_main().

458 {
460 }
#define FALSE
Standard boolean.
Definition: def_const.h:275
void release_resid_main(ptr_psi_term t, long trailflag)
release_resid_main
Definition: lefun.c:411
void remove_cycles ( ptr_definition  d,
ptr_int_list dl 
)

remove_cycles

Parameters
d- ptr_definition d
dl- ptr_int_list *dl

Remove references to d in d's children or parents

Definition at line 85 of file types.c.

References wl_int_list::next.

86 {
87  while (*dl) {
88  if (((ptr_definition)(*dl)->value_1)==d)
89  *dl = (*dl)->next;
90  else
91  dl= &((*dl)->next);
92  }
93 }
ptr_int_list next
Definition: def_struct.h:86
void replace ( ptr_definition  old,
ptr_definition  new,
ptr_psi_term  term 
)

replace

Parameters
old- ptr_definition old
new- ptr_definition new
term- ptr_psi_term term)

REPLACE(old,new,term) Replace all occurrences of type OLD with NEW in TERM.

Definition at line 851 of file modules.c.

References clear_copy(), and rec_replace().

852 {
853  clear_copy();
854  rec_replace(old,new,term);
855 }
void clear_copy()
clear_copy
Definition: copy.c:53
void rec_replace(ptr_definition, ptr_definition, ptr_psi_term)
rec_replace
Definition: modules.c:865
void replace_attr ( ptr_node  old_attr,
ptr_psi_term  term,
ptr_definition  old,
ptr_definition  new 
)

replace_attr

Parameters
old_attr- ptr_node old_attr
term- ptr_psi_term term
old- ptr_definition old
new- ptr_definition new

Definition at line 898 of file modules.c.

References wl_psi_term::attr_list, wl_keyword::combined_name, wl_node::data, FEATCMP, wl_node::key, wl_definition::keyword, wl_node::left, wl_keyword::private_feature, rec_replace(), wl_node::right, stack_insert(), and wl_keyword::symbol.

899 {
900  ptr_psi_term value;
901  char *oldlabel; /* RM: Mar 12 1993 */
902  char *newlabel;
903 
904  if(old_attr->left)
905  replace_attr(old_attr->left,term,old,new);
906 
907  value=(ptr_psi_term)old_attr->data;
908  rec_replace(old,new,value);
909 
910  if(old->keyword->private_feature) /* RM: Mar 12 1993 */
911  oldlabel=old->keyword->combined_name;
912  else
913  oldlabel=old->keyword->symbol;
914 
915  if(new->keyword->private_feature) /* RM: Mar 12 1993 */
916  newlabel=new->keyword->combined_name;
917  else
918  newlabel=new->keyword->symbol;
919 
920  if(!strcmp(old_attr->key,oldlabel))
921  (void)stack_insert(FEATCMP,newlabel,&(term->attr_list),(GENERIC)value);
922  else
923  (void)stack_insert(FEATCMP,old_attr->key,&(term->attr_list),(GENERIC)value);
924 
925  if(old_attr->right)
926  replace_attr(old_attr->right,term,old,new);
927 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * combined_name
Definition: def_struct.h:119
void replace_attr(ptr_node, ptr_psi_term, ptr_definition, ptr_definition)
replace_attr
Definition: modules.c:898
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
char * symbol
Definition: def_struct.h:118
ptr_node left
Definition: def_struct.h:199
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
char * key
Definition: def_struct.h:198
void rec_replace(ptr_definition, ptr_definition, ptr_psi_term)
rec_replace
Definition: modules.c:865
int private_feature
Definition: def_struct.h:121
ptr_node attr_list
Definition: def_struct.h:187
ptr_node right
Definition: def_struct.h:200
void report_error ( ptr_psi_term  g,
char *  s 
)

report_error

Parameters
g- ptr_psi_term g
s- char *s

REPORT_ERROR(g,s) Print an appropriate error message. G is the psi-term which caused the error, S a message to print. Format: '*** Error: s in 'g'.'

Definition at line 856 of file error.c.

References report_error_main().

857 {
858  report_error_main(g,s,"Error");
859 }
void report_error_main(ptr_psi_term g, char *s, char *s2)
report_error_main
Definition: error.c:836
void report_error2 ( ptr_psi_term  g,
char *  s 
)

report_error2

Parameters
g- ptr_psi_term g
s- char *s

REPORT_ERROR2(g,s) Like report_error, with a slightly different format. Format: '*** Error: argument 'g' s.'

Definition at line 923 of file error.c.

References report_error2_main().

924 {
925  report_error2_main(g,s,"Error");
926 }
void report_error2_main(ptr_psi_term g, char *s, char *s2)
report_error2_main
Definition: error.c:904
void report_error2_main ( ptr_psi_term  g,
char *  s,
char *  s2 
)

report_error2_main

Parameters
g- ptr_psi_term g
s- char *s
s2- char *s2

Main routine for report_error2 and report_warning2

Definition at line 904 of file error.c.

References display_psi_stderr(), and perr_s().

905 {
906  // FILE *f;
907 
908  perr_s("*** %s: argument '",s2);
910  perr_s("' %s.\n",s);
911 }
void display_psi_stderr(ptr_psi_term t)
display_psi_stderr
Definition: print.c:1550
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
void report_error_main ( ptr_psi_term  g,
char *  s,
char *  s2 
)

report_error_main

Parameters
g- ptr_psi_term g
s- char *s
s2- char *s2

Main routine for report_error and report_warning

Definition at line 836 of file error.c.

References display_psi_stderr(), perr(), and perr_s2().

837 {
838  // FILE *f;
839 
840  perr_s2("*** %s: %s in '",s2,s);
842  perr("'.\n");
843 }
void perr_s2(char *s1, char *s2, char *s3)
perr_s2
Definition: error.c:788
void display_psi_stderr(ptr_psi_term t)
display_psi_stderr
Definition: print.c:1550
void perr(char *str)
perr
Definition: error.c:763
void report_warning ( ptr_psi_term  g,
char *  s 
)

report_warning

Parameters
g- ptr_psi_term g
s- char *s

REPORT_WARNING(g,s) Print an appropriate error message. G is the psi-term which caused the error, S a message to print. Format: '*** Warning: s in 'g'.'

Definition at line 890 of file error.c.

References report_error_main(), and warningflag.

891 {
892  if (warningflag) report_error_main(g,s,"Warning");
893 }
long warningflag
Definition: error.c:19
void report_error_main(ptr_psi_term g, char *s, char *s2)
report_error_main
Definition: error.c:836
void report_warning2 ( ptr_psi_term  g,
char *  s 
)

report_warning2

Parameters
g- ptr_psi_term g
s- char *s

REPORT_WARNING2(g,s) Like report_warning, with a slightly different format. Format: '*** Warning: argument 'g' s.'

Definition at line 938 of file error.c.

References report_error2_main(), and warningflag.

939 {
940  if (warningflag) report_error2_main(g,s,"Warning");
941 }
long warningflag
Definition: error.c:19
void report_error2_main(ptr_psi_term g, char *s, char *s2)
report_error2_main
Definition: error.c:904
long reportAndAbort ( ptr_psi_term  g,
char *  s 
)

reportAndAbort

Parameters
g- ptr_psi_term g
s- char *s

REPORTANDABORT(g,s) Print an appropriate error message. G is the psi-term which caused the error, S a message to print. Format: '*** Error: s in 'g'.'

Definition at line 872 of file error.c.

References abort_life(), report_error_main(), and TRUE.

873 {
874  report_error_main(g,s,"Error");
875  return abort_life(TRUE); // djd added TRUE
876 }
void report_error_main(ptr_psi_term g, char *s, char *s2)
report_error_main
Definition: error.c:836
long abort_life(int nlflag)
abort_life
Definition: built_ins.c:2259
#define TRUE
Standard boolean.
Definition: def_const.h:268
void reset_stacks ( )

reset_stacks

Called when level jumps back to zero. Setting these two pointers to NULL causes an exit from main_prove and will then reset all other global information.

Definition at line 2047 of file login.c.

References choice_stack, goal_stack, NULL, and undo().

2048 {
2049  undo(NULL); /* 8.10 */
2050  goal_stack=NULL;
2052 #ifdef TS
2053  /* global_time_stamp=INIT_TIME_STAMP; */ /* 9.6 */
2054 #endif
2055 }
ptr_goal goal_stack
Definition: def_glob.h:1025
void undo(ptr_stack limit)
undo
Definition: login.c:691
#define NULL
Definition: def_const.h:533
ptr_choice_point choice_stack
Definition: def_glob.h:1026
void reset_step ( )

reset_step

Reset stepcount to zero Should be called when prompt is printed

Definition at line 665 of file error.c.

References stepcount, stepflag, and TRUE.

666 {
667  if (stepcount>0) {
668  stepcount=0;
669  stepflag=TRUE;
670  }
671 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
long stepcount
Definition: error.c:25
long stepflag
Definition: error.c:23
ptr_psi_term residListGoalQuote ( ptr_residuation  p)

residListGoalQuote

Parameters
p- ptr_residuation p

Return a ptr to a psi-term marked as evaluated. The psi-term is a copy at the top level of the goal residuated on p, with the rest of the psi-term shared.

Definition at line 546 of file bi_sys.c.

References wl_goal::aaaa_1, copyPsiTerm, wl_residuation::goal, stack_psi_term(), and wl_psi_term::status.

547 {
548  ptr_psi_term psi;
549 
550  psi = stack_psi_term(4);
551  copyPsiTerm(psi, p->goal->aaaa_1);
552  psi->status = 4;
553  return psi;
554 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_goal goal
Definition: def_struct.h:172
#define copyPsiTerm(a, b)
Definition: bi_sys.c:10
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC residListNext ( ptr_residuation  p)

residListNext

Parameters
p- ptr_residuation p

Definition at line 562 of file bi_sys.c.

References wl_residuation::next.

563 {
564  return (GENERIC )(p->next);
565 }
ptr_residuation next
Definition: def_struct.h:173
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
void residuate ( ptr_psi_term  t)

residuate

Parameters
t- ptr_psi_term t

Residuate the current expression with T in the Residuation Variable set.

Definition at line 125 of file lefun.c.

References wl_resid_list::next, NULL, wl_resid_list::othervar, resid_vars, STACK_ALLOC, and wl_resid_list::var.

126 {
127  ptr_resid_list curr;
128 
129  curr=STACK_ALLOC(resid_list);
130  curr->var=t;
131  curr->othervar=NULL; /* 21.9 */
132  curr->next=resid_vars;
133  resid_vars=curr;
134 }
ptr_resid_list next
Definition: def_struct.h:97
#define NULL
Definition: def_const.h:533
ptr_resid_list resid_vars
Definition: def_glob.h:866
ptr_psi_term var
Definition: def_struct.h:95
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_psi_term othervar
Definition: def_struct.h:96
void residuate2 ( ptr_psi_term  u,
ptr_psi_term  v 
)

residuate2

Parameters
u- ptr_psi_term u
v- ptr_psi_term v

Residuate the current function on the two variables U and V.

Definition at line 144 of file lefun.c.

References residuate().

145 {
146  residuate(u);
147  if (v && u!=v) residuate(v);
148 }
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void residuate3 ( ptr_psi_term  u,
ptr_psi_term  v,
ptr_psi_term  w 
)

residuate3

Parameters
u- ptr_psi_term u
v- ptr_psi_term v
w- ptr_psi_term w

Residuate the current function on the three variables U, V, and W.

Definition at line 159 of file lefun.c.

References residuate().

160 {
161  residuate(u);
162  if (v && u!=v) residuate(v);
163  if (w && u!=w && v!=w) residuate(w);
164 }
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
void residuate_double ( ptr_psi_term  t,
ptr_psi_term  u 
)

residuate_double

Parameters
t- ptr_psi_term t
u- ptr_psi_term u

Residuate the current expression with T in the Residuation Variable set. Also store the other variable, so that its sort can be used in the 'bestsort' calculation needed to implement disequality constraints.

Definition at line 107 of file lefun.c.

References wl_resid_list::next, wl_resid_list::othervar, resid_vars, STACK_ALLOC, and wl_resid_list::var.

108 {
109  ptr_resid_list curr;
110 
111  curr=STACK_ALLOC(resid_list);
112  curr->var=t;
113  curr->othervar=u;
114  curr->next=resid_vars;
115  resid_vars=curr;
116 }
ptr_resid_list next
Definition: def_struct.h:97
ptr_resid_list resid_vars
Definition: def_glob.h:866
ptr_psi_term var
Definition: def_struct.h:95
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_psi_term othervar
Definition: def_struct.h:96
long residuateGoalOnVar ( ptr_goal  g,
ptr_psi_term  var,
ptr_psi_term  othervar 
)

residuateGoalOnVar

Parameters
g- ptr_goal g
var- ptr_psi_term var
othervar- ptr_psi_term othervar

Add the goal to the variable's residuation list. Also update the residuation's 'bestsort' field if it exists (needed to implement complete disequality semantics). The 'othervar' parameter is needed for this.

Definition at line 192 of file lefun.c.

References code_ptr, def_ptr, Errorline(), FALSE, glb_code(), glb_value(), heap_pointer, int_ptr, wl_goal::next, NULL, wl_goal::pending, push_ptr_value(), wl_psi_term::resid, resid_ptr, STACK_ALLOC, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

193 {
194  long result;
195  long resflag,resflag2;
196  GENERIC rescode,rescode2;
197  GENERIC resvalue;
198  GENERIC resvalue2;
199  /* Set to FALSE if the goal is already residuated on the var: */
200  long not_found = TRUE;
201  /* Points to a pointer to a residuation structure. Used so we can */
202  /* add the goal to the end of the residuation list, so that it can */
203  /* can be undone later if backtracking happens. See the call to */
204  /* push_ptr_value. */
205  ptr_residuation *r;
206 
207  /* 5.8 PVR */
208  if ((GENERIC)var>=heap_pointer) {
209  Errorline("attempt to residuate on psi-term %P in the heap.\n",var);
210 
211  return FALSE;
212  }
213 
214  r= &(var->resid);
215 
216  while (not_found && *r) {
217  if ((*r)->goal == g) { /* This goal is already attached */
218  /* Keep track of best sort so far */
219  /* Glb_code(..) tries to keep 'sortflag' TRUE if possible. */
220  result=glb_code((*r)->sortflag,(*r)->bestsort,
221  TRUE,(GENERIC)var->type,
222  &resflag,&rescode);
223  result=glb_value(result,resflag,rescode,(GENERIC)(*r)->value_2,var->value_3,
224  &resvalue); /* 6.10 */
225  if (!result)
226  return FALSE; /* 21.9 */
227  else if (othervar) {
228  result=glb_code(resflag,rescode,TRUE,(GENERIC)othervar->type,
229  &resflag2,&rescode2);
230  result=glb_value(result,resflag2,rescode2,resvalue,othervar->value_3,
231  &resvalue2); /* 6.10 */
232  if (!result) {
233  return FALSE;
234  }
235  else {
236  /* The value field only has to be trailed once, since its value */
237  /* does not change, once given. */
238  if ((*r)->value_2==NULL && resvalue2!=NULL) { /* 6.10 */
239  push_ptr_value(int_ptr,(GENERIC *)&((*r)->value_2));
240  }
241  if ((*r)->bestsort!=rescode2) {
242  push_ptr_value(((*r)->sortflag?def_ptr:code_ptr),
243  &((*r)->bestsort));
244  (*r)->bestsort=rescode2; /* 21.9 */
245  }
246  if ((*r)->sortflag!=resflag2) {
247  push_ptr_value(int_ptr,(GENERIC *)&((*r)->sortflag));
248  (*r)->sortflag=resflag2; /* 21.9 */
249  }
250  }
251  }
252  else {
253  if ((*r)->value_2==NULL && resvalue!=NULL) { /* 6.10 */
254  push_ptr_value(int_ptr,(GENERIC *)&((*r)->value_2));
255  }
256  if ((*r)->bestsort!=rescode) {
257  push_ptr_value(((*r)->sortflag?def_ptr:code_ptr),
258  &((*r)->bestsort));
259  (*r)->bestsort=rescode; /* 21.9 */
260  }
261  if ((*r)->sortflag!=resflag) {
262  push_ptr_value(int_ptr,(GENERIC *)&((*r)->sortflag));
263  (*r)->sortflag=resflag; /* 21.9 */
264  }
265  }
266  not_found = FALSE;
267  }
268  else
269  r= &((*r)->next); /* look at the next one */
270  }
271 
272  if (not_found) {
273  /* We must attach this goal & the variable's sort onto this variable */
274 
277  if (othervar) {
278  result=glb_code(TRUE,(GENERIC)var->type,TRUE,(GENERIC)othervar->type,&resflag,&rescode);
279  result=glb_value(result,resflag,rescode,var->value_3,othervar->value_3,
280  &resvalue); /* 6.10 */
281  if (!result) {
282  return FALSE;
283  }
284  else {
285  (*r)->sortflag=resflag;
286  (*r)->bestsort=rescode; /* 21.9 */
287  (*r)->value_2=resvalue; /* 6.10 */
288  }
289  }
290  else {
291  (*r)->sortflag=TRUE;
292  (*r)->bestsort=(GENERIC)var->type; /* 21.9 */
293  (*r)->value_2=var->value_3; /* 6.10 */
294  }
295  (*r)->goal=g;
296  (*r)->next=NULL;
297  }
298 
299  if (!(g->pending)) {
300  /* this goal is not pending, so make sure it will be put on the goal
301  * stack later
302  */
305  }
306 
307  return TRUE; /* 21.9 */
308 }
ptr_residuation resid
Definition: def_struct.h:189
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
long glb_value(long result, long f, GENERIC c, GENERIC value1, GENERIC value2, GENERIC *value)
glb_value
Definition: types.c:1290
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
#define def_ptr
values of type_ptr
Definition: def_const.h:404
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define code_ptr
values of type_ptr
Definition: def_const.h:411
struct wl_definition * ptr_definition
Definition: def_struct.h:59
GENERIC value_3
Definition: def_struct.h:186
#define STACK_ALLOC(A)
Definition: def_macro.h:21
long glb_code(long f1, GENERIC c1, long f2, GENERIC c2, long *f3, GENERIC *c3)
glb_code
Definition: types.c:1351
ptr_definition type
Definition: def_struct.h:181
#define resid_ptr
values of type_ptr
Definition: def_const.h:390
ptr_definition pending
Definition: def_struct.h:243
ptr_goal next
Definition: def_struct.h:242
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void restore_parse_state ( ptr_parse_block  pb)

restore_parse_state

Parameters
pb- ptr_parse_block pb

Definition at line 444 of file token.c.

References wl_parse_block::ef, eof_flag, wl_parse_block::lc, line_count, old_saved_char, old_saved_psi_term, wl_parse_block::osc, wl_parse_block::ospt, saved_char, saved_psi_term, wl_parse_block::sc, wl_parse_block::sol, wl_parse_block::spt, and start_of_line.

445 {
446  if (pb) {
447  line_count = pb->lc;
448  start_of_line = pb->sol;
449  saved_char = pb->sc;
450  old_saved_char = pb->osc;
451  saved_psi_term = pb->spt;
452  old_saved_psi_term = pb->ospt;
453  eof_flag = pb->ef;
454  }
455 }
ptr_psi_term ospt
Definition: def_struct.h:377
long eof_flag
Definition: def_glob.h:853
long old_saved_char
Definition: def_glob.h:850
long saved_char
Definition: def_glob.h:849
long line_count
Definition: def_glob.h:1015
long start_of_line
???
Definition: def_glob.h:846
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
ptr_psi_term spt
Definition: def_struct.h:376
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
void restore_resid ( ptr_resid_block  rb,
ptr_psi_term match_date 
)

restore_resid

Parameters
rb- ptr_resid_block rb
match_date- ptr_psi_term *match_date

Definition at line 1417 of file lefun.c.

References can_curry, wl_resid_block::cc_cr, curried, FALSE, wl_resid_block::md, wl_resid_block::ra, resid_aim, resid_vars, wl_resid_block::rv, and TRUE.

1418 {
1419  if (rb) {
1420  can_curry = (rb->cc_cr&2)?TRUE:FALSE; /* 11.9 */
1421  curried = (rb->cc_cr&1)?TRUE:FALSE; /* 11.9 */
1422  resid_aim = rb->ra;
1423  resid_vars = rb->rv;
1424  /* curried = rb->cr; 11.9 */
1425  /* can_curry = rb->cc; 11.9 */
1426  *match_date = rb->md;
1427  }
1428 }
ptr_goal ra
Definition: def_struct.h:263
ptr_goal resid_aim
Definition: def_glob.h:865
ptr_resid_list resid_vars
Definition: def_glob.h:866
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term md
Definition: def_struct.h:267
#define FALSE
Standard boolean.
Definition: def_const.h:275
long can_curry
Definition: def_glob.h:869
long curried
Definition: def_glob.h:868
ptr_resid_list rv
Definition: def_struct.h:266
void restore_state ( ptr_psi_term  t)

restore_state

Parameters
t- ptr_psi_term t

Restore global state from an existing file state psi-term t

Definition at line 334 of file token.c.

References eof_flag, EOF_FLAG, get_attr(), INPUT_FILE_NAME, input_file_name, input_stream, lf_true, LINE_COUNT, line_count, NULL, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, REAL, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, and STREAM.

335 {
336  // long i;
337  char *str;
338 
339 
340  input_stream = (FILE *) ((ptr_psi_term)get_attr(t,STREAM))->value_3;
341  str = (char*) ((ptr_psi_term)get_attr(t,INPUT_FILE_NAME))->value_3;
342  strcpy(input_file_name,str);
343  /* for (i=0;i++;i<=strlen(str)) input_file_name[i]=str[i]; */
344  line_count = *(REAL *) ((ptr_psi_term)get_attr(t,LINE_COUNT))->value_3;
345  saved_char = *(REAL *) ((ptr_psi_term)get_attr(t,SAVED_CHAR))->value_3;
347 
350 
353 
356 
357 
358  /* RM: Jan 27 1993
359  set_current_module(
360  find_module(((ptr_psi_term)get_attr(input_state,
361  CURRENT_MODULE))->value_3));
362  */
363 }
#define LINE_COUNT
feature name
Definition: def_const.h:890
long eof_flag
Definition: def_glob.h:853
string input_file_name
Definition: def_glob.h:1016
#define SAVED_PSI_TERM
feature name
Definition: def_const.h:918
#define OLD_SAVED_CHAR
feature name
Definition: def_const.h:911
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
long old_saved_char
Definition: def_glob.h:850
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long saved_char
Definition: def_glob.h:849
ptr_psi_term null_psi_term
Used to represent an empty parse token.
Definition: def_glob.h:656
long line_count
Definition: def_glob.h:1015
#define STREAM
feature name
Definition: def_const.h:876
#define START_OF_LINE
feature name
Definition: def_const.h:897
FILE * input_stream
Definition: def_glob.h:1014
long start_of_line
???
Definition: def_glob.h:846
#define INPUT_FILE_NAME
feature name
Definition: def_const.h:883
#define OLD_SAVED_PSI_TERM
feature name
Definition: def_const.h:925
GENERIC get_attr(ptr_psi_term t, char *attrname)
get_attr
Definition: token.c:265
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
#define EOF_FLAG
feature name
Definition: def_const.h:932
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
#define SAVED_CHAR
feature name
Definition: def_const.h:904
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
void save_parse_state ( ptr_parse_block  pb)

save_parse_state

Parameters
pb- ptr_parse_block pb

Definition at line 425 of file token.c.

References wl_parse_block::ef, eof_flag, wl_parse_block::lc, line_count, old_saved_char, old_saved_psi_term, wl_parse_block::osc, wl_parse_block::ospt, saved_char, saved_psi_term, wl_parse_block::sc, wl_parse_block::sol, wl_parse_block::spt, and start_of_line.

426 {
427  if (pb) {
428  pb->lc = line_count;
429  pb->sol = start_of_line;
430  pb->sc = saved_char;
431  pb->osc = old_saved_char;
432  pb->spt = saved_psi_term;
433  pb->ospt = old_saved_psi_term;
434  pb->ef = eof_flag;
435  }
436 }
ptr_psi_term ospt
Definition: def_struct.h:377
long eof_flag
Definition: def_glob.h:853
long old_saved_char
Definition: def_glob.h:850
long saved_char
Definition: def_glob.h:849
long line_count
Definition: def_glob.h:1015
long start_of_line
???
Definition: def_glob.h:846
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
ptr_psi_term spt
Definition: def_struct.h:376
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
void save_resid ( ptr_resid_block  rb,
ptr_psi_term  match_date 
)

save_resid

Parameters
rb- ptr_resid_block rb
match_date- ptr_psi_term match_date

Saving & restoring residuation information

Definition at line 1398 of file lefun.c.

References can_curry, wl_resid_block::cc_cr, curried, wl_resid_block::md, wl_resid_block::ra, resid_aim, resid_vars, and wl_resid_block::rv.

1399 {
1400  if (rb) {
1401  rb->cc_cr = (can_curry<<1) + curried; /* 11.9 */
1402  rb->ra = resid_aim;
1403  rb->rv = resid_vars;
1404  /* rb->cr = curried; 11.9 */
1405  /* rb->cc = can_curry; 11.9 */
1406  rb->md = match_date;
1407  }
1408 }
ptr_goal ra
Definition: def_struct.h:263
ptr_goal resid_aim
Definition: def_glob.h:865
ptr_resid_list resid_vars
Definition: def_glob.h:866
ptr_psi_term md
Definition: def_struct.h:267
long can_curry
Definition: def_glob.h:869
long curried
Definition: def_glob.h:868
ptr_resid_list rv
Definition: def_struct.h:266
void save_state ( ptr_psi_term  t)

save_state

Parameters
t- ptr_psi_term t

Save global state into an existing file state psi-term t

Definition at line 293 of file token.c.

References wl_psi_term::attr_list, wl_node::data, eof_flag, EOF_FLAG, FEATCMP, find(), heap_add_psi_attr(), heap_mod_int_attr(), heap_mod_str_attr(), heap_psi_term(), INPUT_FILE_NAME, input_file_name, input_stream, lf_false, lf_true, LINE_COUNT, line_count, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, STREAM, wl_psi_term::type, and wl_psi_term::value_3.

294 {
295  ptr_node n;
296  ptr_psi_term t1;
297 
299  t1=(ptr_psi_term)n->data;
301 
302  /* RM: Jan 27 1993
303  heap_mod_str_attr(t,CURRENT_MODULE,current_module->module_name);
304  */
305 
310 
313 
316 
317  t1=heap_psi_term(4);
320 
321  t1=heap_psi_term(4);
324 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
#define LINE_COUNT
feature name
Definition: def_const.h:890
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
long eof_flag
Definition: def_glob.h:853
void heap_mod_int_attr(ptr_psi_term t, char *attrname, long value)
heap_mod_int_attr
Definition: token.c:116
string input_file_name
Definition: def_glob.h:1016
#define SAVED_PSI_TERM
feature name
Definition: def_const.h:918
ptr_psi_term heap_psi_term(long stat)
heap_psi_term
Definition: lefun.c:75
#define OLD_SAVED_CHAR
feature name
Definition: def_const.h:911
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
long old_saved_char
Definition: def_glob.h:850
long saved_char
Definition: def_glob.h:849
ptr_psi_term null_psi_term
Used to represent an empty parse token.
Definition: def_glob.h:656
long line_count
Definition: def_glob.h:1015
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define STREAM
feature name
Definition: def_const.h:876
#define START_OF_LINE
feature name
Definition: def_const.h:897
void heap_add_psi_attr(ptr_psi_term t, char *attrname, ptr_psi_term g)
heap_add_psi_attr
Definition: token.c:226
FILE * input_stream
Definition: def_glob.h:1014
GENERIC value_3
Definition: def_struct.h:186
long start_of_line
???
Definition: def_glob.h:846
#define INPUT_FILE_NAME
feature name
Definition: def_const.h:883
#define OLD_SAVED_PSI_TERM
feature name
Definition: def_const.h:925
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
#define EOF_FLAG
feature name
Definition: def_const.h:932
void heap_mod_str_attr(ptr_psi_term t, char *attrname, char *str)
heap_mod_str_attr
Definition: token.c:191
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
#define SAVED_CHAR
feature name
Definition: def_const.h:904
ptr_node attr_list
Definition: def_struct.h:187
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
ptr_module set_current_module ( ptr_module  module)

set_current_module

Parameters
module- ptr_module module

SET_CURRENT_MODULE(module) Set the current module to a given string.

Definition at line 100 of file modules.c.

References current_module.

101 {
102  current_module=module;
103  /* printf("*** Current module: '%s'\n",current_module->module_name); */
104  return current_module;
105 }
ptr_module current_module
Definition: modules.c:15
void set_trace_to_prove ( )

set_trace_to_prove

void set_trace_to_prove()

Definition at line 727 of file error.c.

References new_trace().

728 {
729  new_trace(2);
730 }
void new_trace(long newtrace)
new_trace
Definition: error.c:698
void setUnitList ( GENERIC  x)

setUnitList(GENERIC x)

Parameters
x- GENERIC x what to set static unitListElement to (GENERIC)

not sure purpose (DJD ???)

Definition at line 468 of file bi_sys.c.

References unitListElement.

469 {
470  unitListElement = x;
471 }
static GENERIC unitListElement
Definition: bi_sys.c:459
long shift_warning ( long  dir,
ptr_psi_term  arg,
REAL  val 
)

shift_warning

Parameters
dir- long dir
arg- ptr_psi_term arg
val- REAL val

Definition at line 1061 of file error.c.

References nonint_warning().

1062 {
1063  if (dir)
1064  return nonint_warning(arg,val,"of right shift operation is not an integer");
1065  else
1066  return nonint_warning(arg,val,"of left shift operation is not an integer");
1067 }
long nonint_warning(ptr_psi_term arg, REAL val, char *msg)
nonint_warning
Definition: error.c:974
void show ( long  limit)

show

Parameters
limit- long limit

SHOW(limit) This prints the parser's stack, for debugging purposes only, LIMIT marks the bottom of the current stack.

Definition at line 64 of file parser.c.

References display_psi_stdout(), fx, int_stack, nop, parser_stack_index, psi_term_stack, xf, and xfx.

65 {
66  long i;
67 
68  for (i=1;i<=parser_stack_index;i++) {
69  if (i==limit)
70  printf("-> ");
71  else
72  printf(" ");
73  printf("%3ld: ",i);
74  switch (op_stack[i]) {
75  case fx:
76  printf("FX ");
77  break;
78  case xfx:
79  printf("XFX ");
80  break;
81  case xf:
82  printf("XF ");
83  break;
84  case nop:
85  printf("NOP ");
86  break;
87  default:
88  printf("??? ");
89  }
90  printf(" prec=%4ld ",int_stack[i]);
92  printf("\n");
93  }
94  printf("\n");
95 }
#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
void display_psi_stdout(ptr_psi_term t)
display_psi_stdout
Definition: print.c:1536
#define nop
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:986
#define xf
was enum (operator) but va_arg could not handle - now typedef
Definition: def_const.h:993
long parser_stack_index
index to parser stack
Definition: def_glob.h:164
long int_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:959
psi_term psi_term_stack[PARSER_STACK_SIZE]
Definition: def_glob.h:958
void show_count ( )

show_count

SHOW_COUNT() This routine doesn't do anything if not in verbose mode. It prints the number of of sub-goals attempted, along with cpu-time spent during the proof etc...

Definition at line 1161 of file login.c.

References end_time, goal_count, heap_pointer, mem_base, mem_limit, NOTQUIET, stack_info(), stack_pointer, and verbose.

1162 {
1163  float t;
1164 
1165  if (verbose) {
1166  printf(" [");
1167 
1168  (void)times(&end_time);
1169  t = (end_time.tms_utime - start_time.tms_utime)/60.0;
1170 
1171  printf("%1.3fs cpu, %ld goal%s",t,goal_count,(goal_count!=1?"s":""));
1172 
1173  if (t!=0.0) printf(" (%0.0f/s)",goal_count/t);
1174 
1175  printf(", %ld stack",sizeof(mem_base)*(stack_pointer-mem_base));
1176  printf(", %ld heap",sizeof(mem_base)*(mem_limit-heap_pointer));
1177 
1178  printf("]");
1179  }
1180 
1181  if(NOTQUIET) {
1182  printf("\n");
1183  stack_info(stdout);
1184  }
1185 
1186  goal_count=0;
1187 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
GENERIC mem_limit
starting point of heap - mem_base aligned
Definition: def_glob.h:62
#define NOTQUIET
Definition: def_macro.h:15
long verbose
Definition: def_glob.h:914
long goal_count
Definition: def_glob.h:678
void stack_info(FILE *outfile)
stack_info
Definition: error.c:77
struct tms start_time end_time
Definition: def_glob.h:939
GENERIC mem_base
mem_size memory allocated in init_memory by malloc
Definition: def_glob.h:48
void stack_add_int_attr ( ptr_psi_term  t,
char *  attrname,
long  value 
)

stack_add_int_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
value- long value

Definition at line 94 of file token.c.

References wl_psi_term::attr_list, FEATCMP, heap_alloc(), heap_copy_string(), integer, REAL, stack_insert(), stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

95 {
96  ptr_psi_term t1;
97 
98  t1=stack_psi_term(4);
99  t1->type=integer;
100  t1->value_3=heap_alloc(sizeof(REAL)); /* 12.5 */
101  *(REAL *)t1->value_3 = (REAL) value;
102 
103  (void)stack_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) t1);
104 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void stack_add_psi_attr ( ptr_psi_term  t,
char *  attrname,
ptr_psi_term  g 
)

stack_add_psi_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
g- ptr_psi_term g

Definition at line 239 of file token.c.

References wl_psi_term::attr_list, FEATCMP, heap_copy_string(), and stack_insert().

240 {
241  (void)stack_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) g);
242 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
ptr_node attr_list
Definition: def_struct.h:187
void stack_add_str_attr ( ptr_psi_term  t,
char *  attrname,
char *  str 
)

stack_add_str_attr

Parameters
t- ptr_psi_term t
attrname- char *attrname
str- char *str

Definition at line 170 of file token.c.

References wl_psi_term::attr_list, FEATCMP, heap_copy_string(), quoted_string, stack_copy_string(), stack_insert(), stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

171 {
172  ptr_psi_term t1;
173 
174  t1=stack_psi_term(4);
175  t1->type=quoted_string;
177 
178  (void)stack_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) t1);
179 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
char * stack_copy_string(char *s)
stack_copy_string
Definition: trees.c:184
GENERIC stack_alloc ( long  s)

stack_alloc

Parameters
s- long s

STACK_ALLOC(s) This returns a pointer to S bytes of memory in the stack. Alignment is taken into account in the following manner: the macro ALIGN is supposed to be a power of 2 and the pointer returned is a multiple of ALIGN.

Definition at line 1642 of file memory.c.

References ALIGN, Errorline(), heap_pointer, and stack_pointer.

1643 {
1644  GENERIC r;
1645 
1646  r = stack_pointer;
1647 
1648  if (s & (ALIGN-1))
1649  s = s - (s & (ALIGN-1)) + ALIGN;
1650  /* assert(s % sizeof(*stack_pointer) == 0); */
1651  s /= sizeof (*stack_pointer);
1652 
1653  stack_pointer += s;
1654 
1656  Errorline("the stack overflowed into the heap.\n");
1657 
1658  return r;
1659 }
GENERIC stack_pointer
used to allocate from stack - size allocated added - adj for alignment
Definition: def_glob.h:69
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define ALIGN
Definition: def_const.h:66
ptr_psi_term stack_bytes ( char *  s,
int  n 
)

stack_bytes

Parameters
s- char *s
n- int n

STACK_BYTES(s,n) create a STRING object given a sequence of bytes

Definition at line 128 of file built_ins.c.

References heap_ncopy_string(), quoted_string, stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

129 {
131  t->type = quoted_string;
133  return t;
134 }
char * heap_ncopy_string(char *s, int n)
heap_ncopy_string
Definition: trees.c:150
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
ptr_psi_term stack_cons ( ptr_psi_term  head,
ptr_psi_term  tail 
)

stack_cons

Parameters
head- ptr_psi_term head
tail- ptr_psi_term tail

STACK_CONS(head,tail) Create a CONS object.

Definition at line 46 of file built_ins.c.

References alist, wl_psi_term::attr_list, cons(), FEATCMP, one, stack_insert(), stack_psi_term(), two, and wl_psi_term::type.

47 {
49 
50  cons=stack_psi_term(4);
51  cons->type=alist;
52  if(head)
53  (void)stack_insert(FEATCMP,one,&(cons->attr_list),(GENERIC)head);
54  if(tail)
55  (void)stack_insert(FEATCMP,two,&(cons->attr_list),(GENERIC)tail);
56 
57  return cons;
58 }
ptr_definition alist
symbol in bi module
Definition: def_glob.h:319
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * two
Definition: def_glob.h:892
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_int_list cons(GENERIC v, ptr_int_list l)
cons
Definition: types.c:179
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
char * one
Definition: def_glob.h:891
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_psi_term stack_copy_psi_term ( psi_term  t)

stack_copy_psi_term

Parameters
t- psi_term t

STACK_COPY_PSI_TERM(tok) Return the address of a copy of TOK on the STACK. All psi_terms read in by the parser are read into the stack.

Definition at line 205 of file parser.c.

References global_time_stamp, and STACK_ALLOC.

206 {
207  ptr_psi_term p;
208 
210  (*p)=t;
211 #ifdef TS
212  p->time_stamp=global_time_stamp; /* 9.6 */
213 #endif
214 
215  return p;
216 }
#define STACK_ALLOC(A)
Definition: def_macro.h:21
unsigned long global_time_stamp
Definition: login.c:28
char * stack_copy_string ( char *  s)

stack_copy_string

Parameters
s- char *s

STACK_COPY_STRING(string) Make a copy of the string in the stack, and return a pointer to that. Exceptions: "1" and "2" are unique (and in the heap).

Definition at line 184 of file trees.c.

References one, stack_alloc(), and two.

185 {
186  char *p;
187 
188  if (s==one || s==two) return s;
189 
190  p=(char *)stack_alloc(strlen(s)+1);
191  strcpy(p,s);
192 
193  return p;
194 }
char * two
Definition: def_glob.h:892
char * one
Definition: def_glob.h:891
GENERIC stack_alloc(long s)
stack_alloc
Definition: memory.c:1642
void stack_info ( FILE *  outfile)

stack_info

Parameters
outfile- FILE *outfile

Definition at line 77 of file error.c.

References depth_cs(), depth_gs(), depth_ts(), and verbose.

78 {
79  /* Information about size of embedded stacks */
80  if (verbose) {
81  long gn,cn,tn;
82  fprintf(outfile,"*** Stack depths [");
83  gn=depth_gs();
84  cn=depth_cs();
85  tn=depth_ts();
86  fprintf(outfile,"%ld goal%s, %ld choice point%s, %ld trail entr%s",
87  gn,(gn!=1?"s":""),
88  cn,(cn!=1?"s":""),
89  tn,(tn!=1?"ies":"y"));
90  fprintf(outfile,"]\n");
91  }
92 }
static long depth_gs()
depth_gs
Definition: error.c:33
long verbose
Definition: error.c:22
static long depth_ts()
depth_ts
Definition: error.c:62
FILE * outfile
Definition: def_glob.h:974
static long depth_cs()
depth_cs
Definition: error.c:47
ptr_node stack_insert ( long  comp,
char *  keystr,
ptr_node tree,
GENERIC  info 
)

stack_insert

Parameters
comp- long comp
keystr- char *keystr
tree- ptr_node *tree
info- GENERIC info

STACK_INSERT(comp,keystr,tree,info) Exactly the same as heap_insert, only the new node is in the stack.

Definition at line 337 of file trees.c.

References FALSE, general_insert(), and STACK.

338 {
339 
340  return general_insert(comp,keystr,tree,info,STACK,FALSE,0L);
341 }
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_node general_insert(long comp, char *keystr, ptr_node *tree, GENERIC info, long heapflag, long copystr, long bkflag)
ptr_node general_insert
Definition: trees.c:224
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
void stack_insert_copystr ( char *  keystr,
ptr_node tree,
GENERIC  info 
)

stack_insert_copystr

Parameters
keystr- char *keystr
tree- ptr_node *tree
info- GENERIC info

STACK_INSERT_COPYSTR(keystr,tree,info) Insert the pointer INFO under the reference string KEYSTR (which is a feature name) in the binary tree TREE. KEYSTR is copied to the heap. A potential additional node allocated to TREE is put on the stack.

Definition at line 301 of file trees.c.

References FEATCMP, general_insert(), STACK, and TRUE.

302 {
303 
304  (void)general_insert(FEATCMP,keystr,tree,info,STACK,TRUE,0L);
305 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_node general_insert(long comp, char *keystr, ptr_node *tree, GENERIC info, long heapflag, long copystr, long bkflag)
ptr_node general_insert
Definition: trees.c:224
#define STACK
Flag to indicate stack allocation.
Definition: def_const.h:331
ptr_psi_term stack_int ( long  n)

stack_int

Parameters
n- long n

STACK_INT(n) create an INT object

Definition at line 91 of file built_ins.c.

References heap_alloc(), integer, REAL, stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

92 {
93  ptr_psi_term m;
94  m=stack_psi_term(4);
95  m->type=integer;
96  m->value_3= heap_alloc(sizeof(REAL));
97  *(REAL *)m->value_3=(REAL)n;
98  return m;
99 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
ptr_psi_term stack_nil ( )

stack_nil

Create the NIL object on the stack.

Definition at line 26 of file built_ins.c.

References nil, stack_psi_term(), and wl_psi_term::type.

28 {
29  ptr_psi_term empty;
30 
31  empty=stack_psi_term(4);
32  empty->type=nil;
33 
34  return empty;
35 }
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
ptr_definition nil
symbol in bi module
Definition: def_glob.h:340
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term stack_pair ( ptr_psi_term  left,
ptr_psi_term  right 
)

stack_pair

Parameters
left- ptr_psi_term left
right- ptr_psi_term right

STACK_PAIR(left,right) create a PAIR object.

Definition at line 69 of file built_ins.c.

References and, wl_psi_term::attr_list, FEATCMP, one, stack_insert(), stack_psi_term(), two, and wl_psi_term::type.

70 {
71  ptr_psi_term pair;
72 
73  pair=stack_psi_term(4);
74  pair->type=and;
75  if(left)
76  (void)stack_insert(FEATCMP,one,&(pair->attr_list),(GENERIC)left);
77  if(right)
78  (void)stack_insert(FEATCMP,two,&(pair->attr_list),(GENERIC)right);
79 
80  return pair;
81 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
char * two
Definition: def_glob.h:892
ptr_definition and
symbol in syntax module
Definition: def_glob.h:171
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
char * one
Definition: def_glob.h:891
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
ptr_psi_term stack_psi_term ( long  stat)

stack_psi_term

Create a new psi_term on the stack with value '@' (top) and no attributes.

Definition at line 21 of file lefun.c.

References wl_psi_term::attr_list, wl_psi_term::coref, FALSE, wl_psi_term::flags, global_time_stamp, NULL, QUOTED_TRUE, wl_psi_term::resid, STACK_ALLOC, wl_psi_term::status, top, wl_psi_term::type, and wl_psi_term::value_3.

22 {
23  ptr_psi_term result;
24 
25  result=STACK_ALLOC(psi_term);
26  result->type=top;
27  result->status=stat;
28  result->flags=stat?QUOTED_TRUE:FALSE; /* 14.9 */
29  result->attr_list=NULL;
30  result->coref=NULL;
31 #ifdef TS
32  result->time_stamp=global_time_stamp; /* 9.6 */
33 #endif
34  result->resid=NULL;
35  result->value_3=NULL;
36 
37  return result;
38 }
ptr_residuation resid
Definition: def_struct.h:189
#define NULL
Definition: def_const.h:533
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_psi_term coref
Definition: def_struct.h:188
#define STACK_ALLOC(A)
Definition: def_macro.h:21
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
unsigned long global_time_stamp
Definition: login.c:28
ptr_definition type
Definition: def_struct.h:181
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
ptr_psi_term stack_string ( char *  s)

stack_string

Parameters
s- char *s

STACK_STRING(s) create a STRING object

Definition at line 109 of file built_ins.c.

References heap_copy_string(), quoted_string, stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

110 {
112  t->type = quoted_string;
114  return t;
115 }
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
void start_chrono ( )

start_chrono

START_CHRONO() This initialises the CPU time counter.

Definition at line 349 of file login.c.

350 {
351  (void)times(&start_time);
352 }
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
void stdin_cleareof ( )

stdin_cleareof

Clear EOF if necessary for stdin

Definition at line 51 of file token.c.

References eof_flag, FALSE, NULL, old_saved_char, old_saved_psi_term, saved_char, saved_psi_term, start_of_line, stdin_terminal, and TRUE.

52 {
53  if (eof_flag && stdin_terminal) {
54  clearerr(stdin);
58  saved_char=0;
61  }
62 }
long eof_flag
Definition: def_glob.h:853
long old_saved_char
Definition: def_glob.h:850
#define NULL
Definition: def_const.h:533
long saved_char
Definition: def_glob.h:849
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
long start_of_line
???
Definition: def_glob.h:846
ptr_psi_term saved_psi_term
Definition: def_glob.h:851
long stdin_terminal
set in init_io in lib.c to true - never changed - used in token.c
Definition: def_glob.h:832
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:852
char* str_conc ( char *  s1,
char *  s2 
)

str_conc

Parameters
s1- char *s1
s2- char *s2

Definition at line 5496 of file built_ins.c.

References heap_alloc().

5497 {
5498  char *result;
5499 
5500  result=(char *)heap_alloc(strlen(s1)+strlen(s2)+1);
5501  sprintf(result,"%s%s",s1,s2);
5502 
5503  return result;
5504 }
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
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 strict_matches ( ptr_psi_term  t1,
ptr_psi_term  t2,
long *  smaller 
)

strict_matches

Parameters
t1- ptr_psi_term t1
t2- ptr_psi_term t2
smaller- long *smaller

STRICT_MATCHES(t1,t2,s) Almost the same as matches, except that S is set to TRUE only if the type of t1 is strictly less than the type of t2. Because of the implementation of ints, reals, strings, and lists, this has to take the value field into account, and thus must be passed the whole psi-term.

Definition at line 1713 of file types.c.

References FALSE, matches(), NULL, TRUE, wl_psi_term::type, and wl_psi_term::value_3.

1714 {
1715  long result,sm;
1716 
1717  result=matches(t1->type,t2->type,&sm);
1718 
1719  if (sm) {
1720  /* At this point, t1->type <| t2->type */
1721  if (t1->type==t2->type) {
1722  /* Same types: strict only if first has a value & second does not */
1723  if (t1->value_3!=NULL && t2->value_3==NULL)
1724  sm=TRUE;
1725  else
1726  sm=FALSE;
1727  }
1728  else {
1729  /* Different types: the first must be strictly smaller */
1730  sm=TRUE;
1731  }
1732  }
1733 
1734  *smaller=sm;
1735  return result;
1736 }
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
char * string_val ( ptr_psi_term  term)

string_val

Parameters
term- ptr_psi_term term

STRING_VAL(term) Return a string defined by a term, that is: if term is a string, return the value, otherwise return the symbol for that term.

Definition at line 169 of file modules.c.

References deref_ptr, wl_definition::keyword, quoted_string, wl_keyword::symbol, wl_psi_term::type, and wl_psi_term::value_3.

170 {
171  deref_ptr(term);
172  if(term->value_3 && term->type==quoted_string)
173  return (char *)term->value_3;
174  else
175  return term->type->keyword->symbol;
176 }
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
#define deref_ptr(P)
Definition: def_macro.h:100
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
char * strip_module_name ( char *  str)

strip_module_name

Parameters
str- char *str

STRIP_MODULE_NAME(symbol) Return the sub-string of symbol without the module prefix.

Definition at line 144 of file modules.c.

References legal_in_name().

145 {
146  char *s=str;
147 
148  while(legal_in_name(*s))
149  s++;
150  if(s!=str && *s=='#' /* && *(s+1)!=0 */) {
151  s++;
152  /* printf("Stripped module from '%s' yielding '%s'\n",str,s); */
153  return s;
154  }
155  else
156  return str;
157 }
long legal_in_name(long c)
legal_in_name
Definition: token.c:980
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 sub_CodeType ( ptr_int_list  c1,
ptr_int_list  c2 
)

sub_CodeType

Parameters
c1- ptr_int_list c1
c2- ptr_int_list c2

SUB_CodeType(c1,c2) Return TRUE if code C1 is <| than type C2, that is if type represented by code C1 matches type represented by C2.

We already know that t1 and t2 are not top.

Definition at line 1618 of file types.c.

References FALSE, wl_int_list::next, NOT_CODED, TRUE, and wl_int_list::value_1.

1619 {
1620  if (c1!=NOT_CODED && c2!=NOT_CODED) {
1621  while (c1 && c2) {
1622  if ((unsigned long)c1->value_1 & ~(unsigned long)c2->value_1) return FALSE;
1623  c1=c1->next;
1624  c2=c2->next;
1625  }
1626  }
1627  else
1628  return FALSE;
1629 
1630  return TRUE;
1631 }
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
char* sub_str ( char *  s,
long  p,
long  n 
)

sub_str

Parameters
s- char *s
p- long p
n- long n

Definition at line 5514 of file built_ins.c.

References heap_alloc().

5515 {
5516  char *result;
5517  long i;
5518  long l;
5519 
5520  l=strlen(s);
5521  if(p>l || p<0 || n<0)
5522  n=0;
5523  else
5524  if(p+n-1>l)
5525  n=l-p+1;
5526 
5527  result=(char *)heap_alloc(n+1);
5528  for(i=0;i<n;i++)
5529  *(result+i)= *(s+p+i-1);
5530 
5531  *(result+n)=0;
5532 
5533  return result;
5534 }
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
long sub_type ( ptr_definition  t1,
ptr_definition  t2 
)

sub_type

Parameters
t1- ptr_definition t1
t2- ptr_definition t2

SUB_TYPE(t1,t2) Return TRUE if type T1 is <| than type T2, that is if T1 matches T2.

Definition at line 1642 of file types.c.

References wl_definition::code, FALSE, sub_CodeType(), top, and TRUE.

1643 {
1644  if (t1!=t2)
1645  if (t2!=top)
1646  {
1647  if (t1==top)
1648  return FALSE;
1649  else
1650  return sub_CodeType(t1->code, t2->code);
1651  }
1652  return TRUE;
1653 }
long sub_CodeType(ptr_int_list c1, ptr_int_list c2)
sub_CodeType
Definition: types.c:1618
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_int_list code
Definition: def_struct.h:150
long symbolic ( long  c)

symbolic

Parameters
c- long c

SYMBOLIC(character) Tests if character is a symbol (see macro).

Definition at line 967 of file token.c.

References SYMBOL.

968 {
969  return SYMBOL(c);
970 }
#define SYMBOL(C)
Definition: def_macro.h:57
void Syntaxerrorline ( char *  format,
  ... 
)

Syntaxerrorline.

Parameters
format- char *format
...

Definition at line 557 of file error.c.

References assert, display_psi(), FALSE, input_file_name, parse_ok, perr_i(), perr_s(), print_code(), print_def_type(), print_operator_kind(), and psi_term_line_number.

558 {
559  va_list VarArg;
560  // int l;
561  char buffer_loc[5];
562  char *p;
563  unsigned long lng2;
564  char *cptr;
565  ptr_int_list pil;
566  ptr_psi_term psi;
567  operator kind;
568  def_type t ;
569  va_start(VarArg,format);
570  // fprintf(stderr,"format = %lx %s\n",(long)format,format);fflush(stdout);
571  if(parse_ok) { /* RM: Feb 1 1993 */
572  parse_ok=FALSE; /* RM: Feb 1 1993 */
573  fprintf(stderr,"*** Syntax error: ");
574  // fprintf(stderr,"format2 = %lx %s\n",(long)format,format);
575  // vinfoline(format, stderr, VarArg);
576  //#define vinfoline(format, outfile, xxxx) {
577  for (p=format;p && *p; p++)
578  {
579  if (*p == '%')
580  {
581  p++;
582  switch (*p)
583  {
584  case 'd':
585  case 'x':
586  buffer_loc[0] = '%';
587  buffer_loc[1] = 'l';
588  buffer_loc[2] = *p;
589  buffer_loc[3] = 0;
590  lng2 = va_arg(VarArg,long);
591  fprintf(stderr, buffer_loc, lng2);
592  break;
593  case 's':
594  buffer_loc[0] = '%';
595  buffer_loc[1] = *p;
596  buffer_loc[2] = 0;
597  cptr = va_arg(VarArg,char *);
598  fprintf(stderr, buffer_loc, cptr);
599  break;
600  case 'C':
601  /* type coding as bin string */
602  pil = va_arg(VarArg,ptr_int_list);
603  print_code(stderr,pil);
604  break;
605  case 'P':
606  psi = va_arg(VarArg,ptr_psi_term);
607  display_psi(stderr,psi);
608  break;
609  case 'O':
610  kind = va_arg(VarArg,operator);
611  print_operator_kind(stderr,kind);
612  break;
613  case 'T':
614  assert(stderr==stderr);
615  t = va_arg(VarArg,def_type);
616  print_def_type(t);
617  break;
618  case 'E':
619  assert(stderr==stderr);
620  perr_i("near line %ld",psi_term_line_number);
621  if (strcmp(input_file_name,"stdin")) {
622  perr_s(" in file \042%s\042",input_file_name);
623  }
624  parse_ok=FALSE;
625  break;
626  case '%':
627  (void)putc(*p,stderr);
628  break;
629  default:
630  fprintf(stderr,"<%c follows %% : report bug >", *p);
631  break;
632  }
633  }
634  else
635  (void)putc(*p,stderr);
636  }
637  }
638  va_end(VarArg);
639 }
void perr_i(char *str, long i)
perr_i
Definition: error.c:800
long psi_term_line_number
Definition: def_glob.h:909
string input_file_name
Definition: def_glob.h:1016
void display_psi(FILE *s, ptr_psi_term t)
display_psi
Definition: print.c:1579
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
void print_code(FILE *s, ptr_int_list c)
print_code
Definition: print.c:167
void print_def_type(def_type t)
print_def_type
Definition: types.c:24
#define FALSE
Standard boolean.
Definition: def_const.h:275
void print_operator_kind(FILE *s, long kind)
print_operator_kind
Definition: print.c:192
#define assert(N)
Definition: memory.c:114
char * text_buffer_cmp ( struct text_buffer buf,
int  idx,
char *  str 
)

text_buffer_cmp

Parameters
buf- struct text_buffer *buf
idx- int idx
str- char *str

compare string str with text in buffer buf starting at index idx. if the text to the end matches a prefix of the string, return pointer to remaining suffix of str to be matched, else return 0.

Definition at line 934 of file sys.c.

References text_buffer::data, text_buffer::next, and top.

935 {
936  while (buf) {
937  while (idx<buf->top)
938  if (!*str || buf->data[idx] != *str)
939  return 0;
940  else { idx++; str++; }
941  if (!*str && !buf->next) return str;
942  else {
943  buf=buf->next;
944  idx=0;
945  }
946  }
947  return 0;
948 }
char data[TEXTBUFSIZE]
Definition: def_struct.h:401
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
struct text_buffer * next
Definition: def_struct.h:399
void text_buffer_free ( struct text_buffer buf)

text_buffer_free

Parameters
buf- struct text_buffer *buf

free a linked list of buffers

Definition at line 986 of file sys.c.

References text_buffer::next.

987 {
988  struct text_buffer *next;
989  while (buf) {
990  next = buf->next;
991  free(buf);
992  buf=next;
993  }
994 }
struct text_buffer * next
Definition: def_struct.h:399
int text_buffer_next ( struct text_buffer buf,
int  idx,
char  c,
struct text_buffer **  rbuf,
int *  ridx 
)

text_buffer_next

Parameters
buf- struct text_buffer *buf
idx- int idx
c- char c
rbuf- struct text_buffer **rbuf
ridx- int *ridx

find the first match for character c starting from index idx in buffer buf. if found place new buffer and index in rbuf and ridx and return 1, else return 0

Definition at line 907 of file sys.c.

References text_buffer::data, text_buffer::next, and top.

908 {
909  while (buf) {
910  while (idx<buf->top)
911  if (buf->data[idx] == c) {
912  *rbuf=buf;
913  *ridx=idx;
914  return 1;
915  }
916  else idx++;
917  buf=buf->next;
918  idx=0;
919  }
920  return 0;
921 }
char data[TEXTBUFSIZE]
Definition: def_struct.h:401
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
struct text_buffer * next
Definition: def_struct.h:399
void text_buffer_push ( struct text_buffer **  buf,
char  c 
)

text_buffer_push

Parameters
buf- struct text_buffer **buf
c- char c

add a character at the end of a buffer. if the buffer is full, allocate a new buffer and link it to the current one, then overwrite the variable holding the pointer to the current buffer with the pointer to the new buffer.

Definition at line 961 of file sys.c.

References text_buffer::next, TEXTBUFSIZE, and text_buffer::top.

962 {
963  if ((*buf)->top < TEXTBUFSIZE)
964  (*buf)->data[(*buf)->top++] = c;
965  else {
966  (*buf)->next = (struct text_buffer *)
967  malloc(sizeof(struct text_buffer));
968  if (!(*buf)->next) {
969  fprintf(stderr,"Fatal error: malloc failed in text_buffer_push\n");
970  exit(EXIT_FAILURE);
971  }
972  bzero((char*)(*buf)->next,sizeof(struct text_buffer));
973  *buf = (*buf)->next;
974  (*buf)->top = 1;
975  (*buf)->data[0]=c;
976  }
977 }
#define TEXTBUFSIZE
Definition: def_struct.h:396
struct text_buffer * next
Definition: def_struct.h:399
void title ( )

TITLE.

This routine marks the start of Life. It prints info about the compile DATE, some blurb about the author etc... Who cares anyway?? [I do! -hak]

Definition at line 39 of file info.c.

References PARSER_STACK_SIZE, pnf(), quietflag, REAL, and STRLEN.

40 {
41  if(quietflag)
42  return; /* RM: Feb 17 1993 */
43 
44  printf("Wild_Life Interpreter Version +VERSION+ +DATE+\n");
45  printf("Copyright (C) 1991-93 DEC Paris Research Laboratory\n");
46  printf("Extensions, Copyright (C) 1994-1995 Intelligent Software Group, SFU\n");
47  // should comment next 4 lines for test suite
48  // printf("OS/2 Port by Dennis J. Darland 06/17/96\n");
49  // printf("SUSE Linux Port by Dennis J. Darland May 2014\n");
50  // printf("Cygwin Port by Dennis J. Darland March 2015\n");
51  // printf("Further Debugging of Port by Dennis J. Darland June 2016\n");
52  // I don't understand why I cannot have above lines.
53  // has to to with title call in lib.c & life.c - related to memory.c
54  // may be important to understand even not just for above printf's
55 
56 #ifndef X11
57  printf("X interface not installed.\n");
58 #endif
59 
60 #if 0
61  printf("\n- Main data-structure sizes:\n");
62  pnf("rule",sizeof(struct pair_list));
63  pnf("psi_term",sizeof(struct psi_term));
64  pnf("binary tree node",sizeof(struct node));
65  pnf("stacked goal",sizeof(struct goal));
66  pnf("stacked choice-point",sizeof(struct choice_point));
67  pnf("backtracking action",sizeof(struct ptr_stack));
68  pnf("symbol definition",sizeof(struct definition));
69  pnf("code node",sizeof(struct int_list));
70  pnf("list node",sizeof(struct list));
71  pnf("real number",sizeof(REAL));
72 
73  printf("\n- Size of C built-in types:\n");
74  pnf("REAL",sizeof(REAL));
75  pnf("long",sizeof(long));
76  pnf("int",sizeof(unsigned long));
77  pnf("pointer",sizeof(char *));
78 
79  printf("\n- System constants:\n");
80  pnf("Maximum string or line length:",STRLEN);
81  pnf("Parser stack depth:",PARSER_STACK_SIZE);
82  pnf("Size of real numbers:",sizeof(REAL));
83  printf("\n\n");
84 #endif
85 }
static void pnf(char *s, int n)
PNF.
Definition: info.c:21
#define PARSER_STACK_SIZE
Maximum depth of the parser stack.
Definition: def_const.h:198
long quietflag
Definition: def_glob.h:912
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define STRLEN
Maximum size of file names and input tokens (which includes input strings) (Note: calculated tokens c...
Definition: def_const.h:162
void toggle_step ( )

toggle_step

Definition at line 747 of file error.c.

References new_step(), and stepflag.

748 {
749  new_step(!stepflag);
750 }
void new_step(long newstep)
new_step
Definition: error.c:713
long stepflag
Definition: error.c:23
void toggle_trace ( )

toggle_trace

Definition at line 737 of file error.c.

References new_trace(), and trace.

738 {
739  new_trace(trace?0:1);
740 }
void new_trace(long newtrace)
new_trace
Definition: error.c:698
long trace
Definition: error.c:21
void TOKEN_ERROR ( ptr_psi_term  p)

TOKEN_ERROR.

Parameters
p- ptr_psi_term p

Definition at line 38 of file token.c.

References error_psi_term, Syntaxerrorline(), and wl_psi_term::type.

39 {
40  if(p->type==error_psi_term->type) {
41  Syntaxerrorline("Module violation (%E).\n");
42  }
43 }
void Syntaxerrorline(char *format,...)
Syntaxerrorline.
Definition: error.c:557
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
ptr_definition type
Definition: def_struct.h:181
ptr_choice_point topmost_what_next ( )

topmost_what_next

UNUSED 12.7 Return the choice point corresponding to the first 'what_next' choice point in the choice point stack. Return NULL if there is none. This is used to ensure that cuts don't go below the most recent 'what_next' choice point.

Definition at line 2026 of file login.c.

References choice_stack, wl_choice_point::goal_stack, wl_choice_point::next, NULL, wl_goal::type, and what_next.

2027 {
2029 
2030  while (cp && cp->goal_stack && cp->goal_stack->type!=what_next)
2031  cp=cp->next;
2032 
2033  if (cp && cp->goal_stack && cp->goal_stack->type==what_next)
2034  return cp;
2035  else
2036  return (ptr_choice_point) NULL;
2037 }
#define NULL
Definition: def_const.h:533
ptr_choice_point next
Definition: def_struct.h:250
goals type
Definition: def_struct.h:238
#define what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1079
ptr_goal goal_stack
Definition: def_struct.h:249
ptr_choice_point choice_stack
Definition: def_glob.h:1026
void traceline ( char *  format,
  ... 
)

traceline

Parameters
format- char *format
...

Definition at line 186 of file error.c.

References assert, display_psi(), FALSE, input_file_name, parse_ok, perr_i(), perr_s(), print_code(), print_def_type(), print_operator_kind(), psi_term_line_number, trace, and tracing().

187 {
188  va_list VarArg;
189  // int l;
190  char buffer_loc[5];
191  char *p;
192  unsigned long lng2;
193  char *cptr;
194  ptr_int_list pil;
195  ptr_psi_term psi;
196  operator kind;
197  def_type t ;
198 
199  va_start(VarArg,format);
200 
201  if (trace) // DJD
202  {
203  /* RM: Nov 10 1993 */
204 
205  if ((trace == 2) && (format[0] != 'p')) return;
206  tracing();
207 
208  // vinfoline(format, stdout, VarArg);
209  // #define vinfoline(format, outfile, xxxx) {
210  for (p=format;p && *p; p++)
211  {
212  if (*p == '%')
213  {
214  p++;
215  switch (*p)
216  {
217  case 'd':
218  case 'x':
219  buffer_loc[0] = '%';
220  buffer_loc[1] = 'l';
221  buffer_loc[2] = *p;
222  buffer_loc[3] = 0;
223  lng2 = va_arg(VarArg, long);
224  fprintf(stdout, buffer_loc, lng2);
225  break;
226  case 's':
227  buffer_loc[0] = '%';
228  buffer_loc[1] = *p;
229  buffer_loc[2] = 0;
230  cptr = va_arg(VarArg,char *);
231  fprintf(stdout, buffer_loc, cptr);
232  break;
233  case 'C':
234  /* type coding as bin string */
235  pil = va_arg(VarArg,ptr_int_list);
236  print_code(stdout,pil);
237  break;
238  case 'P':
239  psi = va_arg(VarArg,ptr_psi_term);
240  display_psi(stdout,psi);
241  break;
242  case 'O':
243  kind = va_arg(VarArg,operator);
244  print_operator_kind(stdout,kind);
245  break;
246  case 'T':
247  assert(stdout==stderr);
248  t = va_arg(VarArg,def_type);
249  print_def_type(t);
250  break;
251  case 'E':
252  assert(stdout==stderr);
253  perr_i("near line %ld",psi_term_line_number);
254  if (strcmp(input_file_name,"stdin")) {
255  perr_s(" in file \042%s\042",input_file_name);
256  }
257  parse_ok=FALSE;
258  break;
259  case '%':
260  (void)putc(*p,stdout);
261  break;
262  default:
263  fprintf(stdout,"<%c follows %% : report bug >", *p);
264  break;
265  }
266  }
267  else
268  (void)putc(*p,stdout);
269  }
270  }
271  va_end(VarArg);
272 }
void perr_i(char *str, long i)
perr_i
Definition: error.c:800
long psi_term_line_number
Definition: def_glob.h:909
string input_file_name
Definition: def_glob.h:1016
void display_psi(FILE *s, ptr_psi_term t)
display_psi
Definition: print.c:1579
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
void tracing()
tracing
Definition: error.c:678
void print_code(FILE *s, ptr_int_list c)
print_code
Definition: print.c:167
void print_def_type(def_type t)
print_def_type
Definition: types.c:24
#define FALSE
Standard boolean.
Definition: def_const.h:275
long trace
Definition: error.c:21
void print_operator_kind(FILE *s, long kind)
print_operator_kind
Definition: print.c:192
#define assert(N)
Definition: memory.c:114
void tracing ( )

tracing

Definition at line 678 of file error.c.

References depth_cs(), depth_gs(), goal_count, MAX_TRACE_INDENT, steptrace, and TRUE.

679 {
680  long i;
681  long indent_loc;
682 
683  printf("T%04ld",goal_count);
684  printf(" C%02ld",depth_cs());
685  indent_loc=depth_gs();
686  if (indent_loc>=MAX_TRACE_INDENT) printf(" G%02ld",indent_loc);
687  indent_loc = indent_loc % MAX_TRACE_INDENT;
688  for (i=indent_loc; i>=0; i--) printf(" ");
689  steptrace=TRUE;
690 }
static long depth_gs()
depth_gs
Definition: error.c:33
#define MAX_TRACE_INDENT
Maximum goal indentation during tracing.
Definition: def_const.h:247
long steptrace
Definition: error.c:24
long goal_count
Definition: def_glob.h:678
#define TRUE
Standard boolean.
Definition: def_const.h:268
static long depth_cs()
depth_cs
Definition: error.c:47
long trail_condition ( psi_term Q)

trail_condition

Parameters
Q- psi_term *Q

Definition at line 2630 of file login.c.

References choice_stack, and wl_choice_point::time_stamp.

2631 {
2632  return (choice_stack && choice_stack->time_stamp>=Q->time_stamp);
2633 }
unsigned long time_stamp
Definition: def_struct.h:247
ptr_choice_point choice_stack
Definition: def_glob.h:1026
ptr_psi_term translate ( ptr_psi_term  a,
long **  infoptr 
)

translate

Parameters
a- ptr_psi_term a
infoptr- long **infoptr

TRANSLATE(a,info) Get the translation of address A and the info field stored with it. Return NULL if none is found.

Definition at line 108 of file copy.c.

References hashentry::bucketindex, HASH, HASHEND, hashtable, hashtime, hashbucket::info, hashbucket::new_value, hashbucket::next, NULL, and hashbucket::old_value.

109 {
110  long index;
111  /* long i; 20.8 */
112  long bucket;
113 
114  index = HASH(a);
115  if (hashtable[index].timestamp != hashtime) return NULL;
116  bucket = hashtable[index].bucketindex;
117  /* i=0; 20.8 */
118  while (bucket != HASHEND && hashbuckets[bucket].old_value != a) {
119  /* i++; 20.8 */
120  bucket = hashbuckets[bucket].next;
121  }
122  /* hashstats[i]++; 20.8 */
123  if (bucket != HASHEND) {
124  *infoptr = &hashbuckets[bucket].info;
125  return (hashbuckets[bucket].new_value);
126  }
127  else
128  return NULL;
129 }
static struct hashentry hashtable[HASHSIZE]
Definition: copy.c:16
#define HASHEND
Tail of hash bucket.
Definition: def_const.h:1299
#define NULL
Definition: def_const.h:533
static long hashtime
Definition: copy.c:18
static struct hashbucket * hashbuckets
Definition: copy.c:17
long bucketindex
Definition: def_struct.h:393
#define HASH(A)
Definition: def_macro.h:278
void traverse_tree ( ptr_node  n,
int  flag 
)

traverse_tree

Parameters
n- ptr_node n
flag- int flag

Do for all arguments, for the built-ins c_public, c_private, and c_private_feature.

Definition at line 656 of file modules.c.

References wl_node::data, deref_ptr, FALSE, wl_node::left, MAKE_FEATURE_PRIVATE, make_feature_private(), MAKE_PRIVATE, make_public(), MAKE_PUBLIC, wl_node::right, and TRUE.

657 {
658  if (n) {
659  ptr_psi_term t;
660  traverse_tree(n->left,flag);
661 
662  t=(ptr_psi_term)n->data;
663  deref_ptr(t);
664  switch (flag) {
665  case MAKE_PUBLIC:
666  (void)make_public(t,TRUE);
667  break;
668  case MAKE_PRIVATE:
669  (void)make_public(t,FALSE);
670  break;
672  (void)make_feature_private(t);
673  break;
674  }
675  traverse_tree(n->right,flag);
676  }
677 }
void traverse_tree(ptr_node n, int flag)
traverse_tree
Definition: modules.c:656
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 MAKE_PRIVATE
Definition: modules.c:644
#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
int make_feature_private(ptr_psi_term term)
make_feature_private
Definition: modules.c:1256
long make_public(ptr_psi_term term, long bool)
make_public
Definition: modules.c:613
#define MAKE_FEATURE_PRIVATE
Definition: modules.c:645
#define MAKE_PUBLIC
Definition: modules.c:643
ptr_node right
Definition: def_struct.h:200
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
ptr_int_list two_to_the ( long  p)

two_to_the

Parameters
p- long p

TWO_TO_THE(p) Return the code worth 2^p.

Definition at line 776 of file types.c.

References HEAP_ALLOC, INT_SIZE, wl_int_list::next, NULL, and wl_int_list::value_1.

777 {
778  ptr_int_list result,code;
779  long v=1;
780 
781  code=HEAP_ALLOC(int_list);
782  code->value_1=0;
783  code->next=NULL;
784  result=code;
785 
786  while (p>=INT_SIZE) {
787  code->next=HEAP_ALLOC(int_list);
788  code=code->next;
789  code->value_1=0;
790  code->next=NULL;
791  p=p-INT_SIZE;
792  }
793 
794  v= v<<p ;
795  code->value_1=(GENERIC)v;
796 
797  return result;
798 }
#define INT_SIZE
How many types can be encoded on one integer in the transitive closure encoding.
Definition: def_const.h:317
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
GENERIC value_1
Definition: def_struct.h:85
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
ptr_int_list next
Definition: def_struct.h:86
long type_cyclicity ( ptr_definition  d,
ptr_int_list  anc 
)

type_cyclicity

Parameters
d- ptr_definition d
anc- ptr_int_list anc

TYPE_CYCLICITY(d,anc) Check cyclicity of type hierarchy. If cyclic, return a TRUE error condition and print an error message with a cycle.

Definition at line 977 of file types.c.

References wl_definition::code, Errorline(), exit_life(), FALSE, wl_int_list::next, NOT_CODED, wl_definition::parents, perr(), perr_sort_cycle(), TRUE, type_member(), and wl_int_list::value_1.

978 {
979  ptr_int_list p=d->parents;
980  ptr_definition pd;
981  long errflag;
982  int_list anc2;
983 
984  while (p) {
985  pd=(ptr_definition)p->value_1;
986  /* If unmarked, mark and recurse */
987  if (pd->code==NOT_CODED) {
988  pd->code = (ptr_int_list)TRUE;
989  anc2.value_1=(GENERIC)pd;
990  anc2.next=anc;
991  errflag=type_cyclicity(pd,&anc2);
992  if (errflag) return TRUE;
993  }
994  /* If marked, check if it's in the ancestor list */
995  else {
996  if (type_member(pd,anc)) {
997  Errorline("there is a cycle in the sort hierarchy\n");
998  perr("*** Cycle: [");
999  perr_sort_cycle(anc);
1000  perr("]\n");
1001  exit_life(TRUE);
1002  return TRUE;
1003  }
1004  }
1005  p=p->next;
1006  }
1007  return FALSE;
1008 }
long type_cyclicity(ptr_definition d, ptr_int_list anc)
type_cyclicity
Definition: types.c:977
void perr(char *str)
perr
Definition: error.c:763
void exit_life(long nl_flag)
exit_life
Definition: built_ins.c:2219
#define NOT_CODED
For LIFE boolean calculation built-in.
Definition: def_const.h:294
void perr_sort_cycle(ptr_int_list anc)
perr_sort_cycle
Definition: types.c:959
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
struct wl_definition * ptr_definition
Definition: def_struct.h:59
ptr_int_list code
Definition: def_struct.h:150
GENERIC value_1
Definition: def_struct.h:85
struct wl_int_list * ptr_int_list
Definition: def_struct.h:57
long type_member(ptr_definition t, ptr_int_list tlst)
type_member
Definition: types.c:918
ptr_int_list next
Definition: def_struct.h:86
ptr_int_list parents
Definition: def_struct.h:151
void type_disj_aim ( )

type_disj_aim

TYPE_DISJ_AIM() This routine implements type disjunctions, that is, when a type has been decoded and found to be a disjunction of types, enumerates the different values one by one.

Definition at line 1845 of file login.c.

References wl_goal::aaaa_1, aim, wl_definition::always_check, wl_psi_term::attr_list, wl_goal::bbbb_1, def_ptr, FALSE, fetch_def(), wl_definition::keyword, wl_int_list::next, NULL, push_choice_point(), push_ptr_value(), wl_psi_term::status, wl_keyword::symbol, traceline(), wl_psi_term::type, type_disj, and wl_int_list::value_1.

1846 {
1847  ptr_psi_term t;
1848  ptr_int_list d;
1849 
1850  t=(ptr_psi_term)aim->aaaa_1;
1851  d=(ptr_int_list)aim->bbbb_1;
1852 
1853  if (d->next) {
1854  traceline("pushing type disjunction choice point for %P\n", t);
1856  }
1857 
1858  push_ptr_value(def_ptr,(GENERIC *)&(t->type));
1859  /* Below makes cut.lf behave incorrectly: */
1860  /* push_def_ptr_value(t,&(t->type)); */ /* 14.8 */
1861  t->type=(ptr_definition)d->value_1;
1862 
1863  traceline("setting type disjunction to %s.\n", t->type->keyword->symbol);
1864 
1865  if ((t->attr_list || t->type->always_check) && t->status<4)
1866  fetch_def(t, FALSE);
1867 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define def_ptr
values of type_ptr
Definition: def_const.h:404
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define NULL
Definition: def_const.h:533
char * symbol
Definition: def_struct.h:118
char always_check
Definition: def_struct.h:154
void traceline(char *format,...)
traceline
Definition: error.c:186
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define FALSE
Standard boolean.
Definition: def_const.h:275
struct wl_definition * ptr_definition
Definition: def_struct.h:59
ptr_goal aim
Definition: def_glob.h:1024
#define type_disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1128
ptr_definition type
Definition: def_struct.h:181
GENERIC value_1
Definition: def_struct.h:85
ptr_psi_term bbbb_1
Definition: def_struct.h:240
void fetch_def(ptr_psi_term u, long allflag)
fetch_def
Definition: login.c:1208
ptr_node attr_list
Definition: def_struct.h:187
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
void push_choice_point(goals t, ptr_psi_term aaaa_6, ptr_psi_term bbbb_6, GENERIC cccc_6)
push_choice_point
Definition: login.c:638
ptr_int_list next
Definition: def_struct.h:86
long type_member ( ptr_definition  t,
ptr_int_list  tlst 
)

type_member

Parameters
t- ptr_definition t
tlst- ptr_int_list tlst

TYPE_MEMBER(t,tlst) Return TRUE iff type t is in the list tlst.

Definition at line 918 of file types.c.

References FALSE, wl_int_list::next, TRUE, and wl_int_list::value_1.

919 {
920  while (tlst) {
921  if (t==(ptr_definition)tlst->value_1) return TRUE;
922  tlst=tlst->next;
923  }
924  return FALSE;
925 }
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_1
Definition: def_struct.h:85
ptr_int_list next
Definition: def_struct.h:86
void undo ( ptr_stack  limit)

undo

Parameters
limit- ptr_stack limit

UNDO(limit) Undoes any side-effects up to LIMIT. Limit being the adress of the stack of side-effects you wish to return to.

Possible improvement: LIMIT is a useless parameter because GOAL_STACK is equivalent if one takes care when stacking UNDO actions. Namely, anything to be undone must be stacked LATER (=after) the goal which caused these things to be done, so that when the goal fails, everything done after it can be undone and the memory used can be reclaimed. This routine could be modified in order to cope with goals to be proved on backtracking: undo(goal).

Definition at line 691 of file login.c.

References wl_stack::aaaa_3, wl_stack::bbbb_3, destroy_window, hide_subwindow, hide_window, wl_stack::next, show_subwindow, show_window, wl_stack::type, undo_action, undo_stack, x_destroy_window(), x_hide_subwindow(), x_hide_window(), x_show_subwindow(), and x_show_window().

692 {
693  /*
694  while((unsigned long)undo_stack>(unsigned long)goal_stack)
695  */
696 
697  while ((unsigned long)undo_stack>(unsigned long)limit) {
698 #ifdef X11
699  if (undo_stack->type & undo_action) {
700  /* Window operation on backtracking */
701  switch(undo_stack->type) { /*** RM 8/12/92 ***/
702  case destroy_window:
703  x_destroy_window((Display *)undo_stack->aaaa_3,(Window)undo_stack->bbbb_3);
704  break;
705  case show_window:
706  x_show_window((Display *)undo_stack->aaaa_3,(Window)undo_stack->bbbb_3);
707  break;
708  case hide_window:
709  x_hide_window((Display *)undo_stack->aaaa_3,(Window)undo_stack->bbbb_3);
710  break;
711  case show_subwindow:
712  x_show_subwindow((Display *)undo_stack->aaaa_3,(Window)undo_stack->bbbb_3);
713  break;
714  case hide_subwindow:
715  x_hide_subwindow((Display *)undo_stack->aaaa_3,(Window)undo_stack->bbbb_3);
716  break;
717  }
718  }
719  else
720 #endif
721  /* Restoring variable value on backtracking */
724  }
725 }
#define show_subwindow
To backtrack on show sub windows RM 8/12/92.
Definition: def_const.h:470
#define hide_subwindow
To backtrack on hide sub windows RM 8/12/92.
Definition: def_const.h:477
#define show_window
To backtrack on show window.
Definition: def_const.h:456
void x_show_subwindow(Display *display, long window)
x_show_subwindow
Definition: xpred.c:3901
void x_hide_subwindow(Display *display, long window)
x_hide_subwindow
Definition: xpred.c:3915
GENERIC * bbbb_3
Definition: def_struct.h:233
void x_show_window(Display *display, long window)
x_show_window
Definition: xpred.c:3871
#define destroy_window
To backtrack on window creation.
Definition: def_const.h:449
#define hide_window
To backtrack on hide window.
Definition: def_const.h:463
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
type_ptr type
Definition: def_struct.h:231
void x_hide_window(Display *display, long window)
x_hide_window
Definition: xpred.c:3885
GENERIC * aaaa_3
Definition: def_struct.h:232
#define undo_action
Fast checking for an undo action.
Definition: def_const.h:484
ptr_stack next
Definition: def_struct.h:234
void x_destroy_window(Display *display, Window window)
x_destroy_window
Definition: xpred.c:3852
void undo_actions ( )

undo_actions

UNDO_ACTIONS() A subset of undo(limit) (the detrailing routine) that does all undo actions on the undo_stack, but does not undo any variable bindings, nor does it change the value of undo_stack.

Definition at line 736 of file login.c.

References Errorline(), NULL, and undo().

737 {
738  // ptr_stack u=undo_stack;
739 
740  Errorline("undo_actions should not be called.\n");
741  undo(NULL); /* 8.10 */
742  return;
743  /*
744  #ifdef X11
745  while ((unsigned long)u) {
746  if (u->type & undo_action) {
747  if (u->type==destroy_window) {
748  x_destroy_window((unsigned long)u->aaaa_3,(unsigned long)u->bbbb_3);
749  }
750  else if (u->type==show_window) {
751  x_show_window((unsigned long)u->aaaa_3,(unsigned long)u->bbbb_3);
752  }
753  else if (u->type==hide_window) {
754  x_hide_window((unsigned long)u->aaaa_3,(unsigned long)u->bbbb_3);
755  }
756  }
757  u=u->next;
758  }
759  #endif
760  */
761 }
void undo(ptr_stack limit)
undo
Definition: login.c:691
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
long unify_aim ( )

unify_aim

UNIFY_AIM() This routine performs one unification step. AIM is the current unification goal.

U and V are the two psi-terms to unify.

It swaps the two psi-terms into chronological order. U is the oldest (smallest stack address). Calculates their GLB, check their values are unifiable. It deals with all the messy things like: curried functions gaining missing arguments, types which need checking, residuation variables whose constraints must be released, disjunctions appearing in the GLB etc...

It's a rather lengthy routine, only its speed is fairly crucial in the overall performance of Wild_Life, and the code is not duplicated elsewhere.

Definition at line 1344 of file login.c.

References TRUE, and unify_body().

1345 {
1346  return unify_body(TRUE);
1347 }
long unify_body(long eval_flag)
unify_body
Definition: login.c:1365
#define TRUE
Standard boolean.
Definition: def_const.h:268
long unify_aim_noeval ( )

unify_aim_noeval

Definition at line 1354 of file login.c.

References FALSE, and unify_body().

1355 {
1356  return unify_body(FALSE);
1357 }
long unify_body(long eval_flag)
unify_body
Definition: login.c:1365
#define FALSE
Standard boolean.
Definition: def_const.h:275
long unify_body ( long  eval_flag)

unify_body

Parameters
eval_flag- long eval_flag

Definition at line 1365 of file login.c.

References wl_goal::aaaa_1, aim, wl_psi_term::attr_list, wl_goal::bbbb_1, wl_psi_term::coref, cut, cut_ptr, decode(), def_ptr, deref, deref_ptr, equal_types, Errorline(), FALSE, fetch_def_lazy(), wl_psi_term::flags, function_it, glb(), global_unify(), heap_pointer, int_ptr, integer, wl_definition::keyword, merge(), more_u_attr, more_v_attr, new_stat, wl_int_list::next, NULL, overlap_type(), push_choice_point(), push_psi_ptr_value(), push_ptr_value(), quoted_string, QUOTED_TRUE, REAL, real, release_resid(), wl_psi_term::resid, wl_psi_term::status, sub_type(), wl_keyword::symbol, sys_bytedata, traceline(), TRUE, wl_psi_term::type, wl_definition::type_def, type_disj, type_it, u_func, v_func, wl_int_list::value_1, wl_psi_term::value_3, and warningline().

1366 {
1367  long success=TRUE,compare;
1368  ptr_psi_term u,v,tmp;
1369  REAL r;
1370  ptr_definition new_type,old1,old2;
1371  ptr_node old1attr, old2attr;
1372  ptr_int_list new_code;
1373  ptr_int_list d=NULL;
1374  long old1stat,old2stat; /* 18.2.94 */
1375 
1376  u=(ptr_psi_term )aim->aaaa_1;
1377  v=(ptr_psi_term )aim->bbbb_1;
1378 
1379  deref_ptr(u);
1380  deref_ptr(v);
1381 
1382  traceline("unify %P with %P\n",u,v);
1383 
1384  if (eval_flag) {
1385  deref(u);
1386  deref(v);
1387  }
1388 
1389  if (u!=v) {
1390 
1391  /**** Swap the two psi-terms to get them into chronological order ****/
1392  if (u>v) { tmp=v; v=u; u=tmp; }
1393 
1394  /**** Check for curried functions ****/
1397  old1stat=u->status; /* 18.2.94 */
1398  old2stat=v->status; /* 18.2.94 */
1399 
1400  /* PVR 18.2.94 */
1401  /* if (u_func && !(u->flags&QUOTED_TRUE) && v->attr_list) { */
1402  if (u_func && u->status==4 && !(u->flags&QUOTED_TRUE) && v->attr_list) {
1403  Errorline("attempt to unify with curried function %P\n", u);
1404  return FALSE;
1405  }
1406  /* if (v_func && !(v->flags&QUOTED_TRUE) && u->attr_list) { */
1407  if (v_func && v->status==4 && !(v->flags&QUOTED_TRUE) && u->attr_list) {
1408  Errorline("attempt to unify with curried function %P\n", v);
1409  return FALSE;
1410  }
1411 
1412 
1413 #ifdef ARITY /* RM: Mar 29 1993 */
1414  arity_unify(u,v);
1415 #endif
1416 
1417  /***** Deal with global vars **** RM: Feb 8 1993 */
1418  if((GENERIC) v>=heap_pointer)
1419  return global_unify(u,v);
1420 
1421 
1422  /**** Calculate their Greatest Lower Bound and compare them ****/
1423  success=(compare=glb(u->type,v->type,&new_type,&new_code));
1424 
1425  if (success) {
1426 
1427  /**** Keep the old types for later use in incr. constraint checking ****/
1428  old1 = u->type;
1429  old2 = v->type;
1430  old1attr = u->attr_list;
1431  old2attr = v->attr_list;
1432 
1433  /**** DECODE THE RESULTING TYPE ****/
1434  if (!new_type) {
1435  d=decode(new_code);
1436  if (d) {
1437  new_type=(ptr_definition)d->value_1;
1438  d=d->next;
1439  }
1440  else
1441  Errorline("undecipherable sort code.\n");
1442  }
1443 
1444  /**** Make COMPARE a little more precise ****/
1445  if (compare==1)
1446  if (u->value_3 && !v->value_3)
1447  compare=2;
1448  else
1449  if (v->value_3 && !u->value_3)
1450  compare=3;
1451 
1452  /**** Determine the status of the resulting psi-term ****/
1453  new_stat=4;
1454  switch (compare) {
1455  case 1:
1456  if (u->status <4 && v->status <4)
1457  new_stat=2;
1458  break;
1459  case 2:
1460  if (u->status<4)
1461  new_stat=2;
1462  break;
1463  case 3:
1464  if (v->status<4)
1465  new_stat=2;
1466  break;
1467  case 4:
1468  new_stat=2;
1469  break;
1470  }
1471 
1472  /*
1473  printf("u=%s, v=%s, compare=%ld, u.s=%ld, v.s=%ld, ns=%ld\n",
1474  u->type->keyword->symbol,
1475  v->type->keyword->symbol,
1476  compare,
1477  u->status,
1478  v->status,
1479  new_stat);
1480  */
1481 
1482  /**** Check that integers have no decimals ****/
1483  if (u->value_3 && sub_type(new_type,integer)) {
1484  r= *(REAL *)u->value_3;
1485  success=(r==floor(r));
1486  }
1487  if (success && v->value_3 && sub_type(new_type,integer)) {
1488  r= *(REAL *)v->value_3;
1489  success=(r==floor(r));
1490  }
1491 
1492  /**** Unify the values of INTs REALs STRINGs LISTs etc... ****/
1493  if (success) {
1494  /* LAZY-EAGER */
1495  if (u->value_3!=v->value_3)
1496  if (!u->value_3) {
1497  compare=4;
1499  u->value_3=v->value_3;
1500  }
1501  else if (v->value_3) {
1502  if (overlap_type(new_type,real))
1503  success=(*((REAL *)u->value_3)==(*((REAL *)v->value_3)));
1504  else if (overlap_type(new_type,quoted_string))
1505  success=(strcmp((char *)u->value_3,(char *)v->value_3)==0);
1506  else if (overlap_type(new_type,sys_bytedata)) {
1507  unsigned long ulen = *((unsigned long *)u->value_3);
1508  unsigned long vlen = *((unsigned long *)v->value_3);
1509  success=(ulen==vlen &&
1510  (bcmp((char *)u->value_3,(char *)v->value_3,ulen)==0));
1511  }
1512  else if (u->type==cut && v->type==cut) { /* 22.9 */
1513  ptr_psi_term mincut;
1514  mincut = (ptr_psi_term) (u->value_3 < (GENERIC) v->value_3? u->value_3 : v->value_3);
1515  if (mincut!=(ptr_psi_term)u->value_3) {
1517  u->value_3=(GENERIC)mincut;
1518  }
1519  }
1520  else {
1521  warningline("'%s' may not be unified.\n",new_type->keyword->symbol);
1522  success=FALSE;
1523  }
1524  }
1525  else
1526  compare=4;
1527  }
1528 
1529  /**** Bind the two psi-terms ****/
1530  if (success) {
1531  /* push_ptr_value(psi_term_ptr,(ptr_psi_term *)&(v->coref)); 9.6 */
1532  push_psi_ptr_value(v,(GENERIC *)&(v->coref));
1533  v->coref=u;
1534 
1535  if (!equal_types(u->type,new_type)) {
1536  push_ptr_value(def_ptr,(GENERIC *)&(u->type));
1537  /* This does not seem to work right with cut.lf: */
1538  /* push_def_ptr_value(u,&(u->type_3)); */ /* 14.8 */
1539  u->type=new_type;
1540  }
1541 
1542  if (u->status!=new_stat) {
1544  u->status=new_stat;
1545  }
1546 
1547  /**** Unify the attributes ****/
1550 
1551 
1552 #ifdef ARITY /* RM: Mar 29 1993 */
1553  arity_merge(u->attr_list,v->attr_list);
1554 #endif
1555 
1556 
1557  if (u->attr_list || v->attr_list)
1558  merge(&(u->attr_list),v->attr_list);
1559 
1560  /**** Look after curried functions ****/
1561  /*
1562  if ((u_func && more_v_attr) || (v_func && more_u_attr)) {
1563  if (!(u->flags&QUOTED_TRUE | v->flags&QUOTED_TRUE)) {
1564  traceline("re-evaluating curried expression %P\n", u);
1565  if (u->status!=0) {
1566  push_ptr_value(int_ptr,(ptr_psi_term *)&(u->status));
1567  u->status=0;
1568  }
1569  check_func(u);
1570  }
1571  }
1572  */
1573 
1574  if (v->flags&QUOTED_TRUE && !(u->flags&QUOTED_TRUE)) { /* 16.9 */
1575  push_ptr_value(int_ptr,(GENERIC *)&(u->flags));
1576  u->flags|=QUOTED_TRUE;
1577  }
1578 
1579  /**** RELEASE RESIDUATIONS ****/
1580  /* This version implements the correct semantics. */
1581  if (u->resid)
1582  release_resid(u);
1583  if (v->resid)
1584  release_resid(v);
1585 
1586  /**** Alternatives in a type disjunction ****/
1587  if (d) {
1588  traceline("pushing type disjunction choice point for %P\n",u);
1590  }
1591 
1592  /**** VERIFY CONSTRAINTS ****/
1593  /* if ((old1stat<4 || old2stat<4) &&
1594  (u->type->type==type || v->type->type==type)) { 18.2.94 */
1595  if (new_stat<4 && u->type->type_def==(def_type)type_it) {
1596  /* This does not check the already-checked properties */
1597  /* (i.e. those in types t with t>=old1 or t>=old2), */
1598  /* and it does not check anything if u has no attributes. */
1599  /* It will, however, check the unchecked properties if a */
1600  /* type gains attributes. */
1601  fetch_def_lazy(u, old1, old2,
1602  old1attr, old2attr,
1603  old1stat, old2stat);
1604  }
1605  }
1606  }
1607  }
1608  return success;
1609 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
ptr_residuation resid
Definition: def_struct.h:189
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
int global_unify(ptr_psi_term u, ptr_psi_term v)
global_unify
Definition: modules.c:1053
GENERIC heap_pointer
used to allocate from heap - size allocated subtracted - adj for alignment
Definition: def_glob.h:55
struct wl_definition * def_type
Definition: def_struct.h:60
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long glb(ptr_definition t1, ptr_definition t2, ptr_definition *t3, ptr_int_list *c3)
glb
Definition: types.c:1481
#define def_ptr
values of type_ptr
Definition: def_const.h:404
long new_stat
Definition: def_glob.h:948
ptr_definition cut
symbol in syntax module
Definition: def_glob.h:242
ptr_int_list decode(ptr_int_list c)
decode
Definition: types.c:1784
void fetch_def_lazy(ptr_psi_term u, ptr_definition old1, ptr_definition old2, ptr_node old1attr, ptr_node old2attr, long old1stat, long old2stat)
fetch_def_lazy
Definition: login.c:1276
def_type type_def
Definition: def_struct.h:153
long more_u_attr
Definition: def_glob.h:944
ptr_keyword keyword
Definition: def_struct.h:147
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
#define cut_ptr
values of type_ptr 22.9
Definition: def_const.h:425
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
char * symbol
Definition: def_struct.h:118
void merge(ptr_node *u, ptr_node v)
merge
Definition: login.c:1131
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
void release_resid(ptr_psi_term t)
release_resid
Definition: lefun.c:445
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void traceline(char *format,...)
traceline
Definition: error.c:186
ptr_definition real
symbol in bi module
Definition: def_glob.h:375
#define type_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1415
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
void push_psi_ptr_value(ptr_psi_term q, GENERIC *p)
push_psi_ptr_value
Definition: login.c:474
#define deref_ptr(P)
Definition: def_macro.h:100
#define TRUE
Standard boolean.
Definition: def_const.h:268
long v_func
Definition: def_glob.h:947
long u_func
Definition: def_glob.h:947
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
struct wl_definition * ptr_definition
Definition: def_struct.h:59
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
ptr_psi_term coref
Definition: def_struct.h:188
#define equal_types(A, B)
Definition: def_macro.h:111
#define type_disj
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1128
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
GENERIC value_1
Definition: def_struct.h:85
ptr_psi_term bbbb_1
Definition: def_struct.h:240
#define QUOTED_TRUE
True flags for the flags field of psi-terms.
Definition: def_const.h:254
ptr_node attr_list
Definition: def_struct.h:187
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
void push_choice_point(goals t, ptr_psi_term aaaa_6, ptr_psi_term bbbb_6, GENERIC cccc_6)
push_choice_point
Definition: login.c:638
long more_v_attr
Definition: def_glob.h:945
ptr_int_list next
Definition: def_struct.h:86
#define int_ptr
values of type_ptr
Definition: def_const.h:397
void unify_bool_result ( ptr_psi_term  t,
long  v 
)

unify_bool_result

Parameters
t- ptr_psi_term t
v- long v

UNIFY_BOOL_RESULT(t,v) Unify psi_term T to the boolean value V = TRUE or FALSE. This is used by built-in logical functions to return their result.

Definition at line 344 of file built_ins.c.

References lf_false, lf_true, NULL, push_goal(), stack_psi_term(), wl_psi_term::type, and unify.

345 {
346  ptr_psi_term u;
347 
348  u=stack_psi_term(4);
349  u->type=v?lf_true:lf_false;
350  push_goal(unify,t,u,NULL);
351 
352  /* Completely commented out by Richard on Nov 25th 1993
353  What's *your* Birthday? Maybe you'd like a Birthday-Bug-Card!
354  tried restoring 2.07 DJD no effect on test suite - removed again 2.14 DJD
355 
356  if((GENERIC)t<heap_pointer) {
357  push_ptr_value(def_ptr,&(t->type));
358  if (v) {
359  t->type=lf_true;
360  t->status=0;
361  }
362  else {
363  t->type=lf_false;
364  t->status=0;
365  }
366 
367  i_check_out(t);
368  if (t->resid)
369  release_resid(t);
370  }
371  else {
372  warningline("the persistent term '%P' appears in a boolean constraint and cannot be refined\n",t);
373  }
374  / */
375 }
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
long unify_real_result ( ptr_psi_term  t,
REAL  v 
)

unify_real_result

Parameters
t- ptr_psi_term t
v- REAL v

UNIFY_REAL_RESULT(t,v) Unify psi_term T to the real value V. This is used by built-in arithmetic functions to return their result.

Definition at line 386 of file built_ins.c.

References assert, def_ptr, deref_ptr, FALSE, heap_alloc(), heap_pointer, i_check_out(), int_ptr, integer, matches(), NULL, push_ptr_value(), REAL, release_resid(), wl_psi_term::resid, wl_psi_term::status, TRUE, wl_psi_term::type, wl_psi_term::value_3, and warningline().

387 {
388  long smaller;
389  long success=TRUE;
390 
391 #ifdef prlDEBUG
392  if (t->value_3) {
393  printf("*** BUG: value already present in UNIFY_REAL_RESULT\n");
394  }
395 #endif
396 
397  if((GENERIC)t<heap_pointer) { /* RM: Jun 8 1993 */
398  deref_ptr(t);
399  assert(t->value_3==NULL); /* 10.6 */
401  t->value_3=heap_alloc(sizeof(REAL)); /* 12.5 */
402  *(REAL *)t->value_3 = v;
403 
404  (void)matches(t->type,integer,&smaller);
405 
406  if (v==floor(v)){
407  if (!smaller) {
409  t->type=integer;
410  t->status=0;
411  }
412  }
413  else
414  if (smaller)
415  success=FALSE;
416 
417  if (success) {
418  (void)i_check_out(t);
419  if (t->resid)
420  release_resid(t);
421  }
422  }
423  else {
424  warningline("the persistent term '%P' appears in an arithmetic constraint and cannot be refined\n",t);
425  }
426 
427  return success;
428 }
ptr_residuation resid
Definition: def_struct.h:189
void push_ptr_value(type_ptr t, GENERIC *p)
push_ptr_value
Definition: login.c:383
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
#define def_ptr
values of type_ptr
Definition: def_const.h:404
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
matches
Definition: types.c:1666
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void release_resid(ptr_psi_term t)
release_resid
Definition: lefun.c:445
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#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
GENERIC value_3
Definition: def_struct.h:186
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
long i_check_out(ptr_psi_term t)
i_check_out
Definition: lefun.c:1033
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
#define assert(N)
Definition: memory.c:114
#define int_ptr
values of type_ptr
Definition: def_const.h:397
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
GENERIC unitListNext ( )

set unitListElement to NULL & return NULL

not sure purpose (DJD ???)

Definition at line 490 of file bi_sys.c.

References NULL, and unitListElement.

491 {
493  return NULL;
494 }
#define NULL
Definition: def_const.h:533
static GENERIC unitListElement
Definition: bi_sys.c:459
ptr_psi_term unitListValue ( )

make psi term from unitListElement

not sure purpose (DJD ???)

Definition at line 479 of file bi_sys.c.

References makePsiTerm(), and unitListElement.

480 {
481  return makePsiTerm((void *)unitListElement);
482 }
ptr_psi_term makePsiTerm(ptr_definition x)
ptr_psi_term makePsiTerm
Definition: bi_sys.c:573
static GENERIC unitListElement
Definition: bi_sys.c:459
ptr_definition update_feature ( ptr_module  module,
char *  feature 
)

update_feature

Parameters
module- ptr_module module
feature- char *feature

UPDATE_FEATURE(module,feature) Look up a FEATURE. May return NULL if the FEATURE is not visible from MODULE.

Definition at line 1331 of file modules.c.

References current_module, wl_keyword::definition, extract_module_from_name(), hash_lookup(), NULL, wl_keyword::private_feature, wl_module::symbol_table, and update_symbol().

1332 {
1333  ptr_keyword key;
1334  ptr_module explicit;
1335 
1336  /* Check if the feature already contains a module name */
1337 
1338  if(!module)
1339  module=current_module;
1340 
1341  explicit=extract_module_from_name(feature);
1342  if(explicit)
1343  if(explicit!=module)
1344  return NULL; /* Feature isn't visible */
1345  else
1346  return update_symbol(NULL,feature);
1347 
1348  /* Now we have a simple feature to look up */
1349  key=hash_lookup(module->symbol_table,feature);
1350  if(key && key->private_feature)
1351  return key->definition;
1352  else
1353  return update_symbol(module,feature);
1354 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
ptr_definition definition
Definition: def_struct.h:122
ptr_hash_table symbol_table
Definition: def_struct.h:110
#define NULL
Definition: def_const.h:533
ptr_module current_module
Definition: modules.c:15
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
int private_feature
Definition: def_struct.h:121
ptr_module extract_module_from_name(char *str)
extract_module_from_name
Definition: modules.c:116
ptr_definition update_symbol ( ptr_module  module,
char *  symbol 
)

update_symbol

Parameters
module- ptr_module module
symbol- char *symbol

UPDATE_SYMBOL(m,s) S is a string of characters encountered during parsing, M is the module it belongs too.

if M is NULL then extract the module name from S. If that fails then use the current module.

Then, retrieve the keyword for 'module::symbol'. Then find the correct definition by scanning the opened modules.

Definition at line 270 of file modules.c.

References wl_keyword::combined_name, current_module, wl_keyword::definition, error_psi_term, Errorline(), extract_module_from_name(), FALSE, hash_insert(), hash_lookup(), HEAP_ALLOC, heap_copy_string(), make_module_token(), wl_keyword::module, wl_module::module_name, new_definition(), wl_int_list::next, NULL, wl_module::open_modules, wl_keyword::private_feature, wl_keyword::public, strip_module_name(), wl_keyword::symbol, wl_module::symbol_table, wl_psi_term::type, wl_int_list::value_1, and warningline().

271 {
272  ptr_keyword key;
273  ptr_definition result=NULL;
274  ptr_int_list opens;
275  ptr_module opened;
276  ptr_keyword openkey;
277  ptr_keyword tempkey;
278 
279  /* First clean up the arguments and find out which module to use */
280 
281  if(!module) {
282  module=extract_module_from_name(symbol);
283  if(!module)
284  module=current_module;
285  symbol=strip_module_name(symbol);
286  }
287 
288  /* printf("looking up %s#%s\n",module->module_name,symbol); */
289 
290  /* Now look up 'module#symbol' in the symbol table */
291  key=hash_lookup(module->symbol_table,symbol);
292 
293  if(key)
294  if(key->public || module==current_module)
295  result=key->definition;
296  else {
297  Errorline("qualified call to private symbol '%s'\n",
298  key->combined_name);
299 
300  result=error_psi_term->type;
301  }
302  else
303  if(module!=current_module) {
304  Errorline("qualified call to undefined symbol '%s#%s'\n",
305  module->module_name,symbol);
306  result=error_psi_term->type;
307  }
308  else
309  {
310  /* Add 'module#symbol' to the symbol table */
311  key=HEAP_ALLOC(struct wl_keyword);
312  key->module=module;
313  key->symbol=(char *)heap_copy_string(symbol);
314  key->combined_name=heap_copy_string(make_module_token(module,symbol));
315  key->public=FALSE;
316  key->private_feature=FALSE; /* RM: Mar 11 1993 */
317  key->definition=NULL;
318 
319  hash_insert(module->symbol_table,key->symbol,key);
320 
321 
322  /* Search the open modules of 'module' for 'symbol' */
323  opens=module->open_modules;
324  openkey=NULL;
325  while(opens) {
326  opened=(ptr_module)(opens->value_1);
327  if(opened!=module) {
328 
329  tempkey=hash_lookup(opened->symbol_table,symbol);
330 
331  if(tempkey)
332  if(openkey && openkey->public && tempkey->public) {
333  if(openkey->definition==tempkey->definition) {
334  warningline("benign module name clash: %s and %s\n",
335  openkey->combined_name,
336  tempkey->combined_name);
337  }
338  else {
339  Errorline("serious module name clash: \"%s\" and \"%s\"\n",
340  openkey->combined_name,
341  tempkey->combined_name);
342 
343  result=error_psi_term->type;
344  }
345  }
346  else
347  if(!openkey || !openkey->public)
348  openkey=tempkey;
349  }
350 
351  opens=opens->next;
352  }
353 
354  if(!result) { /* RM: Feb 1 1993 */
355 
356  if(openkey && openkey->public) {
357  /* Found the symbol in an open module */
358 
359  if(!openkey->public)
360  warningline("implicit reference to non-public symbol: %s\n",
361  openkey->combined_name);
362 
363  result=openkey->definition;
364  key->definition=result;
365 
366  /*
367  printf("*** Aliasing %s#%s to %s#%s\n",
368  key->module->module_name,
369  key->symbol,
370  openkey->module->module_name,
371  openkey->symbol);
372  */
373 
374  }
375  else { /* Didn't find it */
376  result=new_definition(key);
377  }
378  }
379  }
380 
381  return result;
382 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
char * combined_name
Definition: def_struct.h:119
ptr_definition new_definition(ptr_keyword key)
new_definition
Definition: modules.c:220
ptr_definition definition
Definition: def_struct.h:122
ptr_hash_table symbol_table
Definition: def_struct.h:110
#define NULL
Definition: def_const.h:533
ptr_module current_module
Definition: modules.c:15
char * symbol
Definition: def_struct.h:118
char * strip_module_name(char *str)
strip_module_name
Definition: modules.c:144
struct wl_module * ptr_module
Definition: def_struct.h:114
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
void hash_insert(ptr_hash_table table, char *symbol, ptr_keyword keyword)
HASH_INSERT.
Definition: hash_table.c:151
#define FALSE
Standard boolean.
Definition: def_const.h:275
char * module_name
Definition: def_struct.h:106
ptr_int_list open_modules
Definition: def_struct.h:108
ptr_module module
Definition: def_struct.h:117
ptr_psi_term error_psi_term
symbol in bi module
Definition: def_glob.h:118
int private_feature
Definition: def_struct.h:121
ptr_module extract_module_from_name(char *str)
extract_module_from_name
Definition: modules.c:116
void warningline(char *format,...)
warningline
Definition: error.c:371
ptr_definition type
Definition: def_struct.h:181
GENERIC value_1
Definition: def_struct.h:85
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
char * make_module_token(ptr_module module, char *str)
make_module_token
Definition: modules.c:191
ptr_int_list next
Definition: def_struct.h:86
void vinfoline ( char *  format,
FILE *  outfile,
  ... 
)
long warning ( )

warning

Definition at line 810 of file error.c.

References perr(), and warningflag.

811 {
812  if (warningflag) perr("*** Warning: ");
813  return warningflag;
814 }
long warningflag
Definition: error.c:19
void perr(char *str)
perr
Definition: error.c:763
void warningline ( char *  format,
  ... 
)

warningline

Parameters
format- char *format
...

Definition at line 371 of file error.c.

References assert, display_psi(), FALSE, input_file_name, parse_ok, perr_i(), perr_s(), print_code(), print_def_type(), print_operator_kind(), psi_term_line_number, quietflag, and warningflag.

372 {
373  va_list VarArg;
374  // int l;
375  char buffer_loc[5];
376  char *p;
377  unsigned long lng2;
378  char *cptr;
379  ptr_int_list pil;
380  ptr_psi_term psi;
381  operator kind;
382  def_type t ;
383 
384  va_start(VarArg,format);
385 
386  if (warningflag) { // macro would not work
387 
388 
389  if(quietflag) return; /* RM: Sep 24 1993 */
390  fprintf(stderr,"*** Warning: ");
391  // vinfoline(format, stderr, VarArg);
392  // #define vinfoline(format, stderr, xxxx) {
393  for (p=format;p && *p; p++)
394  {
395  if (*p == '%')
396  {
397  p++;
398  switch (*p)
399  {
400  case 'd':
401  case 'x':
402  buffer_loc[0] = '%';
403  buffer_loc[1] = 'l';
404  buffer_loc[2] = *p;
405  buffer_loc[3] = 0;
406  lng2 = va_arg(VarArg,long);
407  fprintf(stderr, buffer_loc, lng2);
408  break;
409  case 's':
410  buffer_loc[0] = '%';
411  buffer_loc[1] = *p;
412  buffer_loc[2] = 0;
413  cptr = va_arg(VarArg,char *);
414  fprintf(stderr, buffer_loc, cptr);
415  break;
416  case 'C':
417  /* type coding as bin string */
418  pil = va_arg(VarArg,ptr_int_list);
419  print_code(stderr,pil);
420  break;
421  case 'P':
422  psi = va_arg(VarArg,ptr_psi_term);
423  display_psi(stderr,psi);
424  break;
425  case 'O':
426  kind = va_arg(VarArg,operator);
427  print_operator_kind(stderr,kind);
428  break;
429  case 'T':
430  assert(stderr==stderr);
431  t = va_arg(VarArg,def_type);
432  print_def_type(t);
433  break;
434  case 'E':
435  assert(stderr==stderr);
436  perr_i("near line %ld",psi_term_line_number);
437  if (strcmp(input_file_name,"stdin")) {
438  perr_s(" in file 042%s042",input_file_name);
439  }
440  parse_ok=FALSE;
441  break;
442  case '%':
443  (void)putc(*p,stderr);
444  break;
445  default:
446  fprintf(stderr,"<%c follows %% : report bug >", *p);
447  break;
448  }
449  }
450  else
451  (void)putc(*p,stderr);
452  }
453  }
454  va_end(VarArg);
455 }
long warningflag
Definition: error.c:19
void perr_i(char *str, long i)
perr_i
Definition: error.c:800
long psi_term_line_number
Definition: def_glob.h:909
string input_file_name
Definition: def_glob.h:1016
void display_psi(FILE *s, ptr_psi_term t)
display_psi
Definition: print.c:1579
long parse_ok
indicates whether there was a syntax error
Definition: def_glob.h:765
void perr_s(char *s1, char *s2)
perr_s
Definition: error.c:775
void print_code(FILE *s, ptr_int_list c)
print_code
Definition: print.c:167
void print_def_type(def_type t)
print_def_type
Definition: types.c:24
#define FALSE
Standard boolean.
Definition: def_const.h:275
long quietflag
Definition: error.c:20
void print_operator_kind(FILE *s, long kind)
print_operator_kind
Definition: print.c:192
#define assert(N)
Definition: memory.c:114
long warningx ( )

warningx

Definition at line 821 of file error.c.

References perr(), and warningflag.

822 {
823  if (warningflag) perr("*** Warning");
824  return warningflag;
825 }
long warningflag
Definition: error.c:19
void perr(char *str)
perr
Definition: error.c:763
int WFfeature_count_loop ( ptr_node  n)

WFfeature_count_loop.

Parameters
n- ptr_node n

Definition at line 325 of file lib.c.

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

326 {
327  int result=0;
328 
329  if(n) {
330  if(n->left)
331  result+=WFfeature_count_loop(n->left);
332  result++;
333  if(n->right)
334  result+=WFfeature_count_loop(n->right);
335  }
336 
337  return result;
338 }
ptr_node left
Definition: def_struct.h:199
int WFfeature_count_loop(ptr_node n)
WFfeature_count_loop.
Definition: lib.c:325
ptr_node right
Definition: def_struct.h:200
int WFFeatureCount ( ptr_psi_term  psi)

WFFeatureCount.

Parameters
psi- ptr_psi_term psi

Definition at line 346 of file lib.c.

References wl_psi_term::attr_list, deref_ptr, and WFfeature_count_loop().

347 {
348  int result=0;
349 
350  if(psi) {
351  deref_ptr(psi);
352  result=WFfeature_count_loop(psi->attr_list);
353  }
354 
355  return result;
356 }
#define deref_ptr(P)
Definition: def_macro.h:100
int WFfeature_count_loop(ptr_node n)
WFfeature_count_loop.
Definition: lib.c:325
ptr_node attr_list
Definition: def_struct.h:187
char ** WFFeatures ( ptr_psi_term  psi)

WFFeatures.

Parameters
psi- ptr_psi_term psi

Definition at line 380 of file lib.c.

References wl_psi_term::attr_list, deref_ptr, group_features(), NULL, and WFfeature_count_loop().

381 {
382  char **features_loc=NULL;
383  int n;
384 
385  if(psi) {
386  deref_ptr(psi);
387 
389  if(n) {
390  features_loc=(char **)malloc((n+1)*sizeof(char *));
391  (void)group_features(features_loc,psi->attr_list);
392  }
393  }
394 
395  return features_loc;
396 }
#define NULL
Definition: def_const.h:533
#define deref_ptr(P)
Definition: def_macro.h:100
char ** group_features(char **f, ptr_node n)
group_features
Definition: lib.c:34
int WFfeature_count_loop(ptr_node n)
WFfeature_count_loop.
Definition: lib.c:325
ptr_node attr_list
Definition: def_struct.h:187
double WFGetDouble ( ptr_psi_term  psi,
int *  ok 
)

WFGetDouble.

Parameters
psi- ptr_psi_term psi
ok- int *ok

Definition at line 405 of file lib.c.

References deref_ptr, FALSE, real, sub_type(), TRUE, wl_psi_term::type, and wl_psi_term::value_3.

406 {
407  double value=0.0;
408 
409  if(ok)
410  *ok=FALSE;
411 
412  if(psi) {
413  deref_ptr(psi);
414 
415  if(sub_type(psi->type,real) && psi->value_3) {
416  value= *((double *)psi->value_3);
417  if(ok)
418  *ok=TRUE;
419  }
420  }
421  return value;
422 }
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
#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
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
PsiTerm WFGetFeature ( ptr_psi_term  psi,
char *  feature 
)

WFGetFeature.

Parameters
psi- ptr_psi_term psi
feature- char *feature

Definition at line 457 of file lib.c.

References wl_psi_term::attr_list, wl_node::data, deref_ptr, FEATCMP, find(), and NULL.

458 {
459  ptr_psi_term result=NULL;
460  ptr_node n;
461 
462  if(psi && feature) {
463  deref_ptr(psi);
464  n=find(FEATCMP,feature,psi->attr_list);
465  if(n)
466  result=(PsiTerm)n->data;
467  }
468 
469  return result;
470 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
void * PsiTerm
Type for psi-terms, hidden from users.
Definition: def_struct.h:21
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_node attr_list
Definition: def_struct.h:187
char * WFGetString ( ptr_psi_term  psi,
int *  ok 
)

WFGetString.

Parameters
psi- ptr_psi_term psi
ok- int *ok

Definition at line 431 of file lib.c.

References deref_ptr, FALSE, NULL, quoted_string, sub_type(), TRUE, wl_psi_term::type, and wl_psi_term::value_3.

432 {
433  char *value=NULL;
434 
435  if(ok)
436  *ok=FALSE;
437 
438  if(psi) {
439  deref_ptr(psi);
440 
441  if(sub_type(psi->type,quoted_string) && psi->value_3) {
442  value=(char *)psi->value_3;
443  if(ok)
444  *ok=TRUE;
445  }
446  }
447  return value;
448 }
#define NULL
Definition: def_const.h:533
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
#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
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
PsiTerm WFGetVar ( char *  name)

WFGetVar.

Parameters
name- char *name

Definition at line 304 of file lib.c.

References wl_node::data, deref_ptr, find(), NULL, STRCMP, and var_tree.

305 {
306  ptr_psi_term result=NULL;
307  ptr_node n;
308 
310  if(n) {
311  result=(ptr_psi_term)n->data;
312  if(result)
313  deref_ptr(result);
314  }
315 
316  return result;
317 }
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
ptr_node var_tree
Definition: def_glob.h:1005
#define deref_ptr(P)
Definition: def_macro.h:100
char * name
Definition: def_glob.h:966
#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 WFInit ( long  argc,
char **  argv 
)
int WFInput ( char *  query)

WFInput.

Parameters
query- char *query

Definition at line 215 of file lib.c.

References wl_goal::aaaa_1, assert_clause(), assert_first, assert_ok, c_query_level, c_what_next, choice_stack, DEFRULES, encode_types(), FACT, fail, FALSE, goal_count, goal_stack, ignore_eff, init_parse_state(), main_prove(), wl_goal::next, NULL, parse(), prove, push_choice_point(), push_goal(), QUERY, reset_stacks(), save_parse_state(), stack_copy_psi_term(), start_chrono(), stringinput, stringparse, TRUE, wl_goal::type, undo(), undo_stack, var_occurred, WFmore, WFno, and WFyes.

216 {
217  ptr_psi_term t;
218  long sort;
219  parse_block pb;
220  int result=WFno;
221  ptr_stack save_undo_stack;
222  ptr_choice_point old_choice;
223 
224 
225  save_undo_stack=undo_stack;
226  old_choice=choice_stack;
227 
228 
229  if(!strcmp(query,".")) {
230  reset_stacks();
231  result=WFyes;
232  c_query_level=0;
233  }
234  else {
235  if(!strcmp(query,";")) {
236  sort=QUERY;
238  }
239  else {
240  /* Parse the string in its own state */
241  save_parse_state(&pb);
244  stringinput=query;
245 
246  /* old_var_occurred=var_occurred; */
248  t=stack_copy_psi_term(parse(&sort));
249 
250  /* Main loop of interpreter */
251  if(sort==QUERY) {
253  goal_count=0;
254 
256  c_query_level++;
259  /* reset_step(); */
260  }
261  else if (sort==FACT) {
263  assert_clause(t);
264  if(assert_ok)
265  result=WFyes;
266  undo(save_undo_stack);
268  encode_types();
269  }
270  }
271 
272  if(sort==QUERY) {
273  start_chrono();
274  main_prove();
275 
277 
278  if((long)(goal_stack->aaaa_1)==c_query_level)
279  if(choice_stack==old_choice) {
280  result=WFyes;
281  c_query_level--;
282  }
283  else
284  result=WFmore;
285  else {
286  result=WFno;
287  c_query_level--;
288  }
289 
291  }
292  }
293  }
294 
295  return result;
296 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_psi_term aaaa_1
Definition: def_struct.h:239
void undo(ptr_stack limit)
undo
Definition: login.c:691
long assert_first
Definition: def_glob.h:1032
ptr_goal goal_stack
Definition: def_glob.h:1025
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
psi_term parse(long *q)
parse
Definition: parser.c:907
void save_parse_state(ptr_parse_block pb)
save_parse_state
Definition: token.c:425
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define WFmore
Input succeeded with possibly more answers.
Definition: def_const.h:47
#define FACT
Fact Kind of user input.
Definition: def_const.h:338
#define NULL
Definition: def_const.h:533
#define WFno
Input failed.
Definition: def_const.h:34
long ignore_eff
Definition: def_glob.h:677
#define QUERY
Query Kind of user input.
Definition: def_const.h:345
#define WFyes
Input succeeded.
Definition: def_const.h:41
#define c_what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1163
long assert_ok
Definition: def_glob.h:1033
ptr_stack undo_stack
Definition: def_glob.h:1027
long goal_count
Definition: def_glob.h:678
goals type
Definition: def_struct.h:238
#define TRUE
Standard boolean.
Definition: def_const.h:268
void start_chrono()
start_chrono
Definition: login.c:349
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define fail
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1044
void init_parse_state()
init_parse_state
Definition: token.c:464
void reset_stacks()
reset_stacks
Definition: login.c:2047
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
void encode_types()
encode_types
Definition: types.c:1091
void main_prove()
main_prove
Definition: login.c:2333
long c_query_level
Definition: def_glob.h:930
long stringparse
Definition: def_glob.h:859
char * stringinput
Definition: def_glob.h:860
long var_occurred
???
Definition: def_glob.h:839
void assert_clause(ptr_psi_term t)
assert_clause
Definition: login.c:287
ptr_choice_point choice_stack
Definition: def_glob.h:1026
ptr_goal next
Definition: def_struct.h:242
char * WFType ( ptr_psi_term  psi)

WFType.

Parameters
psi- ptr_psi_term psi

Definition at line 364 of file lib.c.

References wl_keyword::combined_name, deref_ptr, wl_definition::keyword, NULL, and wl_psi_term::type.

365 {
366  char *result=NULL;
367  if(psi) {
368  deref_ptr(psi);
369  result=psi->type->keyword->combined_name;
370  }
371  return result;
372 }
char * combined_name
Definition: def_struct.h:119
ptr_keyword keyword
Definition: def_struct.h:147
#define NULL
Definition: def_const.h:533
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_definition type
Definition: def_struct.h:181
long what_next_aim ( )

what_next_aim

WHAT_NEXT_AIM() Find out what the user wants to do: a) retry current goal -> ';' b) quit current goal -> RETURN c) add current goal -> 'new goal ?' d) return to top level -> '.'

Definition at line 2068 of file login.c.

References wl_goal::aaaa_1, aborthooksym, aim, assert_clause(), assert_first, wl_goal::bbbb_1, begin_terminal_io(), wl_goal::cccc_1, current_module, DEFRULES, encode_types(), end_terminal_io(), eof, EOLN, FACT, FALSE, function_it, infoline(), MAX_LEVEL, wl_module::module_name, no_choices(), NOTQUIET, NULL, parse(), print_variables(), PROMPT, prompt, prompt_buffer, prove, push_choice_point(), push_goal(), put_back_char(), QUERY, read_char(), release_resid(), reset_stacks(), reset_step(), show_count(), stack_copy_psi_term(), start_chrono(), stdin_cleareof(), TRUE, TRUEMASK, wl_psi_term::type, wl_definition::type_def, undo(), undo_stack, user_module, var_occurred, what_next, what_next_cut(), x_read_stdin_or_event(), x_window_creation, and xevent_existing.

2069 {
2070  long result=FALSE;
2071  ptr_psi_term s;
2072  long c, c2; /* 21.12 (prev. char) */
2073  char *pr;
2074  long sort,cut_loc=FALSE;
2075  long level,i;
2076  long eventflag;
2077  ptr_stack save_undo_stack;
2078  long lev1,lev2;
2080 
2081  level=((unsigned long)aim->cccc_1);
2082 
2083  if (aim->aaaa_1) {
2084  /* Must remember var_occurred from the what_next goal and from */
2085  /* execution of previous query (it may have contained a parse) */
2086  var_occurred=var_occurred || ((unsigned long)aim->bbbb_1)&TRUEMASK; /* 18.8 */
2087  eventflag=(((unsigned long)aim->bbbb_1)&(TRUEMASK*2))!=0;
2088  if (
2089  !var_occurred && no_choices() && level>0
2090 #ifdef X11
2091  /* Keep level same if no window & no X event */
2092  && !x_window_creation && !eventflag
2093 #endif
2094  ) {
2095  /* Keep level the same if in a query, the number of choice points */
2096  /* has not increased and there are no variables. */
2097  /* This has to have the same behavior as if an EOLN was typed */
2098  /* and no 'No' message should be given on the lowest level, */
2099  level--;
2100  (void)what_next_cut();
2101  if (level==0) { result=TRUE; }
2102  }
2103  }
2104 
2105 #ifdef X11
2107 #endif
2108 
2109  infoline(aim->aaaa_1?"\n*** Yes":"\n*** No");
2110  show_count();
2111  if (aim->aaaa_1 || level>0 ) (void)print_variables(NOTQUIET); // had commente || ... DJD
2112 
2113  {
2114  if (level > 0 && aborthooksym->type_def != (def_type)function_it )
2115  {
2116  lev1=MAX_LEVEL<level?MAX_LEVEL:(level);
2117  lev2=level;
2118  }
2119  else
2120  {
2121  lev1 = 0;
2122  lev2 = 0;
2123  }
2124 
2125  pr=prompt_buffer;
2126  /* RM: Oct 13 1993 */
2128  *pr='\0';
2129  else
2130  strcpy(pr,current_module->module_name);
2131  pr += strlen(pr);
2132  for(i=1;i<=lev1;i++) { *pr='-'; pr++; *pr='-'; pr++; }
2133  if (lev2>0)
2134  sprintf(pr,"%ld",lev2);
2135  strcat(pr,PROMPT);
2136 
2138  }
2139 
2140  stdin_cleareof();
2141  /* The system waits for either an input command or an X event. */
2142  /* An X event is treated *exactly* like an input command that */
2143  /* has the same effect. */
2144 #ifdef X11
2145  c=x_read_stdin_or_event(&eventflag);
2146  if (eventflag) {
2147  /* Include eventflag info in var_occurred field. */
2148  push_goal(what_next,(ptr_psi_term)TRUE,(ptr_psi_term)(FALSE+2*TRUE),(GENERIC)level /* +1 RM: Jun 22 1993 */);
2150  result=TRUE;
2151  }
2152  else
2153 #else
2154  c=read_char();
2155 #endif
2156  {
2157  while (c!=EOLN && c>0 && c<=32 && c!=EOF) {
2158  c=read_char();
2159  }
2160  if (c==EOF) {
2161  reset_stacks();
2162  }
2163  else if (c==EOLN) {
2164  cut_loc=TRUE;
2165  }
2166  else if (c==';' || c=='.') {
2167  do {
2168  c2=read_char();
2169  } while (c2!=EOLN && c2!=EOF && c2>0 && c2<=32);
2170  if (c=='.') { /* 6.10 */
2171  reset_stacks();
2172  result=TRUE;
2173  }
2174  }
2175  else {
2177 
2178  put_back_char(c);
2180  save_undo_stack=undo_stack;
2181  s=stack_copy_psi_term(parse(&sort));
2182 
2183  if (s->type==eof) {
2184  reset_stacks();
2185  put_back_char(EOF);
2186  } else if (sort==QUERY) {
2189  reset_step();
2190  result=TRUE;
2191  }
2192  else if (sort==FACT) { /* A declaration */
2193  push_goal(what_next,(ptr_psi_term)TRUE,(ptr_psi_term)FALSE,(GENERIC)(level + 1)); /* 18.5 */ // HERE
2195  assert_clause(s);
2196  /* Variables in the query may be used in a declaration, */
2197  /* but the declaration may not add any variables. */
2198  undo(save_undo_stack); /* 17.8 */
2199  encode_types();
2200  result=TRUE;
2201  }
2202  else {
2203  /* Stay at same level on syntax error */
2204  push_goal(what_next,(ptr_psi_term)TRUE,(ptr_psi_term)FALSE,(GENERIC)(level+1)); /* 20.8 */
2205  result=TRUE; /* 20.8 */
2206  }
2207  }
2208  }
2209 
2210  if (cut_loc) result = what_next_cut() || result;
2211 
2212  end_terminal_io();
2213 
2214  var_occurred=FALSE;
2215  start_chrono();
2216 
2217  return result;
2218 }
void assert_clause(ptr_psi_term t)
assert_clause
Definition: login.c:287
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
long what_next_cut()
what_next_cut
Definition: login.c:1987
void reset_stacks()
reset_stacks
Definition: login.c:2047
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
long assert_first
Definition: def_glob.h:1032
void put_back_char(long c)
put_back_char
Definition: token.c:729
ptr_module user_module
Default module for user input.
Definition: def_glob.h:694
void show_count()
show_count
Definition: login.c:1161
#define NOTQUIET
Definition: def_macro.h:15
psi_term parse(long *q)
parse
Definition: parser.c:907
char prompt_buffer[PROMPT_BUFFER]
Definition: def_glob.h:878
#define TRUEMASK
Standard boolean.
Definition: def_const.h:282
void undo(ptr_stack limit)
undo
Definition: login.c:691
void reset_step()
reset_step
Definition: error.c:665
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
void push_goal(goals t, ptr_psi_term aaaa_5, ptr_psi_term bbbb_5, GENERIC cccc_5)
push_goal
Definition: login.c:600
GENERIC cccc_1
Definition: def_struct.h:241
def_type type_def
Definition: def_struct.h:153
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define FACT
Fact Kind of user input.
Definition: def_const.h:338
#define NULL
Definition: def_const.h:533
#define PROMPT
Head of prompt.
Definition: def_const.h:218
#define QUERY
Query Kind of user input.
Definition: def_const.h:345
long x_window_creation
Definition: def_glob.h:1046
void release_resid(ptr_psi_term t)
release_resid
Definition: lefun.c:445
ptr_stack undo_stack
Definition: def_glob.h:1027
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define EOLN
End of line.
Definition: def_const.h:309
#define MAX_LEVEL
Maximum indent level.
Definition: def_const.h:232
void end_terminal_io()
end_terminal_io
Definition: token.c:516
long x_read_stdin_or_event(long *ptreventflag)
x_read_stdin_or_event
Definition: xpred.c:3578
void infoline(char *format,...)
infoline
Definition: error.c:281
void begin_terminal_io()
begin_terminal_io
Definition: token.c:493
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_definition eof
symbol in syntax module
Definition: def_glob.h:263
#define what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1079
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_goal aim
Definition: def_glob.h:1024
char * module_name
Definition: def_struct.h:106
ptr_psi_term stack_copy_psi_term(psi_term t)
stack_copy_psi_term
Definition: parser.c:205
void encode_types()
encode_types
Definition: types.c:1091
void start_chrono()
start_chrono
Definition: login.c:349
char * prompt
Definition: def_glob.h:1018
long print_variables(long printflag)
print_variables
Definition: print.c:1368
long read_char()
read_char
Definition: token.c:680
long no_choices()
no_choices
Definition: login.c:1945
ptr_definition type
Definition: def_struct.h:181
ptr_definition aborthooksym
symbol in bi module
Definition: def_glob.h:133
ptr_psi_term bbbb_1
Definition: def_struct.h:240
void stdin_cleareof()
stdin_cleareof
Definition: token.c:51
ptr_psi_term xevent_existing
Definition: def_glob.h:1037
long var_occurred
???
Definition: def_glob.h:839
void push_choice_point(goals t, ptr_psi_term aaaa_6, ptr_psi_term bbbb_6, GENERIC cccc_6)
push_choice_point
Definition: login.c:638
long what_next_cut ( )

what_next_cut

Cut away up to and including the first 'what_next' choice point.

Definition at line 1987 of file login.c.

References backtrack(), choice_stack, FALSE, goal_stack, NULL, TRUE, wl_goal::type, undo(), and what_next.

1988 {
1989  long flag=TRUE;
1990  long result=FALSE;
1991 
1992  do {
1993  if (choice_stack) {
1994  backtrack();
1995  if (goal_stack->type==what_next) {
1996  flag=FALSE;
1997  result=TRUE;
1998  }
1999  }
2000  else {
2001  /* This undo does the last undo actions before returning to top level. */
2002  /* It is not needed for variable undoing, but for actions (like */
2003  /* closing windows). */
2004  undo(NULL);
2005  /* undo(mem_base); 7.8 */
2006 #ifdef TS
2007  /* global_time_stamp=INIT_TIME_STAMP; */ /* 9.6 */
2008 #endif
2009  flag=FALSE;
2010  }
2011  } while (flag);
2012 
2013  return result;
2014 }
ptr_goal goal_stack
Definition: def_glob.h:1025
void undo(ptr_stack limit)
undo
Definition: login.c:691
#define NULL
Definition: def_const.h:533
goals type
Definition: def_struct.h:238
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define what_next
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1079
#define FALSE
Standard boolean.
Definition: def_const.h:275
void backtrack()
backtrack
Definition: login.c:772
ptr_choice_point choice_stack
Definition: def_glob.h:1026
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
long yes_or_no ( )

yes_or_no

Confirm an important change

Definition at line 50 of file types.c.

References EOLN, input_state, open_input_file(), perr(), prompt, read_char(), and restore_state().

51 {
52  char *old_prompt;
53  long c,d;
54  ptr_psi_term old_state_loc;
55 
56  perr("*** Are you really sure you want to do that ");
57  old_prompt=prompt;
58  prompt="(y/n)?";
59  old_state_loc=input_state;
60  (void)open_input_file("stdin");
61 
62  do {
63  do {
64  c=read_char();
65  } while (c!=EOLN && c>0 && c<=32);
66  } while (c!='y' && c!='n');
67 
68  d=c;
69  while (d!=EOLN && d!=EOF) d=read_char();
70 
71  prompt=old_prompt;
72  input_state=old_state_loc;
73  restore_state(old_state_loc);
74  return (c=='y');
75 }
void perr(char *str)
perr
Definition: error.c:763
ptr_psi_term input_state
Definition: def_glob.h:856
#define EOLN
End of line.
Definition: def_const.h:309
void restore_state(ptr_psi_term t)
restore_state
Definition: token.c:334
char * prompt
Definition: def_glob.h:1018
long read_char()
read_char
Definition: token.c:680
long open_input_file(char *file)
open_input_file
Definition: token.c:594