home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / declaration_group.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.0 KB  |  133 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 DECLARATION_GROUP
  17. --
  18. -- When a group of variable have the same type mark.
  19. --
  20. -- Exemple 1 :
  21. --         local 
  22. --           foo, bar : ZOO;
  23. --           --------------
  24. --
  25. -- Exemple 2 :
  26. --         bip(foo, bar : ZOO) is 
  27. --             --------------
  28. --
  29. -- See Eiffel3 grammar for more details.
  30. --
  31. -- Note : it is necessary to have a good pretty pretty_printing to store
  32. --        the user's original text.
  33. --
  34.    
  35. inherit DECLARATION;
  36.  
  37. creation {EIFFEL_PARSER} make
  38.    
  39. feature {NONE}
  40.    
  41.    name_list: ARRAY[LOCAL_ARGUMENT];
  42.  
  43.    make(nl: like name_list; type: TYPE) is
  44.       require
  45.      nl /= Void;
  46.      1 < nl.count;
  47.      type /= Void;
  48.       local
  49.      i: INTEGER;
  50.       do
  51.      name_list := nl;
  52.      from
  53.         i := name_list.upper;
  54.      until
  55.         i = 0
  56.      loop
  57.         name_list.item(i).set_result_type(type);
  58.         i := i - 1;
  59.      end;
  60.       ensure     
  61.      name_list = nl;
  62.       end;
  63.    
  64. feature
  65.  
  66.    count: INTEGER is
  67.       do
  68.      Result := name_list.upper;
  69.       end;
  70.    
  71.    pretty_print is
  72.       local
  73.      i: INTEGER;
  74.       do
  75.      from  
  76.         i := name_list.lower;
  77.         name_list.item(i).pretty_print;
  78.         i := i + 1;
  79.      until
  80.         i > name_list.upper
  81.      loop
  82.         fmt.put_string(", ");
  83.         name_list.item(i).pretty_print;
  84.         i := i + 1;
  85.      end;
  86.      fmt.put_string(": ");
  87.      name_list.item(1).result_type.pretty_print;
  88.       end;
  89.  
  90.    short is
  91.       local
  92.      i: INTEGER;
  93.       do
  94.      from  
  95.         i := name_list.lower;
  96.         name_list.item(i).short;
  97.         i := i + 1;
  98.      until
  99.         i > name_list.upper
  100.      loop
  101.         short_print.hook_or("hook304",", ");
  102.         name_list.item(i).short;
  103.         i := i + 1;
  104.      end;
  105.      short_print.hook_or("hook305",": ");
  106.      name_list.item(1).result_type.short;
  107.       end;
  108.    
  109. feature {DECLARATION_LIST}   
  110.    
  111.    append_in(dl: DECLARATION_LIST) is
  112.       local 
  113.      i: INTEGER;
  114.       do
  115.      from  
  116.         i := name_list.lower;
  117.      until
  118.         i > name_list.upper
  119.      loop
  120.         dl.add_last(name_list.item(i));
  121.         i := i + 1;
  122.      end;
  123.       end;
  124.    
  125. invariant
  126.    
  127.    name_list.lower = 1;
  128.    
  129.    name_list.upper >= 2;
  130.    
  131. end -- DECLARATION_GROUP
  132.  
  133.