[SCM] Lisaac compiler branch, stable, updated. lisaac-0.12-485-g90ed90f
Mildred Ki'Lya
silkensedai at online.fr
Mon Sep 7 18:06:40 UTC 2009
The following commit has been merged in the stable branch:
commit 90ed90f2694ea261fcf6e3bcc7f06368ceda9e01
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Mon Sep 7 20:05:21 2009 +0200
Use the same code in lisaac and shorter for LISAAC_DIRECTORY and help message
diff --git a/src/lisaac.li b/src/lisaac.li
index 996aee2..01eb13a 100644
--- a/src/lisaac.li
+++ b/src/lisaac.li
@@ -27,8 +27,6 @@ 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)
@@ -44,52 +42,17 @@ Section Public
- show_help <-
(
- command_line_header.print;
+ COMMON.command_line_header "Compiler".print;
begin_usage.print;
LIP_CODE.print_usage;
- end_usage.print;
+ COMMON.command_line_footer.print;
);
- show_version <-
- ( + b:BOOLEAN;
- + i:INTEGER;
- command_line_header.print;
- "Built on: ".print; compile_date.print; " ".print;
- compile_time.print; "\n".print;
- `
- #if defined(_LISAAC_DEBUG_LEVEL) && defined(_LISAAC_DEBUG_CODE)
- `;
- b := `_LISAAC_DEBUG_CODE`:BOOLEAN{TRUE,FALSE};
- i := `_LISAAC_DEBUG_LEVEL`:INTEGER;
- "Debug Level: ".print; i.print;
- b.if {
- " (with source code)".println;
- } else {
- " (without source code)".println;
- };
- `
- #endif
- #ifdef _LISAAC_INLINE_LEVEL
- `;
- i := `_LISAAC_INLINE_LEVEL`:INTEGER;
- "Inline Level: ".print; i.println;
- `
- #endif
- #ifdef _LISAAC_OPTIM
- `;
- i := `_LISAAC_OPTIM`:INTEGER;
- "Optimization Level: ".print; i.println;
- `
- #endif
- `;
- '\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;
- };
+ (
+ COMMON.command_line_header "Compiler".print;
+ COMMON.print_info;
+ COMMON.command_line_footer.print;
);
Section Private
@@ -99,75 +62,20 @@ Section Private
- output_basename:STRING_CONSTANT;
- input_name:STRING_CONSTANT;
-
- - 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
- );
//
// Command.
//
- - command_line_header :STRING_CONSTANT :=
- "----------------------------------------------------------------\n\
- \-- Lisaac IS An Advanced Compiler V.0.14 --\n\
- \-- LORIA - LSIIT - ULP - CNRS - FRANCE --\n\
- \-- Benoit SONNTAG - sonntag at icps.u-strasbg.fr --\n\
- \-- http://www.IsaacOS.com --\n\
- \----------------------------------------------------------------\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\
- \\t mail to : sonntag at icps.u-strasbg.fr \n";
- display_usage <-
(
@@ -415,7 +323,7 @@ Section Private
// Load default make.lip in LISAAC_DIRECTORY
//
(is_good).if_false {
- string_tmp.copy path_lisaac;
+ string_tmp.copy (COMMON.path_lisaac);
string_tmp.append "make.lip";
path_lip := ALIAS_STR.get string_tmp;
(is_good := PARSER.read_lip path_lip).if_false {
@@ -434,7 +342,7 @@ Section Private
path_lip := LIP_CODE.list_parent.first;
LIP_CODE.list_parent.remove_first;
(path_lip.is_empty).if {
- string_tmp.copy path_lisaac;
+ string_tmp.copy (COMMON.path_lisaac);
string_tmp.append "make.lip";
path_lip := ALIAS_STR.get string_tmp;
};
@@ -448,7 +356,7 @@ Section Private
};
};
// Auto-load 'lisaac' variable.
- LIP_CODE.put_string path_lisaac to (ALIAS_STR.variable_lisaac);
+ LIP_CODE.put_string (COMMON.path_lisaac) to (ALIAS_STR.variable_lisaac);
);
- put_trace_code buf:STRING <-
@@ -712,33 +620,6 @@ Section Private
STD_ERROR.put_string ")\n";
};
);
-
- - compile_time :TIME <-
- ( + i:INTEGER;
- `
- #ifdef _LISAAC_COMPILE_TIME
- `;
- i := `_LISAAC_COMPILE_TIME`:INTEGER;
- `
- #endif
- `;
- TIME.create_csecond i
- );
-
- - compile_date :DATE <-
- ( + i,j,k,l:INTEGER;
- `
- #ifdef _LISAAC_COMPILE_DATE
- `;
- i := `_LISAAC_COMPILE_DATE_YEAR`:INTEGER;
- j := `_LISAAC_COMPILE_DATE_MONTH`:INTEGER;
- k := `_LISAAC_COMPILE_DATE_DAY`:INTEGER;
- l := `_LISAAC_COMPILE_DATE_WDAY`:INTEGER;
- `
- #endif
- `;
- DATE.create (i, j, k, l)
- );
Section Public
diff --git a/src/shorter.li b/src/shorter.li
index 2b29812..662c79d 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;
@@ -70,13 +68,7 @@ Section Private
//
- usage:STRING_CONSTANT :=
- "----------------------------------------------------------------\n\
- \-- Lisaac source Shorter --\n\
- \-- LORIA - LSIIT - ULP - CNRS - FRANCE --\n\
- \-- Benoit SONNTAG - sonntag at icps.u-strasbg.fr --\n\
- \-- http://www.IsaacOS.com --\n\
- \----------------------------------------------------------------\n\
- \Usage: \n\
+ "Usage: \n\
\ shorter <input_file[.li]> [Options] \n\
\ \n\
\Options: \n\
@@ -88,6 +80,8 @@ Section Private
\ -f <format_file> : formatting description file \n\
\ (see `/lisaac/shorter/') \n\
\ -d : Lisaac doc style (no -c, -r) \n\
+ \ -h : Help \n\
+ \ -version : Show version information \n\
\ \n\
\Examples: \n\
\ * Output format file: \n\
@@ -97,15 +91,21 @@ Section Private
\ shorter -r -f html ~/lisaac/lib \n\
\ \n\
\ * Build html documentation style JavaDoc: \n\
- \ shorter -d -f belinda ~/lisaac/lib \n\
- \ \n\
- \Bug report: \n\
- \ post in : https://gna.org/bugs/?group=isaac \n\
- \ mail to : sonntag at icps.u-strasbg.fr \n";
+ \ shorter -d -f belinda ~/lisaac/lib \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;
);
@@ -117,7 +117,6 @@ Section Private
( + cmd:STRING;
+ j:INTEGER;
+ var_lisaac:STRING_CONSTANT;
- + path:NATIVE_ARRAY(CHARACTER);
// Read argument.
is_shorter := TRUE;
@@ -148,9 +147,11 @@ Section Private
}.elseif {cmd.item 2 = 'r'} then {
is_short_recursive := TRUE;
}.elseif {cmd.item 2 = 'd'} then {
- is_shorter := FALSE;
+ is_shorter := FALSE;
is_shorter2 := TRUE;
is_short_recursive := TRUE;
+ }.elseif {cmd == "-version"} then {
+ display_version;
} else {
display_usage;
};
@@ -172,19 +173,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 {
diff --git a/src/tools/common.li b/src/tools/common.li
new file mode 100644
index 0000000..ac13146
--- /dev/null
+++ b/src/tools/common.li
@@ -0,0 +1,186 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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.14";
+
+ - 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 - ULP - CNRS - FRANCE --\n\
+ \-- Benoit SONNTAG - sonntag at icps.u-strasbg.fr --\n\
+ \-- http://www.IsaacOS.com --\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\
+ \\t post in : https://alioth.debian.org/projects/lisaac/ \n\
+ \\t mail to : sonntag at icps.u-strasbg.fr \n";
+
+ - print_info <-
+ ( + b:BOOLEAN;
+ + i:INTEGER;
+ "Built on: ".print; compile_date.print; " ".print;
+ compile_time.print; "\n".print;
+ `
+ #if defined(_LISAAC_DEBUG_LEVEL) && defined(_LISAAC_DEBUG_CODE)
+ `;
+ b := `_LISAAC_DEBUG_CODE`:BOOLEAN{TRUE,FALSE};
+ i := `_LISAAC_DEBUG_LEVEL`:INTEGER;
+ "Debug Level: ".print; i.print;
+ b.if {
+ " (with source code)".println;
+ } else {
+ " (without source code)".println;
+ };
+ `
+ #endif
+ #ifdef _LISAAC_INLINE_LEVEL
+ `;
+ i := `_LISAAC_INLINE_LEVEL`:INTEGER;
+ "Inline Level: ".print; i.println;
+ `
+ #endif
+ #ifdef _LISAAC_OPTIM
+ `;
+ i := `_LISAAC_OPTIM`:INTEGER;
+ "Optimization Level: ".print; i.println;
+ `
+ #endif
+ `;
+ '\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
+ );
+
+ - compile_time :TIME <-
+ ( + i:INTEGER;
+ `
+ #ifdef _LISAAC_COMPILE_TIME
+ `;
+ i := `_LISAAC_COMPILE_TIME`:INTEGER;
+ `
+ #endif
+ `;
+ TIME.create_csecond i
+ );
+
+ - compile_date :DATE <-
+ ( + i,j,k,l:INTEGER;
+ `
+ #ifdef _LISAAC_COMPILE_DATE
+ `;
+ i := `_LISAAC_COMPILE_DATE_YEAR`:INTEGER;
+ j := `_LISAAC_COMPILE_DATE_MONTH`:INTEGER;
+ k := `_LISAAC_COMPILE_DATE_DAY`:INTEGER;
+ l := `_LISAAC_COMPILE_DATE_WDAY`:INTEGER;
+ `
+ #endif
+ `;
+ DATE.create (i, j, k, l)
+ );
--
Lisaac compiler
More information about the Lisaac-commits
mailing list