home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / tmp_name.e < prev    next >
Text File  |  1999-06-05  |  9KB  |  289 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 TMP_NAME
  17.    --
  18.    -- Singleton object used by `eiffel_parser' to have a temporary storage of
  19.    -- an unkown name during syntax analysis.
  20.    --
  21.  
  22. inherit GLOBALS;
  23.  
  24. feature {EIFFEL_PARSER}
  25.  
  26.    buffer: STRING is "                                                 ";
  27.  
  28.    line, column: INTEGER;
  29.  
  30.    reset(l, c: INTEGER) is
  31.       do
  32.          line := l;
  33.          column := c;
  34.          buffer.clear;
  35.          aliased_string_memory := Void;
  36.       end;
  37.  
  38.    extend(ch: CHARACTER) is
  39.       do
  40.          buffer.extend(ch);
  41.       end;
  42.  
  43.    is_current: BOOLEAN is
  44.       do
  45.          if buffer.count = 7 then
  46.             Result := as_current.same_as(buffer);
  47.          end;
  48.       end;
  49.  
  50.    is_result: BOOLEAN is
  51.       do
  52.          if buffer.count = 6 then
  53.             Result := as_result.same_as(buffer);
  54.          end;
  55.       end;
  56.  
  57.    is_void: BOOLEAN is
  58.       do
  59.          if buffer.count = 4 then
  60.             Result := as_void.same_as(buffer);
  61.          end;
  62.       end;
  63.  
  64.    aliased_string: STRING is
  65.       do
  66.          if aliased_string_memory = Void then
  67.             aliased_string_memory := string_aliaser.item(buffer);
  68.          end;
  69.          Result := aliased_string_memory;
  70.       end;
  71.  
  72.    count: INTEGER is
  73.       do
  74.          Result := buffer.count;
  75.       end;
  76.  
  77.    start_position: POSITION is
  78.       do
  79.          !!Result.make(line,column);
  80.       end;
  81.  
  82.    isa_keyword: BOOLEAN is
  83.       local
  84.          c: CHARACTER;
  85.       do
  86.          c := buffer.first.to_lower;
  87.          inspect
  88.             c
  89.          when 'a' then
  90.             if fz_alias.same_as(buffer) then
  91.                Result := true;
  92.             elseif fz_all.same_as(buffer) then
  93.                Result := true;
  94.             elseif as_and.same_as(buffer) then
  95.                Result := true;
  96.             else
  97.                Result := fz_as.same_as(buffer);
  98.             end;
  99.          when 'c' then
  100.             if fz_check.same_as(buffer) then
  101.                Result := true;
  102.             elseif fz_class.same_as(buffer) then
  103.                Result := true;
  104.             else
  105.                Result := fz_creation.same_as(buffer);
  106.             end;
  107.          when 'd' then
  108.             if fz_debug.same_as(buffer) then
  109.                Result := true;
  110.             elseif fz_deferred.same_as(buffer) then
  111.                Result := true;
  112.             else
  113.                Result := fz_do.same_as(buffer);
  114.             end;
  115.          when 'e' then
  116.             if fz_else.same_as(buffer) then
  117.                Result := true;
  118.             elseif fz_elseif.same_as(buffer) then
  119.                Result := true;
  120.             elseif fz_end.same_as(buffer) then
  121.                Result := true;
  122.             elseif fz_ensure.same_as(buffer) then
  123.                Result := true;
  124.             elseif fz_expanded.same_as(buffer) then
  125.                Result := true;
  126.             elseif fz_export.same_as(buffer) then
  127.                Result := true;
  128.             else
  129.                Result := fz_external.same_as(buffer);
  130.             end;
  131.          when 'f' then
  132.             if fz_false.same_as(buffer) then
  133.                Result := true;
  134.             elseif fz_feature.same_as(buffer) then
  135.                Result := true;
  136.             elseif fz_from.same_as(buffer) then
  137.                Result := true;
  138.             else
  139.                Result := fz_frozen.same_as(buffer);
  140.             end;
  141.          when 'i' then
  142.             if fz_if.same_as(buffer) then
  143.                Result := true;
  144.             elseif as_implies.same_as(buffer) then
  145.                Result := true;
  146.             elseif fz_indexing.same_as(buffer) then
  147.                Result := true;
  148.             elseif fz_infix.same_as(buffer) then
  149.                Result := true;
  150.             elseif fz_inherit.same_as(buffer) then
  151.                Result := true;
  152.             elseif fz_inspect.same_as(buffer) then
  153.                Result := true;
  154.             elseif fz_invariant.same_as(buffer) then
  155.                Result := true;
  156.             else
  157.                Result := fz_is.same_as(buffer);
  158.             end;
  159.          when 'l' then
  160.             if fz_like.same_as(buffer) then
  161.                Result := true;
  162.             elseif fz_local.same_as(buffer) then 
  163.                Result := true;
  164.             else
  165.                Result := fz_loop.same_as(buffer);
  166.             end;
  167.          when 'o' then
  168.             if fz_obsolete.same_as(buffer) then
  169.                Result := true;
  170.             elseif fz_old.same_as(buffer) then
  171.                Result := true;
  172.             elseif fz_once.same_as(buffer) then 
  173.                Result := true;
  174.             else
  175.                Result := as_or.same_as(buffer);
  176.             end;
  177.          when 'p' then
  178.             if as_precursor.same_as(buffer) then 
  179.                Result := true;
  180.             else
  181.                Result := fz_prefix.same_as(buffer);
  182.             end;
  183.          when 'r' then
  184.             if fz_redefine.same_as(buffer) then 
  185.                Result := true;
  186.             elseif fz_rename.same_as(buffer) then 
  187.                Result := true;
  188.             elseif fz_require.same_as(buffer) then 
  189.                Result := true;
  190.             elseif fz_rescue.same_as(buffer) then 
  191.                Result := true;
  192.             else
  193.                Result := fz_retry.same_as(buffer);
  194.             end;
  195.          when 's' then
  196.             if fz_select.same_as(buffer) then 
  197.                Result := true;
  198.             elseif fz_separate.same_as(buffer) then 
  199.                Result := true;
  200.             else
  201.                Result := fz_strip.same_as(buffer);
  202.             end;
  203.          when 't' then
  204.             if fz_then.same_as(buffer) then
  205.                Result := true;
  206.             else
  207.                Result := fz_true.same_as(buffer);
  208.             end;
  209.          when 'u' then
  210.             if fz_undefine.same_as(buffer) then 
  211.                Result := true;
  212.             elseif fz_unique.same_as(buffer) then 
  213.                Result := true;
  214.             else
  215.                Result := fz_until.same_as(buffer);
  216.             end;
  217.          when 'v' then
  218.             Result := fz_variant.same_as(buffer);
  219.          when 'w' then
  220.             Result := fz_when.same_as(buffer);
  221.          when 'x' then
  222.             Result := as_xor.same_as(buffer);
  223.          else
  224.          end;
  225.       end;
  226.  
  227.    to_argument_name1: ARGUMENT_NAME1 is
  228.       do
  229.          !!Result.make(pos(line,column),aliased_string);
  230.       end;
  231.  
  232.    to_argument_name2(fal: FORMAL_ARG_LIST; rank: INTEGER): ARGUMENT_NAME2 is
  233.       do
  234.          !!Result.refer_to(pos(line,column),fal,rank);
  235.       end;
  236.  
  237.    to_class_name: CLASS_NAME is
  238.       do
  239.          !!Result.make(aliased_string,pos(line,column));
  240.       end;
  241.  
  242.    to_e_void: E_VOID is
  243.       require
  244.          is_void
  245.       do
  246.          !!Result.make(pos(line,column));
  247.       end;
  248.  
  249.    to_simple_feature_name: SIMPLE_FEATURE_NAME is
  250.       do
  251.          !!Result.make(aliased_string,pos(line,column));
  252.       end;
  253.  
  254.    to_infix_name_use: INFIX_NAME is
  255.       do
  256.          !!Result.make(aliased_string,pos(line,column));
  257.       end;
  258.  
  259.    to_infix_name(sp: POSITION): INFIX_NAME is
  260.       do
  261.          !!Result.make(aliased_string,sp);
  262.       end;
  263.  
  264.    to_local_name1: LOCAL_NAME1 is
  265.       do
  266.          !!Result.make(pos(line,column),aliased_string);
  267.       end;
  268.  
  269.    to_local_name2(lvl: LOCAL_VAR_LIST; rank: INTEGER): LOCAL_NAME2 is
  270.       do
  271.          !!Result.refer_to(pos(line,column),lvl,rank);
  272.       end;
  273.  
  274.    to_prefix_name: PREFIX_NAME is
  275.       do
  276.          !!Result.make(aliased_string,pos(line,column));
  277.       end;
  278.  
  279.    to_tag_name: TAG_NAME is
  280.       do
  281.          !!Result.make(aliased_string,pos(line,column));
  282.       end;
  283.  
  284. feature {NONE}
  285.  
  286.    aliased_string_memory: STRING;
  287.  
  288. end -- TMP_NAME
  289.