diff options
author | martinw | 2001-06-29 11:58:47 +0000 |
---|---|---|
committer | martinw | 2001-06-29 11:58:47 +0000 |
commit | 46c70fd26e2a048f40a837aba513306a63df7356 (patch) | |
tree | f8dce0916bdd046aacd33f4731c0ee8bf23648fb /portToNewSyntax | |
parent | new application that removes all preprocessor directives (that eventually (diff) |
blabla
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@511 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'portToNewSyntax')
-rw-r--r-- | portToNewSyntax/1.3-and-2.0-differences.txt | 16 | ||||
-rw-r--r-- | portToNewSyntax/help.txt | 59 | ||||
-rw-r--r-- | portToNewSyntax/portToNewSyntax.icl | 14 |
3 files changed, 35 insertions, 54 deletions
diff --git a/portToNewSyntax/1.3-and-2.0-differences.txt b/portToNewSyntax/1.3-and-2.0-differences.txt index 3608b28..ceadbd5 100644 --- a/portToNewSyntax/1.3-and-2.0-differences.txt +++ b/portToNewSyntax/1.3-and-2.0-differences.txt @@ -219,6 +219,16 @@ Differences in the standard environment (StdEnv) uselect_u, uselectf_u, uselectn_u, uselectl_u, updatei_u, size_u, usize_u update_u, createArray_u, createArrayc_u, replace_u + Example: Assume a function "f" that does something with arrays that had + the following type in Clean 1.3: + + f :: (a b) -> b | select_u b & Array .a + + "(a b)" stands for "an array (can be strict, lazy or unboxed) with element b". + In Clean 2.x this simply becomes: + + f :: (a b) -> b | Array a b + Miscellaneous Differences ------------------------- @@ -295,11 +305,11 @@ For the 1.3 this would be the same as Note that the "//1.3", "//3.1", "/*2.0" and "0.2*/" brackets have to be the first characters of the line (no preceeding whitespace characters are -allowed). Otherwise they will be ignored. Furtheron such sections shouldn't -be nested nor overlapping. +allowed). Otherwise they will be ignored. Furtheron such sections should +neither be nested nor overlapping. Finally we have written an application "rmPreprop" that can be used to remove all these preprocessor directives when you don't want them anymore. -We will remove the preprocessor feature in the future. Regard it as +We will remove the preprocessor in the future. Regard it as a temporary feature. diff --git a/portToNewSyntax/help.txt b/portToNewSyntax/help.txt index 17155f5..aa70654 100644 --- a/portToNewSyntax/help.txt +++ b/portToNewSyntax/help.txt @@ -16,15 +16,8 @@ Why to use coclPort syntax there are Clean 1.3.x programs that cannot be compiled with the new Clean 2.0 compiler. Fortunately these changes in syntax are rather small. The most important syntax modification is concerned with explicit - import statements. These are statements like "from m import x". With the - new syntax it's possible to write e.g. - - from m import T, :: T (C1), :: T2 (..), class ==, instance == Int - - Such a statement causes the following symbols to be imported: the function T, - the algebraic type T with it's constructor C1, the algebraic type T2 with all - it's constructors, the class == and it's instance Int. See the Clean 2.0 - language report for further information. + import statements (see the documentation about differences between Clean + 1.3 and Clean 2.0 programs). Purpose of coclPort is to help you to port Clean 1.3.x programs to this new syntax. @@ -53,14 +46,11 @@ What coclPort does The preprocessor ---------------- - We think that for a while it should be made possible to let every source code - file be compiled with both the 1.3 and the 2.0 compiler. How can this be - achieved when the 2.0 compiler is not fully downward compatible? With a - preprocessor of course. The simple preprocessor that we have built into - coclPort and into the 2.0 compiler as well allows to distinguish parts - of code that are either ignored by - the 1.3 compiler or by the 2.0 compiler. To illustrate this we show what - coclPort will produce for a file that contains the following statement: + We have built a primitive preprocessor into the Clean 2.0 compiler + that allows conditional compilation. This enables you to write sources + that can be compiled with Clean 2.0 and Clean 1.3 regardless of + the incompatibility of these compiler versions. coclPort will generate + preprocessor directives, too, e.g consider the following statement: from module_name import == @@ -73,25 +63,8 @@ The preprocessor from module_name import class ==, instance == Int, instance == Real 0.2*/ - For the 2.0 compiler this would be the same as - - from module_name import class ==, instance == Int, instance == Real - - because the preprocessor will take care that everything between "//1.3" and - "//3.1" will be ignored and that everything between "/*2.0" and "0.2*/" - will _not_ be treated as a comment. - For the 1.3 this would be the same as - - from module_name import == - - You can use this feature to keep your files both compilable with 1.3 and - with 2.0. If you don't want your sources cluttered with old 1.3 stuff then - you can use the "rmPreprop" application to extract the pure 1.3 or 2.0 - contents. - Note that the "//1.3", "//3.1", "/*2.0" and "0.2*/" brackets have to be - the first characters of the line (no preceeding whitespace characters are - allowed). Otherwise they will be ignored. Furtheron such sections shouldn't - be nested or overlapping. + The preprocessor is explained in the documentation about differences + between Clean 1.3 and Clean 2.0. How to use this program ----------------------- @@ -101,11 +74,10 @@ How to use this program Clean"). In the CleanIDE select an environment that uses the Clean 2.0 compiler. Now select "Environment/Edit Current" and select the "tools" button. The field at "compiler:" determines where the CleanIDE finds the - Clean commpiler (cocl.exe). You can use this field to ensure that this entry indeed - refers to the Clean 2.0 compiler and not e.g. to a Clean 1.3 compiler: - If it is the Clean 2.0 compiler then there must be a file named "backend.dll" - in the folder that is shown there. Put the file "coclPort.exe" into the same - folder and change the entry in the field at "compiler:" from "cocl.exe" + Clean commpiler (cocl.exe). You should be sure that this entry indeed + refers to the Clean 2.0 compiler and not e.g. to a Clean 1.3 compiler! + Put the file "coclPort.exe" into the same folder as "cocl.exe" + and change the entry in the field at "compiler:" from "cocl.exe" into "coclPort.exe". Now the CleanIDE will use coclPort as the compiler. But coclPort needs another standard environment than cocl. You have to replace @@ -125,7 +97,7 @@ Insufficiencies /* comment */ from module_name import f from /* comment */ module_name import f from - module_name import f + module_name import f An explicit import statement that is outcommented with "//" will work fine, since it will be ignored anyway: // from module_name import f @@ -138,5 +110,6 @@ Insufficiencies from that moment on until forever */ However we think that when something goes wrong with this program it should be easy to adjust the ported modules manually after it has been tried to - compile them. + compile them. The ported import statements will appear at least _somewhere_ + in the generated sources.
\ No newline at end of file diff --git a/portToNewSyntax/portToNewSyntax.icl b/portToNewSyntax/portToNewSyntax.icl index ebaf118..9b948d0 100644 --- a/portToNewSyntax/portToNewSyntax.icl +++ b/portToNewSyntax/portToNewSyntax.icl @@ -109,14 +109,12 @@ write_expl_import all_expl_imp_decls (declarations, _) (dcl_modules, file) = (dcl_modules, fwriteNewSyntax declaration_strings file) // only for portToNewSyntax -decl_to_opt_string all_expl_imp_decls decl=:{dcl_ident, dcl_index, dcl_kind=STE_Imported ste_kind def_mod_index} +decl_to_opt_string all_expl_imp_decls (Declaration {decl_ident, decl_index, decl_kind=STE_Imported ste_kind def_mod_index}) dcl_modules - = imported_decl_to_opt_string all_expl_imp_decls dcl_ident dcl_index ste_kind def_mod_index + = imported_decl_to_opt_string all_expl_imp_decls decl_ident decl_index ste_kind def_mod_index dcl_modules -decl_to_opt_string _ {dcl_ident, dcl_kind=STE_FunctionOrMacro _} dcl_modules - = (Yes dcl_ident.id_name, dcl_modules) -decl_to_opt_string all_expl_imp_decls decl dcl_modules - = abort ("decl_to_opt_string failed"--->decl) +decl_to_opt_string _ (Declaration{decl_ident, decl_kind=STE_FunctionOrMacro _}) dcl_modules + = (Yes decl_ident.id_name, dcl_modules) // only for portToNewSyntax imported_decl_to_opt_string all_expl_imp_decls dcl_ident dcl_index STE_Constructor def_mod_index @@ -201,8 +199,8 @@ constructor_bracket def_mod_index all_expl_imp_decls constructors // only for portToNewSyntax is_expl_imported_constructor def_mod_index ds_ident [] = False -is_expl_imported_constructor def_mod_index ds_ident [{dcl_ident, dcl_kind=STE_Imported STE_Constructor def_mod_index2}:_] - | dcl_ident==ds_ident && def_mod_index==def_mod_index2 +is_expl_imported_constructor def_mod_index ds_ident [Declaration {decl_ident, decl_kind=STE_Imported STE_Constructor def_mod_index2}:_] + | decl_ident==ds_ident && def_mod_index==def_mod_index2 = True // GOTO next alternative is_expl_imported_constructor def_mod_index ds_ident [h:t] |