home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / index_clause.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  101 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 INDEX_CLAUSE
  17.    --
  18.    --
  19.  
  20. inherit GLOBALS;
  21.  
  22. creation with_tag, without_tag
  23.  
  24. feature {NONE}
  25.  
  26.    tag: STRING;
  27.  
  28.    list: FIXED_ARRAY[EXPRESSION];
  29.  
  30.    with_tag(i: like tag) is
  31.       require
  32.          i /= Void
  33.       do
  34.          tag := i;
  35.       ensure
  36.          tag = i
  37.       end;
  38.  
  39.    without_tag(index_value: EXPRESSION) is
  40.       do
  41.          add_last(index_value);
  42.       end;
  43.  
  44. feature
  45.  
  46.    pretty_print is
  47.       local
  48.          i: INTEGER;
  49.          tag_column: INTEGER;
  50.       do
  51.          if tag /= void then
  52.             fmt.put_string(tag);
  53.             fmt.put_string(": ");
  54.             tag_column := fmt.column;
  55.          end;
  56.          if list /= Void then
  57.             fmt.level_incr;
  58.             from
  59.                i := list.lower;
  60.             until
  61.                i > list.upper
  62.             loop
  63.                list.item(i).pretty_print;
  64.                i := i + 1;
  65.                if i <= list.upper then
  66.                   fmt.put_string(",%N");
  67.                   if tag_column > 0 then
  68.                      from
  69.                      until
  70.                         fmt.column >= tag_column
  71.                      loop
  72.                         fmt.put_character(' ');
  73.                      end;
  74.                   else
  75.                      fmt.indent;
  76.                   end;
  77.                end;
  78.             end;
  79.             fmt.level_decr;
  80.          end;
  81.       end;
  82.  
  83. feature {EIFFEL_PARSER}
  84.  
  85.    add_last(index_value: EXPRESSION) is
  86.       require
  87.          index_value /= Void;
  88.       do
  89.          if list = Void then
  90.             !!list.with_capacity(4);
  91.          end;
  92.          list.add_last(index_value);
  93.       end;
  94.  
  95. invariant
  96.  
  97.    tag /= Void or else list /= Void
  98.  
  99. end -- INDEX_CLAUSE
  100.  
  101.