home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / compile_to_c.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  5.2 KB  |  198 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class COMPILE_TO_C -- The command.
  17.  
  18. inherit COMPILE_TO;
  19.    
  20. creation make
  21.    
  22. feature 
  23.    
  24.    make is
  25.       do
  26.      start_proc := us_make;
  27.      eiffel_parser.set_drop_comments;
  28.      if argument_count < 1 then
  29.         std_error.put_string("Bad use of command `compile_to_c'.%N");
  30.         print_help("compile_to_c");
  31.         die_with_code(exit_failure_code);
  32.      else
  33.         automat;
  34.      end;
  35.       end;
  36.    
  37. feature {NONE}
  38.    
  39.    automat is
  40.       local
  41.      arg: INTEGER;
  42.      a: STRING;
  43.      -- state 0  : nothing done.
  44.      -- state 1  : "-o" read.
  45.      -- state 2  : Root class name read.
  46.      -- state 3  : "-cc" read.
  47.      -- state 4  : "-cecil" read.
  48.      -- state 8  : end.
  49.      -- state 9  : error.
  50.       do
  51.      from  
  52.         arg := 1;
  53.      until
  54.         arg > argument_count or else state > 7
  55.      loop
  56.         a := argument(arg);
  57.         inspect 
  58.            state
  59.         when 0 then
  60.            if a.item(1) /= '-' then
  61.           if a.has_suffix(o_suffix) then
  62.              cpp.add_c_object(a);
  63.           elseif a.has_suffix(c_suffix) then
  64.              cpp.add_c_object(a);
  65.           elseif root_class = Void then
  66.              root_class := a;
  67.              run_control.set_root_class(a);
  68.              state := 2;
  69.           else
  70.              cpp.add_c_compiler_option(a);
  71.           end;
  72.            elseif ("-boost").is_equal(a) then
  73.           if level /= Void then
  74.              error_level(a);
  75.           else
  76.              run_control.set_boost;
  77.              level := a;
  78.           end;
  79.            elseif ("-no_check").is_equal(a) then
  80.           if level /= Void then
  81.              error_level(a);
  82.           else
  83.              run_control.set_no_check;
  84.              level := a;
  85.           end;
  86.            elseif ("-require_check").is_equal(a) then
  87.           if level /= Void then
  88.              error_level(a);
  89.           else
  90.              run_control.set_require_check;
  91.              level := a;
  92.           end;
  93.            elseif ("-ensure_check").is_equal(a) then
  94.           if level /= Void then
  95.              error_level(a);
  96.           else
  97.              run_control.set_ensure_check;
  98.              level := a;
  99.           end;
  100.            elseif ("-invariant_check").is_equal(a) then
  101.           if level /= Void then
  102.              error_level(a);
  103.           else
  104.              run_control.set_invariant_check;
  105.              level := a;
  106.           end;
  107.            elseif ("-loop_check").is_equal(a) then
  108.           if level /= Void then
  109.              error_level(a);
  110.           else
  111.              run_control.set_loop_check;
  112.              level := a;
  113.           end;
  114.            elseif ("-all_check").is_equal(a) then
  115.           if level /= Void then
  116.              error_level(a);
  117.           else
  118.              run_control.set_all_check;
  119.              level := a;
  120.           end;
  121.            elseif ("-debug_check").is_equal(a) then
  122.           if level /= Void then
  123.              error_level(a);
  124.           else
  125.              run_control.set_debug_check;
  126.              level := a;
  127.           end;
  128.            elseif ("-case_insensitive").is_equal(a) then
  129.           eiffel_parser.set_case_insensitive;
  130.            elseif ("-no_warning").is_equal(a) then
  131.           eh.set_no_warning;
  132.            elseif ("-verbose").is_equal(a) then
  133.           echo.set_verbose;
  134.            elseif ("-test_gc").is_equal(a) then
  135.           gc_handler.enable;
  136.            elseif ("-gc_info").is_equal(a) then
  137.           gc_handler.set_info_flag;
  138.            elseif ("-no_strip").is_equal(a) then
  139.           cpp.set_no_strip;
  140.            elseif ("-no_split").is_equal(a) then
  141.           cpp.set_no_split;
  142.            elseif ("-trace").is_equal(a) then
  143.           run_control.set_trace;
  144.            elseif ("-cc").is_equal(a) then
  145.           state := 3;
  146.            elseif ("-cecil").is_equal(a) then
  147.           state := 4;
  148.            elseif a.has_prefix("-l") then
  149.           cpp.add_c_library(a);
  150.            elseif ("-o").is_equal(a) then
  151.           state := 1;
  152.            elseif a.item(1) = '-' and then a.item(2) = 'o' then
  153.           a.remove_first(2);
  154.           cpp.set_output_name(a);
  155.           cpp.set_oflag("-o");
  156.            else
  157.           cpp.add_c_compiler_option(a);
  158.            end;
  159.         when 1 then
  160.            cpp.set_output_name(a);
  161.            state := 0;
  162.         when 2 then
  163.            if a.item(1) = '-' or else
  164.           a.has_suffix(c_suffix) or else
  165.           a.has_suffix(o_suffix) then
  166.           arg := arg - 1;
  167.            else
  168.           start_proc := a;
  169.            end;
  170.            state := 0;
  171.         when 3 then
  172.            cpp.c_compiler.clear;
  173.            cpp.c_compiler.append(a);
  174.            state := 0;
  175.         when 4 then
  176.            run_control.set_cecil_path(a);
  177.            state := 0;
  178.         end;
  179.         arg := arg + 1;
  180.      end;
  181.      if nb_errors = 0 then
  182.         if run_control.trace then 
  183.            if run_control.boost then
  184.           run_control.set_no_check
  185.            end;
  186.         end;
  187.         small_eiffel.compile_to_c(root_class,start_proc);
  188.      end;
  189.       end;
  190.    
  191.    command_name: STRING is
  192.       do
  193.      Result := us_compile_to_c;
  194.       end;
  195.  
  196. end -- COMPILE_TO_C -- The command.
  197.  
  198.