home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / declaration_group.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  137 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://SmallEiffel.loria.fr
  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_ARGUMENT1];
  42.  
  43. feature {NONE}
  44.  
  45.    make(nl: like name_list; type: TYPE) is
  46.       require
  47.          nl /= Void;
  48.          1 < nl.count;
  49.          type /= Void;
  50.       local
  51.          i: INTEGER;
  52.       do
  53.          name_list := nl;
  54.          from
  55.             i := name_list.upper;
  56.          until
  57.             i = 0
  58.          loop
  59.             name_list.item(i).set_result_type(type);
  60.             i := i - 1;
  61.          end;
  62.       ensure
  63.          name_list = nl;
  64.       end;
  65.  
  66. feature
  67.  
  68.    pretty_print is
  69.       local
  70.          i: INTEGER;
  71.       do
  72.          from
  73.             i := name_list.lower;
  74.             name_list.item(i).pretty_print;
  75.             i := i + 1;
  76.          until
  77.             i > name_list.upper
  78.          loop
  79.             fmt.put_string(", ");
  80.             name_list.item(i).pretty_print;
  81.             i := i + 1;
  82.          end;
  83.          fmt.put_string(": ");
  84.          name_list.item(1).result_type.pretty_print;
  85.       end;
  86.  
  87.    short is
  88.       local
  89.          i: INTEGER;
  90.       do
  91.          from
  92.             i := name_list.lower;
  93.             name_list.item(i).short;
  94.             i := i + 1;
  95.          until
  96.             i > name_list.upper
  97.          loop
  98.             short_print.hook_or("hook304",", ");
  99.             name_list.item(i).short;
  100.             i := i + 1;
  101.          end;
  102.          short_print.hook_or("hook305",": ");
  103.          name_list.item(1).result_type.short;
  104.       end;
  105.  
  106. feature {DECLARATION_LIST}
  107.  
  108.    count: INTEGER is
  109.       do
  110.          Result := name_list.upper;
  111.       end;
  112.  
  113. feature {DECLARATION_LIST}
  114.  
  115.    append_in(dl: DECLARATION_LIST) is
  116.       local
  117.          i: INTEGER;
  118.       do
  119.          from
  120.             i := name_list.lower;
  121.          until
  122.             i > name_list.upper
  123.          loop
  124.             dl.add_last(name_list.item(i));
  125.             i := i + 1;
  126.          end;
  127.       end;
  128.  
  129. invariant
  130.  
  131.    name_list.lower = 1;
  132.  
  133.    name_list.upper >= 2;
  134.  
  135. end -- DECLARATION_GROUP
  136.  
  137.