[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-606-g4554e79

Mildred Ki'Lya silkensedai at online.fr
Mon Mar 1 01:31:25 UTC 2010


The following commit has been merged in the master branch:
commit cc13da6291b42e18740997974070fff584e414fd
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date:   Sat Feb 20 01:03:26 2010 +0100

    Use the same code in lisaac and shorter for LISAAC_DIRECTORY and help message

diff --git a/src/any.li b/src/any.li
index 26f0cd5..83dae05 100644
--- a/src/any.li
+++ b/src/any.li
@@ -355,29 +355,7 @@ Section Public
   FAST_ARRAY(STRING_CONSTANT).create_with_capacity 3000;
   - path_begin:INTEGER := 1;
 
-  - path_lisaac:STRING_CONSTANT <-
-  ( + path:NATIVE_ARRAY(CHARACTER);
-    + path_str :STRING;
-    + j:INTEGER;
-    //COMMAND_LINE.executable_name.print; '\n'.print;
-    // Load LISAAC_DIRECTORY.
-    path_str := ENVIRONMENT.get_environment_variable "LISAAC_DIRECTORY";
-    (path_str != NULL).if {
-      string_tmp.copy path_str;
-    } else {
-      path := `LISAAC_DIRECTORY`:NATIVE_ARRAY(CHARACTER);
-      string_tmp.clear;
-      j := 0;
-      {path.item j != '\0'}.while_do {
-	string_tmp.add_last (path.item j);
-	j := j + 1;
-      };
-    };
-    ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
-      string_tmp.add_last '/';
-    };
-    path_lisaac := ALIAS_STR.get string_tmp
-  );
+  - path_lisaac:STRING_CONSTANT <- COMMON.path_lisaac;
 
   //
   // Alias type.
diff --git a/src/common.li b/src/common.li
new file mode 100644
index 0000000..706af87
--- /dev/null
+++ b/src/common.li
@@ -0,0 +1,148 @@
+///////////////////////////////////////////////////////////////////////////////
+//                             Lisaac Compiler                               //
+//                                                                           //
+//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
+//                                                                           //
+//   This program is free software: you can redistribute it and/or modify    //
+//   it under the terms of the GNU General Public License as published by    //
+//   the Free Software Foundation, either version 3 of the License, or       //
+//   (at your option) any later version.                                     //
+//                                                                           //
+//   This program is distributed in the hope that it will be useful,         //
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
+//   GNU General Public License for more details.                            //
+//                                                                           //
+//   You should have received a copy of the GNU General Public License       //
+//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
+//                                                                           //
+//                     http://isaacproject.u-strasbg.fr/                     //
+///////////////////////////////////////////////////////////////////////////////
+Section Header
+
+  + name        := COMMON;
+
+  - copyright   := "2009 Mildred Ki'Lya";
+
+  - bibliography:= "http://IsaacOS.com";
+  - author      := "Mildred Ki'Lya <http://ki.lya.online.fr>";
+  - comment     := "Common code to shorter and the compiler";
+
+  - external := `#include "path.h"`;
+
+Section Inherit
+
+  - parent_any:ANY := ANY;
+
+Section Public
+
+  - version :STRING_CONSTANT := "0.39 rc2";
+
+  - command_line_header name:STRING_CONSTANT :STRING_CONSTANT <-
+  ( + before, after :STRING_CONSTANT;
+    + total_length, count :INTEGER;
+    total_length := 60;
+    before :=
+    "----------------------------------------------------------------\n\
+    \--               Lisaac IS An Advanced Compiler               --\n\
+    \--";
+    after :=                                                      "--\n\
+    \--            LORIA - LSIIT - UDS - CNRS - FRANCE             --\n\
+    \--         Benoit SONNTAG - benoit.sonntag at lisaac.org         --\n\
+    \--                   http://www.lisaac.org/                   --\n\
+    \----------------------------------------------------------------\n";
+    string_tmp.copy name;
+    string_tmp.append " - version ";
+    string_tmp.append version;
+    count := string_tmp.count;
+    (count % 2 = 1).if {
+      string_tmp.add_last ' ';
+      count := count + 1;
+    };
+    string_tmp2.copy before;
+    1.to ((total_length - count) / 2) do { i:INTEGER;
+      string_tmp .add_last ' ';
+      string_tmp2.add_last ' ';
+    };
+    string_tmp2.append string_tmp;
+    string_tmp2.append after;
+    ALIAS_STR.get string_tmp2
+  );
+
+  - command_line_footer:STRING_CONSTANT :=
+    "                                                                \n\
+    \Bug report:                                                     \n\
+    \    post in: https://alioth.debian.org/projects/lisaac/         \n";
+
+  - print_info <-
+  ( + debug_code, lisaac_optim :STRING_CONSTANT;
+
+    compiler_debug_with_code.if {
+      debug_code := " (with source code)";
+    } else {
+      debug_code := " (without source code)";
+    };
+    compiler_optimization.if {
+      lisaac_optim := "yes";
+    } else {
+      lisaac_optim := "no";
+    };
+
+    "Built on:             ".print; compile_date.print; " ".print;
+                                    compile_time.print; "\n".print;
+    "Debug Level:          ".print; debug_level.print; debug_code.println;
+    "Inline Level:         ".print; compiler_inlining_level.println;
+    "Lisaac optimizations: ".print; lisaac_optim.println;
+
+    '\n'.print;
+    (path_lisaac_builtin = path_lisaac).if {
+      "Lisaac path:          ".print; path_lisaac.println;
+    } else {
+      "Lisaac path:".println;
+      "  builtin:            ".print; path_lisaac_builtin.println;
+      "  current:            ".print; path_lisaac.println;
+    };
+  );
+
+  - path_lisaac_builtin:STRING_CONSTANT <-
+  ( + path:NATIVE_ARRAY(CHARACTER);
+    + j :INTEGER;
+    path := `LISAAC_DIRECTORY`:NATIVE_ARRAY(CHARACTER);
+    string_tmp.clear;
+    j := 0;
+    {path.item j != '\0'}.while_do {
+      string_tmp.add_last (path.item j);
+      j := j + 1;
+    };
+    ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
+      string_tmp.add_last '/';
+    };
+    path_lisaac_builtin := ALIAS_STR.get string_tmp;
+    path_lisaac_builtin
+  );
+
+  - path_lisaac_env:STRING_CONSTANT <-
+  ( + path_str :STRING;
+    path_str := ENVIRONMENT.get_environment_variable "LISAAC_DIRECTORY";
+    (path_str != NULL).if {
+      string_tmp.copy path_str;
+      ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
+        string_tmp.add_last '/';
+      };
+      path_lisaac_env := ALIAS_STR.get string_tmp;
+    } else {
+      path_lisaac_env := NULL;
+    };
+    path_lisaac_env
+  );
+
+  - path_lisaac:STRING_CONSTANT <-
+  (
+    (path_lisaac_env != NULL).if {
+      path_lisaac := path_lisaac_env;
+    } else {
+      path_lisaac := path_lisaac_builtin;
+    };
+    path_lisaac
+  );
+
diff --git a/src/lip/lip_call.li b/src/lip/lip_call.li
index fb2717f..cce486f 100644
--- a/src/lip/lip_call.li
+++ b/src/lip/lip_call.li
@@ -99,12 +99,12 @@ Section Public
       (val != NULL).if {
         warning_error (position,"No argument for `help_command' method.");
       };
-      LISAAC.print_help;
+      LISAAC.show_help;
     }.elseif {name = ALIAS_STR.slot_compiler_version} then {
       (val != NULL).if {
-        warning_error (position,"No argument for `version' method.");
+        warning_error (position,"No argument for `compiler_version' method.");
       };
-      LISAAC.print_version;
+      LISAAC.show_version;
     }.elseif {name = ALIAS_STR.slot_path} then {
       str ?= val;
       (str = NULL).if {
diff --git a/src/lisaac.li b/src/lisaac.li
index 115bd52..590af95 100644
--- a/src/lisaac.li
+++ b/src/lisaac.li
@@ -26,9 +26,7 @@ Section Header
 
   - author   := "Sonntag Benoit (sonntag at icps.u-strasbg.fr)";
   - comment  := "The main prototype";
-
-  - external := `#include "path.h"`;
-
+  
   // Top 5 memory record :
   // 1 - LOCAL         (>20MB) (il fo Aliaser les tmp !)
   // 2 - READ_LOCAL    (15MB)
@@ -42,86 +40,45 @@ Section Inherit
 
 Section Public
 
-  - print_help <-
+  - show_help <-
   (
-    begin_usage1.print;
-    version.print;
-    (15- version.count).times {
-      ' '.print;
-    };
-    begin_usage2.print;
+    COMMON.command_line_header "Compiler".print;
+    begin_usage.print;
     LIP_CODE.print_usage;
-    end_usage.print;
+    COMMON.command_line_footer.print;
   );
-
-  - print_version <-
+  
+  - show_version <-
   (
-    "Compiler version: ".print;
-    version.print; '\n'.print;
-    //
-    "Built on:         ".print;
-    compiler_built_on.print;
-    '\n'.print;
-    //
-    "Debug level:      ".print;
-    (debug_level = 0).if {
-      "No debug.".print;
-    } else {
-      debug_level.print;
-    };
-    '\n'.print;
-    //
-    "Inlining level:   ".print;
-    compiler_inlining_level.print;
-    '\n'.print;
-    //
-    "Optimization:     ".print;
-    compiler_optimization.print;
-    '\n'.print;
+    COMMON.command_line_header "Compiler".print;
+    COMMON.print_info;
+    COMMON.command_line_footer.print;
   );
 
 Section Private
 
-  - version:STRING_CONSTANT := "0.39 rc2";
-
-  //
-  //
-  //
-
-  - output_name:STRING_CONSTANT;
-
+  - output_name     :STRING_CONSTANT;
+  - output_extension:STRING_CONSTANT;
+  
   - input_name:STRING_CONSTANT;
-
+  
   //
   // Command.
   //
 
-  - begin_usage1: STRING_CONSTANT :=
-  "----------------------------------------------------------------\n\
-  \--            Lisaac IS An Advanced Compiler V.";
-
-  - begin_usage2: STRING_CONSTANT :=
-  "--\n\
-  \--            LORIA - LSIIT - UDS - CNRS - FRANCE             --\n\
-  \--         Benoit SONNTAG - benoit.sonntag at lisaac.org         --\n\
-  \--                   http://www.lisaac.org                    --\n\
-  \----------------------------------------------------------------\n\
-  \Usage:                                                          \n\
+  - begin_usage: STRING_CONSTANT :=
+  "Usage:                                                          \n\
   \  lisaac [<lip_file.lip>] [<input_file[.li]>] {<Options>}       \n\
   \                                                                \n\
-  \  Note: without <lip_file> or <input_file>,                     \n\
-  \        the nearest `make.lip' file is interpreted.             \n\
+  \  Note: without <lip_file> the nearest `make.lip' file is       \n\
+  \        interpreted.                                            \n\
   \                                                                \n\
   \Options:                                                        \n";
-
-  - end_usage:STRING_CONSTANT :=
-  "                                                                \n\
-  \Bug report:                                                     \n\
-  \\t post in: https://alioth.debian.org/projects/lisaac/         \n";
+  
 
   - display_usage <-
   (
-    print_help;
+    show_help;
     die_with_code exit_failure_code;
   );
 
diff --git a/src/shorter.li b/src/shorter.li
index 80ed3b7..b38ccae 100644
--- a/src/shorter.li
+++ b/src/shorter.li
@@ -29,8 +29,6 @@ Section Header
   - author      := "Sonntag Benoit (bsonntag at loria.fr)";
   - comment     := "Shorter source code.";
   
-  - external := `#include "path.h"`;
-    
 Section Inherit
   
   - parent_any:ANY := ANY;
@@ -62,13 +60,7 @@ Section Private
   //
 
   - usage:STRING_CONSTANT :=
-  "----------------------------------------------------------------\n\
-  \--                   Lisaac source Shorter                    --\n\
-  \--            LORIA - LSIIT - UDS - CNRS - FRANCE             --\n\
-  \--         Benoit SONNTAG - benoit.sonntag at lisaac.org         --\n\
-  \--                   http://www.lisaac.org                    --\n\
-  \----------------------------------------------------------------\n\
-  \Usage:                                                      \n\
+  "Usage:                                                      \n\
   \  shorter <input_file[.li]> [Options]                       \n\
   \                                                            \n\
   \Options:                                                    \n\
@@ -94,14 +86,21 @@ Section Private
   \   - With current `make.lip'                                \n\
   \      shorter -d -f belinda                                 \n\ 
   \   - With specific `make.lip'                               \n\
-  \      shorter -d -f belinda ../make.lip                     \n\
-  \                                                            \n\
-  \Bug report:                                                 \n\
-  \    post in: https://alioth.debian.org/projects/lisaac/     \n";
+  \      shorter -d -f belinda ../make.lip                     \n";
 
   - display_usage <-
   (
+    COMMON.command_line_header "Shorter".print;
     usage.print;
+    COMMON.command_line_footer.print;
+    die_with_code exit_failure_code;
+  );
+
+  - display_version <-
+  (
+    COMMON.command_line_header "Shorter".print;
+    COMMON.print_info;
+    COMMON.command_line_footer.print;
     die_with_code exit_failure_code;
   );
   
@@ -113,7 +112,6 @@ Section Private
   ( + cmd:STRING;
     + j:INTEGER;
     + var_lisaac:STRING_CONSTANT;
-    + path:NATIVE_ARRAY(CHARACTER);
     
     // Read argument.
     is_shorter := TRUE;
@@ -176,19 +174,7 @@ Section Private
     };
     
     (format_name != NULL).if {
-      path := `LISAAC_DIRECTORY`:NATIVE_ARRAY(CHARACTER);
-      var_lisaac := STRING_CONSTANT.new_intern path
-      count (path.fast_first_index_of '\0' until 1024);
-      //var_lisaac := ENVIRONMENT.get_environment_variable "LISAAC";
-      //(var_lisaac = NULL).if {
-	//STD_ERROR.put_string "Unable to find `LISAAC' environment variable.\n";
-	//STD_ERROR.put_string "Please, set the environment variable `LISAAC'\n";
-	//STD_ERROR.put_string "with the appropriate absolute path to lisaac \
-	//\root directory.\n";
-	//STD_ERROR.put_string "Example: 'set LISAAC=/lisaac/'\n";
-	//die_with_code exit_failure_code;
-      //};
-      //
+      var_lisaac := COMMON.path_lisaac;
       string_tmp.copy var_lisaac;
       ((var_lisaac.last != '/') &&
       {var_lisaac.last != '\\'}).if {

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list