home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / EXAMPLES / SUPERLIN / SLC.LF < prev    next >
Text File  |  1996-06-04  |  2KB  |  116 lines

  1. %
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. %
  5. %                              RULE COMPILER
  6. %                              -------------
  7. %
  8. %  
  9. %
  10. %
  11. %  AUTHOR : Arnaud Venet                     CREATION : September 16th 1993
  12. %  ------                                    --------
  13. %
  14. %
  15. %                             ---------------                        
  16. %
  17. %                    
  18. %                   Last modification : September 21st 1993 
  19. %
  20. %
  21. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  22. %
  23. %
  24. %
  25. %
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. %
  28.  
  29.  
  30.  
  31. import("accumulators") ?
  32.  
  33. acc_info(dcg,Term, Xs, Ys, acc_pred => 'C'(Term,false,Xs,Ys),
  34.      in_name => 0, out_name => rest) ?
  35.  
  36. expand_load(true) ?
  37.  
  38.  
  39. load("sl_rule_expander.lf") ?
  40.  
  41.  
  42. open("sl_rule_expander") ?
  43.  
  44.  
  45. %
  46. % ------------------------------------------------------------------------------
  47. %
  48.  
  49.  
  50. error(Message) :-
  51.   write_err(Message),
  52.   nl_err,
  53.   halt.
  54.  
  55.  
  56. %
  57. % ------------------------------------------------------------------------------
  58. %
  59.  
  60.  
  61. sort_args(["-h"]) :-
  62.   !,
  63.   error("Usage : slc [-o output-file] name1 name2 ...").
  64.  
  65.  
  66. sort_args(["-o", Output | LArgs], FileName, Rules, FileNumber) :-
  67.   !,
  68.   cond(FileName :== @,
  69.     (
  70.       Output = FileName,
  71.       sort_args(LArgs, FileName, Rules, FileNumber)
  72.     ),
  73.     error("slc : bad arguments")
  74.   ).
  75.  
  76.  
  77. sort_args([RulesFile | LArgs], FileName, [RulesFile | Rules], 
  78.           FileNumber) :-
  79.   !,
  80.   sort_args(LArgs, FileName, Rules, FileNumber + 1).
  81.  
  82.  
  83. sort_args([], FileName, [], FileNumber) :-
  84.   !,
  85.   cond(FileName :== @,
  86.     FileName = "superlint.lf"
  87.   ),
  88.   cond(FileNumber :== 1,
  89.     error("slc : no rules file specified")
  90.   ).
  91.  
  92.  
  93. sort_args :-
  94.   error("slc : bad arguments").
  95.  
  96.  
  97. %
  98. % ------------------------------------------------------------------------------
  99. %
  100.  
  101.  
  102. wl_main(Directory, Args) :-
  103.   chdir(Directory),
  104.   sort_args(Args, Binary, Rules, 1),
  105.   compile_rules(from => Rules, in => Binary).
  106.  
  107.  
  108. %
  109. % ------------------------------------------------------------------------------
  110. %
  111.  
  112.  
  113.  
  114.  
  115.  
  116.