[SCM] Lisaac compiler branch, mildred-projects, updated. lisaac-0.12-421-g00631ef

Mildred Ki'Lya silkensedai at online.fr
Wed Aug 5 21:05:56 UTC 2009


The following commit has been merged in the mildred-projects branch:
commit 43ada02a3141e23744b627041b3ac4c3125cc550
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date:   Wed Aug 5 20:22:47 2009 +0200

    Add support for imported projects

diff --git a/make.lip b/make.lip
index 52d653d..dc42cb7 100644
--- a/make.lip
+++ b/make.lip
@@ -57,14 +57,18 @@ Section Private
   
   + target:STRING := "unix";
   
+  + lib_std :PROJECT;
+  
   //
   // Directory.
   //
   
   - standard_path <-
   // Standard library.
-  ( 
-    path ("lib2/*");
+  (
+    "Load: lib.lip\n".print;
+    lib_std := project ("STD");
+    lib_std.load("lib.lip");
   );
   
   //
@@ -73,31 +77,18 @@ Section Private
   
   - unix_target <-
   (
-    path ("lib2_os/unix/system/");
-    path ("lib2_os/unix/file_system/");
-    path ("lib2_os/unix/video/");
   );
   
   - windows_target <-
   (
-    path ("lib2_os/unix/system/");
-    path ("lib2_os/windows/file_system/");
-    path ("lib2_os/unix/file_system/");  // BSBS: ??
-    path ("lib2_os/windows/video/");
   );
 
   - dos_target <-
   (
-    path ("lib2_os/unix/system/");
-    path ("lib2_os/unix/file_system/"); // BSBS: ??
-    path ("lib2_os/dos/file_system/");
-    path ("lib2_os/dos/video/");
   );
   
   - java_target <-
   (
-    path ("lib2_os/java/system/");
-    path ("lib2_os/java/file_system/");
   );
   
   - get_target <-
@@ -116,7 +107,7 @@ Section Private
     };
     (target = "").if {
       "Target code needed.\n".print;
-      exit;
+      exit 1;
     };
   );
       
@@ -198,6 +189,12 @@ Section Private
   (
     general_back_end;
   );
+
+  - print_info <-
+  // Print information about the project
+  (
+    info_project.print;
+  );
   
 Section Public
   
@@ -285,7 +282,15 @@ Section Public
   //
   // Other.
   //
-  
+
+  - info <-
+  // Information about the project
+  (
+    front_end;
+    print_info;
+    exit;
+  );
+
   - q <-
   // Quiet operation.
   (
diff --git a/src/lip/lip_affect.li b/src/lip/lip_affect.li
index aace410..3501cc9 100644
--- a/src/lip/lip_affect.li
+++ b/src/lip/lip_affect.li
@@ -70,7 +70,7 @@ Section Public
     (slot = NULL).if {
       string_tmp.copy "Slot `";
       string_tmp.append name;
-      string_tmp.append "' not found.";
+      string_tmp.append "' not found for assignment.";
       semantic_error (position,string_tmp);
     };
     val := value.run_expr;
diff --git a/src/lip/lip_boolean.li b/src/lip/lip_boolean.li
index a68f445..d61c78d 100644
--- a/src/lip/lip_boolean.li
+++ b/src/lip/lip_boolean.li
@@ -91,6 +91,8 @@ Section Public
     };
   );
 
+  - to_boolean :BOOLEAN <- value;
+
 Section LIP_CONSTANT
   
   - my_copy other:SELF :LIP_CONSTANT <- other;
diff --git a/src/lip/lip_call.li b/src/lip/lip_call.li
index 5b7551d..4051e1f 100644
--- a/src/lip/lip_call.li
+++ b/src/lip/lip_call.li
@@ -89,21 +89,15 @@ Section Public
       //
       // Call with no receiver
       //
-// string_tmp.copy name;
-// (val = NULL).if {
-//   string_tmp.append ";\n";
-// } else {
-//   string_tmp.append " (";
-//   val.append_in string_tmp;
-//   string_tmp.append ")\n";
-// };
-// string_tmp.print;
       (name = ALIAS_STR.slot_exit).if {
         (val != NULL).if {
           warning_error (position,"No argument for `exit' method.");
         };
         die_with_code exit_failure_code;
-      }.elseif {name = ALIAS_STR.slot_path} then {
+      }.elseif {(name = ALIAS_STR.slot_path) ||
+                {name = ALIAS_STR.slot_public_path} ||
+                {name = ALIAS_STR.slot_private_path}
+      } then {
         str ?= val;
         (str = NULL).if {
           semantic_error (position,"String argument needed.");
@@ -117,7 +111,8 @@ Section Public
         };
         project.load_directory path
                 base_path      (stack_base_directory.last)
-                is_recursive   is_rec;
+                is_recursive   is_rec
+                public         (name != ALIAS_STR.slot_private_path);
       }.elseif {name = ALIAS_STR.slot_run} then {
         str ?= val;
         (str = NULL).if {
@@ -129,10 +124,7 @@ Section Public
       } else {
         slot := project.get_method name;
         (slot = NULL).if {
-          string_tmp.copy "Code slot `";
-          string_tmp.append name;
-          string_tmp.append "' not found.";
-          semantic_error (position,string_tmp);
+          error_slot_not_found "Code slot" name name;
         };
         (slot.run_with val).if_false {
           semantic_error (position,"Invalid argument.");
@@ -147,29 +139,58 @@ Section Public
         + prj  :LIP_PROJECT;
         prj_v ?= self;
         (prj_v != NULL).if { prj := prj_v.value; };
-        (prj != NULL).if {
+        (prj = NULL).if {
+          semantic_error(position, "Call on project NULL");
+        }.elseif {! prj.initialized} then {
+          (name = ALIAS_STR.slot_load).if {
+            str ?= val;
+            ((str = NULL) || {str.value.is_empty}).if {
+              semantic_error (position,"Non empty string argument needed.");
+            };
+            string_tmp.clear;
+            (str.value.first == '/').if_false {
+              string_tmp.append (stack_base_directory.last);
+              ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
+                string_tmp.add_last '/';
+              };
+            };
+            string_tmp.append (str.value);
+            prj.load_lip (ALIAS_STR.get string_tmp).if_false {
+              string_tmp2.copy "Cannot load lip file `";
+              string_tmp2.append string_tmp;
+              string_tmp2.append "': file not found";
+              semantic_error (position,string_tmp2);
+            };
+            slot := prj.get_method (ALIAS_STR.slot_init);
+            (slot != NULL).if {
+              (slot.run_with prj_v).if_false {
+                semantic_error (position,"Invalid argument.");
+              };
+            } else {
+              error_slot_not_found "Code slot" name name project (prj.name) send FALSE;
+//               (prj.list_method.lower).to (prj.list_method.upper) do { i:INTEGER;
+//                 slot := prj.list_method.item i;
+//                 string_tmp2.append "\n - ";
+//                 string_tmp2.append (slot.name);
+//               };
+              warning_error (position, string_tmp);
+            };
+          } else {
+            error_slot_not_found "Code slot" name name project (prj.name) send TRUE;
+          };
+        } else {
           slot := project.get_method name;
           (slot = NULL).if {
-            string_tmp.copy "Code slot `";
-            string_tmp.append name;
-            string_tmp.append "' not found.";
-            semantic_error (position,string_tmp);
+            error_slot_not_found "Code slot" name name project (prj.name) send TRUE;
           };
           (slot.run_with val).if_false {
             semantic_error (position,"Invalid argument.");
           };
-        } else {
-          semantic_error(position, "Call on project NULL");
         };
       }.elseif {name = ALIAS_STR.slot_print} then {
         self.print;
       } else {
-        string_tmp.copy "Slot `";
-        string_tmp.append name;
-        string_tmp.append "' not found (Self = `";
-        self.append_in string_tmp;
-        string_tmp.append "').";
-        semantic_error (position,string_tmp);
+        error_slot_not_found "Slot" name name;
       };
     };
     (val != NULL).if {
@@ -200,15 +221,6 @@ Section Public
       //
       // Call with no receiver
       //
-// string_tmp.copy name;
-// (val = NULL).if {
-//   string_tmp.append ";\n";
-// } else {
-//   string_tmp.append " (";
-//   val.append_in string_tmp;
-//   string_tmp.append ")\n";
-// };
-// string_tmp.print;
       (name = ALIAS_STR.slot_run).if {
         str ?= val;
         (str = NULL).if {
@@ -218,6 +230,24 @@ Section Public
         str.append_in string_tmp;
         res := ENVIRONMENT.execute_command string_tmp;
         result := LIP_INTEGER.get res;
+      }.elseif { name = ALIAS_STR.slot_info_project} then {
+        result := LIP_STRING.get (project.info_project);
+      }.elseif {(name = ALIAS_STR.slot_project) ||
+                {name = ALIAS_STR.slot_public_project} ||
+                {name = ALIAS_STR.slot_private_project}
+      } then {
+        + prj :LIP_PROJECT;
+        str ?= val;
+        (str = NULL).if {
+          semantic_error (position,"String argument needed.");
+        };
+        prj := LIP_PROJECT.clone.make;
+        prj.set_protoname (str.value);
+        prj.set_public (name = ALIAS_STR.slot_public_project);
+        project.list_prj.add_last prj;
+        result := LIP_VALUEPROJECT.get prj;
+      }.elseif {name = ALIAS_STR.variable_lisaac} then {
+        result := LIP_STRING.get (LISAAC.path_lisaac);
       }.elseif {name = ALIAS_STR.slot_get_integer} then {
         IO.read_integer;
         result := LIP_INTEGER.get (IO.last_integer);
@@ -228,15 +258,12 @@ Section Public
         slot := project.get_data name;
         ((slot = NULL) && {!stack.is_empty}).if {
           slot := stack.last;
-          (slot.name != name).if {
+          ((slot != NULL) && {slot.name != name}).if {
             slot := NULL;
           };
         };
         (slot = NULL).if {
-          string_tmp.copy "Data slot `";
-          string_tmp.append name;
-          string_tmp.append "' not found.";
-          semantic_error (position,string_tmp);
+          error_slot_not_found "Data slot" name name;
         };
         result := slot.get_value;
       };
@@ -249,7 +276,11 @@ Section Public
         + prj  :LIP_PROJECT;
         prj_v ?= self;
         (prj_v != NULL).if { prj := prj_v.value; };
-        (prj != NULL).if {
+        (prj = NULL).if {
+          semantic_error(position, "Call on project NULL");
+        }.elseif {! prj.initialized} then {
+          error_slot_not_found "Data slot" name name project (prj.name) send TRUE;
+        } else {
           slot := project.get_data name;
           ((slot = NULL) && {!stack.is_empty}).if {
             slot := stack.last;
@@ -258,22 +289,12 @@ Section Public
             };
           };
           (slot = NULL).if {
-            string_tmp.copy "Data slot `";
-            string_tmp.append name;
-            string_tmp.append "' not found.";
-            semantic_error (position,string_tmp);
+            error_slot_not_found "Data slot" name name project (prj.name) send TRUE;
           };
           result := slot.get_value;
-        } else {
-          semantic_error(position, "Call on project NULL");
         };
       } else {
-        string_tmp.copy "Slot `";
-        string_tmp.append name;
-        string_tmp.append "' not found (Self = `";
-        self.append_in string_tmp;
-        string_tmp.append "').";
-        semantic_error (position,string_tmp);
+        error_slot_not_found "Slot" name name;
       };
     };
     (val != NULL).if {
@@ -285,3 +306,23 @@ Section Public
     result
   );
 
+  - error_slot_not_found type:STRING_CONSTANT name name:STRING_CONSTANT <-
+    error_slot_not_found type name name project NULL send TRUE;
+
+  - error_slot_not_found type:STRING_CONSTANT name name:STRING_CONSTANT project prj:STRING_CONSTANT send send:BOOLEAN <-
+  (
+    string_tmp.copy type;
+    string_tmp.append " `";
+    string_tmp.append name;
+    string_tmp.append "' not found";
+    (prj != NULL).if {
+      string_tmp.append "in project `";
+      string_tmp.append prj;
+      string_tmp.append "'";
+    };
+    string_tmp.append ".";
+    send.if {
+      semantic_error (position, string_tmp);
+    };
+  );
+
diff --git a/src/lip/lip_constant.li b/src/lip/lip_constant.li
index 7c514c8..2e3178a 100644
--- a/src/lip/lip_constant.li
+++ b/src/lip/lip_constant.li
@@ -159,6 +159,8 @@ Section Public
   - print <- deferred;
 
   - append_in str:STRING <- deferred;
+
+  - to_boolean :BOOLEAN <- FALSE;
   
 Section LIP_CONSTANT
   
diff --git a/src/lip/lip_if.li b/src/lip/lip_if.li
index bb3e126..cff5d00 100644
--- a/src/lip/lip_if.li
+++ b/src/lip/lip_if.li
@@ -65,13 +65,13 @@ Section Public
   //
   
   - run <-
-  ( + val:LIP_BOOLEAN;
+  ( + val:LIP_CONSTANT;
     
-    val ?= condition.run_expr;
+    val := condition.run_expr;
     (val = NULL).if {
-      semantic_error (position,"BOOLEAN needed.");
+      semantic_error (position,"BOOLEAN value needed.");
     };
-    (val.value).if {
+    (val.to_boolean).if {
       (then.lower).to (then.upper) do { i:INTEGER;
         then.item i.run;
       };
diff --git a/src/lip/lip_integer.li b/src/lip/lip_integer.li
index 1925606..ad60adf 100644
--- a/src/lip/lip_integer.li
+++ b/src/lip/lip_integer.li
@@ -97,6 +97,8 @@ Section Public
   (
     str.append (value.to_string);
   );
+
+  - to_boolean :BOOLEAN <- value != 0;
   
 Section LIP_CONSTANT
     
diff --git a/src/lip/lip_project.li b/src/lip/lip_project.li
index d3c1cd8..40a6575 100644
--- a/src/lip/lip_project.li
+++ b/src/lip/lip_project.li
@@ -34,58 +34,259 @@ Section Inherit
 
 Section Public
 
-  //
-  // Path directory and command front end.
-  //
+  + list_parent:FAST_ARRAY[STRING_CONSTANT];
+  // List the parent .lip files (Section Inherit in .lip)
+
+  + list_method:FAST_ARRAY[LIP_SLOT_CODE];
+  // List of all code slots
+
+  + list_data:HASHED_DICTIONARY[LIP_SLOT_DATA,STRING_CONSTANT];
+  // List of all data slots
+
+  + list_prj:FAST_ARRAY[LIP_PROJECT];
+  // List of all sub projects
 
   + items :FAST_ARRAY[PRJ_ITEM];
+  // List of all items
 
   + path :STRING_CONSTANT := ALIAS_STR.path_current;
+  // The path where the .lip file is found
   
   + file :STRING_CONSTANT;
+  // The name of the .lip file
+
+  + is_public :BOOLEAN := FALSE;
+  - is_private:BOOLEAN <- ! is_public;
+  - set_public pub:BOOLEAN <- is_public := pub;
+
+  - initialized :BOOLEAN <- file != NULL;
 
   + protoname :STRING_CONSTANT;
+  // The name of the project appended at the beginning of the protopath of the
+  // prototypes. For example "LIB" for the library named "LIB". NULL if no
+  // prefix.
   
   - set_protoname n:STRING_CONSTANT <-
   (
-    protoname := n;
+    string_tmp.clear;
+    (n.lower).to (n.count - 3) do { i:INTEGER;
+      + c:CHARACTER;
+      c := n.item i.to_upper;
+      c.is_upper.if {
+        string_tmp.add_last c;
+      }.elseif {c.is_digit} then {
+        string_tmp.add_last c;
+      }.elseif {c = '.'} then {
+        ((string_tmp.count >= 1) && {string_tmp.last != '.'}).if {
+          string_tmp.add_last '.';
+        };
+      } else {
+        ((string_tmp.count >= 1) && {string_tmp.last != '_'} && {string_tmp.last != '.'}).if {
+          string_tmp.add_last '_';
+        };
+      };
+    };
+    protoname := ALIAS_STR.get string_tmp;
   );
 
   - name :STRING_CONSTANT <-
+  [
+    -? { file != NULL };
+  ]
   (
-    string_tmp.copy path;
-    ((string_tmp.last != '/') || {string_tmp.last != '\\'}).if {
-      string_tmp.add_last '/';
+    string_tmp3.copy path;
+    ((string_tmp3.last != '/') && {string_tmp3.last != '\\'}).if {
+      string_tmp3.add_last '/';
     };
-    string_tmp.append file;
-    ALIAS_STR.get string_tmp
+    string_tmp3.append file;
+    ALIAS_STR.get string_tmp3
   );
 
   - create :SELF <- clone.make;
 
   - make :SELF <-
   (
-    // TODO: Mildred: capacity 3000, isn't it a bit much ?
-    items       := FAST_ARRAY[PRJ_ITEM].create_with_capacity 3000;
+    items       := FAST_ARRAY[PRJ_ITEM].create_with_capacity 128;
     list_parent := FAST_ARRAY[STRING_CONSTANT].create_with_capacity 1;
     list_method := FAST_ARRAY[LIP_SLOT_CODE].create_with_capacity 32;
     list_data   := HASHED_DICTIONARY[LIP_SLOT_DATA,STRING_CONSTANT].create;
+    list_prj    := FAST_ARRAY[LIP_PROJECT].create_with_capacity 8;
     Self
   );
 
-  - add_source filename:STRING_CONSTANT <-
-    add_item (PRJ_ITM_PROTOTYPE.clone.make filename in Self);
+  - info_project :STRING_CONSTANT <-
+  (
+    string_tmp4.clear;
+    append_info_project_in string_tmp4 indent "";
+    ALIAS_STR.get string_tmp4
+  );
 
-  - add_item itm:PRJ_ITEM <-
-  [
-    /*(items.lower).to (items.upper) do { i:INTEGER;
+  - append_info_project_in buffer :STRING indent indent:STRING_CONSTANT <-
+  (
+    buffer.append indent;
+    buffer.append "Project ";
+    (protoname = NULL).if {
+      buffer.append "(unnamed)";
+    } else {
+      buffer.add_last '"';
+      buffer.append protoname;
+      buffer.add_last '"';
+    };
+    buffer.append " `";
+    buffer.append name;
+    buffer.append "'\n";
+    buffer.append indent;
+    (list_parent.lower).to (list_parent.upper) do { i:INTEGER;
+      buffer.append " - Parent: ";
+      list_parent.item i.is_empty.if {
+        buffer.append "(default make.lip)";
+      } else {
+        buffer.append "`";
+        buffer.append (list_parent.item i);
+        buffer.append "'";
+      };
+      buffer.append "\n";
+      buffer.append indent;
+    };
+
+    buffer.append "\n";
+    buffer.append indent;
+    buffer.append "Prototypes:\n";
+    buffer.append indent;
+    (items.lower).to (items.upper) do { i:INTEGER;
       + item :PRJ_ITEM;
       item := items.item i;
-      (item.protopath = itm.protopath).if {
-        ("The Item "+(itm.protopath)+" already exists\n").print;
-        ? { item.protopath != itm.protopath };
+      buffer.append " -";
+      item.is_public.if {
+        buffer.append " (public)  ";
+      } else {
+        buffer.append " (private) ";
       };
-    };*/
+      buffer.append (item.protopath);
+      //buffer.append ": `";
+      //buffer.append (item.filepath);
+      //buffer.append "'";
+      buffer.append "\n";
+      buffer.append indent;
+    };
+
+    buffer.append "\n";
+    buffer.append indent;
+    buffer.append "Data slots:\n";
+    buffer.append indent;
+    (list_data.lower).to (list_data.upper) do { i:INTEGER;
+      + slot :LIP_SLOT_DATA;
+      + val  :LIP_CONSTANT;
+      slot := list_data.item i;
+      val := slot.get_value;
+      buffer.append " - ";
+      buffer.append (list_data.key i);
+      buffer.append ":";
+      buffer.append (val.name);
+      buffer.append " := ";
+      val.append_in buffer;
+      buffer.append "\n";
+      buffer.append indent;
+    };
+
+    buffer.append "\n";
+    buffer.append indent;
+    buffer.append "Code slots:\n";
+    buffer.append indent;
+    (list_method.lower).to (list_method.upper) do { i:INTEGER;
+      + slot  :LIP_SLOT_CODE;
+      slot  := list_method.item i;
+      buffer.append " - ";
+      buffer.append (slot.name);
+      (slot.argument != NULL).if {
+        buffer.append " ";
+        buffer.append (slot.argument.name);
+        (slot.argument.value != NULL).if {
+          buffer.append ":";
+          buffer.append (slot.argument.value.name);
+        };
+      };
+      buffer.append ";";
+//       (slot.base_directory != NULL).if {
+//         buffer.append " (defined in `";
+//         buffer.append (slot.base_directory);
+//         buffer.append "')";
+//       };
+      (slot.comment != NULL).if {
+        buffer.append " //";
+        buffer.append (slot.comment);
+        {buffer.last.is_separator}.while_do {
+          buffer.remove_last 1;
+        };
+      };
+      buffer.append "\n";
+      buffer.append indent;
+    };
+
+    buffer.append "\n";
+    buffer.append indent;
+    buffer.append "Sub-Projects:\n";
+    buffer.append indent;
+    (list_prj.lower).to (list_prj.upper) do { i:INTEGER;
+      + prj :LIP_PROJECT;
+      prj := list_prj.item i;
+      buffer.append " -";
+      prj.is_public.if {
+        buffer.append " (public)  ";
+      } else {
+        buffer.append " (private) ";
+      };
+      buffer.append (prj.protoname);
+      buffer.append ": ";
+      buffer.append (prj.name);
+      buffer.append "\n";
+      string_tmp.copy indent;
+      string_tmp.append "   | ";
+      buffer.append string_tmp;
+      buffer.append "\n";
+      prj.append_info_project_in buffer indent (ALIAS_STR.get string_tmp);
+      buffer.append "\n";
+      buffer.append indent;
+      ALIAS_STR.get buffer
+    };
+
+    buffer.append "\n";
+  );
+
+  - add_imports <-
+  (
+    (list_prj.lower).to (list_prj.upper) do { i:INTEGER;
+      + prj :LIP_PROJECT;
+      prj := list_prj.item i;
+      prj.add_imports;
+      (prj.items.lower).to (prj.items.upper) do { j:INTEGER;
+        + itm,itm2:PRJ_ITEM;
+        itm := prj.items.item j;
+        ((itm.is_public) && {! has_item (itm.externprotopath)}).if {
+          itm2 := PRJ_ITM_ALIAS.clone.make itm in Self;
+          itm2.set_public is_public;
+          add_item itm2;
+        };
+      };
+    };
+  );
+
+  - has_item protopath:STRING_CONSTANT :BOOLEAN <-
+  ( + i:INTEGER;
+    + has:BOOLEAN;
+    i := items.lower;
+    {(!has) && {i <= items.upper}}.while_do {
+      + itm :PRJ_ITEM;
+      itm := items.item i;
+      has := (itm.protopath = protopath);
+      i := i + 1;
+    };
+    has
+  );
+
+  - add_item itm:PRJ_ITEM <-
+  [
+    -? { ! has_item (itm.protopath) };
   ]
   (
     items.add_last itm;
@@ -103,17 +304,18 @@ Section Public
     (item = NULL).if {
       string_tmp.copy search;
       string_tmp.append " is not found in project `";
-      string_tmp.append file;
-      string_tmp.append "'\n";
-      (items.lower).to (items.upper) do { i:INTEGER;
-        item := items.item i;
-        string_tmp.append " - ";
-        string_tmp.append (item.protopath);
-        //string_tmp.append ": `";
-        //string_tmp.append (item.filepath);
-        //string_tmp.append "'";
-        string_tmp.append "\n";
-      };
+      string_tmp.append name;
+      string_tmp.append "'";
+//       string_tmp.append "\n";
+//       (items.lower).to (items.upper) do { i:INTEGER;
+//         item := items.item i;
+//         string_tmp.append " - ";
+//         string_tmp.append (item.protopath);
+//         //string_tmp.append ": `";
+//         //string_tmp.append (item.filepath);
+//         //string_tmp.append "'";
+//         string_tmp.append "\n";
+//       };
       POSITION.put_error semantic text string_tmp;
       (pos != POSITION).if {
         pos.put_position;
@@ -202,12 +404,6 @@ Section Public
   //
 
 
-  + list_parent:FAST_ARRAY[STRING_CONSTANT];
-
-  + list_method:FAST_ARRAY[LIP_SLOT_CODE];
-
-  + list_data:HASHED_DICTIONARY[LIP_SLOT_DATA,STRING_CONSTANT];
-
   - get_data n:STRING_CONSTANT :LIP_SLOT_DATA <-
   (
     list_data.fast_reference_at n
@@ -232,6 +428,7 @@ Section Public
     -? { file_lip != NULL };
   ]
   ( + success:BOOLEAN;
+    + i:INTEGER;
     + path_lip:STRING_CONSTANT;
 
     path_lip := file_lip;
@@ -241,7 +438,10 @@ Section Public
     //
 
     (file = NULL).if {
-      file := path_lip;
+      string_tmp.copy path_lip;
+      i := string_tmp.last_index_of '/';
+      string_tmp.remove_first i;
+      file := ALIAS_STR.get string_tmp;
       string_tmp.copy path_lip;
       {
         (!string_tmp.is_empty)    &&
@@ -444,9 +644,12 @@ Section Public
   );
 
   - load_directory path:STRING_CONSTANT base_path base:STRING_CONSTANT is_recursive is_rec:BOOLEAN <-
-    load_directory path base_path base is_recursive is_rec weak FALSE;
+    load_directory path base_path base is_recursive is_rec public TRUE weak FALSE;
+
+  - load_directory path:STRING_CONSTANT base_path base:STRING_CONSTANT is_recursive is_rec:BOOLEAN public pub:BOOLEAN <-
+    load_directory path base_path base is_recursive is_rec public pub  weak FALSE;
 
-  - load_directory path:STRING_CONSTANT base_path base:STRING_CONSTANT is_recursive is_rec:BOOLEAN weak weak:BOOLEAN <-
+  - load_directory path:STRING_CONSTANT base_path base:STRING_CONSTANT is_recursive is_rec:BOOLEAN public pub:BOOLEAN weak weak:BOOLEAN <-
   [
     -? { path != NULL };
     -? { path.count > 0 };
@@ -497,6 +700,7 @@ Section Public
 
           // Create the item for the .li file
           item := PRJ_ITM_PROTOTYPE.clone.make (entry.path) protopath (PRJ_ITEM.static_protopath_from_path fullpath) in Self;
+          item.set_public pub;
           // Search for similar items
           skip := FALSE;
           i := items.lower;
@@ -524,12 +728,12 @@ Section Public
           //
           // The entry is a directory
           //
-          load_directory fullpath base_path base is_recursive TRUE weak weak;
+          load_directory fullpath base_path base is_recursive TRUE public pub weak weak;
         };
       };
     } else {
       string_tmp.copy "Incorrect directory `";
-      string_tmp.append path;
+      string_tmp.append joined_path;
       string_tmp.append "'.";
       warning_error (position,string_tmp);
     };
diff --git a/src/lip/lip_string.li b/src/lip/lip_string.li
index f6c578e..9747a21 100644
--- a/src/lip/lip_string.li
+++ b/src/lip/lip_string.li
@@ -117,6 +117,8 @@ Section Public
     };
   );
   */
+
+  - to_boolean :BOOLEAN <- (value != NULL) && {!value.is_empty};
   
 Section LIP_CONSTANT
     
diff --git a/src/lip/lip_valueproject.li b/src/lip/lip_valueproject.li
index 3ce0198..2d2bf8f 100644
--- a/src/lip/lip_valueproject.li
+++ b/src/lip/lip_valueproject.li
@@ -83,9 +83,17 @@ Section Public
 
   - append_in str:STRING <-
   (
-    str.append (value.name);
+    (value = NULL).if {
+      str.append "NULL";
+    }.elseif { ! value.initialized } then {
+      str.append "*.lip";
+    } else {
+      str.append (value.name);
+    };
   );
 
+  - to_boolean :BOOLEAN <- value != NULL;
+
 Section LIP_CONSTANT
 
   - my_copy other:SELF :LIP_CONSTANT <-
diff --git a/src/lip/prj_item.li b/src/lip/prj_item.li
index 8f80da4..85f93af 100644
--- a/src/lip/prj_item.li
+++ b/src/lip/prj_item.li
@@ -32,7 +32,7 @@ Section Inherit
 
   + parent_any:Expanded ANY;
 
-Section SELF
+Section PRJ_ITEM
 
   - prototype :PROTOTYPE <- (deferred; NULL);
 
@@ -42,7 +42,13 @@ Section Public
 
   + project  :LIP_PROJECT;
 
-  + projectprotopath :STRING_CONSTANT <-
+  + is_public :BOOLEAN := TRUE;
+  - is_private:BOOLEAN <- !is_public;
+  - set_public pub:BOOLEAN <- is_public := pub;
+
+  + projectprotopath :STRING_CONSTANT <- externprotopath;
+
+  - externprotopath :STRING_CONSTANT <-
   (
     string_tmp.clear;
     (project.protoname != NULL).if {
@@ -53,7 +59,7 @@ Section Public
     ALIAS_STR.get string_tmp
   );
 
-  + protopath:STRING_CONSTANT;
+  - protopath:STRING_CONSTANT <- (deferred; NULL);
 
   - set_projectprotopath ppp:STRING_CONSTANT <- deferred;
 
@@ -128,11 +134,11 @@ Section Public
       }.elseif {c.is_digit} then {
         string_tmp2.add_last c;
       }.elseif {c = '/'} then {
-        ((i > 1) && {string_tmp2.last != '.'}).if {
+        ((string_tmp2.count >= 1) && {string_tmp2.last != '.'}).if {
           string_tmp2.add_last '.';
         };
       } else {
-        ((string_tmp2.last != '_') && {i > 1} && {string_tmp2.last != '.'}).if {
+        ((string_tmp2.count >= 1) && {string_tmp2.last != '_'} && {string_tmp2.last != '.'}).if {
           string_tmp2.add_last '_';
         };
       };
diff --git a/src/lip/prj_itm_alias.li b/src/lip/prj_itm_alias.li
index 9728424..2b8a848 100644
--- a/src/lip/prj_itm_alias.li
+++ b/src/lip/prj_itm_alias.li
@@ -32,7 +32,7 @@ Section Inherit
 
   + parent_prj_item:Expanded PRJ_ITEM;
 
-Section SELF
+Section PRJ_ITEM
 
   - prototype :PROTOTYPE <- source_item.prototype;
 
@@ -44,18 +44,26 @@ Section Public
 
   - filepath :STRING_CONSTANT <- source_item.filepath;
 
+  + protopath:STRING_CONSTANT <- source_item.externprotopath;
+
   - set_projectprotopath ppp:STRING_CONSTANT <-
   (
     projectprotopath := ppp;
     source_item.set_projectprotopath ppp;
   );
 
+  - make src:PRJ_ITEM in prj:LIP_PROJECT :SELF <-
+  (
+    project     := prj;
+    source_item := src;
+    Self
+  );
+
   - make src:PRJ_ITEM protopath pp:STRING_CONSTANT in prj:LIP_PROJECT :SELF <-
   (
     project     := prj;
     source_item := src;
     protopath   := pp;
-
     Self
   );
 
diff --git a/src/lip/prj_itm_prototype.li b/src/lip/prj_itm_prototype.li
index 5ba1f0b..5d181d2 100644
--- a/src/lip/prj_itm_prototype.li
+++ b/src/lip/prj_itm_prototype.li
@@ -32,7 +32,7 @@ Section Inherit
 
   + parent_prj_item:Expanded PRJ_ITEM;
 
-Section SELF
+Section PRJ_ITEM
 
   + prototype :PROTOTYPE;
 
@@ -45,13 +45,15 @@ Section Public
 
   + filename :STRING_CONSTANT;
 
+  + protopath:STRING_CONSTANT;
+
   - filepath :STRING_CONSTANT <-
   // Absolute path (join relative item path and project path)
   (
     string_tmp.clear;
     (filename.first != '/').if {
       string_tmp.append   (project.path);
-      ((string_tmp.last != '/') || {string_tmp.last != '\\'}).if {
+      ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
         string_tmp.add_last '/';
       };
     };
diff --git a/src/lisaac.li b/src/lisaac.li
index e8a332b..0f2f763 100644
--- a/src/lisaac.li
+++ b/src/lisaac.li
@@ -230,7 +230,7 @@ Section Private
             string_tmp2.remove_last (string_tmp2.upper-i+1);
           };
           input_name := ALIAS_STR.get string_tmp2;
-          project.load_directory (ALIAS_STR.get string_tmp) base_path (ALIAS_STR.path_current) is_recursive FALSE weak TRUE;
+          project.load_directory (ALIAS_STR.get string_tmp) base_path (ALIAS_STR.path_current) is_recursive FALSE public TRUE weak TRUE;
           project.put_string input_name to (ALIAS_STR.slot_input_file);
         };
       };
@@ -274,6 +274,7 @@ Section Private
     is_java            := project.get_boolean (ALIAS_STR.slot_is_java);
     is_statistic       := project.get_boolean (ALIAS_STR.slot_is_statistic);
     is_quiet           := project.get_boolean (ALIAS_STR.slot_is_quiet);
+    project.add_imports;
     is_java.if {
       backend := BACKEND_JAVA;
     } else {
diff --git a/src/parser.li b/src/parser.li
index 978bfa0..652e749 100644
--- a/src/parser.li
+++ b/src/parser.li
@@ -2702,6 +2702,9 @@ Section Private
   //// PROGRAM      -> { 'Section' ('Inherit' | 'Public' | 'Private') { SLOT ';' } } 
   ( + idx:INTEGER;
     + section:STRING_CONSTANT;
+    + instr:LIP_CODE;
+    + cst:LIP_CONSTANT;
+    + str:LIP_STRING;
 
     ? { lip_prj != NULL };
     ? { lip_prj.list_parent != NULL };
@@ -2720,19 +2723,32 @@ Section Private
           (read_word (ALIAS_STR.prototype_string)).if_false {
             warning_error (current_position,"`STRING' type needed.");
           };
-          (read_symbol (ALIAS_STR.symbol_affect_immediate)).if {            
-            (read_string).if_false {            
-              syntax_error (current_position,"String needed.");            
+          (read_symbol (ALIAS_STR.symbol_affect_immediate)).if {
+            instr := readlip_expr_operator;
+            (instr = NULL).if {
+              cst := readlip_expr_constant;
+            } else {
+              cst := instr.run_expr;
+            };
+            (cst = NULL).if {
+              syntax_error (current_position,"Incorrect expression.");
+            };
+            str ?= cst;
+            ((str = NULL) || {str.value.count == 0}).if {
+              syntax_error (current_position,"Non empty string needed.");
             };
-            string_tmp.copy (object.filename);
-            {
-              (!string_tmp.is_empty)    && 
-              {string_tmp.last != '/'}  && 
-              {string_tmp.last != '\\'}
-            }.while_do {
-              string_tmp.remove_last 1;
+            string_tmp.clear;
+            (last_string.first != '/').if {
+              string_tmp.append (object.filename);
+              {
+                (!string_tmp.is_empty)    &&
+                {string_tmp.last != '/'}  &&
+                {string_tmp.last != '\\'}
+              }.while_do {
+                string_tmp.remove_last 1;
+              };
             };
-            string_tmp.append last_string;                              
+            string_tmp.append (str.value);
           } else {
             string_tmp.clear;
           };
@@ -2759,7 +2775,7 @@ Section Private
   );
   
   - readlip_slot sec:STRING_CONSTANT :BOOLEAN <-
-  //// SLOT         -> '+' identifier ':' TYPE [ ':=' EXPR_CONSTANT ]
+  //// SLOT         -> '+' identifier ':' TYPE [ ':=' EXPR_OPERATOR ]
   ////               | '-' identifier [ identifier ':' TYPE ] '<-' '(' { EXPR ';' } ')' 
   ( + result:BOOLEAN;
     + t:LIP_CONSTANT;
@@ -2790,7 +2806,12 @@ Section Private
       };      
       data := LIP_SLOT_DATA.create current_position in lip_prj name n value t argument FALSE;
       (read_symbol (ALIAS_STR.symbol_affect_immediate)).if {
-        cst := readlip_expr_constant;
+        instr := readlip_expr_operator;
+        (instr = NULL).if {
+          cst := readlip_expr_constant;
+        } else {
+          cst := instr.run_expr;
+        };
         (cst = NULL).if {
           syntax_error (current_position,"Incorrect expression.");
         };
@@ -2890,11 +2911,11 @@ Section Private
     };    
     (result = NULL).if {
       result := readlip_expr_operator;
-      ((result != NULL) && {read_character '.'}).if {        
+      ((result != NULL) && {read_character '.'}).if {
         result := readlip_function result;
         (result = NULL).if {
           syntax_error (current_position,"Incorrect slot.");
-        };        
+        };
       };
     };
     result
@@ -2944,7 +2965,7 @@ Section Private
     //}.elseif {read_word (ALIAS_STR.slot_print)} then {
     //  result := LIP_PRINT.create current_position message rec;
     }.elseif {read_identifier} then {
-      nam := last_string;
+      nam := ALIAS_STR.get (STRING.create_from_string last_string); // UGLY
       arg := readlip_expr_argument;
       result := LIP_CALL.create current_position in lip_prj self rec name nam with arg;
     };
@@ -3032,7 +3053,7 @@ Section Private
   - readlip_expr_unary:LIP_CODE <- 
   //// EXPR_UNARY   -> ( '-' | '!' ) EXPR_UNARY
   ////               | EXPR_BASE
-  ////               | identifier [ EXPR_ARGUMENT ]
+  ////               | identifier [ EXPR_ARGUMENT ] [ '.' FUNCTION ]
   ( + result:LIP_CODE;
     + is_neg:BOOLEAN;
     + type:CHARACTER;
@@ -3059,13 +3080,19 @@ Section Private
       // readlip_expr_argument changes last_string
       arg := readlip_expr_argument;
       result := LIP_CALL.create current_position in lip_prj self NULL name nam with arg;
+      (read_character '.').if {
+        result := readlip_function result;
+        (result = NULL).if {
+          syntax_error (current_position,"Incorrect slot.");
+        };
+      };
     } else {
       result := readlip_expr_base;
     };
     result
   );
   
-  - readlip_expr_base:LIP_CODE <-  
+  - readlip_expr_base:LIP_CODE <-
   //// EXPR_BASE    -> '(' EXPR_OPERATOR ')'
   ////               | EXPR_CONSTANT
   ( + result:LIP_CODE;
diff --git a/src/tools/alias_str.li b/src/tools/alias_str.li
index 390e7d4..0f7c95c 100644
--- a/src/tools/alias_str.li
+++ b/src/tools/alias_str.li
@@ -156,12 +156,15 @@ Section Public
   - slot_exit         :STRING_CONSTANT := "exit";
   - slot_run          :STRING_CONSTANT := "run";
   - slot_path         :STRING_CONSTANT := "path";
+  - slot_public_path  :STRING_CONSTANT := "public_path";
+  - slot_private_path :STRING_CONSTANT := "private_path";
   - slot_front_end    :STRING_CONSTANT := "front_end";
   - slot_back_end     :STRING_CONSTANT := "back_end";
+  - slot_info_project :STRING_CONSTANT := "info_project";
   - slot_input_file   :STRING_CONSTANT := "input_file";
   - slot_debug_level  :STRING_CONSTANT := "debug_level";
   - slot_debug_with_code:STRING_CONSTANT := "debug_with_code";
-  - slot_is_all_warning:STRING_CONSTANT := "is_all_warning";
+  - slot_is_all_warning :STRING_CONSTANT := "is_all_warning";
   - slot_is_optimization:STRING_CONSTANT := "is_optimization";
   - slot_inline_level :STRING_CONSTANT := "inline_level";
   - slot_is_java      :STRING_CONSTANT := "is_java";
@@ -170,6 +173,11 @@ Section Public
   - slot_get_integer  :STRING_CONSTANT := "get_integer";
   - slot_get_string   :STRING_CONSTANT := "get_string";
   - slot_is_cop       :STRING_CONSTANT := "is_cop";
+  - slot_load         :STRING_CONSTANT := "load";
+  - slot_project      :STRING_CONSTANT := "project";
+  - slot_public_project :STRING_CONSTANT := "public_project";
+  - slot_private_project:STRING_CONSTANT := "private_project";
+  - slot_init         :STRING_CONSTANT := "init";
     
   - c_void           :STRING_CONSTANT := "void";
   - c_struct         :STRING_CONSTANT := "struct __";
@@ -446,8 +454,11 @@ Section Public
     list.add slot_exit;
     list.add slot_run;
     list.add slot_path;
+    list.add slot_public_path;
+    list.add slot_private_path;
     list.add slot_front_end;
     list.add slot_back_end;
+    list.add slot_info_project;
     list.add slot_input_file;
     list.add slot_debug_level;
     list.add slot_debug_with_code;
@@ -459,7 +470,12 @@ Section Public
     list.add slot_is_quiet;
     list.add slot_get_integer;
     list.add slot_get_string;
-    list.add slot_is_cop;    
+    list.add slot_is_cop;
+    list.add slot_load;
+    list.add slot_project;
+    list.add slot_public_project;
+    list.add slot_private_project;
+    list.add slot_init;
           
     // Type C :
     list.add c_void;

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list