home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / LIB / LOADER.EXP < prev    next >
Text File  |  1996-06-04  |  2KB  |  46 lines

  1. %    $Id: loader.exp,v 1.2 1994/12/08 23:58:39 duchier Exp $    
  2. module("parser")?
  3.  
  4. public(load_life,load_l,load_gr,load_in)?
  5.  
  6. load_exp("parser")?
  7.  
  8. :-(load_life(_A: string),,(=(_B,current_module),,(exists_file(_A),,(open_in(_A,_C),,(load_first(_C),,(close(_C),set_module(_B))))))).
  9.  
  10. :-(load_first(_A),,(=(_B,first_token),;(,(=(_B,[]),,(!,,(nl,,(nl,,(write("Empty File"),nl))))),;(,(read_new_expr(_B,_C,_D,_E,_F),,(cond(_C,cond(:==(_E,assertion),assert_declaration(_D,_A),prove_query(_D,_A)),,(!,write_syntax_error(_A))),;(,(=(_F,[]),,(!,,(nl,,(write("*** File '",.(_A,input_file_name),"' loaded"),nl)))),fail))),load_next(_A))))).
  11.  
  12. :-(load_next(_A),;(,(read_new_expr([copy_term(rest_token)|`(next_token)],_B,_C,_D,_E),,(cond(_B,cond(:==(_D,assertion),assert_declaration(_C,_A),prove_query(_C,_A)),,(!,write_syntax_error(_A))),;(,(=(_E,[]),,(!,,(nl,,(write("*** File '",.(_A,input_file_name),"' loaded"),nl)))),fail))),load_next(_A))).
  13.  
  14. non_strict(prove_query)?
  15.  
  16. :-(prove_query(_A,_B),;(,(=(_C,copy_term(rest_chars)),,(=(_D,copy_term(rest_token)),,(open_in("stdin",@),,(retract(:-(load_query,@)),,(assert(:-(load_query,_A)),,(=(@,call_once(load_query)),,(set_input(_B),,(check_changes(_C,_D),fail)))))))),succeed)).
  17.  
  18. dynamic(load_query)?
  19.  
  20. load_query.
  21.  
  22. :-(check_changes(_A,_B),,(<<-(rest_chars,_A),<<-(rest_token,_B))).
  23.  
  24. :-(assert_declaration(_A,_B),;(,(term_xpand(_A,_C),,(!,cond(:=<(_C,list),maprel(assert,_C),assert(_C)))),,(nl_err,,(write_err("*** Error in term expansion in file '",.(_B,input_file_name),"'"),nl_err)))).
  25.  
  26. :-(write_syntax_error(_A),,(close(_A),,(nl_err,,(write_err("*** Syntax error near line ",.(_A,line_count)," in file '",.(_A,input_file_name),"'"),,(nl_err,fail))))).
  27.  
  28. :-(load_l(_A),loadpath2(_A,{".lf";""},true)).
  29.  
  30. :-(load_gr(_A),loadpath2(_A,".gr",true)).
  31.  
  32. :-(load_in(_A),loadpath2(_A,".in",false)).
  33.  
  34. non_strict(loadpath2)?
  35.  
  36. :-(loadpath2(_A,_B,_C),,(cond(:=<(_A,string),=(_D,_A),=(_D,psi2str(_A))),,(=(_E,strcon(_D,eval(_B))),;(,(exists_file(_E),,(!,load_custom2(_E,_C))),,(exists_file(_F: strcon(load_path,_E)),,(!,load_custom2(_F,_C))))))).
  37.  
  38. :-(loadpath2(_A),,(write_err("*** No file '",_A,"' found"),nl_err)).
  39.  
  40. :-(load_custom2(_A,true),,(!,;(,(loaded_file(_A),,(!,,(write("*** File '",_A,"' was already loaded"),nl))),,(load_life(_A),assert(loaded_file(_A)))))).
  41.  
  42. :-(load_custom2(_A,false),,(exists_file(_A),,(!,load_life(_A)))).
  43.  
  44. ,(assert(loaded_file),retract(loaded_file))?
  45.  
  46.