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

  1. %
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. %
  5. %                                SUPERLINT
  6. %                                ---------
  7. %
  8. %  
  9. %
  10. %
  11. %  AUTHOR : Arnaud Venet                     CREATION : September 21st 1993
  12. %  ------                                    --------
  13. %
  14. %
  15. %                             ---------------                        
  16. %
  17. %                    
  18. %                   Last modification : September 24th 1993 
  19. %
  20. %
  21. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  22. %
  23. %
  24. %
  25. %
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. %
  28.  
  29.  
  30.  
  31. wl_main(Directory, Args) :-
  32.   chdir(Directory),
  33.   sort_args(Args, Superlint, Files),
  34.   (
  35.     load(Superlint),
  36.     open("superlint"),
  37.     !,
  38.     chdir(Directory),
  39.     launch_superlint(convert(Files, 1))
  40.   ;
  41.  
  42.     write_err("sl : rules file '", Superlint, "' doesn't exist"),
  43.     nl_err,
  44.     chdir(Directory),
  45.     halt
  46.   ).
  47.  
  48.  
  49. %
  50. % ------------------------------------------------------------------------------
  51. %
  52.  
  53.  
  54. launch_superlint(Files) :-
  55.   str2psi("main") & Files.
  56.  
  57.  
  58. %
  59. % ------------------------------------------------------------------------------
  60. %
  61.  
  62.  
  63. convert([], N) -> @.
  64.  
  65.  
  66. convert([File | LFiles], N) -> Term : convert(LFiles, N + 1)
  67.   | Term.N = File.
  68.  
  69.  
  70. %
  71. % ------------------------------------------------------------------------------
  72. %
  73.  
  74.  
  75. persistent(there_is_a_file) ?
  76.  
  77.  
  78. %
  79. % ------------------------------------------------------------------------------
  80. %  
  81.  
  82.  
  83. sort_args(["-h"]) :-
  84.   !,
  85.   error("Usage : slc [-f superlint-file] name1 name2 ...").
  86.  
  87.  
  88. sort_args(["-f", Binary | LArgs], Superlint, Files) :-
  89.   !,
  90.   cond(Superlint :== @,
  91.     (
  92.       Superlint = Binary,
  93.       sort_args(LArgs, Superlint, Files)
  94.     ),
  95.     error("sl : bad arguments")
  96.   ).
  97.  
  98.  
  99. sort_args([CFile | LArgs], Superlint, [CFile | Files]) :-
  100.   !,
  101.   there_is_a_file <<- true,
  102.   sort_args(LArgs, Superlint, Files).
  103.  
  104.  
  105. sort_args([], Superlint, []) :-
  106.   !,
  107.   cond(Superlint :== @,
  108.     Superlint = "superlint"
  109.   ),
  110.   cond(there_is_a_file :\== true,
  111.     error("sl : no C files specified")
  112.   ).
  113.  
  114.  
  115. sort_args :-
  116.   error("sl : bad arguments").
  117.  
  118.  
  119. %
  120. % ------------------------------------------------------------------------------
  121. %
  122.  
  123.  
  124. error(Message) :-
  125.   write_err(Message),
  126.   nl_err,
  127.   halt.
  128.  
  129.  
  130. %
  131. % ------------------------------------------------------------------------------
  132. %
  133.  
  134.  
  135.