home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / character_constant.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.3 KB  |  142 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 CHARACTER_CONSTANT
  17. --
  18. -- For Manifest Constant CHARACTER.
  19. --   
  20.  
  21. inherit
  22.    BASE_TYPE_CONSTANT
  23.       redefine to_integer
  24.       end;
  25.    
  26. creation {EIFFEL_PARSER}
  27.    make
  28.  
  29. feature
  30.    
  31.    value: CHARACTER;
  32.  
  33. feature
  34.    
  35.    pretty_print_mode: INTEGER;
  36.    
  37.    std_pretty_print: INTEGER is 0;
  38.    
  39.    percent_pretty_print: INTEGER is 1;
  40.    
  41.    ascii_pretty_print: INTEGER is 2;
  42.    
  43.    c_simple: BOOLEAN is true;
  44.  
  45. feature
  46.  
  47.    make(sp: like start_position; v: like value; 
  48.     pm: like pretty_print_mode) is
  49.       require
  50.      sp /= Void;
  51.       do
  52.      start_position := sp;
  53.      value := v;
  54.      set_pretty_print_mode(pm);
  55.       ensure
  56.      start_position = sp;
  57.      value = v;
  58.      pretty_print_mode = pm;
  59.       end;
  60.    
  61.    to_integer: INTEGER is
  62.       do
  63.      Result := value.code;
  64.       end;
  65.    
  66.    is_static: BOOLEAN is 
  67.       do 
  68.      Result := true;
  69.      static_value_mem := to_integer;
  70.       end;
  71.    
  72.    compile_to_c is
  73.       do
  74.      cpp.put_character('%'');
  75.      if value.is_letter or else value.is_digit then
  76.         cpp.put_character(value);
  77.      elseif value = '%N' then
  78.         cpp.put_character('\');
  79.         cpp.put_character('n');
  80.      else
  81.         cpp.put_character('\');
  82.             cpp.put_integer(value.code.to_octal);
  83.      end;
  84.      cpp.put_character('%'');
  85.       end;
  86.    
  87.    compile_to_jvm, compile_target_to_jvm is
  88.       do
  89.      code_attribute.opcode_bipush(value.code);
  90.       end;
  91.    
  92.    jvm_branch_if_false: INTEGER is
  93.       do
  94.       end;
  95.  
  96.    jvm_branch_if_true: INTEGER is
  97.       do
  98.       end;
  99.    
  100.    compile_to_jvm_into(dest: TYPE): INTEGER is
  101.       do
  102.      Result := standard_compile_to_jvm_into(dest);
  103.       end;
  104.  
  105.    set_pretty_print_mode(pm: like pretty_print_mode) is
  106.       require
  107.      pm = std_pretty_print or else
  108.      pm = percent_pretty_print or else
  109.      pm = ascii_pretty_print
  110.       do
  111.      pretty_print_mode := pm;
  112.       ensure      
  113.      pretty_print_mode = pm;
  114.       end;
  115.  
  116.    to_string: STRING is
  117.       do
  118.      !!Result.make(0);
  119.      Result.extend('%'');
  120.      inspect 
  121.         pretty_print_mode
  122.      when std_pretty_print then
  123.         Result.extend(value);
  124.      when percent_pretty_print then
  125.         character_coding(value,Result);
  126.      when ascii_pretty_print then
  127.         Result.extend('%%');
  128.         Result.extend('/');
  129.         value.code.append_in(Result);
  130.         Result.extend('/');
  131.      end;
  132.      Result.extend('%'');
  133.       end;
  134.    
  135.    result_type: TYPE_CHARACTER is
  136.       once
  137.      !!Result.make(Void);
  138.       end;
  139.    
  140. end -- CHARACTER_CONSTANT
  141.  
  142.