[SCM] Lisaac compiler branch, mildred-projects, updated. lisaac-0.12-416-g6a773e6
Mildred Ki'Lya
silkensedai at online.fr
Wed Aug 5 12:37:50 UTC 2009
The following commit has been merged in the mildred-projects branch:
commit 723965ced4af51bcd97c7f79496b054c575b9555
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Wed Aug 5 12:58:56 2009 +0200
Use relative paths in .lip files and protopaths
diff --git a/TODO b/TODO
index 6de6543..9807644 100644
--- a/TODO
+++ b/TODO
@@ -7,12 +7,5 @@
* script that check for svn commit each 10hours and launch a benchmark
game on several architecture and generate a html page on the website.
-[Mildred]
-
- * Project (.lip): the protopath must be relative to the project and not be
- an absolute path. For the moment se see errors messages with prototypes like:
- HOME.MILDRED.PROJECTS.LISAAC.LISAAC_COMPILER_GIT.LIB2.BASE.BOOLEAN
- we should see instead:
- LIB2.BASE.BOOLEAN
diff --git a/example/make.lip b/example/make.lip
index bb46d6d..bc56b41 100644
--- a/example/make.lip
+++ b/example/make.lip
@@ -30,19 +30,19 @@ Section Private
- example_path <-
// Example path.
(
- path (lisaac + "example/su_doku/");
- path (lisaac + "example/tetris/");
- path (lisaac + "example/fouronline/");
- path (lisaac + "example/shell/");
- path (lisaac + "example/gui/calculator/");
- path (lisaac + "example/gui/viewer/");
- path (lisaac + "example/gui/about/");
- path (lisaac + "example/gui/clock/");
- path (lisaac + "example/gui/desktop/");
- path (lisaac + "example/gui/mpg2/");
- path (lisaac + "example/demomaker/fire/");
- path (lisaac + "example/demomaker/glass/");
- path (lisaac + "example/demomaker/rotozoom/");
+ path ("su_doku/");
+ path ("tetris/");
+ path ("fouronline/");
+ path ("shell/");
+ path ("gui/calculator/");
+ path ("gui/viewer/");
+ path ("gui/about/");
+ path ("gui/clock/");
+ path ("gui/desktop/");
+ path ("gui/mpg2/");
+ path ("demomaker/fire/");
+ path ("demomaker/glass/");
+ path ("demomaker/rotozoom/");
);
//
diff --git a/make.lip b/make.lip
index 82c61e3..52d653d 100644
--- a/make.lip
+++ b/make.lip
@@ -64,7 +64,7 @@ Section Private
- standard_path <-
// Standard library.
(
- path (lisaac + "lib2/*");
+ path ("lib2/*");
);
//
@@ -73,31 +73,31 @@ Section Private
- unix_target <-
(
- path (lisaac + "lib2_os/unix/system/");
- path (lisaac + "lib2_os/unix/file_system/");
- path (lisaac + "lib2_os/unix/video/");
+ path ("lib2_os/unix/system/");
+ path ("lib2_os/unix/file_system/");
+ path ("lib2_os/unix/video/");
);
- windows_target <-
(
- path (lisaac + "lib2_os/unix/system/");
- path (lisaac + "lib2_os/windows/file_system/");
- path (lisaac + "lib2_os/unix/file_system/"); // BSBS: ??
- path (lisaac + "lib2_os/windows/video/");
+ 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 (lisaac + "lib2_os/unix/system/");
- path (lisaac + "lib2_os/unix/file_system/"); // BSBS: ??
- path (lisaac + "lib2_os/dos/file_system/");
- path (lisaac + "lib2_os/dos/video/");
+ 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 (lisaac + "lib2_os/java/system/");
- path (lisaac + "lib2_os/java/file_system/");
+ path ("lib2_os/java/system/");
+ path ("lib2_os/java/file_system/");
);
- get_target <-
diff --git a/src/lip/lip_call.li b/src/lip/lip_call.li
index 93d974e..b0a7ed1 100644
--- a/src/lip/lip_call.li
+++ b/src/lip/lip_call.li
@@ -115,7 +115,9 @@ Section Public
path := ALIAS_STR.get string_tmp;
is_rec := TRUE;
};
- project.load_directory path is_recursive is_rec;
+ project.load_directory path
+ base_path (stack_base_directory.last)
+ is_recursive is_rec;
}.elseif {name = ALIAS_STR.slot_run} then {
str ?= val;
(str = NULL).if {
diff --git a/src/lip/lip_code.li b/src/lip/lip_code.li
index 70ea66a..082de55 100644
--- a/src/lip/lip_code.li
+++ b/src/lip/lip_code.li
@@ -37,6 +37,8 @@ Section Inherit
Section Public
- stack:FAST_ARRAY[LIP_SLOT_DATA] := FAST_ARRAY[LIP_SLOT_DATA].create_with_capacity 8;
+
+ - stack_base_directory:FAST_ARRAY[STRING_CONSTANT] := FAST_ARRAY[STRING_CONSTANT].create_with_capacity 8;
//
// Run.
diff --git a/src/lip/lip_project.li b/src/lip/lip_project.li
index fa442c5..e0e1ab7 100644
--- a/src/lip/lip_project.li
+++ b/src/lip/lip_project.li
@@ -367,24 +367,60 @@ Section Public
};
);
- - load_directory path:ABSTRACT_STRING is_recursive is_rec:BOOLEAN <-
- load_directory path is_recursive is_rec weak FALSE;
+ - 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:ABSTRACT_STRING is_recursive is_rec:BOOLEAN weak weak:BOOLEAN <-
+ - load_directory path:STRING_CONSTANT base_path base:STRING_CONSTANT is_recursive is_rec:BOOLEAN weak weak:BOOLEAN <-
+ [
+ -? { path != NULL };
+ -? { path.count > 0 };
+ ]
( + entry:ENTRY;
+ dir:DIRECTORY;
+ item,it:PRJ_ITM_PROTOTYPE;
+ skip :BOOLEAN;
+ i :INTEGER;
+ + joined_path,fullpath:STRING_CONSTANT;
+
+ //
+ // Join path with base path
+ //
+ string_tmp.clear;
+ ((path.first != '/') && {base != NULL} && {base.count != 0}).if {
+ string_tmp.copy base;
+ ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
+ string_tmp.add_last '/';
+ };
+ };
+ string_tmp.append path;
+ joined_path := ALIAS_STR.get string_tmp;
- entry := FILE_SYSTEM.get_entry path;
+ //
+ // Iterate entries in joined_path
+ //
+ entry := FILE_SYSTEM.get_entry joined_path;
((entry != NULL) && {entry.is_directory} && {entry.open}).if {
dir ?= entry;
(dir.lower).to (dir.upper) do { j:INTEGER;
entry := dir.item j;
+
+ //
+ // Join path with the entry name
+ //
+ string_tmp.copy path;
+ ((string_tmp.last != '/') && {string_tmp.last != '\\'}).if {
+ string_tmp.add_last '/';
+ };
+ string_tmp.append (entry.name);
+ fullpath := ALIAS_STR.get string_tmp;
+
(entry.name.has_suffix ".li").if {
+ //
+ // The entry is a file
+ //
+
// Create the item for the .li file
- item := PRJ_ITM_PROTOTYPE.clone.make (entry.path) in Self;
+ item := PRJ_ITM_PROTOTYPE.clone.make (entry.path) protopath (PRJ_ITM_PROTOTYPE.static_protopath_from_path fullpath) in Self;
// Search for similar items
skip := FALSE;
i := items.lower;
@@ -409,7 +445,10 @@ Section Public
add_item item;
};
}.elseif {(is_rec) && {entry.is_directory}} then {
- load_directory (entry.path) is_recursive TRUE;
+ //
+ // The entry is a directory
+ //
+ load_directory fullpath base_path base is_recursive TRUE weak weak;
};
};
} else {
diff --git a/src/lip/lip_slot_code.li b/src/lip/lip_slot_code.li
index 20503b2..eb75c33 100644
--- a/src/lip/lip_slot_code.li
+++ b/src/lip/lip_slot_code.li
@@ -40,7 +40,9 @@ Section Public
+ argument:LIP_SLOT_DATA;
+ code:FAST_ARRAY[LIP_CODE];
-
+
+ + base_directory:STRING_CONSTANT;
+
+ comment:STRING_CONSTANT;
// + comment_chapter:STRING_CONSTANT;
@@ -63,6 +65,7 @@ Section Public
- create p:POSITION
in proj:LIP_PROJECT
+ dir d:STRING_CONSTANT
section sec:STRING_CONSTANT
name n:STRING_CONSTANT
argument arg:LIP_SLOT_DATA
@@ -77,23 +80,25 @@ Section Public
ALIAS_ARRAY[LIP_CODE].free c;
} else {
result := clone;
- result.make p in proj section sec name n argument arg code c;
+ result.make p in proj dir d section sec name n argument arg code c;
};
result
);
- make p:POSITION
in proj:LIP_PROJECT
+ dir d:STRING_CONSTANT
section sec:STRING_CONSTANT
name n:STRING_CONSTANT
argument arg:LIP_SLOT_DATA
code c:FAST_ARRAY[LIP_CODE] <-
(
- position := p;
- section := sec;
- name := n;
- argument := arg;
- code := c;
+ position := p;
+ section := sec;
+ name := n;
+ argument := arg;
+ code := c;
+ base_directory := d;
proj.list_method.add_last Self;
);
@@ -114,9 +119,11 @@ Section Public
stack.add_last NULL;
};
(result).if {
+ stack_base_directory.add_last base_directory;
(code.lower).to (code.upper) do { j:INTEGER;
code.item j.run;
- };
+ };
+ stack_base_directory.remove_last;
};
stack.remove_last;
};
diff --git a/src/lip/lip_slot_data.li b/src/lip/lip_slot_data.li
index a78d267..4d8b049 100644
--- a/src/lip/lip_slot_data.li
+++ b/src/lip/lip_slot_data.li
@@ -47,19 +47,35 @@ Section Public
-? {v != NULL};
]
( + result:SELF;
- result := clone;
- result.make p in proj name n value v argument is_arg;
+ + cst:LIP_CONSTANT;
+ + s:LIP_SLOT_DATA;
+
+ s := proj.get_data n;
+ (s != NULL).if {
+ (s.get_value.type_id_intern != v.type_id_intern).if {
+ POSITION.put_error semantic text "Wrong slot type (double declaration)";
+ p.put_position;
+ s.position.put_position;
+ POSITION.send_error;
+ };
+ cst := s.get_value;
+ s.set_value v;
+ cst.free;
+ result ?= s;
+ } else {
+ result := clone;
+ result.make p in proj name n value v argument is_arg;
+ };
result
- );
+ )
+ [
+ +? { Result != NULL };
+ ];
- make p:POSITION in proj:LIP_PROJECT name n:STRING_CONSTANT
value v:LIP_CONSTANT argument is_arg:BOOLEAN <-
- ( + s:LIP_SLOT_DATA;
+ (
position := p;
- s := proj.get_data n;
- (s != NULL).if {
- semantic_error (s.position,"Double declaration.");
- };
name := n;
value := v;
(is_arg).if_false {
diff --git a/src/lip/prj_itm_prototype.li b/src/lip/prj_itm_prototype.li
index 7a28057..c9cad77 100644
--- a/src/lip/prj_itm_prototype.li
+++ b/src/lip/prj_itm_prototype.li
@@ -43,30 +43,7 @@ Section Public
+ projectprotopath :STRING_CONSTANT <- protopath;
- + protopath:STRING_CONSTANT <-
- (
- string_tmp2.clear;
- (filename.lower).to (filename.count - 3) do { i:INTEGER;
- + c:CHARACTER;
- c := filename.item i.to_upper;
- c.is_upper.if {
- string_tmp2.add_last c;
- }.elseif {c.is_digit} then {
- string_tmp2.add_last c;
- }.elseif {c = '/'} then {
- ((i > 1) && {string_tmp2.last != '.'}).if {
- string_tmp2.add_last '.';
- };
- } else {
- ((string_tmp2.last != '_') && {i > 1} && {string_tmp2.last != '.'}).if {
- string_tmp2.add_last '_';
- };
- };
- };
-
- protopath := ALIAS_STR.get string_tmp2;
- protopath
- );
+ + protopath:STRING_CONSTANT;
+ protoname:STRING_CONSTANT <-
( + i :INTEGER;
@@ -81,10 +58,11 @@ Section Public
protoname
);
- - make fn:STRING_CONSTANT in prj:LIP_PROJECT :SELF <-
+ - make fn:STRING_CONSTANT protopath pp:STRING_CONSTANT in prj:LIP_PROJECT :SELF <-
(
project := prj;
filename := fn;
+ protopath:= pp;
Self
);
@@ -136,6 +114,29 @@ Section Public
match suffix prefix prefix
);
+ - static_protopath_from_path filename:ABSTRACT_STRING :STRING_CONSTANT <-
+ (
+ string_tmp2.clear;
+ (filename.lower).to (filename.count - 3) do { i:INTEGER;
+ + c:CHARACTER;
+ c := filename.item i.to_upper;
+ c.is_upper.if {
+ string_tmp2.add_last c;
+ }.elseif {c.is_digit} then {
+ string_tmp2.add_last c;
+ }.elseif {c = '/'} then {
+ ((i > 1) && {string_tmp2.last != '.'}).if {
+ string_tmp2.add_last '.';
+ };
+ } else {
+ ((string_tmp2.last != '_') && {i > 1} && {string_tmp2.last != '.'}).if {
+ string_tmp2.add_last '_';
+ };
+ };
+ };
+ ALIAS_STR.get string_tmp2
+ );
+
Section LIP_PROJECT
- match name:ABSTRACT_STRING prefix prefix:ABSTRACT_STRING :BOOLEAN <-
diff --git a/src/lisaac.li b/src/lisaac.li
index 2cbe592..710c1f3 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) is_recursive FALSE weak TRUE;
+ project.load_directory (ALIAS_STR.get string_tmp) base_path (ALIAS_STR.path_current) is_recursive FALSE weak TRUE;
project.put_string input_name to (ALIAS_STR.slot_input_file);
};
};
diff --git a/src/parser.li b/src/parser.li
index fa24666..539d163 100644
--- a/src/parser.li
+++ b/src/parser.li
@@ -104,6 +104,7 @@ Section Private
- object : PROTOTYPE;
- lip_prj :LIP_PROJECT;
+ - lip_dir :STRING_CONSTANT;
- source : STRING;
@@ -2835,7 +2836,7 @@ Section Private
warning_error (current_position,"Added ')' is needed.");
};
cod := ALIAS_ARRAY[LIP_CODE].copy cod;
- slot_code := LIP_SLOT_CODE.create pos in lip_prj section sec
+ slot_code := LIP_SLOT_CODE.create pos in lip_prj dir lip_dir section sec
name n argument data code cod;
(sec = ALIAS_STR.section_public).if {
(last_comment_slot = NULL).if {
@@ -3267,6 +3268,16 @@ Section Public
pos_line:=1;
pos_col :=0;
+ string_tmp.copy path_lip;
+ {
+ (!string_tmp.is_empty) &&
+ {string_tmp.last != '/'} &&
+ {string_tmp.last != '\\'}
+ }.while_do {
+ string_tmp.remove_last 1;
+ };
+ lip_dir := ALIAS_STR.get (string_tmp);
+
? { lip_prj != NULL };
// Parse.
--
Lisaac compiler
More information about the Lisaac-commits
mailing list