[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 6a773e6bd79dc16d8c9ce683fdab9874c52ba23a
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Wed Aug 5 14:36:46 2009 +0200
added LIP_PROJECTVALUE a proxy to LIP_PROJECT in LIP code and added Self keyword in LIP grammar
diff --git a/src/lip/lip_boolean.li b/src/lip/lip_boolean.li
index 5f02868..a68f445 100644
--- a/src/lip/lip_boolean.li
+++ b/src/lip/lip_boolean.li
@@ -71,7 +71,7 @@ Section Public
// Operation.
//
- - name:STRING_CONSTANT <- "BOOLEAN";
+ - name:STRING_CONSTANT <- ALIAS_STR.prototype_boolean;
- '!' :LIP_CONSTANT <- get (! value);
diff --git a/src/lip/lip_call.li b/src/lip/lip_call.li
index b0a7ed1..5b7551d 100644
--- a/src/lip/lip_call.li
+++ b/src/lip/lip_call.li
@@ -142,7 +142,26 @@ Section Public
//
// Call with a receiver
//
- (name = ALIAS_STR.slot_print).if {
+ (self.name = ALIAS_STR.prototype_project).if {
+ + prj_v:LIP_VALUEPROJECT;
+ + prj :LIP_PROJECT;
+ prj_v ?= self;
+ (prj_v != NULL).if { prj := prj_v.value; };
+ (prj != NULL).if {
+ 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);
+ };
+ (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 `";
@@ -225,12 +244,37 @@ Section Public
//
// Call with a receiver
//
- 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);
+ (self.name = ALIAS_STR.prototype_project).if {
+ + prj_v:LIP_VALUEPROJECT;
+ + prj :LIP_PROJECT;
+ prj_v ?= self;
+ (prj_v != NULL).if { prj := prj_v.value; };
+ (prj != NULL).if {
+ slot := project.get_data name;
+ ((slot = NULL) && {!stack.is_empty}).if {
+ slot := stack.last;
+ (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);
+ };
+ 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);
+ };
};
(val != NULL).if {
val.free;
diff --git a/src/lip/lip_integer.li b/src/lip/lip_integer.li
index 8f32c3f..1925606 100644
--- a/src/lip/lip_integer.li
+++ b/src/lip/lip_integer.li
@@ -69,7 +69,7 @@ Section Public
// Operation.
//
- - name:STRING_CONSTANT <- "INTEGER";
+ - name:STRING_CONSTANT <- ALIAS_STR.prototype_integer;
- '-' :LIP_CONSTANT <-
(
diff --git a/src/lip/lip_project.li b/src/lip/lip_project.li
index e0e1ab7..359c71b 100644
--- a/src/lip/lip_project.li
+++ b/src/lip/lip_project.li
@@ -43,6 +43,16 @@ Section Public
+ path :STRING_CONSTANT := ALIAS_STR.path_current;
+ file :STRING_CONSTANT;
+ - name :STRING_CONSTANT <-
+ (
+ string_tmp.copy path;
+ ((string_tmp.last != '/') || {string_tmp.last != '\\'}).if {
+ string_tmp.add_last '/';
+ };
+ string_tmp.append file;
+ ALIAS_STR.get string_tmp
+ );
+
- create :SELF <- clone.make;
- make :SELF <-
@@ -314,6 +324,26 @@ Section Public
result
);
+ - get_project n:STRING_CONSTANT :LIP_PROJECT <-
+ ( + d:LIP_SLOT_DATA;
+ + prj:LIP_VALUEPROJECT;
+ + result:LIP_PROJECT;
+
+ d := get_data n;
+ (d = NULL).if {
+ "Warning: Slot `".print;
+ n.print;
+ "' not found.\n".print;
+ } else {
+ prj ?= d.value;
+ (prj = NULL).if {
+ semantic_error (d.position,"PROJECT type is needed.");
+ };
+ result := prj.value;
+ };
+ result
+ );
+
- get_string n:STRING_CONSTANT :STRING_CONSTANT <-
( + d:LIP_SLOT_DATA;
+ str:LIP_STRING;
@@ -367,6 +397,36 @@ Section Public
};
);
+ - put_integer v:INTEGER to n:STRING_CONSTANT <-
+ ( + d:LIP_SLOT_DATA;
+
+ d := get_data n;
+ (d = NULL).if {
+ "Warning: Slot `".print;
+ n.print;
+ "' not found.\n".print;
+ } else {
+ (d.set_value (LIP_INTEGER.get v)).if_false {
+ semantic_error (d.position,"INTEGER type is needed.");
+ };
+ };
+ );
+
+ - put_project v:LIP_PROJECT to n:STRING_CONSTANT <-
+ ( + d:LIP_SLOT_DATA;
+
+ d := get_data n;
+ (d = NULL).if {
+ "Warning: Slot `".print;
+ n.print;
+ "' not found.\n".print;
+ } else {
+ (d.set_value (LIP_VALUEPROJECT.get v)).if_false {
+ semantic_error (d.position,"PROJECT type is needed.");
+ };
+ };
+ );
+
- 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;
diff --git a/src/lip/lip_string.li b/src/lip/lip_string.li
index 75ebadf..f6c578e 100644
--- a/src/lip/lip_string.li
+++ b/src/lip/lip_string.li
@@ -69,7 +69,7 @@ Section Public
// Operation.
//
- - name:STRING_CONSTANT <- "STRING";
+ - name:STRING_CONSTANT <- ALIAS_STR.prototype_string;
- copy:LIP_CONSTANT <-
(
diff --git a/src/lip/lip_boolean.li b/src/lip/lip_valueproject.li
similarity index 63%
copy from src/lip/lip_boolean.li
copy to src/lip/lip_valueproject.li
index 5f02868..3ce0198 100644
--- a/src/lip/lip_boolean.li
+++ b/src/lip/lip_valueproject.li
@@ -20,98 +20,90 @@
///////////////////////////////////////////////////////////////////////////////
Section Header
- + name := LIP_BOOLEAN;
+ + name := LIP_VALUEPROJECT;
- - copyright := "2003-2008 Sonntag Benoit";
+ - copyright := "2009 Mildred Ki'Lya";
- - author := "Sonntag Benoit (sonntag at icps.u-strasbg.fr)";
- - comment := "The main prototype";
+ - author := "Mildred Ki'Lya (http://ki.lya.online.fr)";
+ - comment := "Value representing a project in LIP code";
Section Inherit
- + parent_lip_constant:Expanded LIP_CONSTANT;
-
+ + parent_lip_constant: Expanded LIP_CONSTANT;
+
Section Private
-
- - true:LIP_BOOLEAN :=
- ( + result:LIP_BOOLEAN;
- result := clone;
- result.set_value TRUE;
- result
- );
-
- - false:LIP_BOOLEAN := LIP_BOOLEAN;
-
- - set_value i:BOOLEAN <-
+
+ - storage:FAST_ARRAY[LIP_VALUEPROJECT] := FAST_ARRAY[LIP_VALUEPROJECT].create_with_capacity 10;
+
+ - set_value p:LIP_PROJECT <-
(
- value := i;
+ value := p;
);
-
+
Section Public
- + value:BOOLEAN;
-
+ + value :LIP_PROJECT;
+
//
// Creation.
//
-
- - get b:BOOLEAN :LIP_BOOLEAN <-
- ( + result:LIP_BOOLEAN;
- b.if {
- result := true;
+
+ - get p:LIP_PROJECT :LIP_VALUEPROJECT <-
+ ( + result:LIP_VALUEPROJECT;
+ (storage.is_empty).if {
+ result := clone;
} else {
- result := false;
+ result := storage.last;
+ storage.remove_last;
};
+ result.set_value p;
result
);
-
- - free; // Nothing.
-
+
+ - free <-
+ (
+ storage.add_last Self;
+ );
+
//
// Operation.
//
-
- - name:STRING_CONSTANT <- "BOOLEAN";
-
- - '!' :LIP_CONSTANT <- get (! value);
-
- - copy:LIP_CONSTANT <- Self;
+
+ - name:STRING_CONSTANT <- ALIAS_STR.prototype_project;
+
+ - copy:LIP_CONSTANT <-
+ (
+ get value
+ );
- print <-
(
- value.print;
+ value.name.print;
);
- append_in str:STRING <-
(
- value.if {
- str.append "TRUE";
- } else {
- str.append "FALSE";
- };
+ str.append (value.name);
);
Section LIP_CONSTANT
-
- - my_copy other:SELF :LIP_CONSTANT <- other;
-
- - '|#' other:SELF :LIP_CONSTANT <-
- (
- get (value | other.value)
- );
-
- - '&#' other:SELF :LIP_CONSTANT <-
- (
- get (value & other.value)
+
+ - my_copy other:SELF :LIP_CONSTANT <-
+ (
+ value := other.value;
+ Self
);
-
+
- '=#' other:SELF :LIP_CONSTANT <-
(
- get (value = other.value)
+ other.free;
+ free;
+ LIP_BOOLEAN.get (value = other.value)
);
-
+
- '!=#' other:SELF :LIP_CONSTANT <-
(
- get (value != other.value)
+ other.free;
+ free;
+ LIP_BOOLEAN.get (value != other.value)
);
-
\ No newline at end of file
diff --git a/src/parser.li b/src/parser.li
index 539d163..b2c0061 100644
--- a/src/parser.li
+++ b/src/parser.li
@@ -2860,6 +2860,8 @@ Section Private
result := LIP_STRING.get (ALIAS_STR.get "");
}.elseif {last_string = ALIAS_STR.prototype_boolean} then {
result := LIP_BOOLEAN.get FALSE;
+ }.elseif {last_string = ALIAS_STR.prototype_project} then {
+ result := LIP_VALUEPROJECT.get NULL;
} else {
syntax_error (current_position,"Incorrect type.");
};
@@ -3087,13 +3089,16 @@ Section Private
);
- readlip_expr_constant:LIP_CONSTANT <-
- //// EXPR_CONSTANT-> integer
+ //// EXPR_CONSTANT-> "Self"
+ //// | integer
//// | string
//// | TRUE
//// | FALSE
( + result:LIP_CONSTANT;
- (read_integer).if {
+ (read_this_keyword (ALIAS_STR.variable_self)).if {
+ result := LIP_VALUEPROJECT.get lip_prj;
+ }.elseif {read_integer} then {
result := LIP_INTEGER.get last_integer;
}.elseif {read_string} then {
result := LIP_STRING.get last_string;
diff --git a/src/tools/alias_str.li b/src/tools/alias_str.li
index 23b093a..390e7d4 100644
--- a/src/tools/alias_str.li
+++ b/src/tools/alias_str.li
@@ -94,6 +94,7 @@ Section Public
- prototype_generic :STRING_CONSTANT := "___GENERIC";
- prototype_type_id :STRING_CONSTANT := "___TYPE_ID";
- prototype_self :STRING_CONSTANT := "SELF";
+ - prototype_project :STRING_CONSTANT := "PROJECT";
- prototype_uinteger_64 :STRING_CONSTANT := "UINTEGER_64";
- prototype_uinteger_32 :STRING_CONSTANT := "UINTEGER_32";
@@ -381,6 +382,7 @@ Section Public
list.add prototype_generic;
list.add prototype_type_id;
list.add prototype_self;
+ list.add prototype_project;
// Integers :
list.add prototype_uinteger_64;
--
Lisaac compiler
More information about the Lisaac-commits
mailing list