home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / tmp_name.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  6.5 KB  |  306 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 TMP_NAME
  17.    --
  18.    -- Unique object for temprary storage of an unkown name
  19.    -- during syntax analysis.
  20.    --
  21.    
  22. inherit GLOBALS;
  23.    
  24. creation {EIFFEL_PARSER}
  25.    make
  26.  
  27. feature {NONE}
  28.    
  29.    tmp_string: STRING is
  30.       once
  31.      !!Result.make(256);
  32.       end;
  33.  
  34.    unique_string_memory: STRING;
  35.  
  36. feature {EIFFEL_PARSER}
  37.    
  38.    li, co: INTEGER;
  39.    
  40. feature {NONE}
  41.  
  42.    make is 
  43.       do 
  44.       end;
  45.  
  46. feature {EIFFEL_PARSER}
  47.  
  48.    initialize(l, c: INTEGER) is
  49.       do
  50.      li := l;
  51.      co := c;
  52.      tmp_string.clear;
  53.      unique_string_memory := Void;
  54.       end;
  55.  
  56. feature {EIFFEL_PARSER}
  57.  
  58.    is_current: BOOLEAN is
  59.       do
  60.      if tmp_string.count = 7 then
  61.         Result := us_current.same_as(tmp_string);
  62.      end;
  63.       end;
  64.  
  65.    is_result: BOOLEAN is
  66.       do
  67.      if tmp_string.count = 6 then
  68.         Result := us_result.same_as(tmp_string);
  69.      end;
  70.       end;
  71.  
  72.    is_void: BOOLEAN is
  73.       do
  74.      if tmp_string.count = 4 then
  75.         Result := us_void.same_as(tmp_string);
  76.      end;
  77.       end;
  78.  
  79.    to_string: STRING is
  80.       do
  81.      if unique_string_memory = Void then
  82.         Result := unique_string.item(tmp_string);
  83.         unique_string_memory := Result;
  84.      else
  85.         Result := unique_string_memory;
  86.      end;
  87.       end;
  88.    
  89.    count: INTEGER is
  90.       do
  91.      Result := tmp_string.count;
  92.       end;
  93.  
  94.    start_position: POSITION is
  95.       do
  96.      !!Result.make(li,co);
  97.       end;
  98.    
  99.    extend(ch: CHARACTER) is
  100.       do
  101.      tmp_string.extend(ch);
  102.       end;
  103.    
  104.    isa_keyword: BOOLEAN is
  105.       require
  106.      not tmp_string.empty
  107.       local
  108.      c: CHARACTER;
  109.       do
  110.      c := tmp_string.item(1).to_lower;
  111.      inspect
  112.         c
  113.      when 'a' then
  114.         Result := look_in(keyword_a);
  115.      when 'c' then
  116.         Result := look_in(keyword_c);
  117.      when 'd' then
  118.         Result := look_in(keyword_d);
  119.      when 'e' then
  120.         Result := look_in(keyword_e);
  121.      when 'f' then
  122.         Result := look_in(keyword_f);
  123.      when 'i' then
  124.         Result := look_in(keyword_i);
  125.      when 'l' then
  126.         Result := look_in(keyword_l);
  127.      when 'o' then
  128.         Result := look_in(keyword_o);
  129.      when 'p' then
  130.         Result := fz_prefix.same_as(tmp_string);
  131.      when 'r' then
  132.         Result := look_in(keyword_r);
  133.      when 's' then
  134.         Result := look_in(keyword_s);
  135.      when 't' then
  136.         Result := look_in(keyword_t);
  137.      when 'u' then
  138.         Result := look_in(keyword_u);
  139.      when 'v' then
  140.         Result := fz_variant.same_as(tmp_string);
  141.      when 'w' then
  142.         Result := fz_when.same_as(tmp_string);
  143.      when 'x' then
  144.         Result := us_xor.same_as(tmp_string);
  145.      else
  146.      end;
  147.       end;
  148.  
  149. feature {EIFFEL_PARSER} -- Final Conversion Routines :
  150.    
  151.    to_argument_name1: ARGUMENT_NAME1 is
  152.       do
  153.      !!Result.make(pos(li,co),tmp_string);
  154.       end;
  155.  
  156.    to_argument_name2(fal: FORMAL_ARG_LIST; rank: INTEGER): ARGUMENT_NAME2 is
  157.       do
  158.      !!Result.refer_to(pos(li,co),fal,rank);
  159.       end;
  160.    
  161.    to_class_name: CLASS_NAME is
  162.       do
  163.      !!Result.make(tmp_string,pos(li,co));
  164.       end;
  165.    
  166.    to_e_current: E_CURRENT is
  167.       require
  168.      is_current
  169.       do
  170.      !!Result.make(pos(li,co),true);
  171.       end;
  172.    
  173.    to_e_result: E_RESULT is
  174.       require
  175.      is_result
  176.       do
  177.      !!Result.make(pos(li,co));
  178.       end;
  179.    
  180.    to_e_void: E_VOID is
  181.       require
  182.      is_void
  183.       do
  184.      !!Result.make(pos(li,co));
  185.       end;
  186.    
  187.    to_simple_feature_name: SIMPLE_FEATURE_NAME is
  188.       do
  189.      !!Result.make(tmp_string,pos(li,co));
  190.       end;
  191.    
  192.    to_infix_name_use: INFIX_NAME is
  193.       do
  194.      !!Result.make(tmp_string,pos(li,co));
  195.       end;
  196.    
  197.    to_infix_name(sp: POSITION): INFIX_NAME is
  198.       do
  199.      !!Result.make(tmp_string,sp);
  200.       end;
  201.    
  202.    to_local_name1: LOCAL_NAME1 is
  203.       do
  204.      !!Result.make(pos(li,co),tmp_string);
  205.       end;
  206.  
  207.    to_local_name2(lvl: LOCAL_VAR_LIST; rank: INTEGER): LOCAL_NAME2 is
  208.       do
  209.      !!Result.refer_to(pos(li,co),lvl,rank);
  210.       end;
  211.    
  212.    to_prefix_name: PREFIX_NAME is
  213.       do
  214.      !!Result.make(tmp_string,pos(li,co));
  215.       end;
  216.    
  217.    to_tag_name: TAG_NAME is
  218.       do
  219.      !!Result.make(tmp_string,pos(li,co));
  220.       end;
  221.    
  222. feature {NONE}
  223.    
  224.    keyword_a: ARRAY[STRING] is
  225.       once
  226.      Result := <<fz_alias,fz_all,us_and,fz_as>>;
  227.       end;
  228.    
  229.    keyword_c: ARRAY[STRING] is
  230.       once
  231.      Result := <<fz_check,fz_class,fz_creation>>;
  232.       end;
  233.    
  234.    keyword_d: ARRAY[STRING] is
  235.       once
  236.      Result := <<fz_debug,fz_deferred,fz_do>>;
  237.       end;
  238.    
  239.    keyword_e: ARRAY[STRING] is
  240.       once
  241.      Result := <<fz_else,fz_elseif,fz_end,fz_ensure,
  242.              fz_expanded,fz_export,fz_external>>;
  243.       end;
  244.    
  245.    keyword_f: ARRAY[STRING] is
  246.       once
  247.      Result := <<fz_false,fz_feature,fz_from,fz_frozen>>;
  248.       end;
  249.    
  250.    keyword_i: ARRAY[STRING] is
  251.       once
  252.      Result := <<fz_if,us_implies,fz_indexing,fz_infix,
  253.              fz_inherit,fz_inspect,fz_invariant,fz_is>>;
  254.       end;
  255.    
  256.    keyword_l: ARRAY[STRING] is
  257.       once
  258.      Result := <<fz_like,fz_local,fz_loop>>;
  259.       end;
  260.    
  261.    keyword_o: ARRAY[STRING] is
  262.       once
  263.      Result := <<fz_obsolete,fz_old,fz_once,us_or>>;
  264.       end;
  265.    
  266.    keyword_r: ARRAY[STRING] is
  267.       once
  268.      Result := <<fz_redefine,fz_rename,fz_require,fz_rescue,fz_retry>>;
  269.       end;
  270.    
  271.    keyword_s: ARRAY[STRING] is
  272.       once
  273.      Result := <<fz_select,fz_separate,fz_strip>>;
  274.       end;
  275.    
  276.    keyword_t: ARRAY[STRING] is
  277.       once
  278.      Result := <<fz_then,fz_true>>;
  279.       end;
  280.    
  281.    keyword_u: ARRAY[STRING] is
  282.       once
  283.      Result := <<fz_undefine,fz_unique,fz_until>>;
  284.       end;
  285.    
  286.    look_in(kt: ARRAY[STRING]): BOOLEAN is
  287.       require
  288.      not tmp_string.empty;
  289.      not kt.empty;
  290.      kt.lower = 1
  291.       local
  292.      i: INTEGER;
  293.       do
  294.      from  
  295.         i := kt.upper;
  296.      until
  297.         Result or else i = 0
  298.      loop
  299.         Result := kt.item(i).same_as(tmp_string);
  300.         i := i - 1;
  301.      end;
  302.       end; 
  303.  
  304. end -- TMP_NAME
  305.  
  306.