From 680cb9f35c0c5fad905aed02601dc6b2ed7afee2 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Fri, 24 Apr 2020 00:37:21 +0200 Subject: [PATCH 01/18] Fixes #860, fixes aspect 2 of #861 --- src/Structorizer.java | 2 ++ src/lu/fisch/structorizer/archivar/Archivar.java | 6 ++++++ src/lu/fisch/structorizer/elements/Element.java | 2 +- src/lu/fisch/structorizer/gui/changelog.txt | 4 +++- src/lu/fisch/structorizer/parsers/D7Parser.java | 14 ++++++++++++-- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Structorizer.java b/src/Structorizer.java index 3f8b6eee..bd9f734c 100644 --- a/src/Structorizer.java +++ b/src/Structorizer.java @@ -754,7 +754,9 @@ private static boolean addExportPool(HashMap> pools, A index = archivar.unzipArrangementArchive(f, null); } else { + System.out.println("Making new index..."); index = archivar.makeNewIndexFor(f); + System.out.println(index.toString()); } ArchivePool pool = new ArchivePool(index); // Now collect the starting roots within the pool diff --git a/src/lu/fisch/structorizer/archivar/Archivar.java b/src/lu/fisch/structorizer/archivar/Archivar.java index be3c5424..faa4b168 100644 --- a/src/lu/fisch/structorizer/archivar/Archivar.java +++ b/src/lu/fisch/structorizer/archivar/Archivar.java @@ -36,6 +36,7 @@ * Kay Gürtzig 2019-03-26 Enh. #697: Bugfixes in zipArrangement(), saveArrangement() * Kay Gürtzig 2019-07-31 Bugfix #731 (also comprising #526): new static methods renameTo, copyFile * Kay Gürtzig 2019-10-14 Bugfix #763: Missing references files now add to the problem list on loading + * Kay Gürtzig 2020-04-23 Bugfix #860: ArchiveIndexEntry did not set path field with absolute nsd file paths * ****************************************************************************************************** * @@ -143,6 +144,7 @@ public ArchiveIndexEntry(Point _point, String _path, String _virtualPath, String public ArchiveIndexEntry(String arrangementLine, File _fromArchive, File _extractDir) { super(null, null); + System.out.println("ArchiveIndexEntry(" + arrangementLine + ", ...)"); StringList fields = StringList.explode(arrangementLine, ","); // FIXME what if a path or the name contains a comma? if (fields.count() >= 3) { @@ -153,6 +155,9 @@ public ArchiveIndexEntry(String arrangementLine, File _fromArchive, File _extrac if (nsdFileName.endsWith("\"")) nsdFileName = nsdFileName.substring(0, nsdFileName.length() - 1); File nsdFile = new File(nsdFileName); + // START KGU#858 2020-04-23: Bugfix #860 We forgot to set the path in case it IS absolute + this.path = nsdFileName; + // END KGU#858 2020-04-23 if (!nsdFile.isAbsolute()) { if (_extractDir != null) { this.path = _extractDir.getAbsolutePath() + File.separator + nsdFileName; @@ -161,6 +166,7 @@ public ArchiveIndexEntry(String arrangementLine, File _fromArchive, File _extrac this.virtPath = _fromArchive.getAbsolutePath() + File.separator + nsdFileName; } } + System.out.print("Path: "); System.out.println(this.path); } if (fields.count() >= 6) { this.name = fields.get(3).trim(); diff --git a/src/lu/fisch/structorizer/elements/Element.java b/src/lu/fisch/structorizer/elements/Element.java index 46010edf..a4ea2897 100644 --- a/src/lu/fisch/structorizer/elements/Element.java +++ b/src/lu/fisch/structorizer/elements/Element.java @@ -270,7 +270,7 @@ public String toString() public static final String E_HELP_FILE = "structorizer_user_guide.pdf"; public static final String E_DOWNLOAD_PAGE = "https://www.fisch.lu/Php/download.php"; // END KGU#791 2020-01-20 - public static final String E_VERSION = "3.30-08"; + public static final String E_VERSION = "3.30-09"; public static final String E_THANKS = "Developed and maintained by\n"+ " - Robert Fisch \n"+ diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 1ade311f..ef2d678c 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -13,7 +13,7 @@ Known issues: - Shell export does not cope with nested array/record initializers and component access, neither with clean parameter handling for usual arrays and associative arrays. -Current development version: 3.30-08 (2020-04-23) +Current development version: 3.30-09 (2020-04-23) - 01: Bugfix #759: Another source of stale Mainforms dried up. <2> - 01: Bugfix #761: Code preview defect flooded the log stream. <2> - 01: Precautions against empty error messages on startup <2> @@ -106,6 +106,8 @@ Current development version: 3.30-08 (2020-04-23) - 08: Enh. #855 New configurable default array/string sizes for code export <2> - 08: Bugfix #856: The dump of preferences subsets did not behave correctly <2> - 08: Bugfix #858: Functions did not actually work in FOR-IN loop headers <2> +- 09: Bugfix #860: Batch export for .arr files containing abs. paths failed <2> +- 09: Bugfix #861/2: On Pascal input, routine comments were duplicated <2> Version: 3.30 (2019-10-06) - 01: Issue #657: Spanish message in German locale replaced <2> diff --git a/src/lu/fisch/structorizer/parsers/D7Parser.java b/src/lu/fisch/structorizer/parsers/D7Parser.java index f8a392b4..9bcf713e 100644 --- a/src/lu/fisch/structorizer/parsers/D7Parser.java +++ b/src/lu/fisch/structorizer/parsers/D7Parser.java @@ -69,6 +69,8 @@ * Kay Gürtzig 2020-03-08 Bugfix #833: Parameter parentheses ensured, superfluous Includable suppressed * Kay Gürtzig 2020-03-09 Bugfix #835: Structure preference kywords must not be glued to expressions * Kay Gürtzig 2020-04-12 Bugfix #847 ensured that ids like 'false', 'true', and built-in functions be lowercase + * Kay Gürtzig 2020-04-24 Bugfix #861/2 duplicate procedure comments prevented (was revealed by + * by a modification of the block comment in PasGenerator. * ****************************************************************************************************** * @@ -1458,9 +1460,17 @@ else if ( // END KGU#194 2016-05-08 // START KGU#407 2017-06-20: Enh. #420 - comments already here String comment = this.retrieveComment(_reduction); - if (comment != null && !root.getComment().contains(comment)) { - root.getComment().add(StringList.explode(comment, "\n")); + // START KGU#860 2020-04-24: Bugfix #861/2 Precaution didn't work if newlines are contained + //if (comment != null && !root.getComment().contains(comment)) { + // root.getComment().add(StringList.explode(comment, "\n")); + //} + if (comment != null && !comment.trim().isEmpty()) { + StringList commentLines = StringList.explode(comment, "\n"); + if (root.getComment().indexOf(commentLines, 0, true) < 0) { + root.getComment().add(commentLines); + } } + // END KGU#960 2020-06-20 // END KGU#407 2017-06-22 } else if ( From 134d5042d8f3ab38e20675413e0d4e39575ff380 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Fri, 24 Apr 2020 00:41:01 +0200 Subject: [PATCH 02/18] Version numbers in buildapp.xml modified. --- buildapp.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildapp.xml b/buildapp.xml index c64fd323..614a307c 100644 --- a/buildapp.xml +++ b/buildapp.xml @@ -15,8 +15,8 @@ name="Structorizer" displayname="Structorizer" identifier="lu.fisch.Structorizer" - shortversion="3.30-08" - version="3.30-08" + shortversion="3.30-09" + version="3.30-09" icon="icons/Structorizer.icns" mainclassname="Structorizer" copyright="Bob Fisch" From 291486d0980bc18520c372d7e07c4f39f0a1d7b2 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Fri, 24 Apr 2020 01:33:58 +0200 Subject: [PATCH 03/18] Debug output instructions removed. --- src/Structorizer.java | 2 -- src/lu/fisch/structorizer/archivar/Archivar.java | 1 - 2 files changed, 3 deletions(-) diff --git a/src/Structorizer.java b/src/Structorizer.java index bd9f734c..3f8b6eee 100644 --- a/src/Structorizer.java +++ b/src/Structorizer.java @@ -754,9 +754,7 @@ private static boolean addExportPool(HashMap> pools, A index = archivar.unzipArrangementArchive(f, null); } else { - System.out.println("Making new index..."); index = archivar.makeNewIndexFor(f); - System.out.println(index.toString()); } ArchivePool pool = new ArchivePool(index); // Now collect the starting roots within the pool diff --git a/src/lu/fisch/structorizer/archivar/Archivar.java b/src/lu/fisch/structorizer/archivar/Archivar.java index faa4b168..5048dcb3 100644 --- a/src/lu/fisch/structorizer/archivar/Archivar.java +++ b/src/lu/fisch/structorizer/archivar/Archivar.java @@ -166,7 +166,6 @@ public ArchiveIndexEntry(String arrangementLine, File _fromArchive, File _extrac this.virtPath = _fromArchive.getAbsolutePath() + File.separator + nsdFileName; } } - System.out.print("Path: "); System.out.println(this.path); } if (fields.count() >= 6) { this.name = fields.get(3).trim(); From 1095caaf4bb9e39c4397e4bd7c9d9dd357c598af Mon Sep 17 00:00:00 2001 From: codemanyak Date: Fri, 24 Apr 2020 17:05:42 +0200 Subject: [PATCH 04/18] Fixes #861, fixes #862 --- .../fisch/structorizer/archivar/Archivar.java | 15 ++++++++--- .../structorizer/generators/Generator.java | 6 ++++- .../generators/OberonGenerator.java | 21 ++++++++++----- .../structorizer/generators/PasGenerator.java | 12 +++++---- src/lu/fisch/structorizer/gui/changelog.txt | 8 ++++-- .../structorizer/parsers/CodeParser.java | 26 ++++++++++++++++++- 6 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/lu/fisch/structorizer/archivar/Archivar.java b/src/lu/fisch/structorizer/archivar/Archivar.java index 5048dcb3..fc72f418 100644 --- a/src/lu/fisch/structorizer/archivar/Archivar.java +++ b/src/lu/fisch/structorizer/archivar/Archivar.java @@ -37,6 +37,7 @@ * Kay Gürtzig 2019-07-31 Bugfix #731 (also comprising #526): new static methods renameTo, copyFile * Kay Gürtzig 2019-10-14 Bugfix #763: Missing references files now add to the problem list on loading * Kay Gürtzig 2020-04-23 Bugfix #860: ArchiveIndexEntry did not set path field with absolute nsd file paths + * Kay Gürtzig 2020-04-24 Bugfix #862/3: Ensure correct update of ArchiveIndexEntry on attaching the Root * ****************************************************************************************************** * @@ -144,7 +145,6 @@ public ArchiveIndexEntry(Point _point, String _path, String _virtualPath, String public ArchiveIndexEntry(String arrangementLine, File _fromArchive, File _extractDir) { super(null, null); - System.out.println("ArchiveIndexEntry(" + arrangementLine + ", ...)"); StringList fields = StringList.explode(arrangementLine, ","); // FIXME what if a path or the name contains a comma? if (fields.count() >= 3) { @@ -211,14 +211,21 @@ public Root getRoot(Archivar archivar) throws Exception } /** - * Sets the given {@link Root} object if it hadn't been set already and the updates - * all related information + * Sets the given {@link Root} object and then updates all related information * @param root - the diagram to be set * @return true if the {@code root} was accepted */ protected boolean setRoot(Root root) { - if (root == null || this.root != null) { + // START KGU#861 2020-04-24: Bugfix #862/3 - was nonsense, see comment below + //if (root == null || this.root != null) { + /* This method is either called in getRoot() if this.root IS null or in the + * constructor after this.root hs already been set and hardly anything else. + * So we MUST update all information here (except perhaps another Root had + * been associated. But the result hasn't been asked for nowhere by now + */ + if (root == null || this.root != null && this.root != root) { + // END KGU#861 2020-04-24 return false; } this.root = root; diff --git a/src/lu/fisch/structorizer/generators/Generator.java b/src/lu/fisch/structorizer/generators/Generator.java index 4614aeff..feb01f87 100644 --- a/src/lu/fisch/structorizer/generators/Generator.java +++ b/src/lu/fisch/structorizer/generators/Generator.java @@ -108,6 +108,7 @@ * Kay Gürtzig 2020-03-30 Issue #828: Averted topological sorting in library modules mended * Kay Gürtzig 2020-04-01 Enh. #440, #828: Support for Group export to PapGenerator * Kay Gürtzig 2020-04-22 Enh. #855: New options for default array / string size + * Kay Gürtzig 2020-04-24 Bugfix #862/2: Prevent duplicate export of an entry point root * ****************************************************************************************************** * @@ -5099,7 +5100,10 @@ else if (!_roots.contains(sub)) { // Is this check redundant? this.topLevel = false; } } - else { + // START KGU#861 2020-04-24: Bugfix #862/2: We must not export both as subroutine and library routine + //else { + else if (!_dependencyTree.containsKey(root)) { + // END KGU#861 2020-04-24 insertLibraryRoutine(root, this.subroutineIndent, _entryPoints == null || _entryPoints.contains(root)); } } diff --git a/src/lu/fisch/structorizer/generators/OberonGenerator.java b/src/lu/fisch/structorizer/generators/OberonGenerator.java index 78cffa85..fad81640 100644 --- a/src/lu/fisch/structorizer/generators/OberonGenerator.java +++ b/src/lu/fisch/structorizer/generators/OberonGenerator.java @@ -89,6 +89,7 @@ * bugfix #839, fix for issue #780 revised * Kay Gürtzig 2020-03-26 Bugfix KGU#833: The function name got declared as variable without need. * Kay Gürtzig 2020-04-22 Enh. #855: Configurable default array / string size considered + * Kay Gürtzig 2020-04-24 Issue #861/1: Comment placement now according to the GNU Pascal Coding Standards * ****************************************************************************************************** * @@ -288,7 +289,7 @@ protected void appendComment(StringList _sl, String _indent) this.appendComment(_sl.get(0), _indent); } else { - this.appendBlockComment(_sl, _indent, this.commentSymbolLeft(), " * ", " " + this.commentSymbolRight()); + this.appendBlockComment(_sl, _indent, this.commentSymbolLeft(), " ", " " + this.commentSymbolRight()); } } } @@ -1562,6 +1563,12 @@ protected String generateHeader(Root _root, String _indent, String _procName, } } + // START KGU#860 2020-04-24: Issue #861/1 Moved hitherto from below the header + if (!_root.getComment().getLongString().trim().isEmpty()) + { + appendComment(_root, _indent); // Since #828 this will automatically decide for a block comment + } + // END KGU#860 2020-04-24 // START KGU#815/KGU#824 2020-03-18: Enh. #828, bugfix #836 - An includable has never a procedure heading //code.add(_indent + header + ";"); if (!_root.isInclude()) { @@ -1619,11 +1626,13 @@ protected String generateHeader(Root _root, String _indent, String _procName, // START KGU 2016-01-16: No need to create an empty comment //insertBlockComment(_root.getComment(), _indent, this.commentSymbolLeft(), // " * ", " " + this.commentSymbolRight()); - if (!_root.getComment().getLongString().trim().isEmpty()) - { - appendBlockComment(_root.getComment(), _indent, this.commentSymbolLeft(), - " * ", " " + this.commentSymbolRight()); - } + // START KGU#860 2020-04-24: Issue #861/1 Moved above the declaration + //if (!_root.getComment().getLongString().trim().isEmpty()) + //{ + // appendBlockComment(_root.getComment(), _indent, this.commentSymbolLeft(), + // " * ", " " + this.commentSymbolRight()); + //} + // END KGU#860 2020-04-24 if (topLevel) { // START KGU#363 2017-05-16: Enh. #372 diff --git a/src/lu/fisch/structorizer/generators/PasGenerator.java b/src/lu/fisch/structorizer/generators/PasGenerator.java index 986493ef..b0a08b32 100644 --- a/src/lu/fisch/structorizer/generators/PasGenerator.java +++ b/src/lu/fisch/structorizer/generators/PasGenerator.java @@ -92,6 +92,7 @@ * Kay Gürtzig 2020-03-17/30 Enh. #828: Modification in generatePreamble(), insertion lines * corrected * Kay Gürtzig 2020-04-22 Enh. #855: New configurable default array size considered + * Kay Gürtzig 2020-04-24 Issue #861/1: Comment placement now according to the GNU Pascal Coding Standards * ****************************************************************************************************** * @@ -317,7 +318,7 @@ protected void appendComment(StringList _sl, String _indent) this.appendComment(_sl.get(0), _indent); } else { - this.appendBlockComment(_sl, _indent, this.commentSymbolLeft(), "* ", this.commentSymbolRight()); + this.appendBlockComment(_sl, _indent, this.commentSymbolLeft(), " ", this.commentSymbolRight()); } } } @@ -1525,6 +1526,11 @@ protected String generateHeader(Root _root, String _indent, String _procName, if (topLevel) { + // START KGU#860 2020-04-24: Issue #861/1 + if (!_root.isSubroutine() && !_root.getComment().getLongString().trim().isEmpty()) { + this.appendComment(_root, _indent); + } + // END KGU#860 2020-04-24 // START KGU#311/KGU#815/KGU#836 2020-03-22: Enh. #314, #828, bugfix #836 if (this.usesFileAPI && (this.isLibraryModule() || this.importedLibRoots != null)) { this.generatorIncludes.addIfNew(FILE_API_UNIT_NAME); @@ -1553,10 +1559,6 @@ protected String generateHeader(Root _root, String _indent, String _procName, // START KGU#363 2017-05-16: Enh. #372 appendCopyright(_root, _indent, true); // END KGU#363 2017-05-16 - if (!_root.isSubroutine() && !_root.getComment().getLongString().trim().isEmpty()) { - addSepaLine(); - this.appendComment(_root, _indent); - } addSepaLine(); // START KGU#351 2017-02-26: Enh. #346 if (_root.isProgram()) { diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index ef2d678c..b7250ef9 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -13,7 +13,7 @@ Known issues: - Shell export does not cope with nested array/record initializers and component access, neither with clean parameter handling for usual arrays and associative arrays. -Current development version: 3.30-09 (2020-04-23) +Current development version: 3.30-09 (2020-04-24) - 01: Bugfix #759: Another source of stale Mainforms dried up. <2> - 01: Bugfix #761: Code preview defect flooded the log stream. <2> - 01: Precautions against empty error messages on startup <2> @@ -107,7 +107,11 @@ Current development version: 3.30-09 (2020-04-23) - 08: Bugfix #856: The dump of preferences subsets did not behave correctly <2> - 08: Bugfix #858: Functions did not actually work in FOR-IN loop headers <2> - 09: Bugfix #860: Batch export for .arr files containing abs. paths failed <2> -- 09: Bugfix #861/2: On Pascal input, routine comments were duplicated <2> +- 09: Issue #861/1: Comment placement on Pascal and Oberon export revised <2> +- 09: Bugfix #861/2: On Pascal import, routine comments were duplicated <2> +- 09: Issue #861/3: Improved comment trimming on code import <2> +- 09: Bugfix #862/2: Batch export no longer produces duplicate entry points <2> +- 09: Bugfix #862/3: Batch import produced defective arrangement lists <2> Version: 3.30 (2019-10-06) - 01: Issue #657: Spanish message in German locale replaced <2> diff --git a/src/lu/fisch/structorizer/parsers/CodeParser.java b/src/lu/fisch/structorizer/parsers/CodeParser.java index 6e6ff90d..8cac0a96 100644 --- a/src/lu/fisch/structorizer/parsers/CodeParser.java +++ b/src/lu/fisch/structorizer/parsers/CodeParser.java @@ -51,6 +51,7 @@ * Kay Gürtzig 2019-08-02 Issue #733: New method getPreferenceKeys() for partial preference export * Kay Gürtzig 2020-03-08 Issue #833: Modified API for new mechanism to get rid of superfluous roots * Kay Gürtzig 2020-03-09 Issue #835: New import option and method for insertion of structure preference keywords + * Kay Gürtzig 2020-04-24 Method cleanComment() improved (indentation trimmed, empty lines dropped) * ****************************************************************************************************** * @@ -1065,7 +1066,7 @@ protected String retrieveComment(Reduction _reduction) throws ParserCancelled // Then we check the subtree recursively retrieveComment_R(_reduction, comment); if (comment.length() > 0) { - return cleanComment(comment.toString().substring(1)); // Remove the first newline + return cleanComment(comment.toString().substring(1)); } } return null; @@ -1137,10 +1138,17 @@ protected Element equipWithSourceComment(Element _ele, Reduction _reduction) thr } // END KGU#407 2017-06-22 // START KGU#407 2017-09-30: Enh. #420 + /** + * Removes comment markers according to {@link #getCommentDelimiters()}, then + * removes empty lines and trims the indentation to the minimum of all lines + * @param _rawComment - the collected comments (may contain newlines) + * @return the cleaned (possibly multi-line) comment + */ private String cleanComment(String _rawComment) { StringList lines = StringList.explode(_rawComment, "\n"); String endDelim = null; String[][] delims = this.getCommentDelimiters(); + int minIndent = Integer.MAX_VALUE; for (int i = 0; i < lines.count(); i++) { String line = lines.get(i); if (endDelim == null) { @@ -1161,7 +1169,23 @@ private String cleanComment(String _rawComment) { lines.set(i, line); endDelim = null; } + // START KGU#862 2020-04-24: trim the comment + if (line.trim().isEmpty()) { + lines.set(i, ""); + } + else { + minIndent = Math.min(minIndent, line.indexOf(line.trim())); + } + // END KGU#861 2020-04-24 + } + // START KGU#862 2020-04-24: trim the comment + lines.removeAll(""); + if (minIndent > 0) { + for (int i = 0; i < lines.count(); i++) { + lines.set(i, lines.get(i).substring(minIndent)); + } } + // END KGU#861 2020-04-24 return lines.getText(); } /** From 2d5feb5b90bdda72827f862fed752b3c63cef299 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Fri, 24 Apr 2020 21:16:13 +0200 Subject: [PATCH 05/18] Pascal and Oberon export samples updated after bugfix #861 --- samples/export/Oberon/ComputeSum.Mod | 40 +- samples/export/Oberon/DrawRandomHistogram.Mod | 34 +- samples/export/Oberon/ELIZA_2.2.Mod | 156 ++++---- samples/export/Oberon/ELIZA_2.3.Mod | 182 +++++---- samples/export/Oberon/SORTING_TEST_MAIN.Mod | 118 +++--- samples/export/Oberon/TextDemo.Mod | 346 +++++++++--------- samples/export/Pascal/ComputeSum.pas | 33 +- samples/export/Pascal/DrawRandomHistogram.pas | 17 +- samples/export/Pascal/ELIZA_2.2.pas | 83 +++-- samples/export/Pascal/ELIZA_2.3.pas | 97 +++-- samples/export/Pascal/SORTING_TEST_MAIN.pas | 49 ++- samples/export/Pascal/TextDemo.pas | 109 +++--- .../export_group/Oberon/ELIZA_2_2_arrz.Mod | 156 ++++---- .../export_group/Oberon/ELIZA_2_3_arrz.Mod | 182 +++++---- .../Oberon/FileApiGroupTest_arrz.Mod | 104 +++--- .../export_group/Oberon/SORTING_TEST_arrz.Mod | 118 +++--- .../export_group/Oberon/TextWriter_arrz.Mod | 346 +++++++++--------- .../export_group/Pascal/ELIZA_2_2_arrz.pas | 83 +++-- .../export_group/Pascal/ELIZA_2_3_arrz.pas | 97 +++-- .../Pascal/FileApiGroupTest_arrz.pas | 75 ++-- .../export_group/Pascal/SORTING_TEST_arrz.pas | 49 ++- .../export_group/Pascal/TextWriter_arrz.pas | 109 +++--- 22 files changed, 1273 insertions(+), 1310 deletions(-) diff --git a/samples/export/Oberon/ComputeSum.Mod b/samples/export/Oberon/ComputeSum.Mod index d0eff75a..54ba3af8 100644 --- a/samples/export/Oberon/ComputeSum.Mod +++ b/samples/export/Oberon/ComputeSum.Mod @@ -1,23 +1,23 @@ -MODULE ComputeSum; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Computes the sum and average of the numbers read from a user-specified - * text file (which might have been created via generateRandomNumberFile(4)). - * - * This program is part of an arrangement used to test group code export (issue - * #828) with FileAPI dependency. - * The input check loop has been disabled (replaced by a simple unchecked input - * instruction) in order to test the effect of indirect FileAPI dependency (only the - * called subroutine directly requires FileAPI now). + Computes the sum and average of the numbers read from a user-specified + text file (which might have been created via generateRandomNumberFile(4)). + + This program is part of an arrangement used to test group code export (issue + #828) with FileAPI dependency. + The input check loop has been disabled (replaced by a simple unchecked input + instruction) in order to test the effect of indirect FileAPI dependency (only the + called subroutine directly requires FileAPI now). *) +MODULE ComputeSum; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2020-03-21 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR @@ -31,12 +31,12 @@ VAR fileNo: INTEGER; failure: Exception; -PROCEDURE readNumbers(fileName: ARRAY 128 OF CHAR; VAR numbers: ARRAY 50 OF INTEGER; maxNumbers: INTEGER): INTEGER; (* - * Tries to read as many integer values as possible upto maxNumbers - * from file fileName into the given array numbers. - * Returns the number of the actually read numbers. May cause an exception. + Tries to read as many integer values as possible upto maxNumbers + from file fileName into the given array numbers. + Returns the number of the actually read numbers. May cause an exception. *) +PROCEDURE readNumbers(fileName: ARRAY 128 OF CHAR; VAR numbers: ARRAY 50 OF INTEGER; maxNumbers: INTEGER): INTEGER; VAR (* TODO: check and accomplish variable declarations *) number: INTEGER; @@ -73,8 +73,8 @@ BEGIN (* TODO: Replace "TYPE" by the the actual In procedure name for this type! *) Out.String("Name/path of the number file"); In.TYPE(file_name); (* - * If you enable this loop, then the preceding input instruction is to be disabled - * and the fileClose instruction in the alternative below is to be enabled. + If you enable this loop, then the preceding input instruction is to be disabled + and the fileClose instruction in the alternative below is to be enabled. *) (* REPEAT *) (* TODO: Replace "TYPE" by the the actual In procedure name for this type! *) diff --git a/samples/export/Oberon/DrawRandomHistogram.Mod b/samples/export/Oberon/DrawRandomHistogram.Mod index bb150048..6e276692 100644 --- a/samples/export/Oberon/DrawRandomHistogram.Mod +++ b/samples/export/Oberon/DrawRandomHistogram.Mod @@ -1,17 +1,17 @@ -MODULE DrawRandomHistogram; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Reads a random number file and draws a histogram accotrding to the - * user specifications + Reads a random number file and draws a histogram accotrding to the + user specifications *) +MODULE DrawRandomHistogram; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2020-03-21 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR @@ -32,13 +32,13 @@ VAR count: ARRAY 50 OF INTEGER; failure: Exception; -PROCEDURE drawBarChart(values: ARRAY 50 OF LONGREAL; nValues: ???); (* - * Draws a bar chart from the array "values" of size nValues. - * Turtleizer must be activated and will scale the chart into a square of - * 500 x 500 pixels - * Note: The function is not robust against empty array or totally equal values. + Draws a bar chart from the array "values" of size nValues. + Turtleizer must be activated and will scale the chart into a square of + 500 x 500 pixels + Note: The function is not robust against empty array or totally equal values. *) +PROCEDURE drawBarChart(values: ARRAY 50 OF LONGREAL; nValues: ???); CONST (* Used range of the Turtleizer screen *) xSize = 500; @@ -120,12 +120,12 @@ BEGIN END; END drawBarChart; -PROCEDURE readNumbers(fileName: ARRAY 128 OF CHAR; VAR numbers: ARRAY 50 OF INTEGER; maxNumbers: INTEGER): INTEGER; (* - * Tries to read as many integer values as possible upto maxNumbers - * from file fileName into the given array numbers. - * Returns the number of the actually read numbers. May cause an exception. + Tries to read as many integer values as possible upto maxNumbers + from file fileName into the given array numbers. + Returns the number of the actually read numbers. May cause an exception. *) +PROCEDURE readNumbers(fileName: ARRAY 128 OF CHAR; VAR numbers: ARRAY 50 OF INTEGER; maxNumbers: INTEGER): INTEGER; VAR (* TODO: check and accomplish variable declarations *) number: INTEGER; diff --git a/samples/export/Oberon/ELIZA_2.2.Mod b/samples/export/Oberon/ELIZA_2.2.Mod index f2264b6f..435dd1a0 100644 --- a/samples/export/Oberon/ELIZA_2.2.Mod +++ b/samples/export/Oberon/ELIZA_2.2.Mod @@ -1,25 +1,25 @@ -MODULE ELIZA; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Concept and lisp implementation published by Joseph Weizenbaum (MIT): - * "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: - * Computational Linguistis 1(1966)9, pp. 36-45 - * Revision history: - * 2016-10-06 Initial version - * 2017-03-29 Two diagrams updated (comments translated to English) - * 2017-03-29 More keywords and replies added - * 2019-03-14 Replies and mapping reorganised for easier maintenance - * 2019-03-15 key map joined from keyword array and index map - * 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") + Concept and lisp implementation published by Joseph Weizenbaum (MIT): + "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: + Computational Linguistis 1(1966)9, pp. 36-45 + Revision history: + 2016-10-06 Initial version + 2017-03-29 Two diagrams updated (comments translated to English) + 2017-03-29 More keywords and replies added + 2019-03-14 Replies and mapping reorganised for easier maintenance + 2019-03-15 key map joined from keyword array and index map + 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") *) +MODULE ELIZA; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2018-05-14 ??? *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) TYPE @@ -29,17 +29,17 @@ TYPE END; VAR - indexcb07562: INTEGER; - arraycb07562: ARRAY 5 OF ARRAY 100 OF CHAR; - indexc1c1804a: INTEGER; - index5295402c: INTEGER; - index111025d0: INTEGER; - array111025d0: ARRAY 2 OF ARRAY 100 OF CHAR; + index9218ddfe: INTEGER; + array9218ddfe: ARRAY 5 OF ARRAY 100 OF CHAR; + index827e4261: INTEGER; + indexf357b655: INTEGER; + indexb8030b03: INTEGER; + arrayb8030b03: ARRAY 2 OF ARRAY 100 OF CHAR; (* TODO: check and accomplish variable declarations *) varPart: ARRAY 128 OF CHAR; (* - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string *) userInput: ARRAY 128 OF CHAR; replyRing: ???; (* FIXME! *) @@ -51,18 +51,16 @@ VAR isRepeated: BOOLEAN; isGone: BOOLEAN; (* - * Stores the last five inputs of the user in a ring buffer, - * the first element is the current insertion index + Stores the last five inputs of the user in a ring buffer, + the first element is the current insertion index *) history: ARRAY 6 OF ???; (* FIXME! *) findInfo: ARRAY 2 OF INTEGER; entry: KeyMapEntry; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) +(* Cares for correct letter case among others *) PROCEDURE adjustSpelling(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; -(* - * Cares for correct letter case among others - *) VAR (* TODO: check and accomplish variable declarations *) word: ARRAY 128 OF CHAR; @@ -80,10 +78,10 @@ BEGIN delete(result, 1, position); insert(CAP(start), result, 1); END; - array111025d0[0] := " i "; - array111025d0[1] := " i\'"; - FOR index111025d0 := 0 TO 1 DO - word := array111025d0[index111025d0]; + arrayb8030b03[0] := " i "; + arrayb8030b03[1] := " i\'"; + FOR indexb8030b03 := 0 TO 1 DO + word := arrayb8030b03[indexb8030b03]; position := pos(word, result); WHILE position > 0 DO delete(result, position+1, 1); @@ -94,20 +92,20 @@ BEGIN RETURN result; END adjustSpelling; -PROCEDURE checkGoodBye(text: ARRAY 128 OF CHAR; VAR phrases: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR): BOOLEAN; (* - * Checks whether the given text contains some kind of - * good-bye phrase inducing the end of the conversation - * and if so writes a correspding good-bye message and - * returns true, otherwise false + Checks whether the given text contains some kind of + good-bye phrase inducing the end of the conversation + and if so writes a correspding good-bye message and + returns true, otherwise false *) +PROCEDURE checkGoodBye(text: ARRAY 128 OF CHAR; VAR phrases: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR): BOOLEAN; VAR (* TODO: check and accomplish variable declarations *) saidBye: BOOLEAN; pair: ARRAY 50 OF ARRAY 128 OF CHAR; BEGIN - FOR index5295402c := 0 TO LEN(phrases)-1 DO - pair := phrases[index5295402c]; + FOR indexf357b655 := 0 TO LEN(phrases)-1 DO + pair := phrases[indexf357b655]; IF pos(pair[0], text) > 0 THEN saidBye := true; (* TODO: Replace "TYPE" by the the actual Out procedure name for this type and add a length argument where needed! *) @@ -119,11 +117,11 @@ BEGIN RETURN false; END checkGoodBye; -PROCEDURE checkRepetition(history: ARRAY; VAR newInput: ARRAY 128 OF CHAR): BOOLEAN; (* - * Checks whether newInput has occurred among the last - * length(history) - 1 input strings and updates the history + Checks whether newInput has occurred among the last + length(history) - 1 input strings and updates the history *) +PROCEDURE checkRepetition(history: ARRAY; VAR newInput: ARRAY 128 OF CHAR): BOOLEAN; VAR (* TODO: check and accomplish variable declarations *) i: INTEGER; @@ -155,8 +153,8 @@ VAR left: ARRAY 128 OF CHAR; BEGIN result := " " + copy(sentence, keyPos + length(key), length(sentence)) + " "; - FOR indexc1c1804a := 0 TO LEN(flexions)-1 DO - pair := flexions[indexc1c1804a]; + FOR index827e4261 := 0 TO LEN(flexions)-1 DO + pair := flexions[index827e4261]; left := ""; right := result; position := pos(pair[0], right); @@ -177,15 +175,15 @@ BEGIN END conjugateStrings; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE findKeyword(keyMap: const ARRAY OF KeyMapEntry; VAR sentence: ARRAY 128 OF CHAR): ARRAY 2 OF INTEGER; (* - * Looks for the occurrence of the first of the strings - * contained in keywords within the given sentence (in - * array order). - * Returns an array of - * 0: the index of the first identified keyword (if any, otherwise -1), - * 1: the position inside sentence (0 if not found) + Looks for the occurrence of the first of the strings + contained in keywords within the given sentence (in + array order). + Returns an array of + 0: the index of the first identified keyword (if any, otherwise -1), + 1: the position inside sentence (0 if not found) *) +PROCEDURE findKeyword(keyMap: const ARRAY OF KeyMapEntry; VAR sentence: ARRAY 128 OF CHAR): ARRAY 2 OF INTEGER; CONST keyMap = null; @@ -214,12 +212,12 @@ BEGIN END findKeyword; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE normalizeInput(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; (* - * Converts the sentence to lowercase, eliminates all - * interpunction (i.e. ',', '.', ';'), and pads the - * sentence among blanks + Converts the sentence to lowercase, eliminates all + interpunction (i.e. ',', '.', ';'), and pads the + sentence among blanks *) +PROCEDURE normalizeInput(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; VAR (* TODO: check and accomplish variable declarations *) symbol: CHAR; @@ -227,13 +225,13 @@ VAR position: INTEGER; BEGIN sentence := lowercase(sentence); - arraycb07562[0] := '.'; - arraycb07562[1] := ','; - arraycb07562[2] := ';'; - arraycb07562[3] := '!'; - arraycb07562[4] := '?'; - FOR indexcb07562 := 0 TO 4 DO - symbol := arraycb07562[indexcb07562]; + array9218ddfe[0] := '.'; + array9218ddfe[1] := ','; + array9218ddfe[2] := ';'; + array9218ddfe[3] := '!'; + array9218ddfe[4] := '?'; + FOR index9218ddfe := 0 TO 4 DO + symbol := array9218ddfe[index9218ddfe]; position := pos(symbol, sentence); WHILE position > 0 DO sentence := copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence)); @@ -260,12 +258,12 @@ BEGIN END setupGoodByePhrases; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE setupKeywords: ARRAY 50 OF KeyMapEntry; (* - * The lower the index the higher the rank of the keyword (search is sequential). - * The index of the first keyword found in a user sentence maps to a respective - * reply ring as defined in `setupReplies()´. + The lower the index the higher the rank of the keyword (search is sequential). + The index of the first keyword found in a user sentence maps to a respective + reply ring as defined in `setupReplies()´. *) +PROCEDURE setupKeywords: ARRAY 50 OF KeyMapEntry; VAR (* TODO: check and accomplish variable declarations *) (* The empty key string (last entry) is the default clause - will always be found *) @@ -356,10 +354,8 @@ BEGIN END setupKeywords; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) +(* Returns an array of pairs of mutualy substitutable *) PROCEDURE setupReflexions: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR; -(* - * Returns an array of pairs of mutualy substitutable - *) VAR (* TODO: check and accomplish variable declarations *) reflexions: ARRAY 50 OF ARRAY 2 OF ARRAY 128 OF CHAR; @@ -398,20 +394,20 @@ BEGIN END setupReflexions; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; (* - * This routine sets up the reply rings addressed by the key words defined in - * routine `setupKeywords()´ and mapped hitherto by the cross table defined - * in `setupMapping()´ + This routine sets up the reply rings addressed by the key words defined in + routine `setupKeywords()´ and mapped hitherto by the cross table defined + in `setupMapping()´ *) +PROCEDURE setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; VAR (* TODO: check and accomplish variable declarations *) setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; replies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; BEGIN (* - * We start with the highest index for performance reasons - * (is to avoid frequent array resizing) + We start with the highest index for performance reasons + (is to avoid frequent array resizing) *) (* Hint: Automatically decomposed array initialization *) replies[29, 0] := "Say, do you have any psychological problems?"; @@ -596,8 +592,8 @@ BEGIN Out.String("**********************************"); Out.Ln; (* - * Stores the last five inputs of the user in a ring buffer, - * the first element is the current insertion index + Stores the last five inputs of the user in a ring buffer, + the first element is the current insertion index *) (* Hint: Automatically decomposed array initialization *) history[0] := 0; @@ -619,8 +615,8 @@ BEGIN (* TODO: Replace "TYPE" by the the actual In procedure name for this type! *) In.TYPE(userInput); (* - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string *) userInput := normalizeInput(userInput); isGone := checkGoodBye(userInput, byePhrases); diff --git a/samples/export/Oberon/ELIZA_2.3.Mod b/samples/export/Oberon/ELIZA_2.3.Mod index 56b0bab5..17e61392 100644 --- a/samples/export/Oberon/ELIZA_2.3.Mod +++ b/samples/export/Oberon/ELIZA_2.3.Mod @@ -1,36 +1,36 @@ -MODULE ELIZA; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Concept and lisp implementation published by Joseph Weizenbaum (MIT): - * "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: - * Computational Linguistis 1(1966)9, pp. 36-45 - * Revision history: - * 2016-10-06 Initial version - * 2017-03-29 Two diagrams updated (comments translated to English) - * 2017-03-29 More keywords and replies added - * 2019-03-14 Replies and mapping reorganised for easier maintenance - * 2019-03-15 key map joined from keyword array and index map - * 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") - * 2019-11-28 New global type "History" (to ensure a homogenous array) + Concept and lisp implementation published by Joseph Weizenbaum (MIT): + "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: + Computational Linguistis 1(1966)9, pp. 36-45 + Revision history: + 2016-10-06 Initial version + 2017-03-29 Two diagrams updated (comments translated to English) + 2017-03-29 More keywords and replies added + 2019-03-14 Replies and mapping reorganised for easier maintenance + 2019-03-15 key map joined from keyword array and index map + 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") + 2019-11-28 New global type "History" (to ensure a homogenous array) *) +MODULE ELIZA; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2018-05-14 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) TYPE (* - * histArray contains the most recent user replies as ring buffer; - * histIndex is the index where the next reply is to be stored (= index of the oldest - * cached user reply). - * Note: The depth of the history is to be specified by initializing a variable of this type, - * e.g. for a history of depth 5: - * myhistory <- History{{"", "", "", "", ""}, 0} + histArray contains the most recent user replies as ring buffer; + histIndex is the index where the next reply is to be stored (= index of the oldest + cached user reply). + Note: The depth of the history is to be specified by initializing a variable of this type, + e.g. for a history of depth 5: + myhistory <- History{{"", "", "", "", ""}, 0} *) History* = RECORD histArray: ARRAY 50 OF ARRAY 128 OF CHAR; @@ -44,17 +44,17 @@ TYPE END; VAR - index2881406f: INTEGER; - array2881406f: ARRAY 5 OF ARRAY 100 OF CHAR; - index59775136: INTEGER; - index35b297e8: INTEGER; - indexb3ec7986: INTEGER; - arrayb3ec7986: ARRAY 2 OF ARRAY 100 OF CHAR; + index3a2c1573: INTEGER; + array3a2c1573: ARRAY 5 OF ARRAY 100 OF CHAR; + index375b7e08: INTEGER; + index6e53e8a6: INTEGER; + index450f7da8: INTEGER; + array450f7da8: ARRAY 2 OF ARRAY 100 OF CHAR; (* TODO: check and accomplish variable declarations *) varPart: ARRAY 128 OF CHAR; (* - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string *) userInput: ARRAY 128 OF CHAR; replyRing: ???; (* FIXME! *) @@ -66,18 +66,16 @@ VAR isRepeated: BOOLEAN; isGone: BOOLEAN; (* - * Stores the last five inputs of the user in a ring buffer, - * the second component is the rolling (over-)write index. + Stores the last five inputs of the user in a ring buffer, + the second component is the rolling (over-)write index. *) history: History; findInfo: ARRAY 2 OF INTEGER; entry: KeyMapEntry; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) +(* Cares for correct letter case among others *) PROCEDURE adjustSpelling(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; -(* - * Cares for correct letter case among others - *) VAR (* TODO: check and accomplish variable declarations *) word: ARRAY 128 OF CHAR; @@ -95,10 +93,10 @@ BEGIN delete(result, 1, position); insert(CAP(start), result, 1); END; - arrayb3ec7986[0] := " i "; - arrayb3ec7986[1] := " i\'"; - FOR indexb3ec7986 := 0 TO 1 DO - word := arrayb3ec7986[indexb3ec7986]; + array450f7da8[0] := " i "; + array450f7da8[1] := " i\'"; + FOR index450f7da8 := 0 TO 1 DO + word := array450f7da8[index450f7da8]; position := pos(word, result); WHILE position > 0 DO delete(result, position+1, 1); @@ -109,19 +107,19 @@ BEGIN RETURN result; END adjustSpelling; -PROCEDURE checkGoodBye(text: ARRAY 128 OF CHAR; VAR phrases: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR): BOOLEAN; (* - * Checks whether the given text contains some kind of - * good-bye phrase inducing the end of the conversation - * and if so writes a correspding good-bye message and - * returns true, otherwise false + Checks whether the given text contains some kind of + good-bye phrase inducing the end of the conversation + and if so writes a correspding good-bye message and + returns true, otherwise false *) +PROCEDURE checkGoodBye(text: ARRAY 128 OF CHAR; VAR phrases: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR): BOOLEAN; VAR (* TODO: check and accomplish variable declarations *) pair: ARRAY 50 OF ARRAY 128 OF CHAR; BEGIN - FOR index35b297e8 := 0 TO LEN(phrases)-1 DO - pair := phrases[index35b297e8]; + FOR index6e53e8a6 := 0 TO LEN(phrases)-1 DO + pair := phrases[index6e53e8a6]; IF pos(pair[0], text) > 0 THEN (* TODO: Replace "TYPE" by the the actual Out procedure name for this type and add a length argument where needed! *) Out.TYPE(pair[1]); @@ -132,11 +130,11 @@ BEGIN RETURN false; END checkGoodBye; -PROCEDURE checkRepetition(history: History; VAR newInput: ARRAY 128 OF CHAR): BOOLEAN; (* - * Checks whether newInput has occurred among the recently cached - * input strings in the histArray component of history and updates the history. + Checks whether newInput has occurred among the recently cached + input strings in the histArray component of history and updates the history. *) +PROCEDURE checkRepetition(history: History; VAR newInput: ARRAY 128 OF CHAR): BOOLEAN; VAR (* TODO: check and accomplish variable declarations *) i: INTEGER; @@ -168,8 +166,8 @@ VAR left: ARRAY 128 OF CHAR; BEGIN result := " " + copy(sentence, keyPos + length(key), length(sentence)) + " "; - FOR index59775136 := 0 TO LEN(flexions)-1 DO - pair := flexions[index59775136]; + FOR index375b7e08 := 0 TO LEN(flexions)-1 DO + pair := flexions[index375b7e08]; left := ""; right := result; position := pos(pair[0], right); @@ -190,15 +188,15 @@ BEGIN END conjugateStrings; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE findKeyword(keyMap: const ARRAY OF KeyMapEntry; VAR sentence: ARRAY 128 OF CHAR): ARRAY 2 OF INTEGER; (* - * Looks for the occurrence of the first of the strings - * contained in keywords within the given sentence (in - * array order). - * Returns an array of - * 0: the index of the first identified keyword (if any, otherwise -1), - * 1: the position inside sentence (0 if not found) + Looks for the occurrence of the first of the strings + contained in keywords within the given sentence (in + array order). + Returns an array of + 0: the index of the first identified keyword (if any, otherwise -1), + 1: the position inside sentence (0 if not found) *) +PROCEDURE findKeyword(keyMap: const ARRAY OF KeyMapEntry; VAR sentence: ARRAY 128 OF CHAR): ARRAY 2 OF INTEGER; CONST keyMap = null; @@ -227,12 +225,12 @@ BEGIN END findKeyword; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE normalizeInput(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; (* - * Converts the sentence to lowercase, eliminates all - * interpunction (i.e. ',', '.', ';'), and pads the - * sentence among blanks + Converts the sentence to lowercase, eliminates all + interpunction (i.e. ',', '.', ';'), and pads the + sentence among blanks *) +PROCEDURE normalizeInput(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; VAR (* TODO: check and accomplish variable declarations *) symbol: CHAR; @@ -240,13 +238,13 @@ VAR position: INTEGER; BEGIN sentence := lowercase(sentence); - array2881406f[0] := '.'; - array2881406f[1] := ','; - array2881406f[2] := ';'; - array2881406f[3] := '!'; - array2881406f[4] := '?'; - FOR index2881406f := 0 TO 4 DO - symbol := array2881406f[index2881406f]; + array3a2c1573[0] := '.'; + array3a2c1573[1] := ','; + array3a2c1573[2] := ';'; + array3a2c1573[3] := '!'; + array3a2c1573[4] := '?'; + FOR index3a2c1573 := 0 TO 4 DO + symbol := array3a2c1573[index3a2c1573]; position := pos(symbol, sentence); WHILE position > 0 DO sentence := copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence)); @@ -273,12 +271,12 @@ BEGIN END setupGoodByePhrases; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE setupKeywords: ARRAY 50 OF KeyMapEntry; (* - * The lower the index the higher the rank of the keyword (search is sequential). - * The index of the first keyword found in a user sentence maps to a respective - * reply ring as defined in `setupReplies()´. + The lower the index the higher the rank of the keyword (search is sequential). + The index of the first keyword found in a user sentence maps to a respective + reply ring as defined in `setupReplies()´. *) +PROCEDURE setupKeywords: ARRAY 50 OF KeyMapEntry; VAR (* TODO: check and accomplish variable declarations *) (* The empty key string (last entry) is the default clause - will always be found *) @@ -369,10 +367,8 @@ BEGIN END setupKeywords; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) +(* Returns an array of pairs of mutualy substitutable *) PROCEDURE setupReflexions: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR; -(* - * Returns an array of pairs of mutualy substitutable - *) VAR (* TODO: check and accomplish variable declarations *) reflexions: ARRAY 50 OF ARRAY 2 OF ARRAY 128 OF CHAR; @@ -411,20 +407,20 @@ BEGIN END setupReflexions; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; (* - * This routine sets up the reply rings addressed by the key words defined in - * routine `setupKeywords()´ and mapped hitherto by the cross table defined - * in `setupMapping()´ + This routine sets up the reply rings addressed by the key words defined in + routine `setupKeywords()´ and mapped hitherto by the cross table defined + in `setupMapping()´ *) +PROCEDURE setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; VAR (* TODO: check and accomplish variable declarations *) setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; replies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; BEGIN (* - * We start with the highest index for performance reasons - * (is to avoid frequent array resizing) + We start with the highest index for performance reasons + (is to avoid frequent array resizing) *) (* Hint: Automatically decomposed array initialization *) replies[29, 0] := "Say, do you have any psychological problems?"; @@ -584,12 +580,12 @@ BEGIN Out.Open; (* BEGIN initialization for "History" *) (* - * histArray contains the most recent user replies as ring buffer; - * histIndex is the index where the next reply is to be stored (= index of the oldest - * cached user reply). - * Note: The depth of the history is to be specified by initializing a variable of this type, - * e.g. for a history of depth 5: - * myhistory <- History{{"", "", "", "", ""}, 0} + histArray contains the most recent user replies as ring buffer; + histIndex is the index where the next reply is to be stored (= index of the oldest + cached user reply). + Note: The depth of the history is to be specified by initializing a variable of this type, + e.g. for a history of depth 5: + myhistory <- History{{"", "", "", "", ""}, 0} *) (* END initialization for "History" *) (* BEGIN initialization for "KeyMapEntry" *) @@ -622,8 +618,8 @@ BEGIN Out.String("**********************************"); Out.Ln; (* - * Stores the last five inputs of the user in a ring buffer, - * the second component is the rolling (over-)write index. + Stores the last five inputs of the user in a ring buffer, + the second component is the rolling (over-)write index. *) (* Hint: Automatically decomposed array initialization *) history.histArray[0] := ""; @@ -645,8 +641,8 @@ BEGIN (* TODO: Replace "TYPE" by the the actual In procedure name for this type! *) In.TYPE(userInput); (* - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string *) userInput := normalizeInput(userInput); isGone := checkGoodBye(userInput, byePhrases); diff --git a/samples/export/Oberon/SORTING_TEST_MAIN.Mod b/samples/export/Oberon/SORTING_TEST_MAIN.Mod index 1bbedd1d..893b2ce3 100644 --- a/samples/export/Oberon/SORTING_TEST_MAIN.Mod +++ b/samples/export/Oberon/SORTING_TEST_MAIN.Mod @@ -1,19 +1,19 @@ -MODULE SORTING_TEST_MAIN; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Creates three equal arrays of numbers and has them sorted with different sorting algorithms - * to allow performance comparison via execution counting ("Collect Runtime Data" should - * sensibly be switched on). - * Requested input data are: Number of elements (size) and filing mode. + Creates three equal arrays of numbers and has them sorted with different sorting algorithms + to allow performance comparison via execution counting ("Collect Runtime Data" should + sensibly be switched on). + Requested input data are: Number of elements (size) and filing mode. *) +MODULE SORTING_TEST_MAIN; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2019-10-02 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR @@ -29,15 +29,15 @@ VAR i: INTEGER; elementCount: ???; (* FIXME! *) -PROCEDURE bubbleSort(values: ???); (* - * Implements the well-known BubbleSort algorithm. - * Compares neigbouring elements and swaps them in case of an inversion. - * Repeats this while inversions have been found. After every - * loop passage at least one element (the largest one out of the - * processed subrange) finds its final place at the end of the - * subrange. + Implements the well-known BubbleSort algorithm. + Compares neigbouring elements and swaps them in case of an inversion. + Repeats this while inversions have been found. After every + loop passage at least one element (the largest one out of the + processed subrange) finds its final place at the end of the + subrange. *) +PROCEDURE bubbleSort(values: ???); VAR (* TODO: check and accomplish variable declarations *) temp: ???; (* FIXME! *) @@ -61,13 +61,13 @@ BEGIN UNTIL posSwapped < 0; END bubbleSort; -PROCEDURE maxHeapify(heap: ???; i: ???; range: ???); (* - * Given a max-heap 'heap´ with element at index 'i´ possibly - * violating the heap property wrt. its subtree upto and including - * index range-1, restores heap property in the subtree at index i - * again. + Given a max-heap 'heap´ with element at index 'i´ possibly + violating the heap property wrt. its subtree upto and including + index range-1, restores heap property in the subtree at index i + again. *) +PROCEDURE maxHeapify(heap: ???; i: ???; range: ???); VAR (* TODO: check and accomplish variable declarations *) temp: ???; (* FIXME! *) @@ -96,17 +96,17 @@ BEGIN END; END maxHeapify; -PROCEDURE partition(values: ???; start: ???; stop: ???; p: ???): INTEGER; (* - * Partitions array 'values´ between indices 'start´ und 'stop´-1 with - * respect to the pivot element initially at index 'p´ into smaller - * and greater elements. - * Returns the new (and final) index of the pivot element (which - * separates the sequence of smaller elements from the sequence - * of greater elements). - * This is not the most efficient algorithm (about half the swapping - * might still be avoided) but it is pretty clear. + Partitions array 'values´ between indices 'start´ und 'stop´-1 with + respect to the pivot element initially at index 'p´ into smaller + and greater elements. + Returns the new (and final) index of the pivot element (which + separates the sequence of smaller elements from the sequence + of greater elements). + This is not the most efficient algorithm (about half the swapping + might still be avoided) but it is pretty clear. *) +PROCEDURE partition(values: ???; start: ???; stop: ???; p: ???): INTEGER; VAR (* TODO: check and accomplish variable declarations *) (* Fetch the first element of the undiscovered area *) @@ -124,12 +124,12 @@ BEGIN start := start + 1; stop := stop - 1; (* - * Still unseen elements? - * Loop invariants: - * 1. p = start - 1 - * 2. pivot = values[p] - * 3. i < start → values[i] ≤ pivot - * 4. stop < i → pivot < values[i] + Still unseen elements? + Loop invariants: + 1. p = start - 1 + 2. pivot = values[p] + 3. i < start → values[i] ≤ pivot + 4. stop < i → pivot < values[i] *) WHILE start <= stop DO (* Fetch the first element of the undiscovered area *) @@ -140,8 +140,8 @@ BEGIN values[p] := seen; values[start] := pivot; (* - * Shift the border between lower and undicovered area, - * update pivot position. + Shift the border between lower and undicovered area, + update pivot position. *) p := p + 1; start := start + 1; @@ -157,10 +157,8 @@ BEGIN RETURN p; END partition; +(* Checks whether or not the passed-in array is (ascendingly) sorted. *) PROCEDURE testSorted(numbers: ???): BOOLEAN; -(* - * Checks whether or not the passed-in array is (ascendingly) sorted. - *) VAR (* TODO: check and accomplish variable declarations *) isSorted: BOOLEAN; @@ -181,13 +179,13 @@ BEGIN RETURN isSorted; END testSorted; -PROCEDURE buildMaxHeap(heap: ???); (* - * Runs through the array heap and converts it to a max-heap - * in a bottom-up manner, i.e. starts above the "leaf" level - * (index >= length(heap) div 2) and goes then up towards - * the root. + Runs through the array heap and converts it to a max-heap + in a bottom-up manner, i.e. starts above the "leaf" level + (index >= length(heap) div 2) and goes then up towards + the root. *) +PROCEDURE buildMaxHeap(heap: ???); VAR (* TODO: check and accomplish variable declarations *) lgth: INTEGER; @@ -199,30 +197,30 @@ BEGIN END; END buildMaxHeap; -PROCEDURE quickSort(values: ???; start: ???; stop: ???); (* - * Recursively sorts a subrange of the given array 'values´. - * start is the first index of the subsequence to be sorted, - * stop is the index BEHIND the subsequence to be sorted. + Recursively sorts a subrange of the given array 'values´. + start is the first index of the subsequence to be sorted, + stop is the index BEHIND the subsequence to be sorted. *) +PROCEDURE quickSort(values: ???; start: ???; stop: ???); VAR (* TODO: check and accomplish variable declarations *) (* - * Partition the array into smaller and greater elements - * Get the resulting (and final) position of the pivot element + Partition the array into smaller and greater elements + Get the resulting (and final) position of the pivot element *) p: ???; (* FIXME! *) BEGIN (* At least 2 elements? (Less don't make sense.) *) IF stop >= start + 2 THEN (* - * Select a pivot element, be p its index. - * (here: randomly chosen element out of start ... stop-1) + Select a pivot element, be p its index. + (here: randomly chosen element out of start ... stop-1) *) p := random(stop-start) + start; (* - * Partition the array into smaller and greater elements - * Get the resulting (and final) position of the pivot element + Partition the array into smaller and greater elements + Get the resulting (and final) position of the pivot element *) p := partition(values, start, stop, p); (* Sort subsequances separately and independently ... *) @@ -256,11 +254,11 @@ BEGIN END; END quickSort; -PROCEDURE heapSort(values: ???); (* - * Sorts the array 'values´ of numbers according to he heap sort - * algorithm + Sorts the array 'values´ of numbers according to he heap sort + algorithm *) +PROCEDURE heapSort(values: ???); VAR (* TODO: check and accomplish variable declarations *) (* Swap the maximum value (root of the heap) to the heap end *) diff --git a/samples/export/Oberon/TextDemo.Mod b/samples/export/Oberon/TextDemo.Mod index 72cb7606..17d2d87d 100644 --- a/samples/export/Oberon/TextDemo.Mod +++ b/samples/export/Oberon/TextDemo.Mod @@ -1,19 +1,19 @@ -MODULE TextDemo; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Demo program for routine drawText() - * Asks the user to enter a text, a wanted text height and colour, - * and then draws this string onto the turtle screen. Places every - * entered text to a new line. + Demo program for routine drawText() + Asks the user to enter a text, a wanted text height and colour, + and then draws this string onto the turtle screen. Places every + entered text to a new line. *) +MODULE TextDemo; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2019-10-10 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR @@ -24,10 +24,8 @@ VAR height: ???; (* FIXME! *) colour: ???; (* FIXME! *) +(* Draws a blank for font height h, ignoring the colorNo *) PROCEDURE blank(h: ???; colorNo: ???); -(* - * Draws a blank for font height h, ignoring the colorNo - *) VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -75,11 +73,11 @@ BEGIN END; END forward; -PROCEDURE letterA(h: ???; colorNo: ???); (* - * Draws letter A in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter A in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterA(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -103,11 +101,11 @@ BEGIN right(rotAngle); END letterA; -PROCEDURE letterE(h: ???; colorNo: ???); (* - * Draws letter E in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter E in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterE(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -131,11 +129,11 @@ BEGIN left(90); END letterE; -PROCEDURE letterF(h: ???; colorNo: ???); (* - * Draws letter F in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter F in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterF(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -159,11 +157,11 @@ BEGIN left(90); END letterF; -PROCEDURE letterH(h: ???; colorNo: ???); (* - * Draws letter H in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter H in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterH(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -186,11 +184,11 @@ BEGIN left(180); END letterH; -PROCEDURE letterI(h: ???; colorNo: ???); (* - * Draws letter I in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter I in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterI(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the corner triangle outside the octagon *) @@ -224,11 +222,11 @@ BEGIN penDown(); END letterI; -PROCEDURE letterK(h: ???; colorNo: ???); (* - * Draws letter K in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter K in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterK(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -248,11 +246,11 @@ BEGIN left(135); END letterK; -PROCEDURE letterL(h: ???; colorNo: ???); (* - * Draws letter L in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter L in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterL(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -267,11 +265,11 @@ BEGIN left(90); END letterL; -PROCEDURE letterM(h: ???; colorNo: ???); (* - * Draws letter M in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter M in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterM(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -290,11 +288,11 @@ BEGIN forward(-h, colorNo); END letterM; -PROCEDURE letterN(h: ???; colorNo: ???); (* - * Draws letter N in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter N in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterN(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -314,11 +312,11 @@ BEGIN penDown(); END letterN; -PROCEDURE letterT(h: ???; colorNo: ???); (* - * Draws letter T in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter T in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterT(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -341,11 +339,11 @@ BEGIN left(90); END letterT; -PROCEDURE letterV(h: ???; colorNo: ???); (* - * Draws letter V in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter V in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterV(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -368,11 +366,11 @@ BEGIN penDown(); END letterV; -PROCEDURE letterW(h: ???; colorNo: ???); (* - * Draws letter W in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter W in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterW(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width_3: ???; (* FIXME! *) @@ -405,11 +403,11 @@ BEGIN penDown(); END letterW; -PROCEDURE letterX(h: ???; colorNo: ???); (* - * Draws letter X in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter X in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterX(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -430,11 +428,11 @@ BEGIN right(rotAngle); END letterX; -PROCEDURE letterY(h: ???; colorNo: ???); (* - * Draws letter Y in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter Y in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterY(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -462,11 +460,11 @@ BEGIN penDown(); END letterY; -PROCEDURE letterZ(h: ???; colorNo: ???); (* - * Draws letter Z in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter Z in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterZ(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -488,11 +486,11 @@ BEGIN left(90); END letterZ; -PROCEDURE polygonPart(a: LONGREAL; n: INTEGER; ctrclkws: BOOLEAN; nEdges, color: INTEGER); (* - * Draws nEdges edges of a regular n-polygon with edge length a - * counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false. + Draws nEdges edges of a regular n-polygon with edge length a + counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false. *) +PROCEDURE polygonPart(a: LONGREAL; n: INTEGER; ctrclkws: BOOLEAN; nEdges, color: INTEGER); VAR (* TODO: check and accomplish variable declarations *) rotAngle: ???; (* FIXME! *) @@ -508,11 +506,11 @@ BEGIN END; END polygonPart; -PROCEDURE charDummy(h: ???; colorNo: ???); (* - * Draws a dummy character (small centered square) with font height h and - * the colour encoded by colorNo + Draws a dummy character (small centered square) with font height h and + the colour encoded by colorNo *) +PROCEDURE charDummy(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -544,11 +542,11 @@ BEGIN penDown(); END charDummy; -PROCEDURE comma(h: ???; colorNo: ???); (* - * Draws a comma in colour specified by colorNo with font height h - * from the current turtle position. + Draws a comma in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE comma(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) rotAngle: LONGREAL; @@ -569,8 +567,8 @@ BEGIN forward((c+b)/2.0 + c); (* color = ffffff *) penDown(); (* - * Counterclockwise draw 3 edges of a square with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw 3 edges of a square with edge length c + in the colour endcoded by colorNo *) polygonPart(c, 4, true, 3, colorNo); left(90); @@ -586,11 +584,11 @@ BEGIN penDown(); END comma; -PROCEDURE exclMk(h: ???; colorNo: ???); (* - * Draws an exclamation mark in the colour encoded by colorNo with font height h - * from the current turtle position. + Draws an exclamation mark in the colour encoded by colorNo with font height h + from the current turtle position. *) +PROCEDURE exclMk(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -623,8 +621,8 @@ BEGIN left(90 + rotAngle); penDown(); (* - * Clockwise draw 5 edges of an octagon with edge length b/2 - * in the colour endcoded by colorNo + Clockwise draw 5 edges of an octagon with edge length b/2 + in the colour endcoded by colorNo *) polygonPart(b/2.0, 8, false, 5, colorNo); right(rotAngle2); @@ -639,8 +637,8 @@ BEGIN forward(c/2.0); (* color = ffffff *) penDown(); (* - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo *) polygonPart(c, 4, false, 4, colorNo); penUp(); @@ -650,11 +648,11 @@ BEGIN penDown(); END exclMk; -PROCEDURE fullSt(h: ???; colorNo: ???); (* - * Draws a full stop in colour specified by colorNo with font height h - * from the current turtle position. + Draws a full stop in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE fullSt(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the outer corner triangle of the octagon *) @@ -671,8 +669,8 @@ BEGIN forward((c+b)/2.0 + c); (* color = ffffff *) penDown(); (* - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo *) polygonPart(c, 4, true, 4, colorNo); penUp(); @@ -681,11 +679,11 @@ BEGIN penDown(); END fullSt; -PROCEDURE letterB(h: ???; colorNo: ???); (* - * Draws letter B in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter B in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterB(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the outer corner triangle of the octagon *) @@ -717,11 +715,11 @@ BEGIN left(90); END letterB; -PROCEDURE letterC(h: ???; colorNo: ???); (* - * Draws letter C in the colour encoded by colorNo with font height h - * from the current turtle position. + Draws letter C in the colour encoded by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterC(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -742,8 +740,8 @@ BEGIN penDown(); right(180); (* - * Clockwise draws 3 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draws 3 edges of an octagon with edge length b in the colour + encoded by colorNo *) polygonPart(b, 8, true, 3, colorNo); left(rotAngle); @@ -751,8 +749,8 @@ BEGIN forward(2*b + 2*c); (* color = ffffff *) penDown(); (* - * Counterclockwise draws 4 edges of an octagon with edge length b - * iin the colour encoded by colorNo + Counterclockwise draws 4 edges of an octagon with edge length b + iin the colour encoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -764,11 +762,11 @@ BEGIN left(90); END letterC; -PROCEDURE letterD(h: ???; colorNo: ???); (* - * Draws letter D in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter D in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterD(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the outer corner triangle of the octagon *) @@ -784,14 +782,14 @@ BEGIN right(90); forward(c+b, colorNo); (* - * Clockwise draw 2 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draw 2 edges of an octagon with edge length b in the colour + encoded by colorNo *) polygonPart(b, 8, false, 2, colorNo); forward(b + 2*c, colorNo); (* - * Clockwise draw 2 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draw 2 edges of an octagon with edge length b in the colour + encoded by colorNo *) polygonPart(b, 8, false, 2, colorNo); forward(c, colorNo); @@ -802,11 +800,11 @@ BEGIN left(90); END letterD; -PROCEDURE letterG(h: ???; colorNo: ???); (* - * Draws letter G in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter G in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterG(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the corner triangle outside the octagon. *) @@ -823,8 +821,8 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 4 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b in + the colour encoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(c, colorNo); @@ -836,8 +834,8 @@ BEGIN forward(b + c); (* color = ffffff *) penDown(); (* - * Counterclockwise draw 4 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b in + the colour encoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -849,11 +847,11 @@ BEGIN left(90); END letterG; -PROCEDURE letterJ(h: ???; colorNo: ???); (* - * Draws letter J in colour encoded by colorNo with font height h - * from the current turtle position. + Draws letter J in colour encoded by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterJ(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -874,8 +872,8 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 3 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 3 edges of an octagon with edge length b in + the colour encoded by colorNo *) polygonPart(b, 8, true, 3, colorNo); left(rotAngle); @@ -885,11 +883,11 @@ BEGIN penDown(); END letterJ; -PROCEDURE letterO(h: ???; colorNo: ???); (* - * Draws letter O in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter O in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterO(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the corner triangle outside the octagon *) @@ -906,14 +904,14 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); (* - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -925,11 +923,11 @@ BEGIN left(90); END letterO; -PROCEDURE letterP(h: ???; colorNo: ???); (* - * Draws letter P in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter P in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterP(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the corner triangle outside the octagon *) @@ -945,8 +943,8 @@ BEGIN right(90); forward(c+b, colorNo); (* - * Clockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Clockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, false, 4, colorNo); forward(c, colorNo); @@ -958,11 +956,11 @@ BEGIN left(180); END letterP; -PROCEDURE letterQ(h: ???; colorNo: ???); (* - * Draws letter Q in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter Q in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterQ(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -983,14 +981,14 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); (* - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -1005,11 +1003,11 @@ BEGIN left(90 + rotAngle); END letterQ; -PROCEDURE letterR(h: ???; colorNo: ???); (* - * Zeichnet den Buchstaben R von der Turtleposition aus - * mit Zeilenhöhe h + Zeichnet den Buchstaben R von der Turtleposition aus + mit Zeilenhöhe h *) +PROCEDURE letterR(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -1029,8 +1027,8 @@ BEGIN right(90); forward(c+b, colorNo); (* - * Clockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Clockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, false, 4, colorNo); forward(c, colorNo); @@ -1039,11 +1037,11 @@ BEGIN left(90 + rotAngle); END letterR; -PROCEDURE letterS(h: ???; colorNo: ???); (* - * Draws letter S in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter S in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterS(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -1064,13 +1062,13 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 6 edges of an octagon with edge length b - * in the colour encoded by colorNo + Counterclockwise draw 6 edges of an octagon with edge length b + in the colour encoded by colorNo *) polygonPart(b, 8, true, 6, colorNo); (* - * Clockwise draw 5 edges of an octagon with edge length b - * in the colour encoded by colorNo + Clockwise draw 5 edges of an octagon with edge length b + in the colour encoded by colorNo *) polygonPart(b, 8, false, 5, colorNo); right(rotAngle); @@ -1080,11 +1078,11 @@ BEGIN left(180); END letterS; -PROCEDURE letterU(h: ???; colorNo: ???); (* - * Draws letter U in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter U in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterU(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -1117,11 +1115,11 @@ BEGIN penDown(); END letterU; -PROCEDURE qstnMk(h: ???; colorNo: ???); (* - * Draws a question mark in colour specified by colorNo with font height h - * from the current turtle position. + Draws a question mark in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE qstnMk(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -1141,8 +1139,8 @@ BEGIN forward(h-c); (* color = ffffff *) penDown(); (* - * Counterclockwise draw 5 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 5 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, false, 5, colorNo); forward(c, colorNo); @@ -1154,8 +1152,8 @@ BEGIN forward(c/2.0); (* color = ffffff *) penDown(); (* - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo *) polygonPart(c, 4, false, 4, colorNo); penUp(); @@ -1165,29 +1163,29 @@ BEGIN penDown(); END qstnMk; -PROCEDURE drawText(text: ARRAY 128 OF CHAR; h, c: INTEGER); (* - * Has the turtle draw the given string 'text´ with font height 'h´ (in - * pixels) and the colour coded by integer 'c´ from the current Turtle - * position to the Turtle canvas. If the turtle looks North then - * the text will be written rightwards. In the event, the turtle will be - * placed behind the text in original orientation (such that the next text - * would be written like a continuation. Colour codes: - * 1 = black - * 2 = red - * 3 = yellow - * 4 = green - * 5 = cyan - * 6 = blue - * 7 = pink - * 8 = grey - * 9 = orange - * 10 = violet - * All letters (ASCII) will be converted to uppercase, digits cannot - * be represented, the set of representable special characters is: - * '.', ',', '!', '?'. Other characters will be shown as a small - * centred square (dummy character). + Has the turtle draw the given string 'text´ with font height 'h´ (in + pixels) and the colour coded by integer 'c´ from the current Turtle + position to the Turtle canvas. If the turtle looks North then + the text will be written rightwards. In the event, the turtle will be + placed behind the text in original orientation (such that the next text + would be written like a continuation. Colour codes: + 1 = black + 2 = red + 3 = yellow + 4 = green + 5 = cyan + 6 = blue + 7 = pink + 8 = grey + 9 = orange + 10 = violet + All letters (ASCII) will be converted to uppercase, digits cannot + be represented, the set of representable special characters is: + '.', ',', '!', '?'. Other characters will be shown as a small + centred square (dummy character). *) +PROCEDURE drawText(text: ARRAY 128 OF CHAR; h, c: INTEGER); VAR (* TODO: check and accomplish variable declarations *) letter: ARRAY 128 OF CHAR; @@ -1202,8 +1200,8 @@ BEGIN END ELSE (* - * "," cannot be chacked against because the comma is misinterpreted - * as selector list separator. + "," cannot be chacked against because the comma is misinterpreted + as selector list separator. *) CASE letter OF "A": diff --git a/samples/export/Pascal/ComputeSum.pas b/samples/export/Pascal/ComputeSum.pas index fe1b62bc..db433fcb 100644 --- a/samples/export/Pascal/ComputeSum.pas +++ b/samples/export/Pascal/ComputeSum.pas @@ -1,23 +1,22 @@ +{ + Computes the sum and average of the numbers read from a user-specified + text file (which might have been created via generateRandomNumberFile(4)). + + This program is part of an arrangement used to test group code export (issue + #828) with FileAPI dependency. + The input check loop has been disabled (replaced by a simple unchecked input + instruction) in order to test the effect of indirect FileAPI dependency (only the + called subroutine directly requires FileAPI now). +} program ComputeSum; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2020-03-21 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Computes the sum and average of the numbers read from a user-specified -* text file (which might have been created via generateRandomNumberFile(4)). -* -* This program is part of an arrangement used to test group code export (issue -* #828) with FileAPI dependency. -* The input check loop has been disabled (replaced by a simple unchecked input -* instruction) in order to test the effect of indirect FileAPI dependency (only the -* called subroutine directly requires FileAPI now). + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } var @@ -77,8 +76,8 @@ function readNumbers(fileName: string; numbers: array [0..49] of Longint; maxNum { Disable this if you enable the loop below! } write('Name/path of the number file'); readln(file_name); { - * If you enable this loop, then the preceding input instruction is to be disabled - * and the fileClose instruction in the alternative below is to be enabled. + If you enable this loop, then the preceding input instruction is to be disabled + and the fileClose instruction in the alternative below is to be enabled. } { repeat } { write('Name/path of the number file'); readln(file_name); } diff --git a/samples/export/Pascal/DrawRandomHistogram.pas b/samples/export/Pascal/DrawRandomHistogram.pas index 7a58a565..f48e8aee 100644 --- a/samples/export/Pascal/DrawRandomHistogram.pas +++ b/samples/export/Pascal/DrawRandomHistogram.pas @@ -1,17 +1,16 @@ +{ + Reads a random number file and draws a histogram accotrding to the + user specifications +} program DrawRandomHistogram; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2020-03-21 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Reads a random number file and draws a histogram accotrding to the -* user specifications + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } {===== STRUCTORIZER FILE API START =====} diff --git a/samples/export/Pascal/ELIZA_2.2.pas b/samples/export/Pascal/ELIZA_2.2.pas index 0e141779..9423c3c9 100644 --- a/samples/export/Pascal/ELIZA_2.2.pas +++ b/samples/export/Pascal/ELIZA_2.2.pas @@ -1,25 +1,24 @@ +{ + Concept and lisp implementation published by Joseph Weizenbaum (MIT): + "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: + Computational Linguistis 1(1966)9, pp. 36-45 + Revision history: + 2016-10-06 Initial version + 2017-03-29 Two diagrams updated (comments translated to English) + 2017-03-29 More keywords and replies added + 2019-03-14 Replies and mapping reorganised for easier maintenance + 2019-03-15 key map joined from keyword array and index map + 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") +} program ELIZA; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2018-05-14 ??? } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Concept and lisp implementation published by Joseph Weizenbaum (MIT): -* "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: -* Computational Linguistis 1(1966)9, pp. 36-45 -* Revision history: -* 2016-10-06 Initial version -* 2017-03-29 Two diagrams updated (comments translated to English) -* 2017-03-29 More keywords and replies added -* 2019-03-14 Replies and mapping reorganised for easier maintenance -* 2019-03-15 key map joined from keyword array and index map -* 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } type @@ -38,14 +37,14 @@ keyMap = setupKeywords(); var - indexcb07562: 1..5; - arraycb07562: array [1..5] of string; - index111025d0: 1..2; - array111025d0: array [1..2] of string; + index9218ddfe: 1..5; + array9218ddfe: array [1..5] of string; + indexb8030b03: 1..2; + arrayb8030b03: array [1..2] of string; varPart: String; { - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string } userInput: string; replyRing: ???; { FIXME! } @@ -57,8 +56,8 @@ isRepeated: boolean; isGone: boolean; { - * Stores the last five inputs of the user in a ring buffer, - * the first element is the current insertion index + Stores the last five inputs of the user in a ring buffer, + the first element is the current insertion index } history: array [0..5] of ???; { FIXME! } findInfo: array [0..1] of Longint; @@ -86,11 +85,11 @@ function adjustSpelling(sentence: string): string; delete(result, 1, position); insert(uppercase(start), result, 1); end; - array111025d0[1] := ' i '; - array111025d0[2] := ' i\'''; - for index111025d0 := 1 to 2 do + arrayb8030b03[1] := ' i '; + arrayb8030b03[2] := ' i\'''; + for indexb8030b03 := 1 to 2 do begin - word := array111025d0[index111025d0]; + word := arrayb8030b03[indexb8030b03]; position := pos(word, result); while (position > 0) do begin @@ -257,14 +256,14 @@ function normalizeInput(sentence: string): string; begin sentence := lowercase(sentence); - arraycb07562[1] := '.'; - arraycb07562[2] := ','; - arraycb07562[3] := ';'; - arraycb07562[4] := '!'; - arraycb07562[5] := '?'; - for indexcb07562 := 1 to 5 do + array9218ddfe[1] := '.'; + array9218ddfe[2] := ','; + array9218ddfe[3] := ';'; + array9218ddfe[4] := '!'; + array9218ddfe[5] := '?'; + for index9218ddfe := 1 to 5 do begin - symbol := arraycb07562[indexcb07562]; + symbol := array9218ddfe[index9218ddfe]; position := pos(symbol, sentence); while (position > 0) do begin @@ -443,8 +442,8 @@ function setupReplies(): array [0..49] of array [0..49] of string; begin { - * We start with the highest index for performance reasons - * (is to avoid frequent array resizing) + We start with the highest index for performance reasons + (is to avoid frequent array resizing) } { Hint: Automatically decomposed array initialization } replies[29, 0] := 'Say, do you have any psychological problems?'; @@ -613,8 +612,8 @@ function setupReplies(): array [0..49] of array [0..49] of string; writeln('* Version: 2.2 (2019-03-28)'); writeln('**********************************'); { - * Stores the last five inputs of the user in a ring buffer, - * the first element is the current insertion index + Stores the last five inputs of the user in a ring buffer, + the first element is the current insertion index } { Hint: Automatically decomposed array initialization } history[0] := 0; @@ -634,8 +633,8 @@ function setupReplies(): array [0..49] of array [0..49] of string; repeat readln(userInput); { - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string } userInput := normalizeInput(userInput); isGone := checkGoodBye(userInput, byePhrases); diff --git a/samples/export/Pascal/ELIZA_2.3.pas b/samples/export/Pascal/ELIZA_2.3.pas index 2c797f5e..09ccb703 100644 --- a/samples/export/Pascal/ELIZA_2.3.pas +++ b/samples/export/Pascal/ELIZA_2.3.pas @@ -1,36 +1,35 @@ +{ + Concept and lisp implementation published by Joseph Weizenbaum (MIT): + "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: + Computational Linguistis 1(1966)9, pp. 36-45 + Revision history: + 2016-10-06 Initial version + 2017-03-29 Two diagrams updated (comments translated to English) + 2017-03-29 More keywords and replies added + 2019-03-14 Replies and mapping reorganised for easier maintenance + 2019-03-15 key map joined from keyword array and index map + 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") + 2019-11-28 New global type "History" (to ensure a homogenous array) +} program ELIZA; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2018-05-14 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Concept and lisp implementation published by Joseph Weizenbaum (MIT): -* "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: -* Computational Linguistis 1(1966)9, pp. 36-45 -* Revision history: -* 2016-10-06 Initial version -* 2017-03-29 Two diagrams updated (comments translated to English) -* 2017-03-29 More keywords and replies added -* 2019-03-14 Replies and mapping reorganised for easier maintenance -* 2019-03-15 key map joined from keyword array and index map -* 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") -* 2019-11-28 New global type "History" (to ensure a homogenous array) + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } type { - * histArray contains the most recent user replies as ring buffer; - * histIndex is the index where the next reply is to be stored (= index of the oldest - * cached user reply). - * Note: The depth of the history is to be specified by initializing a variable of this type, - * e.g. for a history of depth 5: - * myhistory <- History{{"", "", "", "", ""{}, 0{} + histArray contains the most recent user replies as ring buffer; + histIndex is the index where the next reply is to be stored (= index of the oldest + cached user reply). + Note: The depth of the history is to be specified by initializing a variable of this type, + e.g. for a history of depth 5: + myhistory <- History{{"", "", "", "", ""{}, 0{} } History = RECORD histArray: array [0..49] of string; @@ -53,14 +52,14 @@ keyMap = setupKeywords(); var - index2881406f: 1..5; - array2881406f: array [1..5] of string; - indexb3ec7986: 1..2; - arrayb3ec7986: array [1..2] of string; + index3a2c1573: 1..5; + array3a2c1573: array [1..5] of string; + index450f7da8: 1..2; + array450f7da8: array [1..2] of string; varPart: String; { - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string } userInput: string; replyRing: ???; { FIXME! } @@ -72,8 +71,8 @@ isRepeated: boolean; isGone: boolean; { - * Stores the last five inputs of the user in a ring buffer, - * the second component is the rolling (over-)write index. + Stores the last five inputs of the user in a ring buffer, + the second component is the rolling (over-)write index. } history: History; findInfo: array [0..1] of Longint; @@ -101,11 +100,11 @@ function adjustSpelling(sentence: string): string; delete(result, 1, position); insert(uppercase(start), result, 1); end; - arrayb3ec7986[1] := ' i '; - arrayb3ec7986[2] := ' i\'''; - for indexb3ec7986 := 1 to 2 do + array450f7da8[1] := ' i '; + array450f7da8[2] := ' i\'''; + for index450f7da8 := 1 to 2 do begin - word := arrayb3ec7986[indexb3ec7986]; + word := array450f7da8[index450f7da8]; position := pos(word, result); while (position > 0) do begin @@ -270,14 +269,14 @@ function normalizeInput(sentence: string): string; begin sentence := lowercase(sentence); - array2881406f[1] := '.'; - array2881406f[2] := ','; - array2881406f[3] := ';'; - array2881406f[4] := '!'; - array2881406f[5] := '?'; - for index2881406f := 1 to 5 do + array3a2c1573[1] := '.'; + array3a2c1573[2] := ','; + array3a2c1573[3] := ';'; + array3a2c1573[4] := '!'; + array3a2c1573[5] := '?'; + for index3a2c1573 := 1 to 5 do begin - symbol := array2881406f[index2881406f]; + symbol := array3a2c1573[index3a2c1573]; position := pos(symbol, sentence); while (position > 0) do begin @@ -456,8 +455,8 @@ function setupReplies(): array [0..49] of array [0..49] of string; begin { - * We start with the highest index for performance reasons - * (is to avoid frequent array resizing) + We start with the highest index for performance reasons + (is to avoid frequent array resizing) } { Hint: Automatically decomposed array initialization } replies[29, 0] := 'Say, do you have any psychological problems?'; @@ -627,8 +626,8 @@ function setupReplies(): array [0..49] of array [0..49] of string; writeln('* (Requires at least Structorizer 3.30-03 to run)'); writeln('**********************************'); { - * Stores the last five inputs of the user in a ring buffer, - * the second component is the rolling (over-)write index. + Stores the last five inputs of the user in a ring buffer, + the second component is the rolling (over-)write index. } { Hint: Automatically decomposed array initialization } history.histArray[0] := ''; @@ -648,8 +647,8 @@ function setupReplies(): array [0..49] of array [0..49] of string; repeat readln(userInput); { - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string } userInput := normalizeInput(userInput); isGone := checkGoodBye(userInput, byePhrases); diff --git a/samples/export/Pascal/SORTING_TEST_MAIN.pas b/samples/export/Pascal/SORTING_TEST_MAIN.pas index 6d28e52f..08945935 100644 --- a/samples/export/Pascal/SORTING_TEST_MAIN.pas +++ b/samples/export/Pascal/SORTING_TEST_MAIN.pas @@ -1,19 +1,18 @@ +{ + Creates three equal arrays of numbers and has them sorted with different sorting algorithms + to allow performance comparison via execution counting ("Collect Runtime Data" should + sensibly be switched on). + Requested input data are: Number of elements (size) and filing mode. +} program SORTING_TEST_MAIN; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2019-10-02 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Creates three equal arrays of numbers and has them sorted with different sorting algorithms -* to allow performance comparison via execution counting ("Collect Runtime Data" should -* sensibly be switched on). -* Requested input data are: Number of elements (size) and filing mode. + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } var @@ -133,12 +132,12 @@ function partition(values: ???; start: ???; stop: ???; p: ???): Longint; start := start + 1; stop := stop - 1; { - * Still unseen elements? - * Loop invariants: - * 1. p = start - 1 - * 2. pivot = values[p] - * 3. i < start → values[i] ≤ pivot - * 4. stop < i → pivot < values[i] + Still unseen elements? + Loop invariants: + 1. p = start - 1 + 2. pivot = values[p] + 3. i < start → values[i] ≤ pivot + 4. stop < i → pivot < values[i] } while (start <= stop) do begin @@ -151,8 +150,8 @@ function partition(values: ???; start: ???; stop: ???; p: ???): Longint; values[p] := seen; values[start] := pivot; { - * Shift the border between lower and undicovered area, - * update pivot position. + Shift the border between lower and undicovered area, + update pivot position. } p := p + 1; start := start + 1; @@ -227,8 +226,8 @@ procedure quickSort(values: ???; start: ???; stop: ???); var { - * Partition the array into smaller and greater elements - * Get the resulting (and final) position of the pivot element + Partition the array into smaller and greater elements + Get the resulting (and final) position of the pivot element } p: ???; { FIXME! } @@ -237,13 +236,13 @@ procedure quickSort(values: ???; start: ???; stop: ???); if (stop >= start + 2) then begin { - * Select a pivot element, be p its index. - * (here: randomly chosen element out of start ... stop-1) + Select a pivot element, be p its index. + (here: randomly chosen element out of start ... stop-1) } p := random(stop-start) + start; { - * Partition the array into smaller and greater elements - * Get the resulting (and final) position of the pivot element + Partition the array into smaller and greater elements + Get the resulting (and final) position of the pivot element } p := partition(values, start, stop, p); { Sort subsequances separately and independently ... } diff --git a/samples/export/Pascal/TextDemo.pas b/samples/export/Pascal/TextDemo.pas index d22f2533..f87fb4d6 100644 --- a/samples/export/Pascal/TextDemo.pas +++ b/samples/export/Pascal/TextDemo.pas @@ -1,19 +1,18 @@ +{ + Demo program for routine drawText() + Asks the user to enter a text, a wanted text height and colour, + and then draws this string onto the turtle screen. Places every + entered text to a new line. +} program TextDemo; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2019-10-10 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Demo program for routine drawText() -* Asks the user to enter a text, a wanted text height and colour, -* and then draws this string onto the turtle screen. Places every -* entered text to a new line. + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } var @@ -617,8 +616,8 @@ procedure comma(h: ???; colorNo: ???); forward((c+b)/2.0 + c); { color = ffffff } penDown(); { - * Counterclockwise draw 3 edges of a square with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw 3 edges of a square with edge length c + in the colour endcoded by colorNo } polygonPart(c, 4, true, 3, colorNo); left(90); @@ -673,8 +672,8 @@ procedure exclMk(h: ???; colorNo: ???); left(90 + rotAngle); penDown(); { - * Clockwise draw 5 edges of an octagon with edge length b/2 - * in the colour endcoded by colorNo + Clockwise draw 5 edges of an octagon with edge length b/2 + in the colour endcoded by colorNo } polygonPart(b/2.0, 8, false, 5, colorNo); right(rotAngle2); @@ -689,8 +688,8 @@ procedure exclMk(h: ???; colorNo: ???); forward(c/2.0); { color = ffffff } penDown(); { - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo } polygonPart(c, 4, false, 4, colorNo); penUp(); @@ -723,8 +722,8 @@ procedure fullSt(h: ???; colorNo: ???); forward((c+b)/2.0 + c); { color = ffffff } penDown(); { - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo } polygonPart(c, 4, true, 4, colorNo); penUp(); @@ -798,8 +797,8 @@ procedure letterC(h: ???; colorNo: ???); penDown(); right(180); { - * Clockwise draws 3 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draws 3 edges of an octagon with edge length b in the colour + encoded by colorNo } polygonPart(b, 8, true, 3, colorNo); left(rotAngle); @@ -807,8 +806,8 @@ procedure letterC(h: ???; colorNo: ???); forward(2*b + 2*c); { color = ffffff } penDown(); { - * Counterclockwise draws 4 edges of an octagon with edge length b - * iin the colour encoded by colorNo + Counterclockwise draws 4 edges of an octagon with edge length b + iin the colour encoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -842,14 +841,14 @@ procedure letterD(h: ???; colorNo: ???); right(90); forward(c+b, colorNo); { - * Clockwise draw 2 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draw 2 edges of an octagon with edge length b in the colour + encoded by colorNo } polygonPart(b, 8, false, 2, colorNo); forward(b + 2*c, colorNo); { - * Clockwise draw 2 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draw 2 edges of an octagon with edge length b in the colour + encoded by colorNo } polygonPart(b, 8, false, 2, colorNo); forward(c, colorNo); @@ -883,8 +882,8 @@ procedure letterG(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 4 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b in + the colour encoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(c, colorNo); @@ -896,8 +895,8 @@ procedure letterG(h: ???; colorNo: ???); forward(b + c); { color = ffffff } penDown(); { - * Counterclockwise draw 4 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b in + the colour encoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -936,8 +935,8 @@ procedure letterJ(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 3 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 3 edges of an octagon with edge length b in + the colour encoded by colorNo } polygonPart(b, 8, true, 3, colorNo); left(rotAngle); @@ -970,14 +969,14 @@ procedure letterO(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); { - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -1011,8 +1010,8 @@ procedure letterP(h: ???; colorNo: ???); right(90); forward(c+b, colorNo); { - * Clockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Clockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, false, 4, colorNo); forward(c, colorNo); @@ -1051,14 +1050,14 @@ procedure letterQ(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); { - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -1099,8 +1098,8 @@ procedure letterR(h: ???; colorNo: ???); right(90); forward(c+b, colorNo); { - * Clockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Clockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, false, 4, colorNo); forward(c, colorNo); @@ -1136,13 +1135,13 @@ procedure letterS(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 6 edges of an octagon with edge length b - * in the colour encoded by colorNo + Counterclockwise draw 6 edges of an octagon with edge length b + in the colour encoded by colorNo } polygonPart(b, 8, true, 6, colorNo); { - * Clockwise draw 5 edges of an octagon with edge length b - * in the colour encoded by colorNo + Clockwise draw 5 edges of an octagon with edge length b + in the colour encoded by colorNo } polygonPart(b, 8, false, 5, colorNo); right(rotAngle); @@ -1217,8 +1216,8 @@ procedure qstnMk(h: ???; colorNo: ???); forward(h-c); { color = ffffff } penDown(); { - * Counterclockwise draw 5 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 5 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, false, 5, colorNo); forward(c, colorNo); @@ -1230,8 +1229,8 @@ procedure qstnMk(h: ???; colorNo: ???); forward(c/2.0); { color = ffffff } penDown(); { - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo } polygonPart(c, 4, false, 4, colorNo); penUp(); @@ -1283,8 +1282,8 @@ procedure drawText(text: string; h: Longint; c: Longint); else begin { - * "," cannot be chacked against because the comma is misinterpreted - * as selector list separator. + "," cannot be chacked against because the comma is misinterpreted + as selector list separator. } case (letter) of "A": diff --git a/samples/export_group/Oberon/ELIZA_2_2_arrz.Mod b/samples/export_group/Oberon/ELIZA_2_2_arrz.Mod index 1870fea3..806477cc 100644 --- a/samples/export_group/Oberon/ELIZA_2_2_arrz.Mod +++ b/samples/export_group/Oberon/ELIZA_2_2_arrz.Mod @@ -1,25 +1,25 @@ -MODULE ELIZA; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Concept and lisp implementation published by Joseph Weizenbaum (MIT): - * "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: - * Computational Linguistis 1(1966)9, pp. 36-45 - * Revision history: - * 2016-10-06 Initial version - * 2017-03-29 Two diagrams updated (comments translated to English) - * 2017-03-29 More keywords and replies added - * 2019-03-14 Replies and mapping reorganised for easier maintenance - * 2019-03-15 key map joined from keyword array and index map - * 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") + Concept and lisp implementation published by Joseph Weizenbaum (MIT): + "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: + Computational Linguistis 1(1966)9, pp. 36-45 + Revision history: + 2016-10-06 Initial version + 2017-03-29 Two diagrams updated (comments translated to English) + 2017-03-29 More keywords and replies added + 2019-03-14 Replies and mapping reorganised for easier maintenance + 2019-03-15 key map joined from keyword array and index map + 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") *) +MODULE ELIZA; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2018-05-14 ??? *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) TYPE @@ -29,17 +29,17 @@ TYPE END; VAR - index99919821: INTEGER; - array99919821: ARRAY 5 OF ARRAY 100 OF CHAR; - index9a6fd359: INTEGER; - indexe76a02f3: INTEGER; - indexd9fc2314: INTEGER; - arrayd9fc2314: ARRAY 2 OF ARRAY 100 OF CHAR; + index9218ddfe: INTEGER; + array9218ddfe: ARRAY 5 OF ARRAY 100 OF CHAR; + index827e4261: INTEGER; + indexf357b655: INTEGER; + indexb8030b03: INTEGER; + arrayb8030b03: ARRAY 2 OF ARRAY 100 OF CHAR; (* TODO: check and accomplish variable declarations *) varPart: ARRAY 128 OF CHAR; (* - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string *) userInput: ARRAY 128 OF CHAR; replyRing: ???; (* FIXME! *) @@ -51,18 +51,16 @@ VAR isRepeated: BOOLEAN; isGone: BOOLEAN; (* - * Stores the last five inputs of the user in a ring buffer, - * the first element is the current insertion index + Stores the last five inputs of the user in a ring buffer, + the first element is the current insertion index *) history: ARRAY 6 OF ???; (* FIXME! *) findInfo: ARRAY 2 OF INTEGER; entry: KeyMapEntry; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) +(* Cares for correct letter case among others *) PROCEDURE adjustSpelling(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; -(* - * Cares for correct letter case among others - *) VAR (* TODO: check and accomplish variable declarations *) word: ARRAY 128 OF CHAR; @@ -80,10 +78,10 @@ BEGIN delete(result, 1, position); insert(CAP(start), result, 1); END; - arrayd9fc2314[0] := " i "; - arrayd9fc2314[1] := " i\'"; - FOR indexd9fc2314 := 0 TO 1 DO - word := arrayd9fc2314[indexd9fc2314]; + arrayb8030b03[0] := " i "; + arrayb8030b03[1] := " i\'"; + FOR indexb8030b03 := 0 TO 1 DO + word := arrayb8030b03[indexb8030b03]; position := pos(word, result); WHILE position > 0 DO delete(result, position+1, 1); @@ -94,20 +92,20 @@ BEGIN RETURN result; END adjustSpelling; -PROCEDURE checkGoodBye(text: ARRAY 128 OF CHAR; VAR phrases: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR): BOOLEAN; (* - * Checks whether the given text contains some kind of - * good-bye phrase inducing the end of the conversation - * and if so writes a correspding good-bye message and - * returns true, otherwise false + Checks whether the given text contains some kind of + good-bye phrase inducing the end of the conversation + and if so writes a correspding good-bye message and + returns true, otherwise false *) +PROCEDURE checkGoodBye(text: ARRAY 128 OF CHAR; VAR phrases: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR): BOOLEAN; VAR (* TODO: check and accomplish variable declarations *) saidBye: BOOLEAN; pair: ARRAY 50 OF ARRAY 128 OF CHAR; BEGIN - FOR indexe76a02f3 := 0 TO LEN(phrases)-1 DO - pair := phrases[indexe76a02f3]; + FOR indexf357b655 := 0 TO LEN(phrases)-1 DO + pair := phrases[indexf357b655]; IF pos(pair[0], text) > 0 THEN saidBye := true; (* TODO: Replace "TYPE" by the the actual Out procedure name for this type and add a length argument where needed! *) @@ -119,11 +117,11 @@ BEGIN RETURN false; END checkGoodBye; -PROCEDURE checkRepetition(history: ARRAY; VAR newInput: ARRAY 128 OF CHAR): BOOLEAN; (* - * Checks whether newInput has occurred among the last - * length(history) - 1 input strings and updates the history + Checks whether newInput has occurred among the last + length(history) - 1 input strings and updates the history *) +PROCEDURE checkRepetition(history: ARRAY; VAR newInput: ARRAY 128 OF CHAR): BOOLEAN; VAR (* TODO: check and accomplish variable declarations *) i: INTEGER; @@ -155,8 +153,8 @@ VAR left: ARRAY 128 OF CHAR; BEGIN result := " " + copy(sentence, keyPos + length(key), length(sentence)) + " "; - FOR index9a6fd359 := 0 TO LEN(flexions)-1 DO - pair := flexions[index9a6fd359]; + FOR index827e4261 := 0 TO LEN(flexions)-1 DO + pair := flexions[index827e4261]; left := ""; right := result; position := pos(pair[0], right); @@ -177,12 +175,12 @@ BEGIN END conjugateStrings; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE normalizeInput(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; (* - * Converts the sentence to lowercase, eliminates all - * interpunction (i.e. ',', '.', ';'), and pads the - * sentence among blanks + Converts the sentence to lowercase, eliminates all + interpunction (i.e. ',', '.', ';'), and pads the + sentence among blanks *) +PROCEDURE normalizeInput(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; VAR (* TODO: check and accomplish variable declarations *) symbol: CHAR; @@ -190,13 +188,13 @@ VAR position: INTEGER; BEGIN sentence := lowercase(sentence); - array99919821[0] := '.'; - array99919821[1] := ','; - array99919821[2] := ';'; - array99919821[3] := '!'; - array99919821[4] := '?'; - FOR index99919821 := 0 TO 4 DO - symbol := array99919821[index99919821]; + array9218ddfe[0] := '.'; + array9218ddfe[1] := ','; + array9218ddfe[2] := ';'; + array9218ddfe[3] := '!'; + array9218ddfe[4] := '?'; + FOR index9218ddfe := 0 TO 4 DO + symbol := array9218ddfe[index9218ddfe]; position := pos(symbol, sentence); WHILE position > 0 DO sentence := copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence)); @@ -223,10 +221,8 @@ BEGIN END setupGoodByePhrases; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) +(* Returns an array of pairs of mutualy substitutable *) PROCEDURE setupReflexions: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR; -(* - * Returns an array of pairs of mutualy substitutable - *) VAR (* TODO: check and accomplish variable declarations *) reflexions: ARRAY 50 OF ARRAY 2 OF ARRAY 128 OF CHAR; @@ -265,20 +261,20 @@ BEGIN END setupReflexions; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; (* - * This routine sets up the reply rings addressed by the key words defined in - * routine `setupKeywords()´ and mapped hitherto by the cross table defined - * in `setupMapping()´ + This routine sets up the reply rings addressed by the key words defined in + routine `setupKeywords()´ and mapped hitherto by the cross table defined + in `setupMapping()´ *) +PROCEDURE setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; VAR (* TODO: check and accomplish variable declarations *) setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; replies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; BEGIN (* - * We start with the highest index for performance reasons - * (is to avoid frequent array resizing) + We start with the highest index for performance reasons + (is to avoid frequent array resizing) *) (* Hint: Automatically decomposed array initialization *) replies[29, 0] := "Say, do you have any psychological problems?"; @@ -434,15 +430,15 @@ BEGIN END setupReplies; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE findKeyword(keyMap: const ARRAY OF KeyMapEntry; VAR sentence: ARRAY 128 OF CHAR): ARRAY 2 OF INTEGER; (* - * Looks for the occurrence of the first of the strings - * contained in keywords within the given sentence (in - * array order). - * Returns an array of - * 0: the index of the first identified keyword (if any, otherwise -1), - * 1: the position inside sentence (0 if not found) + Looks for the occurrence of the first of the strings + contained in keywords within the given sentence (in + array order). + Returns an array of + 0: the index of the first identified keyword (if any, otherwise -1), + 1: the position inside sentence (0 if not found) *) +PROCEDURE findKeyword(keyMap: const ARRAY OF KeyMapEntry; VAR sentence: ARRAY 128 OF CHAR): ARRAY 2 OF INTEGER; CONST keyMap = null; @@ -471,12 +467,12 @@ BEGIN END findKeyword; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE setupKeywords: ARRAY 50 OF KeyMapEntry; (* - * The lower the index the higher the rank of the keyword (search is sequential). - * The index of the first keyword found in a user sentence maps to a respective - * reply ring as defined in `setupReplies()´. + The lower the index the higher the rank of the keyword (search is sequential). + The index of the first keyword found in a user sentence maps to a respective + reply ring as defined in `setupReplies()´. *) +PROCEDURE setupKeywords: ARRAY 50 OF KeyMapEntry; VAR (* TODO: check and accomplish variable declarations *) (* The empty key string (last entry) is the default clause - will always be found *) @@ -596,8 +592,8 @@ BEGIN Out.String("**********************************"); Out.Ln; (* - * Stores the last five inputs of the user in a ring buffer, - * the first element is the current insertion index + Stores the last five inputs of the user in a ring buffer, + the first element is the current insertion index *) (* Hint: Automatically decomposed array initialization *) history[0] := 0; @@ -619,8 +615,8 @@ BEGIN (* TODO: Replace "TYPE" by the the actual In procedure name for this type! *) In.TYPE(userInput); (* - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string *) userInput := normalizeInput(userInput); isGone := checkGoodBye(userInput, byePhrases); diff --git a/samples/export_group/Oberon/ELIZA_2_3_arrz.Mod b/samples/export_group/Oberon/ELIZA_2_3_arrz.Mod index 91f640da..0a870e48 100644 --- a/samples/export_group/Oberon/ELIZA_2_3_arrz.Mod +++ b/samples/export_group/Oberon/ELIZA_2_3_arrz.Mod @@ -1,36 +1,36 @@ -MODULE ELIZA; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Concept and lisp implementation published by Joseph Weizenbaum (MIT): - * "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: - * Computational Linguistis 1(1966)9, pp. 36-45 - * Revision history: - * 2016-10-06 Initial version - * 2017-03-29 Two diagrams updated (comments translated to English) - * 2017-03-29 More keywords and replies added - * 2019-03-14 Replies and mapping reorganised for easier maintenance - * 2019-03-15 key map joined from keyword array and index map - * 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") - * 2019-11-28 New global type "History" (to ensure a homogenous array) + Concept and lisp implementation published by Joseph Weizenbaum (MIT): + "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: + Computational Linguistis 1(1966)9, pp. 36-45 + Revision history: + 2016-10-06 Initial version + 2017-03-29 Two diagrams updated (comments translated to English) + 2017-03-29 More keywords and replies added + 2019-03-14 Replies and mapping reorganised for easier maintenance + 2019-03-15 key map joined from keyword array and index map + 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") + 2019-11-28 New global type "History" (to ensure a homogenous array) *) +MODULE ELIZA; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2018-05-14 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) TYPE (* - * histArray contains the most recent user replies as ring buffer; - * histIndex is the index where the next reply is to be stored (= index of the oldest - * cached user reply). - * Note: The depth of the history is to be specified by initializing a variable of this type, - * e.g. for a history of depth 5: - * myhistory <- History{{"", "", "", "", ""}, 0} + histArray contains the most recent user replies as ring buffer; + histIndex is the index where the next reply is to be stored (= index of the oldest + cached user reply). + Note: The depth of the history is to be specified by initializing a variable of this type, + e.g. for a history of depth 5: + myhistory <- History{{"", "", "", "", ""}, 0} *) History* = RECORD histArray: ARRAY 50 OF ARRAY 128 OF CHAR; @@ -44,17 +44,17 @@ TYPE END; VAR - index2881406f: INTEGER; - array2881406f: ARRAY 5 OF ARRAY 100 OF CHAR; - index59775136: INTEGER; - index35b297e8: INTEGER; - indexb3ec7986: INTEGER; - arrayb3ec7986: ARRAY 2 OF ARRAY 100 OF CHAR; + index3a2c1573: INTEGER; + array3a2c1573: ARRAY 5 OF ARRAY 100 OF CHAR; + index375b7e08: INTEGER; + index6e53e8a6: INTEGER; + index450f7da8: INTEGER; + array450f7da8: ARRAY 2 OF ARRAY 100 OF CHAR; (* TODO: check and accomplish variable declarations *) varPart: ARRAY 128 OF CHAR; (* - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string *) userInput: ARRAY 128 OF CHAR; replyRing: ???; (* FIXME! *) @@ -66,18 +66,16 @@ VAR isRepeated: BOOLEAN; isGone: BOOLEAN; (* - * Stores the last five inputs of the user in a ring buffer, - * the second component is the rolling (over-)write index. + Stores the last five inputs of the user in a ring buffer, + the second component is the rolling (over-)write index. *) history: History; findInfo: ARRAY 2 OF INTEGER; entry: KeyMapEntry; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) +(* Cares for correct letter case among others *) PROCEDURE adjustSpelling(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; -(* - * Cares for correct letter case among others - *) VAR (* TODO: check and accomplish variable declarations *) word: ARRAY 128 OF CHAR; @@ -95,10 +93,10 @@ BEGIN delete(result, 1, position); insert(CAP(start), result, 1); END; - arrayb3ec7986[0] := " i "; - arrayb3ec7986[1] := " i\'"; - FOR indexb3ec7986 := 0 TO 1 DO - word := arrayb3ec7986[indexb3ec7986]; + array450f7da8[0] := " i "; + array450f7da8[1] := " i\'"; + FOR index450f7da8 := 0 TO 1 DO + word := array450f7da8[index450f7da8]; position := pos(word, result); WHILE position > 0 DO delete(result, position+1, 1); @@ -109,19 +107,19 @@ BEGIN RETURN result; END adjustSpelling; -PROCEDURE checkGoodBye(text: ARRAY 128 OF CHAR; VAR phrases: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR): BOOLEAN; (* - * Checks whether the given text contains some kind of - * good-bye phrase inducing the end of the conversation - * and if so writes a correspding good-bye message and - * returns true, otherwise false + Checks whether the given text contains some kind of + good-bye phrase inducing the end of the conversation + and if so writes a correspding good-bye message and + returns true, otherwise false *) +PROCEDURE checkGoodBye(text: ARRAY 128 OF CHAR; VAR phrases: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR): BOOLEAN; VAR (* TODO: check and accomplish variable declarations *) pair: ARRAY 50 OF ARRAY 128 OF CHAR; BEGIN - FOR index35b297e8 := 0 TO LEN(phrases)-1 DO - pair := phrases[index35b297e8]; + FOR index6e53e8a6 := 0 TO LEN(phrases)-1 DO + pair := phrases[index6e53e8a6]; IF pos(pair[0], text) > 0 THEN (* TODO: Replace "TYPE" by the the actual Out procedure name for this type and add a length argument where needed! *) Out.TYPE(pair[1]); @@ -143,8 +141,8 @@ VAR left: ARRAY 128 OF CHAR; BEGIN result := " " + copy(sentence, keyPos + length(key), length(sentence)) + " "; - FOR index59775136 := 0 TO LEN(flexions)-1 DO - pair := flexions[index59775136]; + FOR index375b7e08 := 0 TO LEN(flexions)-1 DO + pair := flexions[index375b7e08]; left := ""; right := result; position := pos(pair[0], right); @@ -165,12 +163,12 @@ BEGIN END conjugateStrings; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE normalizeInput(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; (* - * Converts the sentence to lowercase, eliminates all - * interpunction (i.e. ',', '.', ';'), and pads the - * sentence among blanks + Converts the sentence to lowercase, eliminates all + interpunction (i.e. ',', '.', ';'), and pads the + sentence among blanks *) +PROCEDURE normalizeInput(sentence: ARRAY 128 OF CHAR): ARRAY 128 OF CHAR; VAR (* TODO: check and accomplish variable declarations *) symbol: CHAR; @@ -178,13 +176,13 @@ VAR position: INTEGER; BEGIN sentence := lowercase(sentence); - array2881406f[0] := '.'; - array2881406f[1] := ','; - array2881406f[2] := ';'; - array2881406f[3] := '!'; - array2881406f[4] := '?'; - FOR index2881406f := 0 TO 4 DO - symbol := array2881406f[index2881406f]; + array3a2c1573[0] := '.'; + array3a2c1573[1] := ','; + array3a2c1573[2] := ';'; + array3a2c1573[3] := '!'; + array3a2c1573[4] := '?'; + FOR index3a2c1573 := 0 TO 4 DO + symbol := array3a2c1573[index3a2c1573]; position := pos(symbol, sentence); WHILE position > 0 DO sentence := copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence)); @@ -211,10 +209,8 @@ BEGIN END setupGoodByePhrases; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) +(* Returns an array of pairs of mutualy substitutable *) PROCEDURE setupReflexions: ARRAY OF ARRAY 2 OF ARRAY 128 OF CHAR; -(* - * Returns an array of pairs of mutualy substitutable - *) VAR (* TODO: check and accomplish variable declarations *) reflexions: ARRAY 50 OF ARRAY 2 OF ARRAY 128 OF CHAR; @@ -253,20 +249,20 @@ BEGIN END setupReflexions; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; (* - * This routine sets up the reply rings addressed by the key words defined in - * routine `setupKeywords()´ and mapped hitherto by the cross table defined - * in `setupMapping()´ + This routine sets up the reply rings addressed by the key words defined in + routine `setupKeywords()´ and mapped hitherto by the cross table defined + in `setupMapping()´ *) +PROCEDURE setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; VAR (* TODO: check and accomplish variable declarations *) setupReplies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; replies: ARRAY 50 OF ARRAY 50 OF ARRAY 128 OF CHAR; BEGIN (* - * We start with the highest index for performance reasons - * (is to avoid frequent array resizing) + We start with the highest index for performance reasons + (is to avoid frequent array resizing) *) (* Hint: Automatically decomposed array initialization *) replies[29, 0] := "Say, do you have any psychological problems?"; @@ -421,11 +417,11 @@ BEGIN RETURN setupReplies; END setupReplies; -PROCEDURE checkRepetition(history: History; VAR newInput: ARRAY 128 OF CHAR): BOOLEAN; (* - * Checks whether newInput has occurred among the recently cached - * input strings in the histArray component of history and updates the history. + Checks whether newInput has occurred among the recently cached + input strings in the histArray component of history and updates the history. *) +PROCEDURE checkRepetition(history: History; VAR newInput: ARRAY 128 OF CHAR): BOOLEAN; VAR (* TODO: check and accomplish variable declarations *) i: INTEGER; @@ -447,15 +443,15 @@ BEGIN END checkRepetition; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE findKeyword(keyMap: const ARRAY OF KeyMapEntry; VAR sentence: ARRAY 128 OF CHAR): ARRAY 2 OF INTEGER; (* - * Looks for the occurrence of the first of the strings - * contained in keywords within the given sentence (in - * array order). - * Returns an array of - * 0: the index of the first identified keyword (if any, otherwise -1), - * 1: the position inside sentence (0 if not found) + Looks for the occurrence of the first of the strings + contained in keywords within the given sentence (in + array order). + Returns an array of + 0: the index of the first identified keyword (if any, otherwise -1), + 1: the position inside sentence (0 if not found) *) +PROCEDURE findKeyword(keyMap: const ARRAY OF KeyMapEntry; VAR sentence: ARRAY 128 OF CHAR): ARRAY 2 OF INTEGER; CONST keyMap = null; @@ -484,12 +480,12 @@ BEGIN END findKeyword; (* TODO: Oberon doesn't permit to return arrays - pass the result in a different way! *) -PROCEDURE setupKeywords: ARRAY 50 OF KeyMapEntry; (* - * The lower the index the higher the rank of the keyword (search is sequential). - * The index of the first keyword found in a user sentence maps to a respective - * reply ring as defined in `setupReplies()´. + The lower the index the higher the rank of the keyword (search is sequential). + The index of the first keyword found in a user sentence maps to a respective + reply ring as defined in `setupReplies()´. *) +PROCEDURE setupKeywords: ARRAY 50 OF KeyMapEntry; VAR (* TODO: check and accomplish variable declarations *) (* The empty key string (last entry) is the default clause - will always be found *) @@ -584,12 +580,12 @@ BEGIN Out.Open; (* BEGIN initialization for "History" *) (* - * histArray contains the most recent user replies as ring buffer; - * histIndex is the index where the next reply is to be stored (= index of the oldest - * cached user reply). - * Note: The depth of the history is to be specified by initializing a variable of this type, - * e.g. for a history of depth 5: - * myhistory <- History{{"", "", "", "", ""}, 0} + histArray contains the most recent user replies as ring buffer; + histIndex is the index where the next reply is to be stored (= index of the oldest + cached user reply). + Note: The depth of the history is to be specified by initializing a variable of this type, + e.g. for a history of depth 5: + myhistory <- History{{"", "", "", "", ""}, 0} *) (* END initialization for "History" *) (* BEGIN initialization for "KeyMapEntry" *) @@ -622,8 +618,8 @@ BEGIN Out.String("**********************************"); Out.Ln; (* - * Stores the last five inputs of the user in a ring buffer, - * the second component is the rolling (over-)write index. + Stores the last five inputs of the user in a ring buffer, + the second component is the rolling (over-)write index. *) (* Hint: Automatically decomposed array initialization *) history.histArray[0] := ""; @@ -645,8 +641,8 @@ BEGIN (* TODO: Replace "TYPE" by the the actual In procedure name for this type! *) In.TYPE(userInput); (* - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string *) userInput := normalizeInput(userInput); isGone := checkGoodBye(userInput, byePhrases); diff --git a/samples/export_group/Oberon/FileApiGroupTest_arrz.Mod b/samples/export_group/Oberon/FileApiGroupTest_arrz.Mod index 9393fd28..4a327320 100644 --- a/samples/export_group/Oberon/FileApiGroupTest_arrz.Mod +++ b/samples/export_group/Oberon/FileApiGroupTest_arrz.Mod @@ -1,26 +1,26 @@ MODULE FileApiGroupTest_arrz; -(* Generated by Structorizer 3.30-08 *) +(* Generated by Structorizer 3.30-09 *) (* - * NOTE: - * This first module of the file is a library module providing common resources - * for the following modules, which are separated by comment lines like - * "======= 8< =======...". - * You may have to cut this file apart at these lines in order to get the parts - * running, since the following modules may form sort of mutually independent - * applications or programs the coexistence of which in a single file might not - * be sensible. + NOTE: + This first module of the file is a library module providing common resources + for the following modules, which are separated by comment lines like + "======= 8< =======...". + You may have to cut this file apart at these lines in order to get the parts + running, since the following modules may form sort of mutually independent + applications or programs the coexistence of which in a single file might not + be sensible. *) -(* Copyright (C) 2020-04-23 kay *) +(* Copyright (C) 2020-04-24 kay *) -PROCEDURE drawBarChart*(values: ARRAY 50 OF LONGREAL; nValues: ???); (* - * Draws a bar chart from the array "values" of size nValues. - * Turtleizer must be activated and will scale the chart into a square of - * 500 x 500 pixels - * Note: The function is not robust against empty array or totally equal values. + Draws a bar chart from the array "values" of size nValues. + Turtleizer must be activated and will scale the chart into a square of + 500 x 500 pixels + Note: The function is not robust against empty array or totally equal values. *) +PROCEDURE drawBarChart*(values: ARRAY 50 OF LONGREAL; nValues: ???); CONST (* Used range of the Turtleizer screen *) xSize = 500; @@ -102,12 +102,12 @@ BEGIN END; END drawBarChart; -PROCEDURE readNumbers*(fileName: ARRAY 128 OF CHAR; VAR numbers: ARRAY 50 OF INTEGER; maxNumbers: INTEGER): INTEGER; (* - * Tries to read as many integer values as possible upto maxNumbers - * from file fileName into the given array numbers. - * Returns the number of the actually read numbers. May cause an exception. + Tries to read as many integer values as possible upto maxNumbers + from file fileName into the given array numbers. + Returns the number of the actually read numbers. May cause an exception. *) +PROCEDURE readNumbers*(fileName: ARRAY 128 OF CHAR; VAR numbers: ARRAY 50 OF INTEGER; maxNumbers: INTEGER): INTEGER; VAR (* TODO: check and accomplish variable declarations *) number: INTEGER; @@ -141,26 +141,26 @@ END FileApiGroupTest_arrz. (* ======= 8< =========================================================== *) -MODULE ComputeSum; -(* Generated by Structorizer 3.30-08 *) -IMPORT FileApiGroupTest_arrz,In,Out; (* - * Computes the sum and average of the numbers read from a user-specified - * text file (which might have been created via generateRandomNumberFile(4)). - * - * This program is part of an arrangement used to test group code export (issue - * #828) with FileAPI dependency. - * The input check loop has been disabled (replaced by a simple unchecked input - * instruction) in order to test the effect of indirect FileAPI dependency (only the - * called subroutine directly requires FileAPI now). + Computes the sum and average of the numbers read from a user-specified + text file (which might have been created via generateRandomNumberFile(4)). + + This program is part of an arrangement used to test group code export (issue + #828) with FileAPI dependency. + The input check loop has been disabled (replaced by a simple unchecked input + instruction) in order to test the effect of indirect FileAPI dependency (only the + called subroutine directly requires FileAPI now). *) +MODULE ComputeSum; +(* Generated by Structorizer 3.30-09 *) +IMPORT FileApiGroupTest_arrz,In,Out; (* Copyright (C) 2020-03-21 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR @@ -183,8 +183,8 @@ BEGIN (* TODO: Replace "TYPE" by the the actual In procedure name for this type! *) Out.String("Name/path of the number file"); In.TYPE(file_name); (* - * If you enable this loop, then the preceding input instruction is to be disabled - * and the fileClose instruction in the alternative below is to be enabled. + If you enable this loop, then the preceding input instruction is to be disabled + and the fileClose instruction in the alternative below is to be enabled. *) (* REPEAT *) (* TODO: Replace "TYPE" by the the actual In procedure name for this type! *) @@ -222,20 +222,20 @@ END ComputeSum. (* ======= 8< =========================================================== *) -MODULE DrawRandomHistogram; -(* Generated by Structorizer 3.30-08 *) -IMPORT FileApiGroupTest_arrz,In,Out; (* - * Reads a random number file and draws a histogram accotrding to the - * user specifications + Reads a random number file and draws a histogram accotrding to the + user specifications *) +MODULE DrawRandomHistogram; +(* Generated by Structorizer 3.30-09 *) +IMPORT FileApiGroupTest_arrz,In,Out; (* Copyright (C) 2020-03-21 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR @@ -345,23 +345,23 @@ END DrawRandomHistogram. (* ======= 8< =========================================================== *) MODULE generateRandomNumberFile; -(* Generated by Structorizer 3.30-08 *) +(* Generated by Structorizer 3.30-09 *) IMPORT In,Out; -PROCEDURE generateRandomNumberFile*(fileName: ARRAY 128 OF CHAR; count, minVal, maxVal: INTEGER): INTEGER; (* - * Writes a text file with name fileName, consisting of count lines, each containing - * a random number in the range from minVal to maxVal (both inclusive). - * Returns either the number of written number if all went well or some potential - * error code if something went wrong. + Writes a text file with name fileName, consisting of count lines, each containing + a random number in the range from minVal to maxVal (both inclusive). + Returns either the number of written number if all went well or some potential + error code if something went wrong. *) +PROCEDURE generateRandomNumberFile*(fileName: ARRAY 128 OF CHAR; count, minVal, maxVal: INTEGER): INTEGER; (* Copyright (C) 2020-03-21 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR diff --git a/samples/export_group/Oberon/SORTING_TEST_arrz.Mod b/samples/export_group/Oberon/SORTING_TEST_arrz.Mod index 1bbedd1d..893b2ce3 100644 --- a/samples/export_group/Oberon/SORTING_TEST_arrz.Mod +++ b/samples/export_group/Oberon/SORTING_TEST_arrz.Mod @@ -1,19 +1,19 @@ -MODULE SORTING_TEST_MAIN; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Creates three equal arrays of numbers and has them sorted with different sorting algorithms - * to allow performance comparison via execution counting ("Collect Runtime Data" should - * sensibly be switched on). - * Requested input data are: Number of elements (size) and filing mode. + Creates three equal arrays of numbers and has them sorted with different sorting algorithms + to allow performance comparison via execution counting ("Collect Runtime Data" should + sensibly be switched on). + Requested input data are: Number of elements (size) and filing mode. *) +MODULE SORTING_TEST_MAIN; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2019-10-02 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR @@ -29,15 +29,15 @@ VAR i: INTEGER; elementCount: ???; (* FIXME! *) -PROCEDURE bubbleSort(values: ???); (* - * Implements the well-known BubbleSort algorithm. - * Compares neigbouring elements and swaps them in case of an inversion. - * Repeats this while inversions have been found. After every - * loop passage at least one element (the largest one out of the - * processed subrange) finds its final place at the end of the - * subrange. + Implements the well-known BubbleSort algorithm. + Compares neigbouring elements and swaps them in case of an inversion. + Repeats this while inversions have been found. After every + loop passage at least one element (the largest one out of the + processed subrange) finds its final place at the end of the + subrange. *) +PROCEDURE bubbleSort(values: ???); VAR (* TODO: check and accomplish variable declarations *) temp: ???; (* FIXME! *) @@ -61,13 +61,13 @@ BEGIN UNTIL posSwapped < 0; END bubbleSort; -PROCEDURE maxHeapify(heap: ???; i: ???; range: ???); (* - * Given a max-heap 'heap´ with element at index 'i´ possibly - * violating the heap property wrt. its subtree upto and including - * index range-1, restores heap property in the subtree at index i - * again. + Given a max-heap 'heap´ with element at index 'i´ possibly + violating the heap property wrt. its subtree upto and including + index range-1, restores heap property in the subtree at index i + again. *) +PROCEDURE maxHeapify(heap: ???; i: ???; range: ???); VAR (* TODO: check and accomplish variable declarations *) temp: ???; (* FIXME! *) @@ -96,17 +96,17 @@ BEGIN END; END maxHeapify; -PROCEDURE partition(values: ???; start: ???; stop: ???; p: ???): INTEGER; (* - * Partitions array 'values´ between indices 'start´ und 'stop´-1 with - * respect to the pivot element initially at index 'p´ into smaller - * and greater elements. - * Returns the new (and final) index of the pivot element (which - * separates the sequence of smaller elements from the sequence - * of greater elements). - * This is not the most efficient algorithm (about half the swapping - * might still be avoided) but it is pretty clear. + Partitions array 'values´ between indices 'start´ und 'stop´-1 with + respect to the pivot element initially at index 'p´ into smaller + and greater elements. + Returns the new (and final) index of the pivot element (which + separates the sequence of smaller elements from the sequence + of greater elements). + This is not the most efficient algorithm (about half the swapping + might still be avoided) but it is pretty clear. *) +PROCEDURE partition(values: ???; start: ???; stop: ???; p: ???): INTEGER; VAR (* TODO: check and accomplish variable declarations *) (* Fetch the first element of the undiscovered area *) @@ -124,12 +124,12 @@ BEGIN start := start + 1; stop := stop - 1; (* - * Still unseen elements? - * Loop invariants: - * 1. p = start - 1 - * 2. pivot = values[p] - * 3. i < start → values[i] ≤ pivot - * 4. stop < i → pivot < values[i] + Still unseen elements? + Loop invariants: + 1. p = start - 1 + 2. pivot = values[p] + 3. i < start → values[i] ≤ pivot + 4. stop < i → pivot < values[i] *) WHILE start <= stop DO (* Fetch the first element of the undiscovered area *) @@ -140,8 +140,8 @@ BEGIN values[p] := seen; values[start] := pivot; (* - * Shift the border between lower and undicovered area, - * update pivot position. + Shift the border between lower and undicovered area, + update pivot position. *) p := p + 1; start := start + 1; @@ -157,10 +157,8 @@ BEGIN RETURN p; END partition; +(* Checks whether or not the passed-in array is (ascendingly) sorted. *) PROCEDURE testSorted(numbers: ???): BOOLEAN; -(* - * Checks whether or not the passed-in array is (ascendingly) sorted. - *) VAR (* TODO: check and accomplish variable declarations *) isSorted: BOOLEAN; @@ -181,13 +179,13 @@ BEGIN RETURN isSorted; END testSorted; -PROCEDURE buildMaxHeap(heap: ???); (* - * Runs through the array heap and converts it to a max-heap - * in a bottom-up manner, i.e. starts above the "leaf" level - * (index >= length(heap) div 2) and goes then up towards - * the root. + Runs through the array heap and converts it to a max-heap + in a bottom-up manner, i.e. starts above the "leaf" level + (index >= length(heap) div 2) and goes then up towards + the root. *) +PROCEDURE buildMaxHeap(heap: ???); VAR (* TODO: check and accomplish variable declarations *) lgth: INTEGER; @@ -199,30 +197,30 @@ BEGIN END; END buildMaxHeap; -PROCEDURE quickSort(values: ???; start: ???; stop: ???); (* - * Recursively sorts a subrange of the given array 'values´. - * start is the first index of the subsequence to be sorted, - * stop is the index BEHIND the subsequence to be sorted. + Recursively sorts a subrange of the given array 'values´. + start is the first index of the subsequence to be sorted, + stop is the index BEHIND the subsequence to be sorted. *) +PROCEDURE quickSort(values: ???; start: ???; stop: ???); VAR (* TODO: check and accomplish variable declarations *) (* - * Partition the array into smaller and greater elements - * Get the resulting (and final) position of the pivot element + Partition the array into smaller and greater elements + Get the resulting (and final) position of the pivot element *) p: ???; (* FIXME! *) BEGIN (* At least 2 elements? (Less don't make sense.) *) IF stop >= start + 2 THEN (* - * Select a pivot element, be p its index. - * (here: randomly chosen element out of start ... stop-1) + Select a pivot element, be p its index. + (here: randomly chosen element out of start ... stop-1) *) p := random(stop-start) + start; (* - * Partition the array into smaller and greater elements - * Get the resulting (and final) position of the pivot element + Partition the array into smaller and greater elements + Get the resulting (and final) position of the pivot element *) p := partition(values, start, stop, p); (* Sort subsequances separately and independently ... *) @@ -256,11 +254,11 @@ BEGIN END; END quickSort; -PROCEDURE heapSort(values: ???); (* - * Sorts the array 'values´ of numbers according to he heap sort - * algorithm + Sorts the array 'values´ of numbers according to he heap sort + algorithm *) +PROCEDURE heapSort(values: ???); VAR (* TODO: check and accomplish variable declarations *) (* Swap the maximum value (root of the heap) to the heap end *) diff --git a/samples/export_group/Oberon/TextWriter_arrz.Mod b/samples/export_group/Oberon/TextWriter_arrz.Mod index 72cb7606..17d2d87d 100644 --- a/samples/export_group/Oberon/TextWriter_arrz.Mod +++ b/samples/export_group/Oberon/TextWriter_arrz.Mod @@ -1,19 +1,19 @@ -MODULE TextDemo; -(* Generated by Structorizer 3.30-08 *) -IMPORT In,Out; (* - * Demo program for routine drawText() - * Asks the user to enter a text, a wanted text height and colour, - * and then draws this string onto the turtle screen. Places every - * entered text to a new line. + Demo program for routine drawText() + Asks the user to enter a text, a wanted text height and colour, + and then draws this string onto the turtle screen. Places every + entered text to a new line. *) +MODULE TextDemo; +(* Generated by Structorizer 3.30-09 *) +IMPORT In,Out; (* Copyright (C) 2019-10-10 Kay Gürtzig *) (* License: GPLv3-link *) (* - * GNU General Public License (V 3) - * https://www.gnu.org/licenses/gpl.html - * http://www.gnu.de/documents/gpl.de.html + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html *) VAR @@ -24,10 +24,8 @@ VAR height: ???; (* FIXME! *) colour: ???; (* FIXME! *) +(* Draws a blank for font height h, ignoring the colorNo *) PROCEDURE blank(h: ???; colorNo: ???); -(* - * Draws a blank for font height h, ignoring the colorNo - *) VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -75,11 +73,11 @@ BEGIN END; END forward; -PROCEDURE letterA(h: ???; colorNo: ???); (* - * Draws letter A in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter A in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterA(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -103,11 +101,11 @@ BEGIN right(rotAngle); END letterA; -PROCEDURE letterE(h: ???; colorNo: ???); (* - * Draws letter E in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter E in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterE(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -131,11 +129,11 @@ BEGIN left(90); END letterE; -PROCEDURE letterF(h: ???; colorNo: ???); (* - * Draws letter F in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter F in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterF(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -159,11 +157,11 @@ BEGIN left(90); END letterF; -PROCEDURE letterH(h: ???; colorNo: ???); (* - * Draws letter H in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter H in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterH(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -186,11 +184,11 @@ BEGIN left(180); END letterH; -PROCEDURE letterI(h: ???; colorNo: ???); (* - * Draws letter I in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter I in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterI(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the corner triangle outside the octagon *) @@ -224,11 +222,11 @@ BEGIN penDown(); END letterI; -PROCEDURE letterK(h: ???; colorNo: ???); (* - * Draws letter K in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter K in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterK(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -248,11 +246,11 @@ BEGIN left(135); END letterK; -PROCEDURE letterL(h: ???; colorNo: ???); (* - * Draws letter L in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter L in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterL(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -267,11 +265,11 @@ BEGIN left(90); END letterL; -PROCEDURE letterM(h: ???; colorNo: ???); (* - * Draws letter M in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter M in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterM(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -290,11 +288,11 @@ BEGIN forward(-h, colorNo); END letterM; -PROCEDURE letterN(h: ???; colorNo: ???); (* - * Draws letter N in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter N in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterN(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -314,11 +312,11 @@ BEGIN penDown(); END letterN; -PROCEDURE letterT(h: ???; colorNo: ???); (* - * Draws letter T in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter T in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterT(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -341,11 +339,11 @@ BEGIN left(90); END letterT; -PROCEDURE letterV(h: ???; colorNo: ???); (* - * Draws letter V in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter V in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterV(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -368,11 +366,11 @@ BEGIN penDown(); END letterV; -PROCEDURE letterW(h: ???; colorNo: ???); (* - * Draws letter W in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter W in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterW(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width_3: ???; (* FIXME! *) @@ -405,11 +403,11 @@ BEGIN penDown(); END letterW; -PROCEDURE letterX(h: ???; colorNo: ???); (* - * Draws letter X in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter X in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterX(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -430,11 +428,11 @@ BEGIN right(rotAngle); END letterX; -PROCEDURE letterY(h: ???; colorNo: ???); (* - * Draws letter Y in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter Y in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterY(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -462,11 +460,11 @@ BEGIN penDown(); END letterY; -PROCEDURE letterZ(h: ???; colorNo: ???); (* - * Draws letter Z in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter Z in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterZ(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -488,11 +486,11 @@ BEGIN left(90); END letterZ; -PROCEDURE polygonPart(a: LONGREAL; n: INTEGER; ctrclkws: BOOLEAN; nEdges, color: INTEGER); (* - * Draws nEdges edges of a regular n-polygon with edge length a - * counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false. + Draws nEdges edges of a regular n-polygon with edge length a + counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false. *) +PROCEDURE polygonPart(a: LONGREAL; n: INTEGER; ctrclkws: BOOLEAN; nEdges, color: INTEGER); VAR (* TODO: check and accomplish variable declarations *) rotAngle: ???; (* FIXME! *) @@ -508,11 +506,11 @@ BEGIN END; END polygonPart; -PROCEDURE charDummy(h: ???; colorNo: ???); (* - * Draws a dummy character (small centered square) with font height h and - * the colour encoded by colorNo + Draws a dummy character (small centered square) with font height h and + the colour encoded by colorNo *) +PROCEDURE charDummy(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -544,11 +542,11 @@ BEGIN penDown(); END charDummy; -PROCEDURE comma(h: ???; colorNo: ???); (* - * Draws a comma in colour specified by colorNo with font height h - * from the current turtle position. + Draws a comma in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE comma(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) rotAngle: LONGREAL; @@ -569,8 +567,8 @@ BEGIN forward((c+b)/2.0 + c); (* color = ffffff *) penDown(); (* - * Counterclockwise draw 3 edges of a square with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw 3 edges of a square with edge length c + in the colour endcoded by colorNo *) polygonPart(c, 4, true, 3, colorNo); left(90); @@ -586,11 +584,11 @@ BEGIN penDown(); END comma; -PROCEDURE exclMk(h: ???; colorNo: ???); (* - * Draws an exclamation mark in the colour encoded by colorNo with font height h - * from the current turtle position. + Draws an exclamation mark in the colour encoded by colorNo with font height h + from the current turtle position. *) +PROCEDURE exclMk(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) width: ???; (* FIXME! *) @@ -623,8 +621,8 @@ BEGIN left(90 + rotAngle); penDown(); (* - * Clockwise draw 5 edges of an octagon with edge length b/2 - * in the colour endcoded by colorNo + Clockwise draw 5 edges of an octagon with edge length b/2 + in the colour endcoded by colorNo *) polygonPart(b/2.0, 8, false, 5, colorNo); right(rotAngle2); @@ -639,8 +637,8 @@ BEGIN forward(c/2.0); (* color = ffffff *) penDown(); (* - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo *) polygonPart(c, 4, false, 4, colorNo); penUp(); @@ -650,11 +648,11 @@ BEGIN penDown(); END exclMk; -PROCEDURE fullSt(h: ???; colorNo: ???); (* - * Draws a full stop in colour specified by colorNo with font height h - * from the current turtle position. + Draws a full stop in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE fullSt(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the outer corner triangle of the octagon *) @@ -671,8 +669,8 @@ BEGIN forward((c+b)/2.0 + c); (* color = ffffff *) penDown(); (* - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo *) polygonPart(c, 4, true, 4, colorNo); penUp(); @@ -681,11 +679,11 @@ BEGIN penDown(); END fullSt; -PROCEDURE letterB(h: ???; colorNo: ???); (* - * Draws letter B in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter B in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterB(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the outer corner triangle of the octagon *) @@ -717,11 +715,11 @@ BEGIN left(90); END letterB; -PROCEDURE letterC(h: ???; colorNo: ???); (* - * Draws letter C in the colour encoded by colorNo with font height h - * from the current turtle position. + Draws letter C in the colour encoded by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterC(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -742,8 +740,8 @@ BEGIN penDown(); right(180); (* - * Clockwise draws 3 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draws 3 edges of an octagon with edge length b in the colour + encoded by colorNo *) polygonPart(b, 8, true, 3, colorNo); left(rotAngle); @@ -751,8 +749,8 @@ BEGIN forward(2*b + 2*c); (* color = ffffff *) penDown(); (* - * Counterclockwise draws 4 edges of an octagon with edge length b - * iin the colour encoded by colorNo + Counterclockwise draws 4 edges of an octagon with edge length b + iin the colour encoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -764,11 +762,11 @@ BEGIN left(90); END letterC; -PROCEDURE letterD(h: ???; colorNo: ???); (* - * Draws letter D in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter D in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterD(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the outer corner triangle of the octagon *) @@ -784,14 +782,14 @@ BEGIN right(90); forward(c+b, colorNo); (* - * Clockwise draw 2 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draw 2 edges of an octagon with edge length b in the colour + encoded by colorNo *) polygonPart(b, 8, false, 2, colorNo); forward(b + 2*c, colorNo); (* - * Clockwise draw 2 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draw 2 edges of an octagon with edge length b in the colour + encoded by colorNo *) polygonPart(b, 8, false, 2, colorNo); forward(c, colorNo); @@ -802,11 +800,11 @@ BEGIN left(90); END letterD; -PROCEDURE letterG(h: ???; colorNo: ???); (* - * Draws letter G in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter G in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterG(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the corner triangle outside the octagon. *) @@ -823,8 +821,8 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 4 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b in + the colour encoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(c, colorNo); @@ -836,8 +834,8 @@ BEGIN forward(b + c); (* color = ffffff *) penDown(); (* - * Counterclockwise draw 4 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b in + the colour encoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -849,11 +847,11 @@ BEGIN left(90); END letterG; -PROCEDURE letterJ(h: ???; colorNo: ???); (* - * Draws letter J in colour encoded by colorNo with font height h - * from the current turtle position. + Draws letter J in colour encoded by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterJ(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -874,8 +872,8 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 3 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 3 edges of an octagon with edge length b in + the colour encoded by colorNo *) polygonPart(b, 8, true, 3, colorNo); left(rotAngle); @@ -885,11 +883,11 @@ BEGIN penDown(); END letterJ; -PROCEDURE letterO(h: ???; colorNo: ???); (* - * Draws letter O in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter O in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterO(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the corner triangle outside the octagon *) @@ -906,14 +904,14 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); (* - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -925,11 +923,11 @@ BEGIN left(90); END letterO; -PROCEDURE letterP(h: ???; colorNo: ???); (* - * Draws letter P in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter P in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterP(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* Cathetus of the corner triangle outside the octagon *) @@ -945,8 +943,8 @@ BEGIN right(90); forward(c+b, colorNo); (* - * Clockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Clockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, false, 4, colorNo); forward(c, colorNo); @@ -958,11 +956,11 @@ BEGIN left(180); END letterP; -PROCEDURE letterQ(h: ???; colorNo: ???); (* - * Draws letter Q in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter Q in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterQ(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -983,14 +981,14 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); (* - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -1005,11 +1003,11 @@ BEGIN left(90 + rotAngle); END letterQ; -PROCEDURE letterR(h: ???; colorNo: ???); (* - * Zeichnet den Buchstaben R von der Turtleposition aus - * mit Zeilenhöhe h + Zeichnet den Buchstaben R von der Turtleposition aus + mit Zeilenhöhe h *) +PROCEDURE letterR(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -1029,8 +1027,8 @@ BEGIN right(90); forward(c+b, colorNo); (* - * Clockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Clockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, false, 4, colorNo); forward(c, colorNo); @@ -1039,11 +1037,11 @@ BEGIN left(90 + rotAngle); END letterR; -PROCEDURE letterS(h: ???; colorNo: ???); (* - * Draws letter S in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter S in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterS(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -1064,13 +1062,13 @@ BEGIN penDown(); right(180); (* - * Counterclockwise draw 6 edges of an octagon with edge length b - * in the colour encoded by colorNo + Counterclockwise draw 6 edges of an octagon with edge length b + in the colour encoded by colorNo *) polygonPart(b, 8, true, 6, colorNo); (* - * Clockwise draw 5 edges of an octagon with edge length b - * in the colour encoded by colorNo + Clockwise draw 5 edges of an octagon with edge length b + in the colour encoded by colorNo *) polygonPart(b, 8, false, 5, colorNo); right(rotAngle); @@ -1080,11 +1078,11 @@ BEGIN left(180); END letterS; -PROCEDURE letterU(h: ???; colorNo: ???); (* - * Draws letter U in colour specified by colorNo with font height h - * from the current turtle position. + Draws letter U in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE letterU(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -1117,11 +1115,11 @@ BEGIN penDown(); END letterU; -PROCEDURE qstnMk(h: ???; colorNo: ???); (* - * Draws a question mark in colour specified by colorNo with font height h - * from the current turtle position. + Draws a question mark in colour specified by colorNo with font height h + from the current turtle position. *) +PROCEDURE qstnMk(h: ???; colorNo: ???); VAR (* TODO: check and accomplish variable declarations *) (* 360°/8 *) @@ -1141,8 +1139,8 @@ BEGIN forward(h-c); (* color = ffffff *) penDown(); (* - * Counterclockwise draw 5 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 5 edges of an octagon with edge length b + in the colour endcoded by colorNo *) polygonPart(b, 8, false, 5, colorNo); forward(c, colorNo); @@ -1154,8 +1152,8 @@ BEGIN forward(c/2.0); (* color = ffffff *) penDown(); (* - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo *) polygonPart(c, 4, false, 4, colorNo); penUp(); @@ -1165,29 +1163,29 @@ BEGIN penDown(); END qstnMk; -PROCEDURE drawText(text: ARRAY 128 OF CHAR; h, c: INTEGER); (* - * Has the turtle draw the given string 'text´ with font height 'h´ (in - * pixels) and the colour coded by integer 'c´ from the current Turtle - * position to the Turtle canvas. If the turtle looks North then - * the text will be written rightwards. In the event, the turtle will be - * placed behind the text in original orientation (such that the next text - * would be written like a continuation. Colour codes: - * 1 = black - * 2 = red - * 3 = yellow - * 4 = green - * 5 = cyan - * 6 = blue - * 7 = pink - * 8 = grey - * 9 = orange - * 10 = violet - * All letters (ASCII) will be converted to uppercase, digits cannot - * be represented, the set of representable special characters is: - * '.', ',', '!', '?'. Other characters will be shown as a small - * centred square (dummy character). + Has the turtle draw the given string 'text´ with font height 'h´ (in + pixels) and the colour coded by integer 'c´ from the current Turtle + position to the Turtle canvas. If the turtle looks North then + the text will be written rightwards. In the event, the turtle will be + placed behind the text in original orientation (such that the next text + would be written like a continuation. Colour codes: + 1 = black + 2 = red + 3 = yellow + 4 = green + 5 = cyan + 6 = blue + 7 = pink + 8 = grey + 9 = orange + 10 = violet + All letters (ASCII) will be converted to uppercase, digits cannot + be represented, the set of representable special characters is: + '.', ',', '!', '?'. Other characters will be shown as a small + centred square (dummy character). *) +PROCEDURE drawText(text: ARRAY 128 OF CHAR; h, c: INTEGER); VAR (* TODO: check and accomplish variable declarations *) letter: ARRAY 128 OF CHAR; @@ -1202,8 +1200,8 @@ BEGIN END ELSE (* - * "," cannot be chacked against because the comma is misinterpreted - * as selector list separator. + "," cannot be chacked against because the comma is misinterpreted + as selector list separator. *) CASE letter OF "A": diff --git a/samples/export_group/Pascal/ELIZA_2_2_arrz.pas b/samples/export_group/Pascal/ELIZA_2_2_arrz.pas index 2a8a4e1c..dce03589 100644 --- a/samples/export_group/Pascal/ELIZA_2_2_arrz.pas +++ b/samples/export_group/Pascal/ELIZA_2_2_arrz.pas @@ -1,25 +1,24 @@ +{ + Concept and lisp implementation published by Joseph Weizenbaum (MIT): + "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: + Computational Linguistis 1(1966)9, pp. 36-45 + Revision history: + 2016-10-06 Initial version + 2017-03-29 Two diagrams updated (comments translated to English) + 2017-03-29 More keywords and replies added + 2019-03-14 Replies and mapping reorganised for easier maintenance + 2019-03-15 key map joined from keyword array and index map + 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") +} program ELIZA; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2018-05-14 ??? } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Concept and lisp implementation published by Joseph Weizenbaum (MIT): -* "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: -* Computational Linguistis 1(1966)9, pp. 36-45 -* Revision history: -* 2016-10-06 Initial version -* 2017-03-29 Two diagrams updated (comments translated to English) -* 2017-03-29 More keywords and replies added -* 2019-03-14 Replies and mapping reorganised for easier maintenance -* 2019-03-15 key map joined from keyword array and index map -* 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } type @@ -38,14 +37,14 @@ keyMap = setupKeywords(); var - index99919821: 1..5; - array99919821: array [1..5] of string; - indexd9fc2314: 1..2; - arrayd9fc2314: array [1..2] of string; + index9218ddfe: 1..5; + array9218ddfe: array [1..5] of string; + indexb8030b03: 1..2; + arrayb8030b03: array [1..2] of string; varPart: String; { - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string } userInput: string; replyRing: ???; { FIXME! } @@ -57,8 +56,8 @@ isRepeated: boolean; isGone: boolean; { - * Stores the last five inputs of the user in a ring buffer, - * the first element is the current insertion index + Stores the last five inputs of the user in a ring buffer, + the first element is the current insertion index } history: array [0..5] of ???; { FIXME! } findInfo: array [0..1] of Longint; @@ -86,11 +85,11 @@ function adjustSpelling(sentence: string): string; delete(result, 1, position); insert(uppercase(start), result, 1); end; - arrayd9fc2314[1] := ' i '; - arrayd9fc2314[2] := ' i\'''; - for indexd9fc2314 := 1 to 2 do + arrayb8030b03[1] := ' i '; + arrayb8030b03[2] := ' i\'''; + for indexb8030b03 := 1 to 2 do begin - word := arrayd9fc2314[indexd9fc2314]; + word := arrayb8030b03[indexb8030b03]; position := pos(word, result); while (position > 0) do begin @@ -215,14 +214,14 @@ function normalizeInput(sentence: string): string; begin sentence := lowercase(sentence); - array99919821[1] := '.'; - array99919821[2] := ','; - array99919821[3] := ';'; - array99919821[4] := '!'; - array99919821[5] := '?'; - for index99919821 := 1 to 5 do + array9218ddfe[1] := '.'; + array9218ddfe[2] := ','; + array9218ddfe[3] := ';'; + array9218ddfe[4] := '!'; + array9218ddfe[5] := '?'; + for index9218ddfe := 1 to 5 do begin - symbol := array99919821[index99919821]; + symbol := array9218ddfe[index9218ddfe]; position := pos(symbol, sentence); while (position > 0) do begin @@ -304,8 +303,8 @@ function setupReplies(): array [0..49] of array [0..49] of string; begin { - * We start with the highest index for performance reasons - * (is to avoid frequent array resizing) + We start with the highest index for performance reasons + (is to avoid frequent array resizing) } { Hint: Automatically decomposed array initialization } replies[29, 0] := 'Say, do you have any psychological problems?'; @@ -613,8 +612,8 @@ function setupKeywords(): array [0..49] of KeyMapEntry; writeln('* Version: 2.2 (2019-03-28)'); writeln('**********************************'); { - * Stores the last five inputs of the user in a ring buffer, - * the first element is the current insertion index + Stores the last five inputs of the user in a ring buffer, + the first element is the current insertion index } { Hint: Automatically decomposed array initialization } history[0] := 0; @@ -634,8 +633,8 @@ function setupKeywords(): array [0..49] of KeyMapEntry; repeat readln(userInput); { - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string } userInput := normalizeInput(userInput); isGone := checkGoodBye(userInput, byePhrases); diff --git a/samples/export_group/Pascal/ELIZA_2_3_arrz.pas b/samples/export_group/Pascal/ELIZA_2_3_arrz.pas index 9c84a9d7..686f45f1 100644 --- a/samples/export_group/Pascal/ELIZA_2_3_arrz.pas +++ b/samples/export_group/Pascal/ELIZA_2_3_arrz.pas @@ -1,36 +1,35 @@ +{ + Concept and lisp implementation published by Joseph Weizenbaum (MIT): + "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: + Computational Linguistis 1(1966)9, pp. 36-45 + Revision history: + 2016-10-06 Initial version + 2017-03-29 Two diagrams updated (comments translated to English) + 2017-03-29 More keywords and replies added + 2019-03-14 Replies and mapping reorganised for easier maintenance + 2019-03-15 key map joined from keyword array and index map + 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") + 2019-11-28 New global type "History" (to ensure a homogenous array) +} program ELIZA; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2018-05-14 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Concept and lisp implementation published by Joseph Weizenbaum (MIT): -* "ELIZA - A Computer Program For the Study of Natural Language Communication Between Man and Machine" - In: -* Computational Linguistis 1(1966)9, pp. 36-45 -* Revision history: -* 2016-10-06 Initial version -* 2017-03-29 Two diagrams updated (comments translated to English) -* 2017-03-29 More keywords and replies added -* 2019-03-14 Replies and mapping reorganised for easier maintenance -* 2019-03-15 key map joined from keyword array and index map -* 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") -* 2019-11-28 New global type "History" (to ensure a homogenous array) + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } type { - * histArray contains the most recent user replies as ring buffer; - * histIndex is the index where the next reply is to be stored (= index of the oldest - * cached user reply). - * Note: The depth of the history is to be specified by initializing a variable of this type, - * e.g. for a history of depth 5: - * myhistory <- History{{"", "", "", "", ""{}, 0{} + histArray contains the most recent user replies as ring buffer; + histIndex is the index where the next reply is to be stored (= index of the oldest + cached user reply). + Note: The depth of the history is to be specified by initializing a variable of this type, + e.g. for a history of depth 5: + myhistory <- History{{"", "", "", "", ""{}, 0{} } History = RECORD histArray: array [0..49] of string; @@ -53,14 +52,14 @@ keyMap = setupKeywords(); var - index2881406f: 1..5; - array2881406f: array [1..5] of string; - indexb3ec7986: 1..2; - arrayb3ec7986: array [1..2] of string; + index3a2c1573: 1..5; + array3a2c1573: array [1..5] of string; + index450f7da8: 1..2; + array450f7da8: array [1..2] of string; varPart: String; { - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string } userInput: string; replyRing: ???; { FIXME! } @@ -72,8 +71,8 @@ isRepeated: boolean; isGone: boolean; { - * Stores the last five inputs of the user in a ring buffer, - * the second component is the rolling (over-)write index. + Stores the last five inputs of the user in a ring buffer, + the second component is the rolling (over-)write index. } history: History; findInfo: array [0..1] of Longint; @@ -101,11 +100,11 @@ function adjustSpelling(sentence: string): string; delete(result, 1, position); insert(uppercase(start), result, 1); end; - arrayb3ec7986[1] := ' i '; - arrayb3ec7986[2] := ' i\'''; - for indexb3ec7986 := 1 to 2 do + array450f7da8[1] := ' i '; + array450f7da8[2] := ' i\'''; + for index450f7da8 := 1 to 2 do begin - word := arrayb3ec7986[indexb3ec7986]; + word := array450f7da8[index450f7da8]; position := pos(word, result); while (position > 0) do begin @@ -198,14 +197,14 @@ function normalizeInput(sentence: string): string; begin sentence := lowercase(sentence); - array2881406f[1] := '.'; - array2881406f[2] := ','; - array2881406f[3] := ';'; - array2881406f[4] := '!'; - array2881406f[5] := '?'; - for index2881406f := 1 to 5 do + array3a2c1573[1] := '.'; + array3a2c1573[2] := ','; + array3a2c1573[3] := ';'; + array3a2c1573[4] := '!'; + array3a2c1573[5] := '?'; + for index3a2c1573 := 1 to 5 do begin - symbol := array2881406f[index2881406f]; + symbol := array3a2c1573[index3a2c1573]; position := pos(symbol, sentence); while (position > 0) do begin @@ -287,8 +286,8 @@ function setupReplies(): array [0..49] of array [0..49] of string; begin { - * We start with the highest index for performance reasons - * (is to avoid frequent array resizing) + We start with the highest index for performance reasons + (is to avoid frequent array resizing) } { Hint: Automatically decomposed array initialization } replies[29, 0] := 'Say, do you have any psychological problems?'; @@ -627,8 +626,8 @@ function setupKeywords(): array [0..49] of KeyMapEntry; writeln('* (Requires at least Structorizer 3.30-03 to run)'); writeln('**********************************'); { - * Stores the last five inputs of the user in a ring buffer, - * the second component is the rolling (over-)write index. + Stores the last five inputs of the user in a ring buffer, + the second component is the rolling (over-)write index. } { Hint: Automatically decomposed array initialization } history.histArray[0] := ''; @@ -648,8 +647,8 @@ function setupKeywords(): array [0..49] of KeyMapEntry; repeat readln(userInput); { - * Converts the input to lowercase, cuts out interpunctation - * and pads the string + Converts the input to lowercase, cuts out interpunctation + and pads the string } userInput := normalizeInput(userInput); isGone := checkGoodBye(userInput, byePhrases); diff --git a/samples/export_group/Pascal/FileApiGroupTest_arrz.pas b/samples/export_group/Pascal/FileApiGroupTest_arrz.pas index 688ec45c..5874d0f7 100644 --- a/samples/export_group/Pascal/FileApiGroupTest_arrz.pas +++ b/samples/export_group/Pascal/FileApiGroupTest_arrz.pas @@ -1,18 +1,17 @@ -UNIT FileApiGroupTest_arrz; -{ Generated by Structorizer 3.30-08 } - -{ Copyright (C) 2020-04-23 kay } - { -* NOTE: -* This first module of the file is a library module providing common resources -* for the following modules, which are separated by comment lines like -* "======= 8< =======...". -* You may have to cut this file apart at these lines in order to get the parts -* running, since the following modules may form sort of mutually independent -* applications or programs the coexistence of which in a single file might not -* be sensible. + NOTE: + This first module of the file is a library module providing common resources + for the following modules, which are separated by comment lines like + "======= 8< =======...". + You may have to cut this file apart at these lines in order to get the parts + running, since the following modules may form sort of mutually independent + applications or programs the coexistence of which in a single file might not + be sensible. } +UNIT FileApiGroupTest_arrz; +{ Generated by Structorizer 3.30-09 } + +{ Copyright (C) 2020-04-24 kay } INTERFACE uses StructorizerFileAPI; @@ -219,26 +218,25 @@ function readNumbers(fileName: string; numbers: array [0..49] of Longint; maxNum { ======= 8< =========================================================== } +{ + Computes the sum and average of the numbers read from a user-specified + text file (which might have been created via generateRandomNumberFile(4)). + + This program is part of an arrangement used to test group code export (issue + #828) with FileAPI dependency. + The input check loop has been disabled (replaced by a simple unchecked input + instruction) in order to test the effect of indirect FileAPI dependency (only the + called subroutine directly requires FileAPI now). +} program ComputeSum; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2020-03-21 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Computes the sum and average of the numbers read from a user-specified -* text file (which might have been created via generateRandomNumberFile(4)). -* -* This program is part of an arrangement used to test group code export (issue -* #828) with FileAPI dependency. -* The input check loop has been disabled (replaced by a simple unchecked input -* instruction) in order to test the effect of indirect FileAPI dependency (only the -* called subroutine directly requires FileAPI now). + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } uses FileApiGroupTest_arrz; @@ -258,8 +256,8 @@ function readNumbers(fileName: string; numbers: array [0..49] of Longint; maxNum { Disable this if you enable the loop below! } write('Name/path of the number file'); readln(file_name); { - * If you enable this loop, then the preceding input instruction is to be disabled - * and the fileClose instruction in the alternative below is to be enabled. + If you enable this loop, then the preceding input instruction is to be disabled + and the fileClose instruction in the alternative below is to be enabled. } { repeat } { write('Name/path of the number file'); readln(file_name); } @@ -294,20 +292,19 @@ function readNumbers(fileName: string; numbers: array [0..49] of Longint; maxNum { ======= 8< =========================================================== } +{ + Reads a random number file and draws a histogram accotrding to the + user specifications +} program DrawRandomHistogram; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2020-03-21 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Reads a random number file and draws a histogram accotrding to the -* user specifications + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } uses FileApiGroupTest_arrz,StructorizerFileAPI; diff --git a/samples/export_group/Pascal/SORTING_TEST_arrz.pas b/samples/export_group/Pascal/SORTING_TEST_arrz.pas index 6d28e52f..08945935 100644 --- a/samples/export_group/Pascal/SORTING_TEST_arrz.pas +++ b/samples/export_group/Pascal/SORTING_TEST_arrz.pas @@ -1,19 +1,18 @@ +{ + Creates three equal arrays of numbers and has them sorted with different sorting algorithms + to allow performance comparison via execution counting ("Collect Runtime Data" should + sensibly be switched on). + Requested input data are: Number of elements (size) and filing mode. +} program SORTING_TEST_MAIN; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2019-10-02 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Creates three equal arrays of numbers and has them sorted with different sorting algorithms -* to allow performance comparison via execution counting ("Collect Runtime Data" should -* sensibly be switched on). -* Requested input data are: Number of elements (size) and filing mode. + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } var @@ -133,12 +132,12 @@ function partition(values: ???; start: ???; stop: ???; p: ???): Longint; start := start + 1; stop := stop - 1; { - * Still unseen elements? - * Loop invariants: - * 1. p = start - 1 - * 2. pivot = values[p] - * 3. i < start → values[i] ≤ pivot - * 4. stop < i → pivot < values[i] + Still unseen elements? + Loop invariants: + 1. p = start - 1 + 2. pivot = values[p] + 3. i < start → values[i] ≤ pivot + 4. stop < i → pivot < values[i] } while (start <= stop) do begin @@ -151,8 +150,8 @@ function partition(values: ???; start: ???; stop: ???; p: ???): Longint; values[p] := seen; values[start] := pivot; { - * Shift the border between lower and undicovered area, - * update pivot position. + Shift the border between lower and undicovered area, + update pivot position. } p := p + 1; start := start + 1; @@ -227,8 +226,8 @@ procedure quickSort(values: ???; start: ???; stop: ???); var { - * Partition the array into smaller and greater elements - * Get the resulting (and final) position of the pivot element + Partition the array into smaller and greater elements + Get the resulting (and final) position of the pivot element } p: ???; { FIXME! } @@ -237,13 +236,13 @@ procedure quickSort(values: ???; start: ???; stop: ???); if (stop >= start + 2) then begin { - * Select a pivot element, be p its index. - * (here: randomly chosen element out of start ... stop-1) + Select a pivot element, be p its index. + (here: randomly chosen element out of start ... stop-1) } p := random(stop-start) + start; { - * Partition the array into smaller and greater elements - * Get the resulting (and final) position of the pivot element + Partition the array into smaller and greater elements + Get the resulting (and final) position of the pivot element } p := partition(values, start, stop, p); { Sort subsequances separately and independently ... } diff --git a/samples/export_group/Pascal/TextWriter_arrz.pas b/samples/export_group/Pascal/TextWriter_arrz.pas index d22f2533..f87fb4d6 100644 --- a/samples/export_group/Pascal/TextWriter_arrz.pas +++ b/samples/export_group/Pascal/TextWriter_arrz.pas @@ -1,19 +1,18 @@ +{ + Demo program for routine drawText() + Asks the user to enter a text, a wanted text height and colour, + and then draws this string onto the turtle screen. Places every + entered text to a new line. +} program TextDemo; -{ Generated by Structorizer 3.30-08 } +{ Generated by Structorizer 3.30-09 } { Copyright (C) 2019-10-10 Kay Gürtzig } { License: GPLv3-link } { -* GNU General Public License (V 3) -* https://www.gnu.org/licenses/gpl.html -* http://www.gnu.de/documents/gpl.de.html -} - -{ -* Demo program for routine drawText() -* Asks the user to enter a text, a wanted text height and colour, -* and then draws this string onto the turtle screen. Places every -* entered text to a new line. + GNU General Public License (V 3) + https://www.gnu.org/licenses/gpl.html + http://www.gnu.de/documents/gpl.de.html } var @@ -617,8 +616,8 @@ procedure comma(h: ???; colorNo: ???); forward((c+b)/2.0 + c); { color = ffffff } penDown(); { - * Counterclockwise draw 3 edges of a square with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw 3 edges of a square with edge length c + in the colour endcoded by colorNo } polygonPart(c, 4, true, 3, colorNo); left(90); @@ -673,8 +672,8 @@ procedure exclMk(h: ???; colorNo: ???); left(90 + rotAngle); penDown(); { - * Clockwise draw 5 edges of an octagon with edge length b/2 - * in the colour endcoded by colorNo + Clockwise draw 5 edges of an octagon with edge length b/2 + in the colour endcoded by colorNo } polygonPart(b/2.0, 8, false, 5, colorNo); right(rotAngle2); @@ -689,8 +688,8 @@ procedure exclMk(h: ???; colorNo: ???); forward(c/2.0); { color = ffffff } penDown(); { - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo } polygonPart(c, 4, false, 4, colorNo); penUp(); @@ -723,8 +722,8 @@ procedure fullSt(h: ???; colorNo: ???); forward((c+b)/2.0 + c); { color = ffffff } penDown(); { - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo } polygonPart(c, 4, true, 4, colorNo); penUp(); @@ -798,8 +797,8 @@ procedure letterC(h: ???; colorNo: ???); penDown(); right(180); { - * Clockwise draws 3 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draws 3 edges of an octagon with edge length b in the colour + encoded by colorNo } polygonPart(b, 8, true, 3, colorNo); left(rotAngle); @@ -807,8 +806,8 @@ procedure letterC(h: ???; colorNo: ???); forward(2*b + 2*c); { color = ffffff } penDown(); { - * Counterclockwise draws 4 edges of an octagon with edge length b - * iin the colour encoded by colorNo + Counterclockwise draws 4 edges of an octagon with edge length b + iin the colour encoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -842,14 +841,14 @@ procedure letterD(h: ???; colorNo: ???); right(90); forward(c+b, colorNo); { - * Clockwise draw 2 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draw 2 edges of an octagon with edge length b in the colour + encoded by colorNo } polygonPart(b, 8, false, 2, colorNo); forward(b + 2*c, colorNo); { - * Clockwise draw 2 edges of an octagon with edge length b in the colour - * encoded by colorNo + Clockwise draw 2 edges of an octagon with edge length b in the colour + encoded by colorNo } polygonPart(b, 8, false, 2, colorNo); forward(c, colorNo); @@ -883,8 +882,8 @@ procedure letterG(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 4 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b in + the colour encoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(c, colorNo); @@ -896,8 +895,8 @@ procedure letterG(h: ???; colorNo: ???); forward(b + c); { color = ffffff } penDown(); { - * Counterclockwise draw 4 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b in + the colour encoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -936,8 +935,8 @@ procedure letterJ(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 3 edges of an octagon with edge length b in - * the colour encoded by colorNo + Counterclockwise draw 3 edges of an octagon with edge length b in + the colour encoded by colorNo } polygonPart(b, 8, true, 3, colorNo); left(rotAngle); @@ -970,14 +969,14 @@ procedure letterO(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); { - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -1011,8 +1010,8 @@ procedure letterP(h: ???; colorNo: ???); right(90); forward(c+b, colorNo); { - * Clockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Clockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, false, 4, colorNo); forward(c, colorNo); @@ -1051,14 +1050,14 @@ procedure letterQ(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); { - * Counterclockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, true, 4, colorNo); forward(b + 2*c, colorNo); @@ -1099,8 +1098,8 @@ procedure letterR(h: ???; colorNo: ???); right(90); forward(c+b, colorNo); { - * Clockwise draw 4 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Clockwise draw 4 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, false, 4, colorNo); forward(c, colorNo); @@ -1136,13 +1135,13 @@ procedure letterS(h: ???; colorNo: ???); penDown(); right(180); { - * Counterclockwise draw 6 edges of an octagon with edge length b - * in the colour encoded by colorNo + Counterclockwise draw 6 edges of an octagon with edge length b + in the colour encoded by colorNo } polygonPart(b, 8, true, 6, colorNo); { - * Clockwise draw 5 edges of an octagon with edge length b - * in the colour encoded by colorNo + Clockwise draw 5 edges of an octagon with edge length b + in the colour encoded by colorNo } polygonPart(b, 8, false, 5, colorNo); right(rotAngle); @@ -1217,8 +1216,8 @@ procedure qstnMk(h: ???; colorNo: ???); forward(h-c); { color = ffffff } penDown(); { - * Counterclockwise draw 5 edges of an octagon with edge length b - * in the colour endcoded by colorNo + Counterclockwise draw 5 edges of an octagon with edge length b + in the colour endcoded by colorNo } polygonPart(b, 8, false, 5, colorNo); forward(c, colorNo); @@ -1230,8 +1229,8 @@ procedure qstnMk(h: ???; colorNo: ???); forward(c/2.0); { color = ffffff } penDown(); { - * Counterclockwise draw all 4 edges of a squarfe with edge length c - * in the colour endcoded by colorNo + Counterclockwise draw all 4 edges of a squarfe with edge length c + in the colour endcoded by colorNo } polygonPart(c, 4, false, 4, colorNo); penUp(); @@ -1283,8 +1282,8 @@ procedure drawText(text: string; h: Longint; c: Longint); else begin { - * "," cannot be chacked against because the comma is misinterpreted - * as selector list separator. + "," cannot be chacked against because the comma is misinterpreted + as selector list separator. } case (letter) of "A": From 5f9a58c24665e197b1c0ef1657372f9d63ff5ff4 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Sat, 25 Apr 2020 17:07:56 +0200 Subject: [PATCH 06/18] Fixes #863 (flaws on PapDesigner and StrukTex export) --- .../structorizer/generators/Generator.java | 40 +++++++++++++++++++ .../structorizer/generators/PapGenerator.java | 6 +++ src/lu/fisch/structorizer/gui/changelog.txt | 4 +- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/lu/fisch/structorizer/generators/Generator.java b/src/lu/fisch/structorizer/generators/Generator.java index feb01f87..0a333033 100644 --- a/src/lu/fisch/structorizer/generators/Generator.java +++ b/src/lu/fisch/structorizer/generators/Generator.java @@ -109,6 +109,7 @@ * Kay Gürtzig 2020-04-01 Enh. #440, #828: Support for Group export to PapGenerator * Kay Gürtzig 2020-04-22 Enh. #855: New options for default array / string size * Kay Gürtzig 2020-04-24 Bugfix #862/2: Prevent duplicate export of an entry point root + * Kay Gürtzig 2020-04-25 Bugfix #863/1: Duplicate routine export to PapDesigner and StrukTex * ****************************************************************************************************** * @@ -4848,6 +4849,45 @@ else if (mainIndices.size() > 1 && !this.max1MainPerModule()) { this.subroutines.remove(root); } } + // START KGU#862 2020-04-25: Bugfix #863 + else { + /* Now it is likely that there is no main at all. + * We must prevent duplicate expression of routines. So find an independent + * top level candidate or sort topologically. + * What cases may occur (in falling precedence): + * 1. There might be an entry point not being member of subroutines -> take it + * 2. There will be an entry point with largest subtree, then this will be the one + * 3. Hardly possible - would mean that all entry points are in subroutines + * (i.e. called by some other routine though none has a subtree) -> just + * sort them (?) topologically and clear subroutines. + */ + Root starter = null; + int maxDependents = 0; + for (int i = 0; i < _entryPoints.size(); i++) { + Root root = _entryPoints.get(i); + TreeMap subTree = subTrees.get(i); + if (!this.subroutines.containsKey(root)) { + starter = root; + break; + } + else if (subTree != null && subTree.size() > maxDependents) { + maxDependents = subTree.size(); + starter = root; + // We will continue searching, though + } + } + if (starter == null) { + _entryPoints.clear(); + // this.subroutines gets cleared here. + _entryPoints.addAll(this.sortTopologically(this.subroutines)); + } + else { + this.subroutines.remove(starter); + _entryPoints.remove(starter); + _entryPoints.insertElementAt(starter, 0); + } + } + // END KGU#862 2020-04-25 // Note: this.subroutines is likely to be consumed by method generateModule()! _someRootUsesFileAPI = generateModule(_entryPoints, this.subroutines, _batchMode, null, null); } diff --git a/src/lu/fisch/structorizer/generators/PapGenerator.java b/src/lu/fisch/structorizer/generators/PapGenerator.java index 97e9cf08..9b4816a4 100644 --- a/src/lu/fisch/structorizer/generators/PapGenerator.java +++ b/src/lu/fisch/structorizer/generators/PapGenerator.java @@ -34,6 +34,7 @@ * Kay Gürtzig 2020-02-27 First Issue for Enhancement request #440 * Kay Gürtzig 2020-03-07 PapItem and PapElement classes integrated * Kay Gürtzig 2020-04-02 PapParallel fundamentally rewritten, provisional Jump mechanism implemented + * Kay Gürtzig 2020-04-25 Bugfix #863/2: Assignment symbols hadn't been transformed in CALLs * ****************************************************************************************************** * @@ -489,6 +490,11 @@ public long[] generateItems(List figures, List connect } if (element instanceof Call) { papType = PapFigure.Type.PapModule; + // START KGU#862 2020-04-25: Bugfix #863/2 - the assignment symbol must be transformed + for (int i = 0; i < text.count(); i++) { + text.set(i, transform(text.get(i))); + } + // END KGU#862 2020-04-25 } else if (element instanceof Jump) { boolean isRegularReturn = false; diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index b7250ef9..35ed4046 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -13,7 +13,7 @@ Known issues: - Shell export does not cope with nested array/record initializers and component access, neither with clean parameter handling for usual arrays and associative arrays. -Current development version: 3.30-09 (2020-04-24) +Current development version: 3.30-09 (2020-04-25) - 01: Bugfix #759: Another source of stale Mainforms dried up. <2> - 01: Bugfix #761: Code preview defect flooded the log stream. <2> - 01: Precautions against empty error messages on startup <2> @@ -112,6 +112,8 @@ Current development version: 3.30-09 (2020-04-24) - 09: Issue #861/3: Improved comment trimming on code import <2> - 09: Bugfix #862/2: Batch export no longer produces duplicate entry points <2> - 09: Bugfix #862/3: Batch import produced defective arrangement lists <2> +- 09: Bugfix #863/1: Duplicate routines on PapDesigner/StrukTex export <2> +- 09: Bugfix #863/2: Wrong assignment symbols in CALLs on PapDesigner export <2> Version: 3.30 (2019-10-06) - 01: Issue #657: Spanish message in German locale replaced <2> From 6f7acb32adc2efca18e1fd63bfc4ee34e5a2048e Mon Sep 17 00:00:00 2001 From: codemanyak Date: Sat, 25 Apr 2020 17:18:47 +0200 Subject: [PATCH 07/18] Known issues section in changelog.txt updated. --- src/lu/fisch/structorizer/gui/changelog.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 35ed4046..71d3db6a 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -6,12 +6,14 @@ <2> --> idea and coding done by Kay Gürtzig Known issues: -- Copying diagram images to the clipboard may fail with some OS/JRE combination (#685). -- COBOL import may fail if certain single-letter identifiers are used (rename them!). -- COBOL import doesn't cope with some statement variants and variable redefinitions. +- Copying diagram images to the clipboard may fail with some OS/JRE combination (#685), + on Windows the image format may be JPG instead of PNG. +- COBOL import may fail if certain single-letter identifiers are used (rename them!), + also if the code contains a SPECIAL-NAMES clause or float literals. +- COBOL import does not cope with some statement variants and variable redefinitions. - The Javascript generator is just a prototype and may be deficient. -- Shell export does not cope with nested array/record initializers and component access, - neither with clean parameter handling for usual arrays and associative arrays. +- Shell export copes neither with nested array/record initializers and component access + nor with cleanly handling usual and associative arrays as parameters or results. Current development version: 3.30-09 (2020-04-25) - 01: Bugfix #759: Another source of stale Mainforms dried up. <2> From 74d8d5db13889ece69e5e8f385e16e72548be8d3 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Sat, 25 Apr 2020 19:54:43 +0200 Subject: [PATCH 08/18] Update of pap export samples after bugfix #863 --- samples/export/PAP/ComputeSum_1966.pap | 4 +- samples/export/PAP/ComputeSum_1982.pap | 4 +- .../export/PAP/DrawRandomHistogram_1966.pap | 12 ++-- .../export/PAP/DrawRandomHistogram_1982.pap | 12 ++-- samples/export/PAP/ELIZA_2.2_1966.pap | 36 +++++----- samples/export/PAP/ELIZA_2.2_1982.pap | 36 +++++----- samples/export/PAP/ELIZA_2.3_1966.pap | 22 +++--- samples/export/PAP/ELIZA_2.3_1982.pap | 22 +++--- samples/export/PAP/SORTING_TEST_MAIN_1966.pap | 10 +-- samples/export/PAP/SORTING_TEST_MAIN_1982.pap | 10 +-- .../export_group/PAP/ELIZA_2_2_arrz_1966.pap | 36 +++++----- .../export_group/PAP/ELIZA_2_2_arrz_1982.pap | 36 +++++----- .../export_group/PAP/ELIZA_2_3_arrz_1966.pap | 22 +++--- .../export_group/PAP/ELIZA_2_3_arrz_1982.pap | 22 +++--- .../PAP/FileApiGroupTest_arrz_1966.pap | 14 ++-- .../PAP/FileApiGroupTest_arrz_1982.pap | 14 ++-- .../PAP/SORTING_TEST_arrz_1966.pap | 10 +-- .../PAP/SORTING_TEST_arrz_1982.pap | 10 +-- .../export_group/PAP/TextWriter_arrz_1966.pap | 72 +++++++++---------- .../export_group/PAP/TextWriter_arrz_1982.pap | 72 +++++++++---------- 20 files changed, 238 insertions(+), 238 deletions(-) diff --git a/samples/export/PAP/ComputeSum_1966.pap b/samples/export/PAP/ComputeSum_1966.pap index 23cef33b..d18da978 100644 --- a/samples/export/PAP/ComputeSum_1966.pap +++ b/samples/export/PAP/ComputeSum_1966.pap @@ -1,5 +1,5 @@ - + @@ -107,7 +107,7 @@ nValues := 0]]>
- +
diff --git a/samples/export/PAP/ComputeSum_1982.pap b/samples/export/PAP/ComputeSum_1982.pap index 1691fa5b..6e2d6213 100644 --- a/samples/export/PAP/ComputeSum_1982.pap +++ b/samples/export/PAP/ComputeSum_1982.pap @@ -1,5 +1,5 @@ - + @@ -97,7 +97,7 @@ nValues := 0]]>
- +
diff --git a/samples/export/PAP/DrawRandomHistogram_1966.pap b/samples/export/PAP/DrawRandomHistogram_1966.pap index cd2a41a0..f1d9d85f 100644 --- a/samples/export/PAP/DrawRandomHistogram_1966.pap +++ b/samples/export/PAP/DrawRandomHistogram_1966.pap @@ -1,5 +1,5 @@ - + @@ -159,7 +159,7 @@ user specifications]]>
- +
@@ -979,7 +979,7 @@ backward(xSize-1)]]>
- +
@@ -989,7 +989,7 @@ backward(xSize-1)]]>
- +
@@ -999,7 +999,7 @@ backward(xSize-1)]]>
- +
@@ -1014,7 +1014,7 @@ backward(xSize-1)]]>
- +
diff --git a/samples/export/PAP/DrawRandomHistogram_1982.pap b/samples/export/PAP/DrawRandomHistogram_1982.pap index 57654c3b..a64e475e 100644 --- a/samples/export/PAP/DrawRandomHistogram_1982.pap +++ b/samples/export/PAP/DrawRandomHistogram_1982.pap @@ -1,5 +1,5 @@ - + @@ -109,7 +109,7 @@ user specifications]]>
- +
@@ -678,7 +678,7 @@ backward(xSize-1)]]>
- +
@@ -688,7 +688,7 @@ backward(xSize-1)]]>
- +
@@ -698,7 +698,7 @@ backward(xSize-1)]]>
- +
@@ -713,7 +713,7 @@ backward(xSize-1)]]>
- +
diff --git a/samples/export/PAP/ELIZA_2.2_1966.pap b/samples/export/PAP/ELIZA_2.2_1966.pap index 5bf3d184..33e75c3d 100644 --- a/samples/export/PAP/ELIZA_2.2_1966.pap +++ b/samples/export/PAP/ELIZA_2.2_1966.pap @@ -1,5 +1,5 @@ - + @@ -103,22 +103,22 @@ the first element is the current insertion index]]>
- +
- +
- +
- +
@@ -159,12 +159,12 @@ and pads the string]]>
- +
- +
@@ -179,7 +179,7 @@ and pads the string]]>
- +
@@ -189,7 +189,7 @@ and pads the string]]>
- +
@@ -249,7 +249,7 @@ and pads the string]]>
- +
@@ -350,7 +350,7 @@ insert(varPart, reply, posAster)]]>
- +
@@ -489,7 +489,7 @@ insert(varPart, reply, posAster)]]> - + @@ -713,7 +713,7 @@ insert(varPart, reply, posAster)]]> - + @@ -811,7 +811,7 @@ returns true, otherwise false]]> - + @@ -988,7 +988,7 @@ length(history) - 1 input strings and updates the history]]> - + @@ -1333,7 +1333,7 @@ result[1] := position]]> - + @@ -1455,7 +1455,7 @@ sentence among blanks]]> - + @@ -1579,7 +1579,7 @@ keywords[38] := KeyMapEntry{"mother ", 28}]]> - + diff --git a/samples/export/PAP/ELIZA_2.2_1982.pap b/samples/export/PAP/ELIZA_2.2_1982.pap index 8f48e81d..a1dfc4cc 100644 --- a/samples/export/PAP/ELIZA_2.2_1982.pap +++ b/samples/export/PAP/ELIZA_2.2_1982.pap @@ -1,5 +1,5 @@ - + @@ -103,22 +103,22 @@ the first element is the current insertion index]]>
- +
- +
- +
- +
@@ -159,12 +159,12 @@ and pads the string]]>
- +
- +
@@ -179,7 +179,7 @@ and pads the string]]>
- +
@@ -189,7 +189,7 @@ and pads the string]]>
- +
@@ -249,7 +249,7 @@ and pads the string]]>
- +
@@ -350,7 +350,7 @@ insert(varPart, reply, posAster)]]>
- +
@@ -476,7 +476,7 @@ insert(varPart, reply, posAster)]]>
- + @@ -626,7 +626,7 @@ insert(varPart, reply, posAster)]]> - + @@ -724,7 +724,7 @@ returns true, otherwise false]]> - + @@ -852,7 +852,7 @@ length(history) - 1 input strings and updates the history]]> - + @@ -1086,7 +1086,7 @@ result[1] := position]]> - + @@ -1171,7 +1171,7 @@ sentence among blanks]]> - + @@ -1295,7 +1295,7 @@ keywords[38] := KeyMapEntry{"mother ", 28}]]> - + diff --git a/samples/export/PAP/ELIZA_2.3_1966.pap b/samples/export/PAP/ELIZA_2.3_1966.pap index 7a06f704..0f3c39d0 100644 --- a/samples/export/PAP/ELIZA_2.3_1966.pap +++ b/samples/export/PAP/ELIZA_2.3_1966.pap @@ -1,5 +1,5 @@ - + @@ -109,22 +109,22 @@ the second component is the rolling (over-)write index.]]>
- +
- +
- +
- +
@@ -165,12 +165,12 @@ and pads the string]]>
- +
- +
@@ -185,7 +185,7 @@ and pads the string]]>
- +
@@ -195,7 +195,7 @@ and pads the string]]>
- +
@@ -255,7 +255,7 @@ and pads the string]]>
- +
@@ -356,7 +356,7 @@ insert(varPart, reply, posAster)]]>
- +
diff --git a/samples/export/PAP/ELIZA_2.3_1982.pap b/samples/export/PAP/ELIZA_2.3_1982.pap index 5a13dbd9..4d25cc55 100644 --- a/samples/export/PAP/ELIZA_2.3_1982.pap +++ b/samples/export/PAP/ELIZA_2.3_1982.pap @@ -1,5 +1,5 @@ - + @@ -109,22 +109,22 @@ the second component is the rolling (over-)write index.]]>
- +
- +
- +
- +
@@ -165,12 +165,12 @@ and pads the string]]>
- +
- +
@@ -185,7 +185,7 @@ and pads the string]]>
- +
@@ -195,7 +195,7 @@ and pads the string]]>
- +
@@ -255,7 +255,7 @@ and pads the string]]>
- +
@@ -356,7 +356,7 @@ insert(varPart, reply, posAster)]]>
- +
diff --git a/samples/export/PAP/SORTING_TEST_MAIN_1966.pap b/samples/export/PAP/SORTING_TEST_MAIN_1966.pap index c0a3a32c..6a69914f 100644 --- a/samples/export/PAP/SORTING_TEST_MAIN_1966.pap +++ b/samples/export/PAP/SORTING_TEST_MAIN_1966.pap @@ -1,5 +1,5 @@ - + @@ -301,17 +301,17 @@ Requested input data are: Number of elements (size) and filing mode.]]>
- +
- +
- +
@@ -1516,7 +1516,7 @@ Get the resulting (and final) position of the pivot element]]>
- +
diff --git a/samples/export/PAP/SORTING_TEST_MAIN_1982.pap b/samples/export/PAP/SORTING_TEST_MAIN_1982.pap index 7ab0e388..fe2bb5dd 100644 --- a/samples/export/PAP/SORTING_TEST_MAIN_1982.pap +++ b/samples/export/PAP/SORTING_TEST_MAIN_1982.pap @@ -1,5 +1,5 @@ - + @@ -201,17 +201,17 @@ Requested input data are: Number of elements (size) and filing mode.]]>
- +
- +
- +
@@ -1096,7 +1096,7 @@ Get the resulting (and final) position of the pivot element]]>
- +
diff --git a/samples/export_group/PAP/ELIZA_2_2_arrz_1966.pap b/samples/export_group/PAP/ELIZA_2_2_arrz_1966.pap index 2c582057..89745938 100644 --- a/samples/export_group/PAP/ELIZA_2_2_arrz_1966.pap +++ b/samples/export_group/PAP/ELIZA_2_2_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -103,22 +103,22 @@ the first element is the current insertion index]]>
- +
- +
- +
- +
@@ -159,12 +159,12 @@ and pads the string]]>
- +
- +
@@ -179,7 +179,7 @@ and pads the string]]>
- +
@@ -189,7 +189,7 @@ and pads the string]]>
- +
@@ -249,7 +249,7 @@ and pads the string]]>
- +
@@ -350,7 +350,7 @@ insert(varPart, reply, posAster)]]>
- +
@@ -489,7 +489,7 @@ insert(varPart, reply, posAster)]]>
- + @@ -713,7 +713,7 @@ insert(varPart, reply, posAster)]]> - + @@ -811,7 +811,7 @@ returns true, otherwise false]]> - + @@ -988,7 +988,7 @@ length(history) - 1 input strings and updates the history]]> - + @@ -1183,7 +1183,7 @@ right := copy(right, position + length(pair[0]), length(right))]]> - + @@ -1305,7 +1305,7 @@ sentence among blanks]]> - + @@ -1342,7 +1342,7 @@ phrases[1] := {"bye", "Well, let\'s end our talk for now. See you later. Bye."}] - + diff --git a/samples/export_group/PAP/ELIZA_2_2_arrz_1982.pap b/samples/export_group/PAP/ELIZA_2_2_arrz_1982.pap index 06643720..b3b70cf0 100644 --- a/samples/export_group/PAP/ELIZA_2_2_arrz_1982.pap +++ b/samples/export_group/PAP/ELIZA_2_2_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -103,22 +103,22 @@ the first element is the current insertion index]]>
- +
- +
- +
- +
@@ -159,12 +159,12 @@ and pads the string]]>
- +
- +
@@ -179,7 +179,7 @@ and pads the string]]>
- +
@@ -189,7 +189,7 @@ and pads the string]]>
- +
@@ -249,7 +249,7 @@ and pads the string]]>
- +
@@ -350,7 +350,7 @@ insert(varPart, reply, posAster)]]>
- +
@@ -476,7 +476,7 @@ insert(varPart, reply, posAster)]]>
- + @@ -626,7 +626,7 @@ insert(varPart, reply, posAster)]]> - + @@ -724,7 +724,7 @@ returns true, otherwise false]]> - + @@ -852,7 +852,7 @@ length(history) - 1 input strings and updates the history]]> - + @@ -973,7 +973,7 @@ right := copy(right, position + length(pair[0]), length(right))]]> - + @@ -1058,7 +1058,7 @@ sentence among blanks]]> - + @@ -1095,7 +1095,7 @@ phrases[1] := {"bye", "Well, let\'s end our talk for now. See you later. Bye."}] - + diff --git a/samples/export_group/PAP/ELIZA_2_3_arrz_1966.pap b/samples/export_group/PAP/ELIZA_2_3_arrz_1966.pap index 5feab7e1..daf6013a 100644 --- a/samples/export_group/PAP/ELIZA_2_3_arrz_1966.pap +++ b/samples/export_group/PAP/ELIZA_2_3_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -109,22 +109,22 @@ the second component is the rolling (over-)write index.]]>
- +
- +
- +
- +
@@ -165,12 +165,12 @@ and pads the string]]>
- +
- +
@@ -185,7 +185,7 @@ and pads the string]]>
- +
@@ -195,7 +195,7 @@ and pads the string]]>
- +
@@ -255,7 +255,7 @@ and pads the string]]>
- +
@@ -356,7 +356,7 @@ insert(varPart, reply, posAster)]]>
- +
diff --git a/samples/export_group/PAP/ELIZA_2_3_arrz_1982.pap b/samples/export_group/PAP/ELIZA_2_3_arrz_1982.pap index 278b53b7..1eb9f179 100644 --- a/samples/export_group/PAP/ELIZA_2_3_arrz_1982.pap +++ b/samples/export_group/PAP/ELIZA_2_3_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -109,22 +109,22 @@ the second component is the rolling (over-)write index.]]>
- +
- +
- +
- +
@@ -165,12 +165,12 @@ and pads the string]]>
- +
- +
@@ -185,7 +185,7 @@ and pads the string]]>
- +
@@ -195,7 +195,7 @@ and pads the string]]>
- +
@@ -255,7 +255,7 @@ and pads the string]]>
- +
@@ -356,7 +356,7 @@ insert(varPart, reply, posAster)]]>
- +
diff --git a/samples/export_group/PAP/FileApiGroupTest_arrz_1966.pap b/samples/export_group/PAP/FileApiGroupTest_arrz_1966.pap index 2d2959c5..0dfe4d91 100644 --- a/samples/export_group/PAP/FileApiGroupTest_arrz_1966.pap +++ b/samples/export_group/PAP/FileApiGroupTest_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -107,7 +107,7 @@ nValues := 0]]>
- +
@@ -446,7 +446,7 @@ user specifications]]>
- +
@@ -1267,7 +1267,7 @@ backward(xSize-1)]]>
- +
@@ -1277,7 +1277,7 @@ backward(xSize-1)]]>
- +
@@ -1287,7 +1287,7 @@ backward(xSize-1)]]>
- +
@@ -1302,7 +1302,7 @@ backward(xSize-1)]]>
- +
diff --git a/samples/export_group/PAP/FileApiGroupTest_arrz_1982.pap b/samples/export_group/PAP/FileApiGroupTest_arrz_1982.pap index f2981b7d..e7da0796 100644 --- a/samples/export_group/PAP/FileApiGroupTest_arrz_1982.pap +++ b/samples/export_group/PAP/FileApiGroupTest_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -97,7 +97,7 @@ nValues := 0]]>
- +
@@ -334,7 +334,7 @@ user specifications]]>
- +
@@ -904,7 +904,7 @@ backward(xSize-1)]]>
- +
@@ -914,7 +914,7 @@ backward(xSize-1)]]>
- +
@@ -924,7 +924,7 @@ backward(xSize-1)]]>
- +
@@ -939,7 +939,7 @@ backward(xSize-1)]]>
- +
diff --git a/samples/export_group/PAP/SORTING_TEST_arrz_1966.pap b/samples/export_group/PAP/SORTING_TEST_arrz_1966.pap index bc6973f8..2838412a 100644 --- a/samples/export_group/PAP/SORTING_TEST_arrz_1966.pap +++ b/samples/export_group/PAP/SORTING_TEST_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -301,17 +301,17 @@ Requested input data are: Number of elements (size) and filing mode.]]>
- +
- +
- +
@@ -1516,7 +1516,7 @@ Get the resulting (and final) position of the pivot element]]>
- +
diff --git a/samples/export_group/PAP/SORTING_TEST_arrz_1982.pap b/samples/export_group/PAP/SORTING_TEST_arrz_1982.pap index f0173969..afd3fada 100644 --- a/samples/export_group/PAP/SORTING_TEST_arrz_1982.pap +++ b/samples/export_group/PAP/SORTING_TEST_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -201,17 +201,17 @@ Requested input data are: Number of elements (size) and filing mode.]]>
- +
- +
- +
@@ -1096,7 +1096,7 @@ Get the resulting (and final) position of the pivot element]]>
- +
diff --git a/samples/export_group/PAP/TextWriter_arrz_1966.pap b/samples/export_group/PAP/TextWriter_arrz_1966.pap index a821de20..ccd572e6 100644 --- a/samples/export_group/PAP/TextWriter_arrz_1966.pap +++ b/samples/export_group/PAP/TextWriter_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -224,7 +224,7 @@ entered text to a new line.]]>
- + @@ -268,7 +268,7 @@ left(90)]]> - + @@ -494,7 +494,7 @@ left(90)]]> - + @@ -604,7 +604,7 @@ penDown()]]> - + @@ -696,7 +696,7 @@ penDown()]]> - + @@ -783,7 +783,7 @@ penDown()]]> - + @@ -874,7 +874,7 @@ penDown()]]> - + @@ -981,7 +981,7 @@ penDown()]]> - + @@ -1063,7 +1063,7 @@ penDown()]]> - + @@ -1126,7 +1126,7 @@ penDown()]]> - + @@ -1216,7 +1216,7 @@ from the current turtle position.]]> - + @@ -1302,7 +1302,7 @@ penDown()]]> - + @@ -1398,7 +1398,7 @@ penDown()]]> - + @@ -1482,7 +1482,7 @@ penDown()]]> - + @@ -1600,7 +1600,7 @@ penDown()]]> - + @@ -1682,7 +1682,7 @@ penDown()]]> - + @@ -1791,7 +1791,7 @@ penDown()]]> - + @@ -1884,7 +1884,7 @@ penDown()]]> - + @@ -2024,7 +2024,7 @@ counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.]]> - + @@ -2121,7 +2121,7 @@ penDown()]]> - + @@ -2252,7 +2252,7 @@ penDown()]]> - + @@ -2426,7 +2426,7 @@ penDown()]]> - + @@ -2508,7 +2508,7 @@ penDown()]]> - + @@ -2636,7 +2636,7 @@ penDown()]]> - + @@ -2783,7 +2783,7 @@ left(90)]]> - + @@ -2904,7 +2904,7 @@ penDown()]]> - + @@ -3054,7 +3054,7 @@ left(90)]]> - + @@ -3163,7 +3163,7 @@ penDown()]]> - + @@ -3281,7 +3281,7 @@ penDown()]]> - + @@ -3385,7 +3385,7 @@ penDown()]]> - + @@ -3527,7 +3527,7 @@ penDown()]]> - + @@ -3644,7 +3644,7 @@ in the colour endcoded by colorNo]]> - + @@ -3765,7 +3765,7 @@ penDown()]]> - + @@ -3887,7 +3887,7 @@ penDown()]]> - + @@ -4020,7 +4020,7 @@ penDown()]]> - + diff --git a/samples/export_group/PAP/TextWriter_arrz_1982.pap b/samples/export_group/PAP/TextWriter_arrz_1982.pap index bebd1a66..12302f23 100644 --- a/samples/export_group/PAP/TextWriter_arrz_1982.pap +++ b/samples/export_group/PAP/TextWriter_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -185,7 +185,7 @@ entered text to a new line.]]> - + @@ -229,7 +229,7 @@ left(90)]]> - + @@ -455,7 +455,7 @@ left(90)]]> - + @@ -565,7 +565,7 @@ penDown()]]> - + @@ -657,7 +657,7 @@ penDown()]]> - + @@ -744,7 +744,7 @@ penDown()]]> - + @@ -835,7 +835,7 @@ penDown()]]> - + @@ -942,7 +942,7 @@ penDown()]]> - + @@ -1024,7 +1024,7 @@ penDown()]]> - + @@ -1087,7 +1087,7 @@ penDown()]]> - + @@ -1177,7 +1177,7 @@ from the current turtle position.]]> - + @@ -1263,7 +1263,7 @@ penDown()]]> - + @@ -1359,7 +1359,7 @@ penDown()]]> - + @@ -1443,7 +1443,7 @@ penDown()]]> - + @@ -1561,7 +1561,7 @@ penDown()]]> - + @@ -1643,7 +1643,7 @@ penDown()]]> - + @@ -1752,7 +1752,7 @@ penDown()]]> - + @@ -1845,7 +1845,7 @@ penDown()]]> - + @@ -1936,7 +1936,7 @@ counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.]]> - + @@ -2033,7 +2033,7 @@ penDown()]]> - + @@ -2164,7 +2164,7 @@ penDown()]]> - + @@ -2338,7 +2338,7 @@ penDown()]]> - + @@ -2420,7 +2420,7 @@ penDown()]]> - + @@ -2548,7 +2548,7 @@ penDown()]]> - + @@ -2695,7 +2695,7 @@ left(90)]]> - + @@ -2816,7 +2816,7 @@ penDown()]]> - + @@ -2966,7 +2966,7 @@ left(90)]]> - + @@ -3075,7 +3075,7 @@ penDown()]]> - + @@ -3193,7 +3193,7 @@ penDown()]]> - + @@ -3297,7 +3297,7 @@ penDown()]]> - + @@ -3439,7 +3439,7 @@ penDown()]]> - + @@ -3556,7 +3556,7 @@ in the colour endcoded by colorNo]]> - + @@ -3677,7 +3677,7 @@ penDown()]]> - + @@ -3799,7 +3799,7 @@ penDown()]]> - + @@ -3932,7 +3932,7 @@ penDown()]]> - + From 4014236e3139798c872ffacd9d601c32b6073b6f Mon Sep 17 00:00:00 2001 From: codemanyak Date: Tue, 28 Apr 2020 22:14:33 +0200 Subject: [PATCH 09/18] Fixes #864 (parameter list syntax for PapDesigner export) --- .../structorizer/generators/PapGenerator.java | 123 ++++++++++++++++-- src/lu/fisch/structorizer/gui/changelog.txt | 3 +- 2 files changed, 113 insertions(+), 13 deletions(-) diff --git a/src/lu/fisch/structorizer/generators/PapGenerator.java b/src/lu/fisch/structorizer/generators/PapGenerator.java index 9b4816a4..02aa8ce9 100644 --- a/src/lu/fisch/structorizer/generators/PapGenerator.java +++ b/src/lu/fisch/structorizer/generators/PapGenerator.java @@ -35,6 +35,7 @@ * Kay Gürtzig 2020-03-07 PapItem and PapElement classes integrated * Kay Gürtzig 2020-04-02 PapParallel fundamentally rewritten, provisional Jump mechanism implemented * Kay Gürtzig 2020-04-25 Bugfix #863/2: Assignment symbols hadn't been transformed in CALLs + * Kay Gürtzig 2020-04-28 Issue #864: Parameter lists of calls and routine declarations had to be transformed * ****************************************************************************************************** * @@ -73,6 +74,7 @@ import lu.fisch.structorizer.elements.Subqueue; import lu.fisch.structorizer.elements.Try; import lu.fisch.structorizer.elements.While; +import lu.fisch.structorizer.executor.Function; import lu.fisch.structorizer.parsers.CodeParser; import lu.fisch.utils.BString; import lu.fisch.utils.StringList; @@ -423,7 +425,30 @@ public PapElement(Element el) if (!element.getComment().getLongString().trim().isEmpty()) { right++; } - if (element.getClass().getSimpleName().equals("Instruction")) { + // START KGU#863 2020-04-28: Issue #864 In case of a muti-line we must decompose it + if (element instanceof Call) { + StringList lines = element.getUnbrokenText(); + if (lines.count() > 1) { + for (int i = 0; i < lines.count(); i++) { + if (!lines.get(i).trim().isEmpty()) { + height++; + } + } + // Subtract the standard height since we counted all (non-empty) lines + if (height > 1) { + height--; + } + } + } + // END KGU#863 2020-04-28 + // START KGU#396 2020-04-02: Issue #440 Makeshift approach for Jump elements + else if (element instanceof Jump) { + if (!(((Jump) element).isReturn() && this.isLastElementOfRoot())) { + height++; + } + } + // END KGU396 2020-04-02 + else if (element.getClass().getSimpleName().equals("Instruction")) { // Input and output lines are to be separated and hence increase height StringList lines = element.getUnbrokenText(); boolean isIO = false; @@ -439,13 +464,6 @@ public PapElement(Element el) } } } - // START KGU#396 2020-04-02: Issue #440 Makeshift approach for Jump elements - else if (element instanceof Jump) { - if (!(((Jump) element).isReturn() && this.isLastElementOfRoot())) { - height++; - } - } - // END KGU396 2020-04-02 } /** @return the number of occupied raster columns */ @@ -490,9 +508,46 @@ public long[] generateItems(List figures, List connect } if (element instanceof Call) { papType = PapFigure.Type.PapModule; + Root owningRoot = Element.getRoot(element); // START KGU#862 2020-04-25: Bugfix #863/2 - the assignment symbol must be transformed for (int i = 0; i < text.count(); i++) { - text.set(i, transform(text.get(i))); + String line = text.get(i).trim(); + if (line.isEmpty()) { + continue; + } + // START KGU#863 2020-04-28: issues #385, #864/2 Support for declared optional arguments + Function call = ((Call)element).getCalledRoutine(i); + if (call != null && (routinePool != null) && line.endsWith(")")) { + java.util.Vector callCandidates = routinePool.findRoutinesBySignature(call.getName(), call.paramCount(), owningRoot); + if (!callCandidates.isEmpty()) { + // FIXME We'll just fetch the very first one for now... + Root called = callCandidates.get(0); + StringList defaults = new StringList(); + called.collectParameters(null, null, defaults); + if (defaults.count() > call.paramCount()) { + // We just insert the list of default values for the missing arguments + line = line.substring(0, line.length()-1) + (call.paramCount() > 0 ? ", " : "") + + defaults.subSequence(call.paramCount(), defaults.count()).concatenate(", ") + ")"; + } + } + } + PapFigure lastFigure = new PapFigure(row++, column0, papType, transform(line), null); + figures.add(lastFigure); + if (prevId >= 0) { + connections.add(new PapConnection(prevId, lastFigure.getId())); + } + prevId = lastFigure.getId(); + if (firstId < 0) { + firstId = prevId; + } + // END KGU#863 2020-04-28 + } + // All done in general, avert the creation of another figure ... + text.clear(); + // ... unless the call has not produced any figure (?) + if (prevId < 0) { + // Obviously there was no non-empty line, have a dummy node created + text.add(""); } // END KGU#862 2020-04-25 } @@ -640,7 +695,11 @@ public long[] generateItems(List figures, List connect int row = this.row0; PapItem.resetNextId(); // Generate the title figure - figures.add(new PapFigure(row, column0, PapFigure.Type.PapTitle, element.getText().getLongString(), null)); + // START KGU#863 2020-04-28: Issue #864/1: PapDesigner does not recognise semicolons + //figures.add(new PapFigure(row, column0, PapFigure.Type.PapTitle, element.getText().getLongString(), null)); + String header = transformHeader((Root)element); + figures.add(new PapFigure(row, column0, PapFigure.Type.PapTitle, header, null)); + // END KGU#863 2020-04-28 // Generate the comment if necessary String comment = element.getComment().getText().trim(); if (!comment.isEmpty()) { @@ -1771,7 +1830,10 @@ public String generateCode(Root _root, String _indent, boolean _public) code.add(indent2 + ""); } - code.add(indent3 + ""); + // START KGU#863 2020-04-28: Issue #864: Transform parameter list + //code.add(indent3 + ""); + code.add(indent3 + ""); + // END KGU#863 2020-04-28 PapRoot rootNode = new PapRoot(_root); int columns = rootNode.getWidth(); @@ -1867,5 +1929,42 @@ protected boolean max1MainPerModule() return false; } // END KGU#815 2020-04-01 - + + // START KGU#863 2020-04-28: Issue #864/1 + /** + * Provides a (possibly adapted) Root header that meets the requirements + * for the PapDesigner mapping between Calls and routines. + * (For PapDesigner v2.2.08.06, semicolons must be substituted.) + * @param root - the {@link Root} the header for which is needed + * @return the transformed routine header + */ + private String transformHeader(Root root) { + String header = root.getText().getLongString(); + if (header.contains(";")) { + // We might convert it to C or to some pseudo Pascal syntax with commas + header = root.getMethodName(); + String resType = root.getResultType(); + StringList paramNames = new StringList(); + StringList paramTypes = new StringList(); + if (root.collectParameters(paramNames, paramTypes, null)) { + header += "("; + for (int i = 0; i < paramNames.count(); i++) { + if (i > 0) { + header += ", "; + } + String type = paramTypes.get(i); + header += paramNames.get(i); + if (type != null) { + header += ":" + type; + } + } + header += ")"; + } + if (resType != null) { + header += ": " + resType; + } + } + return header; + } + // END KGU#863 2020-04-28 } diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 71d3db6a..b21f49d7 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -15,7 +15,7 @@ Known issues: - Shell export copes neither with nested array/record initializers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version: 3.30-09 (2020-04-25) +Current development version: 3.30-09 (2020-04-28) - 01: Bugfix #759: Another source of stale Mainforms dried up. <2> - 01: Bugfix #761: Code preview defect flooded the log stream. <2> - 01: Precautions against empty error messages on startup <2> @@ -116,6 +116,7 @@ Current development version: 3.30-09 (2020-04-25) - 09: Bugfix #862/3: Batch import produced defective arrangement lists <2> - 09: Bugfix #863/1: Duplicate routines on PapDesigner/StrukTex export <2> - 09: Bugfix #863/2: Wrong assignment symbols in CALLs on PapDesigner export <2> +- 09: Issue #864: Parameter lists had to be transformed for PapDesigner export <2> Version: 3.30 (2019-10-06) - 01: Issue #657: Spanish message in German locale replaced <2> From ec86ac531349c2b09469797d72b503848725ca97 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Tue, 28 Apr 2020 22:46:12 +0200 Subject: [PATCH 10/18] More sensible error message on executing an empty CALL line (#822 sequel). --- .../fisch/structorizer/executor/Control.java | 18 +++++++++++------- .../fisch/structorizer/executor/Executor.java | 7 +++++++ src/lu/fisch/structorizer/gui/changelog.txt | 1 + src/lu/fisch/structorizer/locales/de.txt | 1 + src/lu/fisch/structorizer/locales/en.txt | 1 + src/lu/fisch/structorizer/locales/es.txt | 1 + src/lu/fisch/structorizer/locales/nl.txt | 1 + 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/lu/fisch/structorizer/executor/Control.java b/src/lu/fisch/structorizer/executor/Control.java index a09033b7..1f3624c6 100644 --- a/src/lu/fisch/structorizer/executor/Control.java +++ b/src/lu/fisch/structorizer/executor/Control.java @@ -70,6 +70,7 @@ * Kay Gürtzig 2019-11-21 Enh. #739: Mnemonic display and ComboBox editing for enumerator values * Editability check bug fixed in the table model fixed * Kay Gürtzig 2019-11-25 Enh. #739: Protection against pending EnumeratorCellEditor on stop + * Kay Gürtzig 2020-04-28 Issue #822: New message for empty lines in CALL elements * ****************************************************************************************************** * @@ -1110,13 +1111,16 @@ public void actionPerformed(ActionEvent evt) { // START KGU#569 2018-08-09: New messages for issue #577 public static final LangTextHolder msgGUISyncFault = new LangTextHolder("Possible GUI synchronisation fault on executing «%».\nTry to resume execution?"); // END KGU#569 2018-08-09 - // START KGU#686 2019-03-17: Enh. #56 Try-Catch element and throw flavour of Jump introduced - public static final LangTextHolder msgErrorInSubroutine = new LangTextHolder("Caught error on executing «%1» at level %2:\n\t%3!"); - public static final LangTextHolder msgThrown = new LangTextHolder("Exception thrown in «%1» at level %2: %3"); - // END KGU#686 2019-03-17 - // START KGU#452 2019-11-17: Enh. #739 - public static final LangTextHolder msgInvalidEnumDefinition = new LangTextHolder("Invalid enumeration type definition «%»!"); - // END KGU#452 2019-11-17 + // START KGU#686 2019-03-17: Enh. #56 Try-Catch element and throw flavour of Jump introduced + public static final LangTextHolder msgErrorInSubroutine = new LangTextHolder("Caught error on executing «%1» at level %2:\n\t%3!"); + public static final LangTextHolder msgThrown = new LangTextHolder("Exception thrown in «%1» at level %2: %3"); + // END KGU#686 2019-03-17 + // START KGU#452 2019-11-17: Enh. #739 + public static final LangTextHolder msgInvalidEnumDefinition = new LangTextHolder("Invalid enumeration type definition «%»!"); + // END KGU#452 2019-11-17 + // START KGU#809 2020-04-28: Issue #822 + public static final LangTextHolder msgIllegalEmptyLine = new LangTextHolder("Empty lines within a @j are illegal!"); + // END KGU#809 2020-04-28 // START KGU#68 2015-11-06: Register variable value editing events private final ConcurrentMap varUpdates = new ConcurrentHashMap(); diff --git a/src/lu/fisch/structorizer/executor/Executor.java b/src/lu/fisch/structorizer/executor/Executor.java index 61a8b595..745f5357 100644 --- a/src/lu/fisch/structorizer/executor/Executor.java +++ b/src/lu/fisch/structorizer/executor/Executor.java @@ -194,6 +194,7 @@ * Kay Gürtzig 2020-04-04 Issue #829: Control should not automatically close after debugging [mawa290669] * Kay Gürtzig 2020-04-13 Bugfix #848: On updating the context of includables mere declarations had been forgotten * Kay Gürtzig 2020-04-23 Bugfix #858: split function in FOR-IN loop was not correctly handled + * Kay Gürtzig 2020-04-28 Issue #822: Empty CALL lines should cause more sensible error messages * ****************************************************************************************************** * @@ -4684,6 +4685,12 @@ private String stepCall(Call element) // END KGU#77 2015-11-11 { String cmd = sl.get(i); + // START KGU#809 2020-04-28: Issue #822 Sensible error messages on empty lines + if (cmd.trim().isEmpty()) { + trouble = Control.msgIllegalEmptyLine.getText(); + break; + } + // END KGU#809 2020-04-28 // cmd=cmd.replace(":=", "<-"); // START KGU#490 2018-02-08: Bugfix #503 - postpone string comparison conversion //cmd = convert(cmd); diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index b21f49d7..858b4ab7 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -108,6 +108,7 @@ Current development version: 3.30-09 (2020-04-28) - 08: Enh. #855 New configurable default array/string sizes for code export <2> - 08: Bugfix #856: The dump of preferences subsets did not behave correctly <2> - 08: Bugfix #858: Functions did not actually work in FOR-IN loop headers <2> +- 09: Issue #822: More sensible error message on executing an empty CALL <2> - 09: Bugfix #860: Batch export for .arr files containing abs. paths failed <2> - 09: Issue #861/1: Comment placement on Pascal and Oberon export revised <2> - 09: Bugfix #861/2: On Pascal import, routine comments were duplicated <2> diff --git a/src/lu/fisch/structorizer/locales/de.txt b/src/lu/fisch/structorizer/locales/de.txt index 6c3bc0b9..3ae4abef 100644 --- a/src/lu/fisch/structorizer/locales/de.txt +++ b/src/lu/fisch/structorizer/locales/de.txt @@ -1442,6 +1442,7 @@ Control.msgBadValueList.text=<%> kann nicht als Wertliste interpretiert werden. Control.msgBadValueListDetails.text=Details: % Control.msgIndexOutOfBounds.text=Index «%1» (%2) überschreitet Indexbereich für Array «%3»! Control.msgInitializerAsArgument.text=Ein Array-Initialisierer kann nicht direkt als Argument an eine eingebaute Funktion übergeben werden.\nWeisen Sie das Array vorher einer Variablen zu und übergeben Sie diese. +Control.msgIllegalEmptyLine.text=Illegale leere Zeile in einem @j! Control.msgVarUpdateErrors.text=Problem beim Variablen-Update Control.msgVarUpdatesFailed.text=Diese Variablen-Änderungen scheiterten an syntaktischen Fehlern:\n\n% Control.msgEndEditing.text=Zum Fortfahren erst Variablen-Editierung beenden (Enter oder Esc). diff --git a/src/lu/fisch/structorizer/locales/en.txt b/src/lu/fisch/structorizer/locales/en.txt index 9b1b5395..47d3d525 100644 --- a/src/lu/fisch/structorizer/locales/en.txt +++ b/src/lu/fisch/structorizer/locales/en.txt @@ -1442,6 +1442,7 @@ Control.msgBadValueList.text=<%> cannot be interpreted as value list. Control.msgBadValueListDetails.text=Details: % Control.msgIndexOutOfBounds.text=Index «%1» (%2) is out of bounds for array «%3»! Control.msgInitializerAsArgument.text=You may not pass an array initializer directly as argument to a built-in function.\nAssign the array to a variable first. +Control.msgIllegalEmptyLine.text=Empty lines within a @j are illegal! Control.msgVarUpdateErrors.text=Trouble updating variables Control.msgVarUpdatesFailed.text=These variable modifications failed because of evaluation errors:\n\n% Control.msgEndEditing.text=To continue, first release the variable cell editor (Enter or Esc). diff --git a/src/lu/fisch/structorizer/locales/es.txt b/src/lu/fisch/structorizer/locales/es.txt index c7ab5b6e..349ba6a3 100644 --- a/src/lu/fisch/structorizer/locales/es.txt +++ b/src/lu/fisch/structorizer/locales/es.txt @@ -1427,6 +1427,7 @@ Control.msgBadValueList.text=<%> no se puede interpretar como lista de valores. Control.msgIndexOutOfBounds.text=¡Indice «%1» (%2) está fuera de los márgines del array «%3»! Control.msgInitializerAsArgument.text=Un inicialisador de array ne se puede pasar diréctamente como parámetro a una función interna.\nPon el array anteriórmente en una variable y pasa ésa pués. Control.msgBadValueListDetails.text=Detalles: % +Control.msgIllegalEmptyLine.text=¡Una linea vacías no es aceptable en un @j! Control.msgVarUpdateErrors.text=Problemas poniendo nuevos valores Control.msgVarUpdatesFailed.text=Estas modificaciones de variables no valen por faltas sintacticas:\n\n% Control.msgEndEditing.text=Para continuar cesa editar variables (Enter o Esc). diff --git a/src/lu/fisch/structorizer/locales/nl.txt b/src/lu/fisch/structorizer/locales/nl.txt index d8e00df7..45d11453 100644 --- a/src/lu/fisch/structorizer/locales/nl.txt +++ b/src/lu/fisch/structorizer/locales/nl.txt @@ -1359,6 +1359,7 @@ Control.msgBadValueList.text=<%> kan geen lijst met waarden zijn Control.msgBadValueListDetails.text=Details: % Control.msgIndexOutOfBounds.text=Index «%1» (%2) is voorbij de grenzen van array «%3»! Control.msgInitializerAsArgument.text=U kunt geen array direct als argument initialiseren in een built-in functie.\nKen eerst de array toe aan een variable. +Control.msgIllegalEmptyLine.text=Lege regel in een @j is onjuist! Control.msgVarUpdateErrors.text=Problemen bij bijwerken van variabelen Control.msgVarUpdatesFailed.text=Veranderen van deze variabelen is mislukt als gevolg van foutieve berekeningen:\n\n% Control.msgEndEditing.text=Om verder te kunnen gaan moet u de celeditor voor variabelen vrijgeven (Enter of Escape). From b109ee0814a1a4248ba5196980060ca445707417 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Tue, 28 Apr 2020 23:25:18 +0200 Subject: [PATCH 11/18] Fixes #865 (flaw on generating a subroutine) --- src/lu/fisch/structorizer/gui/Diagram.java | 17 +++++++++++++---- src/lu/fisch/structorizer/gui/changelog.txt | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/lu/fisch/structorizer/gui/Diagram.java b/src/lu/fisch/structorizer/gui/Diagram.java index bf1bdf42..a9751b02 100644 --- a/src/lu/fisch/structorizer/gui/Diagram.java +++ b/src/lu/fisch/structorizer/gui/Diagram.java @@ -199,6 +199,7 @@ * Kay Gürtzig 2020-03-16/17 Enh. #828: New method to export an arrangement group * Kay Gürtzig 2020-04-22 Enh. #855: New export options for array size / string length defaults * Kay Gürtzig 2020-04-23 Bugfix #856: Selective preference saving to file didn't work properly + * Kay Gürtzig 2020-04-28 Bugfix #865: On subroutine generation arguments true and false weren't recognised * ****************************************************************************************************** * @@ -4260,6 +4261,11 @@ private StringList prepareArgTypesForSub(HashMap parentTyp if (varType != null) { typeName = varType.getCanonicalType(true, true); } + // START KGU#864 2020-04-28: Bugfix #865 + else if (varName.equals("true") || varName.contentEquals("false")) { + typeName = "boolean"; + } + // END KGU#864 2020-04-28 } else { typeName = Element.identifyExprType(parentTypes, varName, true); @@ -4398,7 +4404,6 @@ public boolean canEditSub() { * @see #canEditSub() */ public void editSubNSD() { - // TODO Auto-generated method stub if (selected instanceof Call && this.canEditSub()) { Call call = (Call)selected; Function called = call.getCalledRoutine(); @@ -4453,11 +4458,15 @@ else if (candidates.size() > 1) { String paramSeparator = ", "; for (int i = 0; i < params.count(); i++) { String typeName = argTypes.get(i).replace("@", "array of "); - if (!Function.testIdentifier(params.get(i), "")) { - params.set(i, "param" + (i+1)); + // START KGU#864 2020-04-28: Bugfix #865 + //if (!Function.testIdentifier(params.get(i), "")) { + String param = params.get(i); + if (!Function.testIdentifier(param, "") || param.equals("true") || param.equals("false")) { + // END KGU#864 2020-04-28 + params.set(i, param = ("param" + (i+1))); } if (!typeName.isEmpty() && !typeName.equals("???")) { - params.set(i, params.get(i) + ": " + typeName); + params.set(i, param + ": " + typeName); paramSeparator = "; "; } } diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 858b4ab7..fd987530 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -117,7 +117,8 @@ Current development version: 3.30-09 (2020-04-28) - 09: Bugfix #862/3: Batch import produced defective arrangement lists <2> - 09: Bugfix #863/1: Duplicate routines on PapDesigner/StrukTex export <2> - 09: Bugfix #863/2: Wrong assignment symbols in CALLs on PapDesigner export <2> -- 09: Issue #864: Parameter lists had to be transformed for PapDesigner export <2> +- 09: Issue #864: Parameter list transformation for PapDesigner export <2> +- 09: Bugfix #865: Flaw in parameter recognition on subroutine generation <2> Version: 3.30 (2019-10-06) - 01: Issue #657: Spanish message in German locale replaced <2> From 34aa9d6f561f153b6c59c9a35846a3ddd61e16f4 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Wed, 29 Apr 2020 00:03:04 +0200 Subject: [PATCH 12/18] Flaw in #828 fixed (unreferenced subroutines missing on group export with 1 main) --- .../fisch/structorizer/generators/Generator.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lu/fisch/structorizer/generators/Generator.java b/src/lu/fisch/structorizer/generators/Generator.java index 0a333033..16ffff42 100644 --- a/src/lu/fisch/structorizer/generators/Generator.java +++ b/src/lu/fisch/structorizer/generators/Generator.java @@ -110,6 +110,7 @@ * Kay Gürtzig 2020-04-22 Enh. #855: New options for default array / string size * Kay Gürtzig 2020-04-24 Bugfix #862/2: Prevent duplicate export of an entry point root * Kay Gürtzig 2020-04-25 Bugfix #863/1: Duplicate routine export to PapDesigner and StrukTex + * Kay Gürtzig 2020-04-28 Bugfix #828: Unreferenced subroutines were missing on group export with 1 main * ****************************************************************************************************** * @@ -4820,12 +4821,20 @@ protected boolean generatePartitionedCode(Vector _entryPoints, boolean _ba // Now we can put all diagrams together and generate a common module if (!_batchMode && mainIndices.size() == 1 && _entryPoints.size() > 1) { /* In case of group export (_batchMode = false) the main (if there is one) can - * be made the only entry point, we just have to find it again first + * be made the only entry point if all remaining entry points are redundant, + * we just have to find it again first */ for (Root root: _entryPoints) { if (root.isProgram()) { - _entryPoints.clear(); - _entryPoints.add(root); + // START KGU#865 2020-04-28: Bugfix of #828 + //_entryPoints.clear(); + //_entryPoints.add(root); + _entryPoints.remove(root); + if (nRedundant == _entryPoints.size()) { + _entryPoints.clear(); + } + _entryPoints.insertElementAt(root, 0); + // END KGU#865 2020-04-08 break; } } From 7a4e34945bac5029296519625ba11d1de3612ff2 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Wed, 29 Apr 2020 01:31:34 +0200 Subject: [PATCH 13/18] Changelog revised for bugfix #828. --- src/lu/fisch/structorizer/gui/changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index fd987530..540e2692 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -15,7 +15,7 @@ Known issues: - Shell export copes neither with nested array/record initializers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version: 3.30-09 (2020-04-28) +Current development version: 3.30-09 (2020-04-29) - 01: Bugfix #759: Another source of stale Mainforms dried up. <2> - 01: Bugfix #761: Code preview defect flooded the log stream. <2> - 01: Precautions against empty error messages on startup <2> @@ -109,6 +109,7 @@ Current development version: 3.30-09 (2020-04-28) - 08: Bugfix #856: The dump of preferences subsets did not behave correctly <2> - 08: Bugfix #858: Functions did not actually work in FOR-IN loop headers <2> - 09: Issue #822: More sensible error message on executing an empty CALL <2> +- 09: Bugfix #828: Missing unreferenced subroutines on group export. <2> - 09: Bugfix #860: Batch export for .arr files containing abs. paths failed <2> - 09: Issue #861/1: Comment placement on Pascal and Oberon export revised <2> - 09: Bugfix #861/2: On Pascal import, routine comments were duplicated <2> From deb39754485b15bc21b561fc1e98a20fdff7b4b6 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Thu, 30 Apr 2020 01:56:23 +0200 Subject: [PATCH 14/18] Export samples for PapDesigner updated (#684) --- samples/export/PAP/ComputeSum_1966.pap | 6 +- samples/export/PAP/ComputeSum_1982.pap | 6 +- .../export/PAP/DrawRandomHistogram_1966.pap | 18 ++--- .../export/PAP/DrawRandomHistogram_1982.pap | 18 ++--- samples/export/PAP/ELIZA_2.2_1966.pap | 26 +++---- samples/export/PAP/ELIZA_2.2_1982.pap | 26 +++---- samples/export/PAP/ELIZA_2.3_1966.pap | 18 ++--- samples/export/PAP/ELIZA_2.3_1982.pap | 18 ++--- samples/export/PAP/TextDemo_1966.pap | 76 +++++++++---------- samples/export/PAP/TextDemo_1982.pap | 76 +++++++++---------- .../export_group/PAP/ELIZA_2_2_arrz_1966.pap | 26 +++---- .../export_group/PAP/ELIZA_2_2_arrz_1982.pap | 26 +++---- .../export_group/PAP/ELIZA_2_3_arrz_1966.pap | 18 ++--- .../export_group/PAP/ELIZA_2_3_arrz_1982.pap | 18 ++--- .../PAP/FileApiGroupTest_arrz_1966.pap | 22 +++--- .../PAP/FileApiGroupTest_arrz_1982.pap | 22 +++--- .../export_group/PAP/TextWriter_arrz_1966.pap | 76 +++++++++---------- .../export_group/PAP/TextWriter_arrz_1982.pap | 76 +++++++++---------- 18 files changed, 286 insertions(+), 286 deletions(-) diff --git a/samples/export/PAP/ComputeSum_1966.pap b/samples/export/PAP/ComputeSum_1966.pap index d18da978..9826ba20 100644 --- a/samples/export/PAP/ComputeSum_1966.pap +++ b/samples/export/PAP/ComputeSum_1966.pap @@ -1,5 +1,5 @@ - + @@ -289,12 +289,12 @@ caught?]]> - +
- +
diff --git a/samples/export/PAP/ComputeSum_1982.pap b/samples/export/PAP/ComputeSum_1982.pap index 6e2d6213..621c20ef 100644 --- a/samples/export/PAP/ComputeSum_1982.pap +++ b/samples/export/PAP/ComputeSum_1982.pap @@ -1,5 +1,5 @@ - + @@ -227,12 +227,12 @@ caught?]]>
- +
- +
diff --git a/samples/export/PAP/DrawRandomHistogram_1966.pap b/samples/export/PAP/DrawRandomHistogram_1966.pap index f1d9d85f..c4ca1537 100644 --- a/samples/export/PAP/DrawRandomHistogram_1966.pap +++ b/samples/export/PAP/DrawRandomHistogram_1966.pap @@ -1,5 +1,5 @@ - + @@ -699,12 +699,12 @@ max := numberArray[0]]]>
- +
- +
@@ -979,7 +979,7 @@ backward(xSize-1)]]>
- +
@@ -989,7 +989,7 @@ backward(xSize-1)]]>
- +
@@ -999,7 +999,7 @@ backward(xSize-1)]]>
- +
@@ -1014,7 +1014,7 @@ backward(xSize-1)]]>
- +
@@ -1167,12 +1167,12 @@ penUp()]]>
- +
- +
diff --git a/samples/export/PAP/DrawRandomHistogram_1982.pap b/samples/export/PAP/DrawRandomHistogram_1982.pap index a64e475e..848cab26 100644 --- a/samples/export/PAP/DrawRandomHistogram_1982.pap +++ b/samples/export/PAP/DrawRandomHistogram_1982.pap @@ -1,5 +1,5 @@ - + @@ -453,12 +453,12 @@ max := numberArray[0]]]>
- +
- +
@@ -678,7 +678,7 @@ backward(xSize-1)]]>
- +
@@ -688,7 +688,7 @@ backward(xSize-1)]]>
- +
@@ -698,7 +698,7 @@ backward(xSize-1)]]>
- +
@@ -713,7 +713,7 @@ backward(xSize-1)]]>
- +
@@ -823,12 +823,12 @@ penUp()]]>
- +
- +
diff --git a/samples/export/PAP/ELIZA_2.2_1966.pap b/samples/export/PAP/ELIZA_2.2_1966.pap index 33e75c3d..3aadbecf 100644 --- a/samples/export/PAP/ELIZA_2.2_1966.pap +++ b/samples/export/PAP/ELIZA_2.2_1966.pap @@ -1,5 +1,5 @@ - + @@ -489,7 +489,7 @@ insert(varPart, reply, posAster)]]>
- + @@ -713,12 +713,12 @@ insert(varPart, reply, posAster)]]> - +
- +
@@ -811,12 +811,12 @@ returns true, otherwise false]]>
- +
- +
@@ -988,12 +988,12 @@ length(history) - 1 input strings and updates the history]]>
- +
- +
@@ -1183,12 +1183,12 @@ right := copy(right, position + length(pair[0]), length(right))]]>
- +
- +
@@ -1333,7 +1333,7 @@ result[1] := position]]>
- + @@ -1455,7 +1455,7 @@ sentence among blanks]]> - + @@ -1579,7 +1579,7 @@ keywords[38] := KeyMapEntry{"mother ", 28}]]> - + diff --git a/samples/export/PAP/ELIZA_2.2_1982.pap b/samples/export/PAP/ELIZA_2.2_1982.pap index a1dfc4cc..3c3bed2b 100644 --- a/samples/export/PAP/ELIZA_2.2_1982.pap +++ b/samples/export/PAP/ELIZA_2.2_1982.pap @@ -1,5 +1,5 @@ - + @@ -476,7 +476,7 @@ insert(varPart, reply, posAster)]]> - + @@ -626,12 +626,12 @@ insert(varPart, reply, posAster)]]> - +
- +
@@ -724,12 +724,12 @@ returns true, otherwise false]]>
- +
- +
@@ -852,12 +852,12 @@ length(history) - 1 input strings and updates the history]]>
- +
- +
@@ -973,12 +973,12 @@ right := copy(right, position + length(pair[0]), length(right))]]>
- +
- +
@@ -1086,7 +1086,7 @@ result[1] := position]]>
- + @@ -1171,7 +1171,7 @@ sentence among blanks]]> - + @@ -1295,7 +1295,7 @@ keywords[38] := KeyMapEntry{"mother ", 28}]]> - + diff --git a/samples/export/PAP/ELIZA_2.3_1966.pap b/samples/export/PAP/ELIZA_2.3_1966.pap index 0f3c39d0..1e14a52c 100644 --- a/samples/export/PAP/ELIZA_2.3_1966.pap +++ b/samples/export/PAP/ELIZA_2.3_1966.pap @@ -1,5 +1,5 @@ - + @@ -720,12 +720,12 @@ insert(varPart, reply, posAster)]]> - +
- +
@@ -812,12 +812,12 @@ returns true, otherwise false]]>
- +
- +
@@ -989,12 +989,12 @@ input strings in the histArray component of history and updates the history.]]><
- +
- +
@@ -1184,12 +1184,12 @@ right := copy(right, position + length(pair[0]), length(right))]]>
- +
- +
diff --git a/samples/export/PAP/ELIZA_2.3_1982.pap b/samples/export/PAP/ELIZA_2.3_1982.pap index 4d25cc55..975c335c 100644 --- a/samples/export/PAP/ELIZA_2.3_1982.pap +++ b/samples/export/PAP/ELIZA_2.3_1982.pap @@ -1,5 +1,5 @@ - + @@ -633,12 +633,12 @@ insert(varPart, reply, posAster)]]>
- +
- +
@@ -725,12 +725,12 @@ returns true, otherwise false]]>
- +
- +
@@ -853,12 +853,12 @@ input strings in the histArray component of history and updates the history.]]><
- +
- +
@@ -974,12 +974,12 @@ right := copy(right, position + length(pair[0]), length(right))]]>
- +
- +
diff --git a/samples/export/PAP/TextDemo_1966.pap b/samples/export/PAP/TextDemo_1966.pap index d1813023..381be858 100644 --- a/samples/export/PAP/TextDemo_1966.pap +++ b/samples/export/PAP/TextDemo_1966.pap @@ -1,5 +1,5 @@ - + @@ -224,7 +224,7 @@ entered text to a new line.]]>
- + @@ -268,7 +268,7 @@ left(90)]]> - + @@ -494,7 +494,7 @@ left(90)]]> - + @@ -604,7 +604,7 @@ penDown()]]> - + @@ -696,7 +696,7 @@ penDown()]]> - + @@ -783,7 +783,7 @@ penDown()]]> - + @@ -874,7 +874,7 @@ penDown()]]> - + @@ -981,7 +981,7 @@ penDown()]]> - + @@ -1063,7 +1063,7 @@ penDown()]]> - + @@ -1126,7 +1126,7 @@ penDown()]]> - + @@ -1216,7 +1216,7 @@ from the current turtle position.]]> - + @@ -1302,7 +1302,7 @@ penDown()]]> - + @@ -1398,7 +1398,7 @@ penDown()]]> - + @@ -1482,7 +1482,7 @@ penDown()]]> - + @@ -1600,7 +1600,7 @@ penDown()]]> - + @@ -1682,7 +1682,7 @@ penDown()]]> - + @@ -1791,7 +1791,7 @@ penDown()]]> - + @@ -1884,12 +1884,12 @@ penDown()]]> - +
- +
@@ -2024,7 +2024,7 @@ counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.]]>
- + @@ -2121,7 +2121,7 @@ penDown()]]> - + @@ -2252,7 +2252,7 @@ penDown()]]> - + @@ -2426,7 +2426,7 @@ penDown()]]> - + @@ -2508,7 +2508,7 @@ penDown()]]> - + @@ -2636,7 +2636,7 @@ penDown()]]> - + @@ -2783,7 +2783,7 @@ left(90)]]> - + @@ -2904,7 +2904,7 @@ penDown()]]> - + @@ -3054,7 +3054,7 @@ left(90)]]> - + @@ -3163,7 +3163,7 @@ penDown()]]> - + @@ -3281,7 +3281,7 @@ penDown()]]> - + @@ -3385,7 +3385,7 @@ penDown()]]> - + @@ -3527,7 +3527,7 @@ penDown()]]> - + @@ -3644,7 +3644,7 @@ in the colour endcoded by colorNo]]> - + @@ -3765,7 +3765,7 @@ penDown()]]> - + @@ -3887,7 +3887,7 @@ penDown()]]> - + @@ -4020,12 +4020,12 @@ penDown()]]> - +
- +
diff --git a/samples/export/PAP/TextDemo_1982.pap b/samples/export/PAP/TextDemo_1982.pap index 9cee7a02..0447ad18 100644 --- a/samples/export/PAP/TextDemo_1982.pap +++ b/samples/export/PAP/TextDemo_1982.pap @@ -1,5 +1,5 @@ - + @@ -185,7 +185,7 @@ entered text to a new line.]]>
- + @@ -229,7 +229,7 @@ left(90)]]> - + @@ -455,7 +455,7 @@ left(90)]]> - + @@ -565,7 +565,7 @@ penDown()]]> - + @@ -657,7 +657,7 @@ penDown()]]> - + @@ -744,7 +744,7 @@ penDown()]]> - + @@ -835,7 +835,7 @@ penDown()]]> - + @@ -942,7 +942,7 @@ penDown()]]> - + @@ -1024,7 +1024,7 @@ penDown()]]> - + @@ -1087,7 +1087,7 @@ penDown()]]> - + @@ -1177,7 +1177,7 @@ from the current turtle position.]]> - + @@ -1263,7 +1263,7 @@ penDown()]]> - + @@ -1359,7 +1359,7 @@ penDown()]]> - + @@ -1443,7 +1443,7 @@ penDown()]]> - + @@ -1561,7 +1561,7 @@ penDown()]]> - + @@ -1643,7 +1643,7 @@ penDown()]]> - + @@ -1752,7 +1752,7 @@ penDown()]]> - + @@ -1845,12 +1845,12 @@ penDown()]]> - +
- +
@@ -1936,7 +1936,7 @@ counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.]]>
- + @@ -2033,7 +2033,7 @@ penDown()]]> - + @@ -2164,7 +2164,7 @@ penDown()]]> - + @@ -2338,7 +2338,7 @@ penDown()]]> - + @@ -2420,7 +2420,7 @@ penDown()]]> - + @@ -2548,7 +2548,7 @@ penDown()]]> - + @@ -2695,7 +2695,7 @@ left(90)]]> - + @@ -2816,7 +2816,7 @@ penDown()]]> - + @@ -2966,7 +2966,7 @@ left(90)]]> - + @@ -3075,7 +3075,7 @@ penDown()]]> - + @@ -3193,7 +3193,7 @@ penDown()]]> - + @@ -3297,7 +3297,7 @@ penDown()]]> - + @@ -3439,7 +3439,7 @@ penDown()]]> - + @@ -3556,7 +3556,7 @@ in the colour endcoded by colorNo]]> - + @@ -3677,7 +3677,7 @@ penDown()]]> - + @@ -3799,7 +3799,7 @@ penDown()]]> - + @@ -3932,12 +3932,12 @@ penDown()]]> - +
- +
diff --git a/samples/export_group/PAP/ELIZA_2_2_arrz_1966.pap b/samples/export_group/PAP/ELIZA_2_2_arrz_1966.pap index 89745938..0f9607ae 100644 --- a/samples/export_group/PAP/ELIZA_2_2_arrz_1966.pap +++ b/samples/export_group/PAP/ELIZA_2_2_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -489,7 +489,7 @@ insert(varPart, reply, posAster)]]>
- + @@ -713,12 +713,12 @@ insert(varPart, reply, posAster)]]> - +
- +
@@ -811,12 +811,12 @@ returns true, otherwise false]]>
- +
- +
@@ -988,12 +988,12 @@ length(history) - 1 input strings and updates the history]]>
- +
- +
@@ -1183,7 +1183,7 @@ right := copy(right, position + length(pair[0]), length(right))]]>
- + @@ -1305,7 +1305,7 @@ sentence among blanks]]> - + @@ -1342,7 +1342,7 @@ phrases[1] := {"bye", "Well, let\'s end our talk for now. See you later. Bye."}] - + @@ -1666,12 +1666,12 @@ in `setupMapping()´]]> - +
- +
diff --git a/samples/export_group/PAP/ELIZA_2_2_arrz_1982.pap b/samples/export_group/PAP/ELIZA_2_2_arrz_1982.pap index b3b70cf0..a8cdacdd 100644 --- a/samples/export_group/PAP/ELIZA_2_2_arrz_1982.pap +++ b/samples/export_group/PAP/ELIZA_2_2_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -476,7 +476,7 @@ insert(varPart, reply, posAster)]]>
- + @@ -626,12 +626,12 @@ insert(varPart, reply, posAster)]]> - +
- +
@@ -724,12 +724,12 @@ returns true, otherwise false]]>
- +
- +
@@ -852,12 +852,12 @@ length(history) - 1 input strings and updates the history]]>
- +
- +
@@ -973,7 +973,7 @@ right := copy(right, position + length(pair[0]), length(right))]]>
- + @@ -1058,7 +1058,7 @@ sentence among blanks]]> - + @@ -1095,7 +1095,7 @@ phrases[1] := {"bye", "Well, let\'s end our talk for now. See you later. Bye."}] - + @@ -1419,12 +1419,12 @@ in `setupMapping()´]]> - +
- +
diff --git a/samples/export_group/PAP/ELIZA_2_3_arrz_1966.pap b/samples/export_group/PAP/ELIZA_2_3_arrz_1966.pap index daf6013a..62444d9d 100644 --- a/samples/export_group/PAP/ELIZA_2_3_arrz_1966.pap +++ b/samples/export_group/PAP/ELIZA_2_3_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -720,12 +720,12 @@ insert(varPart, reply, posAster)]]>
- +
- +
@@ -812,12 +812,12 @@ returns true, otherwise false]]>
- +
- +
@@ -1490,12 +1490,12 @@ in `setupMapping()´]]>
- +
- +
@@ -1667,12 +1667,12 @@ input strings in the histArray component of history and updates the history.]]><
- +
- +
diff --git a/samples/export_group/PAP/ELIZA_2_3_arrz_1982.pap b/samples/export_group/PAP/ELIZA_2_3_arrz_1982.pap index 1eb9f179..55a660c8 100644 --- a/samples/export_group/PAP/ELIZA_2_3_arrz_1982.pap +++ b/samples/export_group/PAP/ELIZA_2_3_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -633,12 +633,12 @@ insert(varPart, reply, posAster)]]>
- +
- +
@@ -725,12 +725,12 @@ returns true, otherwise false]]>
- +
- +
@@ -1292,12 +1292,12 @@ in `setupMapping()´]]>
- +
- +
@@ -1420,12 +1420,12 @@ input strings in the histArray component of history and updates the history.]]><
- +
- +
diff --git a/samples/export_group/PAP/FileApiGroupTest_arrz_1966.pap b/samples/export_group/PAP/FileApiGroupTest_arrz_1966.pap index 0dfe4d91..27264eef 100644 --- a/samples/export_group/PAP/FileApiGroupTest_arrz_1966.pap +++ b/samples/export_group/PAP/FileApiGroupTest_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -987,12 +987,12 @@ max := numberArray[0]]]>
- +
- +
@@ -1267,7 +1267,7 @@ backward(xSize-1)]]>
- +
@@ -1277,7 +1277,7 @@ backward(xSize-1)]]>
- +
@@ -1287,7 +1287,7 @@ backward(xSize-1)]]>
- +
@@ -1302,7 +1302,7 @@ backward(xSize-1)]]>
- +
@@ -1456,12 +1456,12 @@ penUp()]]>
- +
- +
@@ -1672,12 +1672,12 @@ caught?]]>
- +
- +
diff --git a/samples/export_group/PAP/FileApiGroupTest_arrz_1982.pap b/samples/export_group/PAP/FileApiGroupTest_arrz_1982.pap index e7da0796..d2a84b66 100644 --- a/samples/export_group/PAP/FileApiGroupTest_arrz_1982.pap +++ b/samples/export_group/PAP/FileApiGroupTest_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -679,12 +679,12 @@ max := numberArray[0]]]>
- +
- +
@@ -904,7 +904,7 @@ backward(xSize-1)]]>
- +
@@ -914,7 +914,7 @@ backward(xSize-1)]]>
- +
@@ -924,7 +924,7 @@ backward(xSize-1)]]>
- +
@@ -939,7 +939,7 @@ backward(xSize-1)]]>
- +
@@ -1050,12 +1050,12 @@ penUp()]]>
- +
- +
@@ -1217,12 +1217,12 @@ caught?]]>
- +
- +
diff --git a/samples/export_group/PAP/TextWriter_arrz_1966.pap b/samples/export_group/PAP/TextWriter_arrz_1966.pap index ccd572e6..77219393 100644 --- a/samples/export_group/PAP/TextWriter_arrz_1966.pap +++ b/samples/export_group/PAP/TextWriter_arrz_1966.pap @@ -1,5 +1,5 @@ - + @@ -224,7 +224,7 @@ entered text to a new line.]]>
- + @@ -268,7 +268,7 @@ left(90)]]> - + @@ -494,7 +494,7 @@ left(90)]]> - + @@ -604,7 +604,7 @@ penDown()]]> - + @@ -696,7 +696,7 @@ penDown()]]> - + @@ -783,7 +783,7 @@ penDown()]]> - + @@ -874,7 +874,7 @@ penDown()]]> - + @@ -981,7 +981,7 @@ penDown()]]> - + @@ -1063,7 +1063,7 @@ penDown()]]> - + @@ -1126,7 +1126,7 @@ penDown()]]> - + @@ -1216,7 +1216,7 @@ from the current turtle position.]]> - + @@ -1302,7 +1302,7 @@ penDown()]]> - + @@ -1398,7 +1398,7 @@ penDown()]]> - + @@ -1482,7 +1482,7 @@ penDown()]]> - + @@ -1600,7 +1600,7 @@ penDown()]]> - + @@ -1682,7 +1682,7 @@ penDown()]]> - + @@ -1791,7 +1791,7 @@ penDown()]]> - + @@ -1884,12 +1884,12 @@ penDown()]]> - +
- +
@@ -2024,7 +2024,7 @@ counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.]]>
- + @@ -2121,7 +2121,7 @@ penDown()]]> - + @@ -2252,7 +2252,7 @@ penDown()]]> - + @@ -2426,7 +2426,7 @@ penDown()]]> - + @@ -2508,7 +2508,7 @@ penDown()]]> - + @@ -2636,7 +2636,7 @@ penDown()]]> - + @@ -2783,7 +2783,7 @@ left(90)]]> - + @@ -2904,7 +2904,7 @@ penDown()]]> - + @@ -3054,7 +3054,7 @@ left(90)]]> - + @@ -3163,7 +3163,7 @@ penDown()]]> - + @@ -3281,7 +3281,7 @@ penDown()]]> - + @@ -3385,7 +3385,7 @@ penDown()]]> - + @@ -3527,7 +3527,7 @@ penDown()]]> - + @@ -3644,7 +3644,7 @@ in the colour endcoded by colorNo]]> - + @@ -3765,7 +3765,7 @@ penDown()]]> - + @@ -3887,7 +3887,7 @@ penDown()]]> - + @@ -4020,12 +4020,12 @@ penDown()]]> - +
- +
diff --git a/samples/export_group/PAP/TextWriter_arrz_1982.pap b/samples/export_group/PAP/TextWriter_arrz_1982.pap index 12302f23..55e21946 100644 --- a/samples/export_group/PAP/TextWriter_arrz_1982.pap +++ b/samples/export_group/PAP/TextWriter_arrz_1982.pap @@ -1,5 +1,5 @@ - + @@ -185,7 +185,7 @@ entered text to a new line.]]>
- + @@ -229,7 +229,7 @@ left(90)]]> - + @@ -455,7 +455,7 @@ left(90)]]> - + @@ -565,7 +565,7 @@ penDown()]]> - + @@ -657,7 +657,7 @@ penDown()]]> - + @@ -744,7 +744,7 @@ penDown()]]> - + @@ -835,7 +835,7 @@ penDown()]]> - + @@ -942,7 +942,7 @@ penDown()]]> - + @@ -1024,7 +1024,7 @@ penDown()]]> - + @@ -1087,7 +1087,7 @@ penDown()]]> - + @@ -1177,7 +1177,7 @@ from the current turtle position.]]> - + @@ -1263,7 +1263,7 @@ penDown()]]> - + @@ -1359,7 +1359,7 @@ penDown()]]> - + @@ -1443,7 +1443,7 @@ penDown()]]> - + @@ -1561,7 +1561,7 @@ penDown()]]> - + @@ -1643,7 +1643,7 @@ penDown()]]> - + @@ -1752,7 +1752,7 @@ penDown()]]> - + @@ -1845,12 +1845,12 @@ penDown()]]> - +
- +
@@ -1936,7 +1936,7 @@ counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false.]]>
- + @@ -2033,7 +2033,7 @@ penDown()]]> - + @@ -2164,7 +2164,7 @@ penDown()]]> - + @@ -2338,7 +2338,7 @@ penDown()]]> - + @@ -2420,7 +2420,7 @@ penDown()]]> - + @@ -2548,7 +2548,7 @@ penDown()]]> - + @@ -2695,7 +2695,7 @@ left(90)]]> - + @@ -2816,7 +2816,7 @@ penDown()]]> - + @@ -2966,7 +2966,7 @@ left(90)]]> - + @@ -3075,7 +3075,7 @@ penDown()]]> - + @@ -3193,7 +3193,7 @@ penDown()]]> - + @@ -3297,7 +3297,7 @@ penDown()]]> - + @@ -3439,7 +3439,7 @@ penDown()]]> - + @@ -3556,7 +3556,7 @@ in the colour endcoded by colorNo]]> - + @@ -3677,7 +3677,7 @@ penDown()]]> - + @@ -3799,7 +3799,7 @@ penDown()]]> - + @@ -3932,12 +3932,12 @@ penDown()]]> - +
- +
From 46398a620392b1cd4758cea292dfb38a063db3ac Mon Sep 17 00:00:00 2001 From: codemanyak Date: Fri, 1 May 2020 17:32:17 +0200 Subject: [PATCH 15/18] Changelog.txt updates --- src/lu/fisch/structorizer/gui/changelog.txt | 102 ++++++++++---------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 540e2692..65f4f677 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -12,21 +12,21 @@ Known issues: also if the code contains a SPECIAL-NAMES clause or float literals. - COBOL import does not cope with some statement variants and variable redefinitions. - The Javascript generator is just a prototype and may be deficient. -- Shell export copes neither with nested array/record initializers and component access +- Shell export copes neither with nested array/record initialisers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version: 3.30-09 (2020-04-29) -- 01: Bugfix #759: Another source of stale Mainforms dried up. <2> +Current development version: 3.30-09 (2020-05-01) +- 01: Bugfix #759: Dried up another source of stale Mainforms. <2> - 01: Bugfix #761: Code preview defect flooded the log stream. <2> - 01: Precautions against empty error messages on startup <2> - 01: Bugfix #705: Find&Replace: Flawed traversal in CASE/PARALLEL branches <2> - 01: Bugfix #763: Stale file precautions on loading / saving arrangements <2> -- 01: Bugfix #764: Updating of the .arr file for a modified group may fail <2> +- 01: Bugfix #764: Group modifications failed to update the associated .arr file <2> - 01: Bugfix #765: KSH export of diagrams using record types failed with error <2> - 01: Deprecated ANSI-C73 import disabled (ANSI-C99 parser subsumes it) <2> - 02: Bugfix #752: Incomplete declarations in C, Java etc. no longer outcommented <2> - 02: Issue #766: Deterministic order of subroutines on code export <2> -- 02: Bugfix #769: String literals containing commas in CASE branch selectors <2> +- 02: Bugfix #769: Commas in string literals compromised CASE branch selection <2> - 02: Enh. #770: New Analyser checks for CASE elements (selector consistency) <2> - 02: Bugfix #771: Unhandled syntax errors during execution (e.g. type names) <2> - 02: Bugfix #772: Possible NullPointerException averting Pascal code preview <2> @@ -38,7 +38,7 @@ Current development version: 3.30-09 (2020-04-29) - 03: Bugfix #770: Not all CASE selectors were checked to be constant integers <2> - 03: Enh. #775: More type-sensitive export of input instructions to OBERON <2> - 03: Bugfix #776: Global variables are locally eclipsed on Pascal/Oberon export <2> -- 03: Bugfix #777: Concurrently changed favourite export language handled. <2> +- 03: Bugfix #777: Concurrent changes of favourite export language handled. <2> - 03: Bugfix #778: License text was not exported with "fresh" diagrams <2> - 03: Bugfix #779: Defective Oberon export of main program diagrams with I/O <2> - 03: Issue #780: Parameterless procedures in Oberon without parentheses [K.-P. R.]2 @@ -49,9 +49,9 @@ Current development version: 3.30-09 (2020-04-29) - 03: Bugfix #787: Multiplied top-level type definitions on Pascal export <2> - 03: Bugfix #788: Arrz file extraction to a user-specific folder did not work. <2> - 03: Bugfix #789: Wrong BASIC export of function calls (started with "CALL") <2> -- 03: Bugfix #790: BASIC export failed with line continuation and initializers <2> +- 03: Bugfix #790: BASIC export failed with line continuation and initialisers <2> - 03: Bugfix #791: Shell export flaws (function calls, array/assoc declarators) <2> -- 04: Bugfix #793: Wrong Perl export of initialized explicit var declarations <2> +- 04: Bugfix #793: Wrong Perl export of initialised explicit var declarations <2> - 04: Bugfix #794: Code preview fails with error if license is not configured <2> - 05: Enh. #801: Mechanism to show User Guide as PDF in offline mode <2> - 05: Bugfix #802: Placement of license texts and User Guides was flawed by #741 <2> @@ -96,14 +96,14 @@ Current development version: 3.30-09 (2020-04-29) - 08: Issue #828/#836: The fallback to all diagrams of an arr file on batch export without specified entry points or contained programs hadn't worked <2> - 08: Enh. #842: Improved usability of the include list editor [H.-U. Hölscher]2 -- 08: Bugfix #847: Inconsistent handling of upper/lowercase operand names <2> +- 08: Bugfix #847: Inconsistent handling of upper-/lower-case operand names <2> - 08: Bugfix #848: Incomplete variable synchronisation with Includables <2> - 08: Bugfix #849: New log file name scheme change of release 3.30 ensured <2> - 08: Issue #851/1: Declarations for auxiliary variables on COBOL import <2> - 08: Issue #851/4: Provisional import of SORT statements from COBOL <2> - 08: Issue #851/5: Solution for the import of PERFORM ... THRU ... from COBOL <2> - 08: Bugfix #852: Case-ignorant F&R replacements failed for certain strings <2> -- 08: Bugfix #853: Batch export with relative paths of and in arr file failed <2> +- 08: Bugfix #853: Batch export with relative paths of and in .arr file failed <2> - 08: Bugfix #854: Topological order of type definitions on export ensured <2> - 08: Enh. #855 New configurable default array/string sizes for code export <2> - 08: Bugfix #856: The dump of preferences subsets did not behave correctly <2> @@ -839,51 +839,51 @@ Version: 3.24 (2016-03-14) - 17: Bugfix #97 update: Arranger updated on global drawing changes <2> Version 3.23 (2015-12-04) -- 01: executor: fixed a bug in the Repeat loop [Sylvio Tabor] -- 02: executor: fixed a bug while interpreting the title [Benjamin Bartsch] -- 03: export: split PNG export into multiple images [Moritz Schulze] -- 04: executor: logical operator in CASE-statement [Lies Callemeyn] -- 05: export: added code export option [Hanspeter Thöni] -- 06: export: added comments to Pascal export [Dirk Wilhelmi] -- 06: export: moved export options into menu [Hanspeter Thöni] -- 07: export: added namespace "nsd" to save files [Treaki] -- 08: added Polish translation [Jacek Dzieniewicz] -- 09: new drawing strategy for the IF statement [David Tremain] -- 09: new colorizing strategy for elements [David Tremain] -- 10: visual re-enforcement for drag & drop [David Tremain] -- 11: allow to collapse / expand elements by scrolling the mouse [David Tremain] -- 12: added preferences on how to draw IF statements [David Tremain] -- 13: fixed "empty line" bug [David Tremain] -- 14: fixed a drawing bug while dragging an element [Bob Fisch] -- 15: added a Python generator [Daniel Spittank] -- 16: removed a bug when double clicking en element [Bob Fisch] -- 16: variable highlighting did not work anymore [Andreas Schwierz] -- 17: executor: array support [Gennaro Donnarumma] -- 18: added traditional Chinese translation [Joe Chem] -- 19: multiple improvements +- 01: Executor: fixed a bug in the Repeat loop [Sylvio Tabor] +- 02: Executor: fixed a bug while interpreting the title [Benjamin Bartsch] +- 03: Export: split PNG export into multiple images [Moritz Schulze] +- 04: Executor: logical operator in CASE-statement [Lies Callemeyn] +- 05: Export: added code export option [Hanspeter Thöni] +- 06: Export: added comments to Pascal export [Dirk Wilhelmi] +- 06: Export: moved export options into menu [Hanspeter Thöni] +- 07: Export: added namespace "nsd" to save files [Treaki] +- 08: Added Polish translation [Jacek Dzieniewicz] +- 09: New drawing strategy for the IF statement [David Tremain] +- 09: New colorizing strategy for elements [David Tremain] +- 10: Visual re-enforcement for drag & drop [David Tremain] +- 11: Allow to collapse / expand elements by scrolling the mouse [David Tremain] +- 12: Added preferences on how to draw IF statements [David Tremain] +- 13: Fixed "empty line" bug [David Tremain] +- 14: Fixed a drawing bug while dragging an element [Bob Fisch] +- 15: Added a Python generator [Daniel Spittank] +- 16: Removed a bug when double clicking en element [Bob Fisch] +- 16: Variable highlighting did not work anymore [Andreas Schwierz] +- 17: Executor: array support [Gennaro Donnarumma] +- 18: Added traditional Chinese translation [Joe Chem] +- 19: Multiple improvements - 20: DE: linguistic flaws corrected -- 21: major revision of generators files -- 22: possibility to switch text/comment in diagram [Samuel Schmidt] -- 23: bug while parsing NSD files [Benedict Thienpont] -- 24: fine tuning the ExportOptionDialoge -- 24: updated language files (RU,DE,EN,ES) -- 24: updated language files (LU,FR) [Bob Fisch] -- 25: added hints to speed buttons [Rens Duijsens] -- 26: export for Basic [Jacek Dzieniewicz] +- 21: Major revision of generators files +- 22: Possibility to switch text/comment in diagram [Samuel Schmidt] +- 23: Bug while parsing NSD files [Benedict Thienpont] +- 24: Fine tuning the ExportOptionDialoge +- 24: Updated language files (RU,DE,EN,ES) +- 24: Updated language files (LU,FR) [Bob Fisch] +- 25: Added hints to speed buttons [Rens Duijsens] +- 26: Export for BASIC [Jacek Dzieniewicz] - 26: PL: updated [Jacek Dzieniewicz] - 27: Array variable improvements in executor -- 27: updated language files (RU,DE,EN,ES) -- 28: minor change in executor for comp. with Unimozer [Bob Fisch] +- 27: Updated language files (RU,DE,EN,ES) +- 28: Minor change in executor for comp. with Unimozer [Bob Fisch] - 29: Complex changes and enhancements as described (pull-request #7) -- 29: executor: breakpoints may now be placed throughout the diagram <2> -- 29: executor: implementation for Endless loops and Parallel elements <2> -- 29: executor: eexecution highlighting separated from selection <2> -- 29: executor: variable list now updated on every pause even with delay 0 <2> -- 29: gui: More localisation support for element editor (InputBox) <2> -- 29: updated language files (DE,EN,ES,RU,IT) <2> -- 29: export: indentation mechanism revised, BASH export corrected <2> -- 29: export: Python export no longer "eats" lines within Repeat loops <2> -- 29: comment popup: sticky popups eliminated, no element level limit <2> +- 29: Executor: breakpoints may now be placed throughout the diagram <2> +- 29: Executor: implementation for Endless loops and Parallel elements <2> +- 29: Executor: execution highlighting separated from selection <2> +- 29: Executor: variable list now updated on every pause even with delay 0 <2> +- 29: GUI: More localisation support for element editor (InputBox) <2> +- 29: Updated language files (DE,EN,ES,RU,IT) <2> +- 29: Export: indentation mechanism revised, BASH export corrected <2> +- 29: Export: Python export no longer "eats" lines within Repeat loops <2> +- 29: Comment popup: sticky popups eliminated, no element level limit <2> - 29: Arranger: No longer loses track when related Structorizer reloads <2> - 30: Several Chinese (ZH-CN) translations added and typos eliminated - 30: Issue on closing Structorizer fixed, file update question may be cancelled. <2> From d1f9dfdd2fc8d3d64493e16151833be2659a3a72 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Sun, 3 May 2020 02:27:28 +0200 Subject: [PATCH 16/18] Fixes #866 (new expansion/reduction strategy for element selection) --- .../elements/IElementSequence.java | 18 +- src/lu/fisch/structorizer/gui/Diagram.java | 90 +++++++-- src/lu/fisch/structorizer/gui/Editor.java | 14 +- .../structorizer/gui/SelectedSequence.java | 174 ++++++++++++++---- src/lu/fisch/structorizer/gui/changelog.txt | 3 +- 5 files changed, 248 insertions(+), 51 deletions(-) diff --git a/src/lu/fisch/structorizer/elements/IElementSequence.java b/src/lu/fisch/structorizer/elements/IElementSequence.java index 1017fcc6..b1911fc6 100644 --- a/src/lu/fisch/structorizer/elements/IElementSequence.java +++ b/src/lu/fisch/structorizer/elements/IElementSequence.java @@ -38,6 +38,7 @@ * Kay Gürtzig 2019-03-17 Bugfix #705: Substructure of Case and Parallel hadn't been traversed * Kay Gürtzig 2019-03-17 Enh. #56: New element class Try integrated * Kay Gürtzig 2019-10-12 Bugfix #705/2: Retrieval mistake for CASE, PARALLEL branches in getNext(boolean) +* Kay Gürtzig 2020-05-02 Javadoc completed on occasion of issue #866 * ****************************************************************************************************** * @@ -410,13 +411,26 @@ else if (((Try)el).qTry.getSize() > 0) { */ public abstract int getSize(); + /** + * Tries to find {@link Element} {@code _ele} within this sequence and returns + * its position if found. + * @param _ele - the {@link Element} to be located. + * @return the index, or -1 if not found + */ public abstract int getIndexOf(Element _ele); + /** + * Fetches the {@link Element} at position {@code _index} if this is a + * valid index. Will cause an exception otherwise. + * @param _index - must be in interval [0, {@link #getSize()}-1] + * @return the requested {@link Element} + * @throws ArrayIndexOutOfBoundsException if the index is out of range + */ public abstract Element getElement(int _index); /** - * Appends the given _element to the already held elements - * @param _element + * Appends the given {@code _element} to the already held {@link Element}s + * @param _element - {@link Element} to be added. */ public abstract void addElement(Element _element); diff --git a/src/lu/fisch/structorizer/gui/Diagram.java b/src/lu/fisch/structorizer/gui/Diagram.java index a9751b02..137efae4 100644 --- a/src/lu/fisch/structorizer/gui/Diagram.java +++ b/src/lu/fisch/structorizer/gui/Diagram.java @@ -200,6 +200,7 @@ * Kay Gürtzig 2020-04-22 Enh. #855: New export options for array size / string length defaults * Kay Gürtzig 2020-04-23 Bugfix #856: Selective preference saving to file didn't work properly * Kay Gürtzig 2020-04-28 Bugfix #865: On subroutine generation arguments true and false weren't recognised + * Kay Gürtzig 2020-05-02 Issue #866: Selection expansion / reduction mechanisms revised * ****************************************************************************************************** * @@ -1017,11 +1018,11 @@ public void mouseDragged(MouseEvent e) if ((selectedDown!=null) && (e.getX()!=mouseX) && (e.getY()!=mouseY) && (selectedMoved!=bSome)) { mouseMove=true; - if(selectedDown.getClass().getSimpleName().equals("Root") || - selectedDown.getClass().getSimpleName().equals("Subqueue") || - bSome.getClass().getSimpleName().equals("Root") || - //root.checkChild(bSome, selectedDown)) - bSome.isDescendantOf(selectedDown)) + if (selectedDown.getClass().getSimpleName().equals("Root") || + selectedDown.getClass().getSimpleName().equals("Subqueue") || + bSome.getClass().getSimpleName().equals("Root") || + //root.checkChild(bSome, selectedDown)) + bSome.isDescendantOf(selectedDown)) { Element.E_DRAWCOLOR=Color.RED; } @@ -1126,6 +1127,12 @@ else if (ele != selected) //((Subqueue)ele.parent).getIndexOf(selected)); selected.setSelected(false); selected = new SelectedSequence(selected, ele); + // START KGU#866 2020-05-02: Issue #866 span may get reduced now + if (((SelectedSequence)selected).getSize() == 1) { + // Replace the span by its only member + selected = ((SelectedSequence)selected).getElement(0); + } + // END KGU#866 2020-05-02 selected.setSelected(true); redraw(); selectedDown = ele; @@ -10042,23 +10049,84 @@ public void expandSelection(Editor.SelectionExpandDirection _direction) Subqueue sq = (Subqueue)selected.parent; Element first = selected; Element last = selected; + // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy + int anchorOffset = 0; + boolean atUpperEnd = true; // Is the selection to be modified at upper end? + boolean atLowerEnd = true; // Is the selection to be modified at lower end? + // END KGU#866 2020-05-02 if (selected instanceof SelectedSequence) { - first = ((SelectedSequence)selected).getElement(0); - last = ((SelectedSequence)selected).getElement(((SelectedSequence)selected).getSize()-1); + SelectedSequence sel = (SelectedSequence)selected; + first = sel.getElement(0); + last = sel.getElement(sel.getSize()-1); + // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy + anchorOffset = sel.getAnchorOffset(); + atUpperEnd = !sel.wasModifiedBelowAnchor(); // FIXME offset of anchor? + atLowerEnd = sel.wasModifiedBelowAnchor(); + // END KGU#866 2020-05-02 } int index0 = sq.getIndexOf(first); int index1 = sq.getIndexOf(last); - if (_direction == Editor.SelectionExpandDirection.EXPAND_UP && index0 > 0) + // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy + //if (_direction == Editor.SelectionExpandDirection.EXPAND_UP && index0 > 0) + if (index0 > 0 && + (_direction == Editor.SelectionExpandDirection.EXPAND_TOP + || _direction == Editor.SelectionExpandDirection.EXPAND_UP && atUpperEnd)) + // END KGU#866 2020-05-02 { - selected = new SelectedSequence(sq, index0-1, index1); + System.out.println("Case 1: " + index0 + ", " + index1 + " / " + anchorOffset); + // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy + //selected = new SelectedSequence(sq, index0-1, index1); + selected = new SelectedSequence(sq, index0-1, index1, anchorOffset+1, false); + // END KGU#866 2020-05-02 newSelection = true; } - else if (_direction == Editor.SelectionExpandDirection.EXPAND_DOWN && index1 < sq.getSize()-1) + // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy + //else if (_direction == Editor.SelectionExpandDirection.EXPAND_DOWN && index1 < sq.getSize()-1) + else if (index1 < sq.getSize()-1 && + (_direction == Editor.SelectionExpandDirection.EXPAND_BOTTOM + || _direction == Editor.SelectionExpandDirection.EXPAND_DOWN && atLowerEnd)) + // END KGU#866 2020-05-02 { - selected = new SelectedSequence(sq, index0, index1+1); + System.out.println("Case 2: " + index0 + ", " + index1 + " / " + anchorOffset); + // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy + //selected = new SelectedSequence(sq, index0, index1+1, _index1, true); + selected = new SelectedSequence(sq, index0, index1+1, anchorOffset, true); + // END KGU#866 2020-05-02 + newSelection = true; + } + // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy + else if (_direction == Editor.SelectionExpandDirection.EXPAND_UP && atLowerEnd) { + // Reduce at end + selected.setSelected(false); + redraw(selected); + if (index0+1 >= index1) { + // Selected sequence collapses to a single element + selected = first; + } + else { + selected = new SelectedSequence(sq, index0, index1-1, + (anchorOffset == index1 - index0 ? anchorOffset - 1 : anchorOffset), + true); + } + newSelection = true; + } + else if (_direction == Editor.SelectionExpandDirection.EXPAND_DOWN && atUpperEnd) { + // Reduce at start + selected.setSelected(false); + redraw(selected); + if (index0+1 >= index1) { + // Selected sequence collapses to a single element + selected = last; + } + else { + selected = new SelectedSequence(sq, index0+1, index1, + (anchorOffset == 0 ? 0 : anchorOffset - 1), + false); + } newSelection = true; } + // END KGU#866 2020-05-02 if (newSelection) { selected.setSelected(true); diff --git a/src/lu/fisch/structorizer/gui/Editor.java b/src/lu/fisch/structorizer/gui/Editor.java index 7d2151d9..77abed60 100644 --- a/src/lu/fisch/structorizer/gui/Editor.java +++ b/src/lu/fisch/structorizer/gui/Editor.java @@ -80,6 +80,7 @@ * Kay Gürtzig 2019-09-27 Enh. #738: Click in code preview now selects element and highlights code, * double-click opens element editor * Kay Gürtzig 2019-10-02 Enh. #738 code preview font control via Ctrl-Numpad-+/- + * Kay Gürtzig 2020-05-02 Issue #866: Modified key bindings for expanding / reducing selection * ****************************************************************************************************** * @@ -336,7 +337,10 @@ public void actionPerformed(ActionEvent ev) { } // END KGU#177 2016-04-06 // START KGU#206 2016-07-21: Enh. #158, #197 - public enum SelectionExpandDirection { EXPAND_UP, EXPAND_DOWN }; + // START KGU#866 2020-05-02: Issue #866 + //public enum SelectionExpandDirection { EXPAND_UP, EXPAND_DOWN }; + public enum SelectionExpandDirection { EXPAND_UP, EXPAND_DOWN, EXPAND_TOP, EXPAND_BOTTOM }; + // END KGU#866 2020-05-02 private class SelectionExpandAction extends AbstractAction { Diagram diagram; // The object responsible for executing the action @@ -568,6 +572,10 @@ private void createDiagramArea() { inpMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_DOWN_MASK ), SelectionExpandDirection.EXPAND_UP); inpMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.SHIFT_DOWN_MASK ), SelectionExpandDirection.EXPAND_DOWN); // END KGU#206 2016-07-21 + // START KGU#866 2020-05-02: Issue #866 + inpMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK ), SelectionExpandDirection.EXPAND_TOP); + inpMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK ), SelectionExpandDirection.EXPAND_BOTTOM); + // END KGU#866 2020-05-02 // START KGU#177 2016-04-14: Enh. #158 inpMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PAGE_DOWN"); inpMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PAGE_UP"); @@ -599,6 +607,10 @@ private void createDiagramArea() { actMap.put(SelectionExpandDirection.EXPAND_UP, new SelectionExpandAction(diagram, SelectionExpandDirection.EXPAND_UP)); actMap.put(SelectionExpandDirection.EXPAND_DOWN, new SelectionExpandAction(diagram, SelectionExpandDirection.EXPAND_DOWN)); // END KGU#206 2016-07-21 + // START KGU#866 2020-05-02: Issue #866 + actMap.put(SelectionExpandDirection.EXPAND_TOP, new SelectionExpandAction(diagram, SelectionExpandDirection.EXPAND_TOP)); + actMap.put(SelectionExpandDirection.EXPAND_BOTTOM, new SelectionExpandAction(diagram, SelectionExpandDirection.EXPAND_BOTTOM)); + // END KGU#866 2020-05-02 // START KGU#177 2016-04-14: Enh. #158 actMap.put("PAGE_DOWN", new PageScrollAction(scrollarea.getVerticalScrollBar(), false, "PAGE_DOWN")); actMap.put("PAGE_UP", new PageScrollAction(scrollarea.getVerticalScrollBar(), true, "PAGE_UP")); diff --git a/src/lu/fisch/structorizer/gui/SelectedSequence.java b/src/lu/fisch/structorizer/gui/SelectedSequence.java index 1c744029..dfbd9c78 100644 --- a/src/lu/fisch/structorizer/gui/SelectedSequence.java +++ b/src/lu/fisch/structorizer/gui/SelectedSequence.java @@ -46,6 +46,7 @@ * Kay Gürtzig 2017.03.26 Enh. #380: Methods addElement() and insertElementAt() now substantially implemented * Kay Gürtzig 2018.10.26 Enh. #619: New method getMaxLineLength(boolean) implemented * Kay Gürtzig 2019-03-13 Issues #518, #544, #557: Element drawing now restricted to visible rect. + * Kay Gürtzig 2020-05-02 Issue #866: Additional fields and methods to support revised selection expansion * ****************************************************************************************************** * @@ -70,64 +71,108 @@ /** * @author Kay Gürtzig - * Class represents a selected subsequence of a Subqueue + * Class represents a selected subsequence of a {@link Subqueue} */ public class SelectedSequence extends Element implements IElementSequence { - private int firstIndex = 0, lastIndex = -1; // The positions of the first and last selected element within the parent Subqueue + // Positions of the first and last selected element within the parent Subqueue + private int firstIndex = 0, lastIndex = -1; + // START KGU#866 2020-05-02: Issue #866 New fields to support revised expansion strategy + // Selection seed index offset w.r.t. firstIndex + private int anchorOffset = 0; + // Where the most recent expansion had taken place w.r.t. the anchorIndex + private boolean lastActionBelow = true; + // END KGU#866 2020-05-02 - // START KGU#136 2016-03-01: Bugfix #97 + // START KGU#136 2016-03-01: Bugfix #97 We must retain the base y coordinate to avoid flickering private Vector y0Children = new Vector(); // END KGU#136 2016-03-01 /** - * @param _child1 - a selected Element, marking one end of the sequence - * @param _child2 - a selected Element, marking the other end of sequence + * If this is used to replace (expand/reduce) a previous selection then the old + * selection must be {@code _child1}. + * @param _child1 - a selected {@link Element}, marking one end of the sequence, + * may be a {@link SelectedSequence} + * @param _child2 - a selected {@link Element}, marking the other end of sequence, + * must not be a {@link SelectedSequence} */ - public SelectedSequence(Element _child1, Element _child2) { + public SelectedSequence(Element _child1, Element _child2) + { super(""); // _child1 and _child2 should have got a common parent (in particular, a Subqueue) this.parent = _child1.parent; + assert parent == _child2.parent; + int i1 = ((Subqueue)this.parent).getIndexOf(_child1); int i2 = ((Subqueue)this.parent).getIndexOf(_child2); - if (i1 < 0) - { - if (_child1 instanceof SelectedSequence) - { - this.firstIndex = Math.min(((SelectedSequence)_child1).firstIndex, i2); - this.lastIndex = Math.max(((SelectedSequence)_child1).lastIndex, i2); + if (i1 < 0) { + if (_child1 instanceof SelectedSequence) { + // START KGU#866 2020-05-02: Issue #866 - improved selection expansion / reduction + //this.firstIndex = Math.min(((SelectedSequence)_child1).firstIndex, i2); + //this.lastIndex = Math.max(((SelectedSequence)_child1).lastIndex, i2); + SelectedSequence sel = (SelectedSequence)_child1; + int ixAnchor = sel.firstIndex + sel.anchorOffset; + if (i2 < ixAnchor || i2 == ixAnchor && !sel.lastActionBelow) { + this.firstIndex = i2; + this.lastIndex = sel.lastIndex; + this.lastActionBelow = false; + } + else { + // i2 > ixAnchor || i2 == ixAnchor && sel.lastActionBelow + this.firstIndex = sel.firstIndex; + this.lastIndex = i2; + } + this.anchorOffset = ixAnchor - this.firstIndex; + // END KGU#866 2020-05-02 } else if (i2 >= 0) { this.firstIndex = this.lastIndex = i2; } } - else if (i2 < 0) - { + else if (i2 < 0) { this.firstIndex = this.lastIndex = i1; } - else if (i1 <= i2) - { + else if (i1 <= i2) { this.firstIndex = i1; this.lastIndex = i2; } - else - { + else { this.firstIndex = i2; - this.lastIndex = i1; + this.lastIndex = i1; + // START KGU#866 2020-05-02: Issue #866 - improved selection expansion / reduction + this.anchorOffset = i1 - i2; + this.lastActionBelow = false; + // END KGU#866 2020-05-02 } } /** - * @param _owner - Subqueue this is to represent a subsequence of + * Establishes new selection span with respect to the given {@code _owner} + * @param _owner - {@link Subqueue} this is to represent a subsequence of + * @param _index1 - Index of the first Element of the sequence within {@code _owner} + * @param _index2 - Index of the last Element of the sequence within {@code _owner} + */ + public SelectedSequence(Subqueue _owner, int _index1, int _index2) { + this(_owner, _index1, _index2, 0, true); + } + + /** + * Establishes new selection span with respect to the given {@code _owner}, where + * element at {@code _index0} is retained as selection anchor for expansion/reduction. + * @param _owner - {@link Subqueue} this is to represent a subsequence of * @param _index1 - Index of the Element marking the begin of the sequence * @param _index2 - Index of the Element marking the end of the sequence + * @param _offset0 - Index offset of the selection anchor (w.r.t. {@code _index0} for expansion or reduction) + * @param _modifiedBelow - true if last expanded or reduced at or below anchor (false otherwise) */ - public SelectedSequence(Subqueue _owner, int _index1, int _index2) { + public SelectedSequence(Subqueue _owner, int _index1, int _index2, int _offset0, boolean _modifiedBelow) { super(""); this.parent = _owner; this.firstIndex = Math.max(0, _index1); this.lastIndex = Math.min(_owner.getSize()-1, _index2); + this.anchorOffset = Math.max(0, Math.min(this.lastIndex - this.firstIndex, _offset0)); + this.lastActionBelow = _modifiedBelow; } /** @@ -260,6 +305,7 @@ public void draw(Canvas _canvas, Rect _top_left, Rectangle _viewport, boolean _i /* (non-Javadoc) * @see lu.fisch.structorizer.elements.Element#getRect() */ + @Override public Rect getRect() { Rect first = this.getElement(0).getRect(); @@ -275,6 +321,7 @@ public Rect getRect() /* (non-Javadoc) * @see lu.fisch.structorizer.elements.Element#getRect(java.awt.Point) */ + @Override public Rect getRect(Point relativeTo) { Rect combined = getRect(); @@ -285,6 +332,7 @@ public Rect getRect(Point relativeTo) /* (non-Javadoc) * @see lu.fisch.structorizer.elements.Element#getRectOffDrawPoint() */ + @Override public Rect getRectOffDrawPoint() { // First find out the topLeft coordinate of the first element @@ -296,8 +344,8 @@ public Rect getRectOffDrawPoint() } // END KGU#206 2016-07-21 - /* (non-Javadoc) - * The copy will be related to a new Suqueue only consisting of copies of + /** + * The copy will be related to a new {@link Subqueue} only consisting of copies of * my referenced elements * @see lu.fisch.structorizer.elements.Element#copy() */ @@ -312,11 +360,13 @@ public Element copy() { return new SelectedSequence(newParent, 0, getSize()); } + @Override public int getSize() { return lastIndex >= 0 ? lastIndex - firstIndex + 1 : 0; } + @Override public int getIndexOf(Element _ele) { int index = ((Subqueue)parent).getIndexOf(_ele); @@ -331,6 +381,7 @@ public int getIndexOf(Element _ele) return index; } + @Override public Element getElement(int _index) { Element ele = null; @@ -371,6 +422,7 @@ public Element getElementByCoord(int _x, int _y, boolean _forSelection) * (if it was referenced here) * @param _element - Element t be removed */ + @Override public void removeElement(Element _element) { // Is _element within my range? @@ -390,6 +442,7 @@ public void removeElement(Element _element) * drops the virtual reference here. * @param _index */ + @Override public void removeElement(int _index) { // START KGU#199 2016-07-07: Bugfix (on occasion of Enh. #188) @@ -426,6 +479,7 @@ public boolean isExecuted(boolean ignored) // END KGU#143 2016-01-22 // START KGU#144 2016-01-22: Bugfix #38, #114 - moveDown and moveUp hadn't been implemented + @Override public boolean canMoveDown() { boolean canMove = this.lastIndex + 1 < ((Subqueue)this.parent).getSize(); @@ -440,6 +494,7 @@ public boolean canMoveDown() return canMove; } + @Override public boolean canMoveUp() { boolean canMove = this.firstIndex > 0; @@ -454,6 +509,12 @@ public boolean canMoveUp() return canMove; } + /** + * Moves all {@link Element}s representing this selection one position downwards + * within the owner {@link Subqueue} if possible + * @return true if the selected {@link Element}s could be moved, false otherwise + * @see #canMoveDown() + */ public boolean moveDown() { boolean feasible = this.canMoveDown(); @@ -471,6 +532,12 @@ public boolean moveDown() return feasible; } + /** + * Moves all {@link Element}s representing this selection one position upwards + * within the owner {@link Subqueue} if possible + * @return true if the selected {@link Element}s could be moved, false otherwise + * @see #canMoveUp() + */ public boolean moveUp() { boolean feasible = this.canMoveUp(); @@ -519,19 +586,19 @@ protected void addFullText(StringList _lines, boolean _instructionsOnly) { // This class will hardly be object of code generation } - @Override - public void setColor(Color _color) - { - for(int i = firstIndex; i <= lastIndex; i++) - { - ((Subqueue)parent).getElement(i).setColor(_color); - } - } - - /** - * Sets this element sequence as a whole and also all individual members to selected - * (if {@code _sel} is true) or unselected (otherwise). - */ + @Override + public void setColor(Color _color) + { + for(int i = firstIndex; i <= lastIndex; i++) + { + ((Subqueue)parent).getElement(i).setColor(_color); + } + } + + /** + * Sets this element sequence as a whole and also all individual members to selected + * (if {@code _sel} is true) or unselected (otherwise). + */ @Override public Element setSelected(boolean _sel) { @@ -688,4 +755,39 @@ public int getMaxLineLength(boolean _includeSubstructure) return maxLen; } // END KGU#602 2018-10-25 + + // START KGU#866 2020-05-02: Issue #866 - modified expansion / reduction strategy + /** + * @return the index offset of the first selected element within the parenting {@link Subqueue} + */ + public int getStartOffset() + { + return this.firstIndex; + } + + /** + * @return the index offset of the first selected element within the parenting {@link Subqueue} + */ + public int getEndOffset() + { + return this.lastIndex; + } + + /** + * @return the index offset of the first selected element within the parenting {@link Subqueue} + */ + public int getAnchorOffset() + { + return this.anchorOffset; + } + + /** + * @return true if last expansion/reduction was below anchor position (or if no + * expansion / reduction had been done recently), false otherwise. + */ + public boolean wasModifiedBelowAnchor() + { + return this.lastActionBelow; + } + // END KGU#866 2020-05-02 } diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 65f4f677..5934db75 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -15,7 +15,7 @@ Known issues: - Shell export copes neither with nested array/record initialisers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version: 3.30-09 (2020-05-01) +Current development version: 3.30-09 (2020-05-03) - 01: Bugfix #759: Dried up another source of stale Mainforms. <2> - 01: Bugfix #761: Code preview defect flooded the log stream. <2> - 01: Precautions against empty error messages on startup <2> @@ -120,6 +120,7 @@ Current development version: 3.30-09 (2020-05-01) - 09: Bugfix #863/2: Wrong assignment symbols in CALLs on PapDesigner export <2> - 09: Issue #864: Parameter list transformation for PapDesigner export <2> - 09: Bugfix #865: Flaw in parameter recognition on subroutine generation <2> +- 09: Issue #866: Selection expansion/reduction in the diagram revised <2> Version: 3.30 (2019-10-06) - 01: Issue #657: Spanish message in German locale replaced <2> From aa5c9df174b9deccf82fab13d8bbdff80a1efe94 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Sun, 3 May 2020 03:18:03 +0200 Subject: [PATCH 17/18] Remnants of debug prints for #866 removed from code. --- src/lu/fisch/structorizer/gui/Diagram.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lu/fisch/structorizer/gui/Diagram.java b/src/lu/fisch/structorizer/gui/Diagram.java index 137efae4..96b86c71 100644 --- a/src/lu/fisch/structorizer/gui/Diagram.java +++ b/src/lu/fisch/structorizer/gui/Diagram.java @@ -10074,7 +10074,6 @@ public void expandSelection(Editor.SelectionExpandDirection _direction) || _direction == Editor.SelectionExpandDirection.EXPAND_UP && atUpperEnd)) // END KGU#866 2020-05-02 { - System.out.println("Case 1: " + index0 + ", " + index1 + " / " + anchorOffset); // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy //selected = new SelectedSequence(sq, index0-1, index1); selected = new SelectedSequence(sq, index0-1, index1, anchorOffset+1, false); @@ -10088,7 +10087,6 @@ else if (index1 < sq.getSize()-1 && || _direction == Editor.SelectionExpandDirection.EXPAND_DOWN && atLowerEnd)) // END KGU#866 2020-05-02 { - System.out.println("Case 2: " + index0 + ", " + index1 + " / " + anchorOffset); // START KGU#866 2020-05-02: Issue #866 improved expansion / reduction strategy //selected = new SelectedSequence(sq, index0, index1+1, _index1, true); selected = new SelectedSequence(sq, index0, index1+1, anchorOffset, true); From ace91843677b45585fa027dd8e8316d5165a39d4 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Wed, 13 May 2020 17:35:21 +0200 Subject: [PATCH 18/18] Known issue comment added. --- src/lu/fisch/structorizer/gui/changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 5934db75..0e21745a 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -8,6 +8,7 @@ Known issues: - Copying diagram images to the clipboard may fail with some OS/JRE combination (#685), on Windows the image format may be JPG instead of PNG. +- Pascal import does not cope with nested comments and unit name aliases. - COBOL import may fail if certain single-letter identifiers are used (rename them!), also if the code contains a SPECIAL-NAMES clause or float literals. - COBOL import does not cope with some statement variants and variable redefinitions. @@ -15,7 +16,7 @@ Known issues: - Shell export copes neither with nested array/record initialisers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version: 3.30-09 (2020-05-03) +Current development version: 3.30-09 (2020-05-13) - 01: Bugfix #759: Dried up another source of stale Mainforms. <2> - 01: Bugfix #761: Code preview defect flooded the log stream. <2> - 01: Precautions against empty error messages on startup <2>