From d69167e3af8bc48db08c47994454b42e69d46c1e Mon Sep 17 00:00:00 2001 From: codemanyak Date: Mon, 20 Sep 2021 01:20:58 +0200 Subject: [PATCH 01/14] Prepared for bugfixing after release 3.32 (version number 3.32-01) --- buildapp.xml | 4 ++-- src/lu/fisch/structorizer/elements/Element.java | 2 +- src/lu/fisch/structorizer/gui/changelog.txt | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/buildapp.xml b/buildapp.xml index ecf207ca..24ad3397 100644 --- a/buildapp.xml +++ b/buildapp.xml @@ -15,8 +15,8 @@ name="Structorizer" displayname="Structorizer" identifier="lu.fisch.Structorizer" - shortversion="3.32" - version="3.32" + shortversion="3.32-01" + version="3.32-01" icon="icons/Structorizer.icns" mainclassname="Structorizer" copyright="Bob Fisch" diff --git a/src/lu/fisch/structorizer/elements/Element.java b/src/lu/fisch/structorizer/elements/Element.java index e52fdf95..2ed35448 100644 --- a/src/lu/fisch/structorizer/elements/Element.java +++ b/src/lu/fisch/structorizer/elements/Element.java @@ -295,7 +295,7 @@ public String toString() public static final long E_HELP_FILE_SIZE = 11700000; 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.32"; + public static final String E_VERSION = "3.32-01"; 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 a5cc2156..4484d1b2 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -19,6 +19,9 @@ Known issues: - Shell export neither copes with nested array/record initialisers and component access nor with cleanly handling usual and associative arrays as parameters or results. +Current development version 3.32-01 (2021-09-20) +- 01: + Version 3.32 (2021-09-19) requiring Java 11 or newer - 01: Bugfix #851/2: COBOL import: SPECIAL-NAMES sections caused parser abort <2> - 01: Bugfix #851/3: COBOL import flaws concerning floating-point literals <2>: From f215436069e3b360c4ae1040d8c52fda0dbe8d42 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Tue, 21 Sep 2021 02:06:05 +0200 Subject: [PATCH 02/14] Fixes #987 --- .../structorizer/generators/PasGenerator.java | 14 ++++++++++---- src/lu/fisch/structorizer/gui/changelog.txt | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lu/fisch/structorizer/generators/PasGenerator.java b/src/lu/fisch/structorizer/generators/PasGenerator.java index 9460d68e..52dc225d 100644 --- a/src/lu/fisch/structorizer/generators/PasGenerator.java +++ b/src/lu/fisch/structorizer/generators/PasGenerator.java @@ -93,6 +93,7 @@ * 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 + * Kay Gürtzig 2021-09-21 Bugfix #987: Duplicate comments for subroutines, inconsistent multi-line comments * ****************************************************************************************************** * @@ -338,7 +339,10 @@ protected int insertComment(StringList _sl, String _indent, int _atLine) else if (_sl.count() == 1 && !_sl.get(0).contains("\n")) { return this.insertComment(_sl.get(0), _indent, _atLine); } - return this.insertBlockComment(_sl, _indent, this.commentSymbolLeft(), "* ", this.commentSymbolRight(), _atLine); + // START KGU#983 2021-09-21: Bugfix #987 - this was inconsistent with appendComment() + //return this.insertBlockComment(_sl, _indent, this.commentSymbolLeft(), "* ", this.commentSymbolRight(), _atLine); + return this.insertBlockComment(_sl, _indent, this.commentSymbolLeft(), " ", this.commentSymbolRight(), _atLine); + // END KGU#983 2021-09-21 } // END KGU#815 2020-03-26 @@ -1582,11 +1586,13 @@ protected String generateHeader(Root _root, String _indent, String _procName, this.appendGeneratorIncludes(_indent, false); // END KGU#815/KGU#824 2020-03-19 addSepaLine(); + // START KGU#815/KGU#983 2021-09-21: Bugfix #987 - duplicate comment for subroutines (cf. #828) // START KGU#194/KGU#376 2017-09-22: Bugfix #185, Enh. #389 - the function header shall have the comment - if (!_root.isInclude() && _public) { - appendComment(_root, _indent); - } + //if (!_root.isInclude() && _public) { + // appendComment(_root, _indent); + //} // END KGU#194/KGU#376 2017-09-22 + // END KGU#815/KGU#983 2021-09-21 // START KGU#815 2020-03-16: Enh. #828 //code.add(_indent + pr + " " + signature + ";"); diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 4484d1b2..817ee14a 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -19,8 +19,8 @@ Known issues: - Shell export neither copes with nested array/record initialisers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version 3.32-01 (2021-09-20) -- 01: +Current development version 3.32-01 (2021-09-21) +- 01: Bugfix #987: Duplicate subroutine comment export by Pascal generator <2> Version 3.32 (2021-09-19) requiring Java 11 or newer - 01: Bugfix #851/2: COBOL import: SPECIAL-NAMES sections caused parser abort <2> From 66755e986b22ca8240ed6381a302221829d8c525 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Thu, 23 Sep 2021 20:24:16 +0200 Subject: [PATCH 03/14] Fixes #988, corrects/adds some messages for the CASE editor. --- Structorizer.bat | 3 ++- src/lu/fisch/structorizer/gui/changelog.txt | 3 ++- src/lu/fisch/structorizer/locales/en.txt | 2 +- src/lu/fisch/structorizer/locales/nl.txt | 5 +++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Structorizer.bat b/Structorizer.bat index 672863ca..e6360026 100644 --- a/Structorizer.bat +++ b/Structorizer.bat @@ -14,6 +14,7 @@ :: Kay Gürtzig 2017-07-04 Drive variable added to path :: Kay Gürtzig 2018-11-27 Precaution against installation path with blanks :: Kay Gürtzig 2021-06-13 Issue #944: Java version check (against 11) inserted +:: Kay Gürtzig 2021-09-23 Bugfix #988: Syntax error in nested "if" statement mended :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -26,7 +27,7 @@ set JAVAVER=%JAVAVER:"=_% for /f "tokens=2 delims=_" %%a in ("%JAVAVER%") do set JAVAVER=%%a for /f "tokens=1,2 delims=." %%a in ("%JAVAVER%") do ( set VERSION=%%a - if %VERSION% equ 1 set VERSION=%%b + if %%VERSION%% equ 1 set VERSION=%%b ) if %VERSION% lss %REQVERSION% ( echo on diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 817ee14a..810abc5a 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -19,8 +19,9 @@ Known issues: - Shell export neither copes with nested array/record initialisers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version 3.32-01 (2021-09-21) +Current development version 3.32-01 (2021-09-23) - 01: Bugfix #987: Duplicate subroutine comment export by Pascal generator <2> +- 01: Bugfix #988: Syntax error in Structorizer.bat fixed <2> Version 3.32 (2021-09-19) requiring Java 11 or newer - 01: Bugfix #851/2: COBOL import: SPECIAL-NAMES sections caused parser abort <2> diff --git a/src/lu/fisch/structorizer/locales/en.txt b/src/lu/fisch/structorizer/locales/en.txt index f31a8b99..ba5272b0 100644 --- a/src/lu/fisch/structorizer/locales/en.txt +++ b/src/lu/fisch/structorizer/locales/en.txt @@ -837,7 +837,7 @@ InputBoxCase.btnAddRow.tooltip=Append a new case row (and let you fill in the co InputBoxCase.btnDelRows.tooltip=Remove the selected case row InputBoxCase.btnUpRow.tooltip=Move the selected case row one position up InputBoxCase.btnDnRow.tooltip=Move the selected case row one position down -InputBoxCase.btnMergeRows.tooltip=Merge the selected case row (not enabled with differing non-empty branches) +InputBoxCase.btnMergeRows.tooltip=Merge the selected case rows (not enabled with differing non-empty branches) InputBoxCase.btnSplitRow.tooltip=Split the selected case row InputBoxCase.btnEnumAssist.tooltip=Ensure case lines for all enumerator values, remove non-matching case lines (except those with nonempty branches) InputBoxCase.btnCheckRows.tooltip=Check consistency and report detected problems diff --git a/src/lu/fisch/structorizer/locales/nl.txt b/src/lu/fisch/structorizer/locales/nl.txt index d909a734..409e090b 100644 --- a/src/lu/fisch/structorizer/locales/nl.txt +++ b/src/lu/fisch/structorizer/locales/nl.txt @@ -60,6 +60,7 @@ * Jaap Woldringh 2020-12-20/25 Enh. #704: New messages for Turtleizer GUI, many revisions * Kay Gürtzig 2021-01-23 Enh. #714: InputBox.chkShowFinally added * Kay Gürtzig 2021-01-25 Enh. #915: InputBoxCase messages added + * Kay Gürtzig 2021-09-22 Enh. #915: Some missing InputBoxCase tooltips concocted * ****************************************************************************************************** * @@ -759,6 +760,10 @@ InputBoxCase.btnAddRow.tooltip=Regel voor een nieuw geval toevoegen (en de komma InputBoxCase.btnDelRows.tooltip=Geselecteerd geval-regel verwijderen (in verband met de associeerde tak!) InputBoxCase.btnUpRow.tooltip=Geselecteerd geval-regel naar boven verplaatsen InputBoxCase.btnDnRow.tooltip=Geselecteerd geval-regel naar beneden verplaatsen +InputBoxCase.btnMergeRows.tooltip=Geselecteerde geval-regels fusioneren (ongeoorloofd met verschillend niet-lege taks) +InputBoxCase.btnSplitRow.tooltip=Geselecteerd geval-regel separeren +InputBoxCase.btnEnumAssist.tooltip=Zorgen ervoor dat een geval-regel bestaan voor elke enumerator waarde, dat onjuist geval-regels verdwijnen (behalve met niet-lege tak) +InputBoxCase.btnCheckRows.tooltip=Consistentie keuren en problemen rapporteren InputBoxCase.chkMoveBranches.text=Takken meeverplaatsen InputBoxCase.chkMoveBranches.tooltip=Als activeerd (gerecommandeerd), de connectie van de takken met de verplaatste regelen wordt bewaardt. InputBoxCase.chkDefaultBranch.text=Anderszins-tak: From e7647df478d7f78ece2445d98fb489de4c08e0ae Mon Sep 17 00:00:00 2001 From: codemanyak Date: Fri, 1 Oct 2021 13:28:43 +0200 Subject: [PATCH 04/14] Fixes #989 (Exit transform) --- .../structorizer/generators/CGenerator.java | 19 +++++++++++++++---- src/lu/fisch/structorizer/gui/changelog.txt | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/lu/fisch/structorizer/generators/CGenerator.java b/src/lu/fisch/structorizer/generators/CGenerator.java index f5b4afb3..1ba501c6 100644 --- a/src/lu/fisch/structorizer/generators/CGenerator.java +++ b/src/lu/fisch/structorizer/generators/CGenerator.java @@ -109,6 +109,7 @@ * Kay Gürtzig 2020-10-16 Bugfix #873: Type definition handling was compromised by bugfix #808 * Kay Gürtzig 2020-10-16 Bugfix #874: Nullpointer exception on Calls with non-ASCII letters in name * Kay Gürtzig 2021-02-03 Issue #920: Transformation for "Infinity" literal + * Kay Gürtzig 2021-10-01 Bugfix #989: No expression translation in EXIT elements to C, C++, etc. * ****************************************************************************************************** * @@ -2090,18 +2091,28 @@ protected void generateCode(Jump _jump, String _indent) //if (line.matches(preReturnMatch)) if (_jump.isReturn()) { - addCode("return " + line.substring(preReturn.length()).trim() + ";", + // START KGU#988 2021-10-01: Bugfix #989 missing expression translation + //addCode("return " + line.substring(preReturn.length()).trim() + ";", + addCode("return " + transform(line.substring(preReturn.length()).trim()) + ";", + // END KGU#988 2021-10-01 _indent, isDisabled); } //else if (line.matches(preExitMatch)) else if (_jump.isExit()) { - appendExitInstr(line.substring(preExit.length()).trim(), _indent, isDisabled); + // START KGU#988 2021-10-01: Bugfix #989 missing expression translation + //appendExitInstr(line.substring(preExit.length()).trim(), _indent, isDisabled); + appendExitInstr(transform(line.substring(preExit.length()).trim()), _indent, isDisabled); + // END KGU#988 2021-10-01 } // START KGU#686 2019-03-20: Enh. #56 Throw has to be implemented else if (_jump.isThrow() && this.getTryCatchLevel() != TryCatchSupportLevel.TC_NO_TRY) { - this.generateThrowWith(line.substring( - CodeParser.getKeywordOrDefault("preThrow", "throw").length()).trim(), _indent, isDisabled); + // START KGU#988 2021-10-01: Bugfix #989 missing expression translation + //this.generateThrowWith(line.substring( + // CodeParser.getKeywordOrDefault("preThrow", "throw").length()).trim(), _indent, isDisabled); + this.generateThrowWith(transform(line.substring( + CodeParser.getKeywordOrDefault("preThrow", "throw").length()).trim()), _indent, isDisabled); + // END KGU#988 2021-10-01 } // END KGU#686 2019-03-20 // Has it already been matched with a loop? Then syntax must have been okay... diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 810abc5a..0271256e 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -19,9 +19,10 @@ Known issues: - Shell export neither copes with nested array/record initialisers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version 3.32-01 (2021-09-23) +Current development version 3.32-01 (2021-10-01) - 01: Bugfix #987: Duplicate subroutine comment export by Pascal generator <2> - 01: Bugfix #988: Syntax error in Structorizer.bat fixed <2> +- 01: Bugfix #989: Missing translation of EXIT expressions on export to C etc. <2> Version 3.32 (2021-09-19) requiring Java 11 or newer - 01: Bugfix #851/2: COBOL import: SPECIAL-NAMES sections caused parser abort <2> From 42019dcaa3016267fa66bd2076ff8d035e8f1158 Mon Sep 17 00:00:00 2001 From: codemanyak Date: Sun, 3 Oct 2021 14:06:23 +0200 Subject: [PATCH 05/14] Fixes #990, fixes #991 --- samples/export/Pascal/ELIZA_2.2.pas | 79 ++++---- .../fisch/structorizer/elements/Element.java | 187 +++++++++--------- src/lu/fisch/structorizer/elements/Root.java | 180 +++++++++++------ .../generators/BASHGenerator.java | 4 + .../structorizer/generators/CGenerator.java | 21 +- .../generators/CPlusPlusGenerator.java | 9 +- .../structorizer/generators/Generator.java | 6 +- .../structorizer/generators/KSHGenerator.java | 4 + .../structorizer/generators/PasGenerator.java | 34 +++- src/lu/fisch/structorizer/gui/changelog.txt | 4 +- .../fisch/structorizer/parsers/D7Parser.java | 172 +++++++++------- 11 files changed, 426 insertions(+), 274 deletions(-) diff --git a/samples/export/Pascal/ELIZA_2.2.pas b/samples/export/Pascal/ELIZA_2.2.pas index f8d3479e..10e5403d 100644 --- a/samples/export/Pascal/ELIZA_2.2.pas +++ b/samples/export/Pascal/ELIZA_2.2.pas @@ -11,7 +11,7 @@ 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") } program ELIZA; -{ Generated by Structorizer 3.30-11 } +{ Generated by Structorizer 3.32-01 } { Copyright (C) 2018-05-14 ??? } { License: GPLv3-link } @@ -37,22 +37,22 @@ keyMap = setupKeywords(); var - indexad60b0f8: 1..5; - arrayad60b0f8: array [1..5] of string; - index74593207: 1..2; - array74593207: array [1..2] of string; + index645848ab: 1..5; + array645848ab: array [1..5] of string; + index9aaba44a: 1..2; + array9aaba44a: array [1..2] of string; varPart: String; { Converts the input to lowercase, cuts out interpunctation and pads the string } userInput: string; - replyRing: ???; { FIXME! } + replyRing: array [-1..49] of string; reply: String; posAster: Longint; offsets: array [0..49] of Longint; { Should never happen... } - keyIndex: ???; { FIXME! } + keyIndex: Longint; isRepeated: boolean; isGone: boolean; { @@ -85,11 +85,11 @@ function adjustSpelling(sentence: string): string; delete(result, 1, position); insert(uppercase(start), result, 1); end; - array74593207[1] := ' i '; - array74593207[2] := ' i\'''; - for index74593207 := 1 to 2 do + array9aaba44a[1] := ' i '; + array9aaba44a[2] := ' i\'''; + for index9aaba44a := 1 to 2 do begin - word := array74593207[index74593207]; + word := array9aaba44a[index9aaba44a]; position := pos(word, result); while (position > 0) do begin @@ -105,10 +105,10 @@ function adjustSpelling(sentence: string): string; end; { -* 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 } function checkGoodBye(text: string; phrases: array [0..49] of array [0..1] of string): boolean; @@ -133,8 +133,8 @@ function checkGoodBye(text: string; phrases: array [0..49] of array [0..1] of st end; { -* 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 } function checkRepetition(history: array; newInput: string): boolean; @@ -201,16 +201,15 @@ function conjugateStrings(sentence: string; key: string; keyPos: Longint; flexio end; { -* 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) } function findKeyword(keyMap: const array of KeyMapEntry; sentence: string): array [0..1] of Longint; -const keyMap = null; var @@ -243,9 +242,9 @@ function findKeyword(keyMap: const array of KeyMapEntry; sentence: string): arra end; { -* 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 } function normalizeInput(sentence: string): string; @@ -256,14 +255,14 @@ function normalizeInput(sentence: string): string; begin sentence := lowercase(sentence); - arrayad60b0f8[1] := '.'; - arrayad60b0f8[2] := ','; - arrayad60b0f8[3] := ';'; - arrayad60b0f8[4] := '!'; - arrayad60b0f8[5] := '?'; - for indexad60b0f8 := 1 to 5 do + array645848ab[1] := '.'; + array645848ab[2] := ','; + array645848ab[3] := ';'; + array645848ab[4] := '!'; + array645848ab[5] := '?'; + for index645848ab := 1 to 5 do begin - symbol := arrayad60b0f8[indexad60b0f8]; + symbol := array645848ab[index645848ab]; position := pos(symbol, sentence); while (position > 0) do begin @@ -295,9 +294,9 @@ function setupGoodByePhrases(): array [0..49] of array [0..1] of string; end; { -* 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()´. } function setupKeywords(): array [0..49] of KeyMapEntry; @@ -431,9 +430,9 @@ function setupReflexions(): array [0..49] of array [0..1] of string; end; { -* 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()´ } function setupReplies(): array [0..49] of array [0..49] of string; diff --git a/src/lu/fisch/structorizer/elements/Element.java b/src/lu/fisch/structorizer/elements/Element.java index 2ed35448..d85fef3a 100644 --- a/src/lu/fisch/structorizer/elements/Element.java +++ b/src/lu/fisch/structorizer/elements/Element.java @@ -4408,13 +4408,15 @@ public ImageIcon getMiniIcon() // (The obvious disadvantage is slightly reduced performance, of course) /** * Returns the serialised texts held within this element and its substructure. - * The argument _instructionsOnly controls whether mere expressions like logical conditions or - * even call statements are included. As a rule, no lines that may not potentially introduce new - * variables are added if true (which not only reduces time and space requirements but also avoids - * "false positives" in variable detection). - * Uses addFullText() - so possibly better override that method if necessary. - * @param _instructionsOnly - if true then only the texts of Instruction elements are included - * @return the composed StringList + * The argument {@code _instructionsOnly} controls whether mere expressions like + * logical conditions or even call statements are included. As a rule, no lines + * that may not potentially introduce new variables are added if {@code true} + * (which not only reduces time and space requirements but also avoids "false positives" + * in variable detection).
+ * Uses {@link #addFullText(StringList, boolean)} - so possibly better override that method if + * necessary. + * @param _instructionsOnly - if {@code true} then only the texts of Instruction elements are included + * @return the composed {@link StringList} */ public StringList getFullText(boolean _instructionsOnly) { @@ -4439,13 +4441,16 @@ public StringList getFullText(boolean _instructionsOnly) // START KGU#18/KGU#23 2015-10-24 intermediate transformation added and decomposed /** - * Converts the operator symbols accepted by Structorizer into Java operators: - * - Assignment: "<-" - * - Comparison: "==", "<", ">", "<=", ">=", "!=" - * - Logic: "&&", "||", "!", "^" - * - Arithmetics: "div" and usual Java operators (e.g. "mod" -> "%") + * Converts the operator symbols accepted by Structorizer into mostly Java operators: + *
    + *
  • Assignment: "<-"
  • + *
  • Comparison: "==", "<", ">", "<=", ">=", "!="
  • + *
  • Logic: "&&", "||", "!", "^"
  • + *
  • Arithmetics: usual Java operators plus "div" (e.g. "mod" -> "%")
  • + *
* @param _expression - an Element's text in practically unknown syntax - * @return an equivalent of the _expression String with replaced operators + * @return an equivalent of the {@code _expression} String with replaced operators + * @see #unifyOperators(StringList, boolean) */ public static String unifyOperators(String _expression) { @@ -4459,16 +4464,15 @@ public static String unifyOperators(String _expression) // START KGU#92 2015-12-01: Bugfix #41 Okay now, here is the new approach (still a sketch) /** - * Converts the operator symbols accepted by Structorizer into intermediate operators - * (mostly Java operators): + * Converts the operator symbols accepted by Structorizer into mostly Java operators: *
    - *
  • Assignment: "<-"
  • - *
  • Comparison*: "==", "<", ">", "<=", ">=", "!="
  • - *
  • Logic*: "&&", "||", "!", "^"
  • - *
  • Arithmetics*: "div" and usual Java operators (e. g. "mod" -> "%")
  • + *
  • Assignment: "<-"
  • + *
  • Comparison*: "==", "<", ">", "<=", ">=", "!="
  • + *
  • Logic*: "&&", "||", "!", "^"
  • + *
  • Arithmetics: usual Java operators plus "div" (e. g. "mod" -> "%")
  • *
* @param _tokens - a tokenised line of an Element's text (in practically unknown syntax) - * @param _assignmentOnly - if true then only assignment operator will be unified + * @param _assignmentOnly - if {@code true} then only assignment operators will be unified * @return total number of deletions / replacements */ public static int unifyOperators(StringList _tokens, boolean _assignmentOnly) @@ -4480,21 +4484,21 @@ public static int unifyOperators(StringList _tokens, boolean _assignmentOnly) if (!_assignmentOnly) // END KGU#115 2015-12-23 { - count += _tokens.replaceAll("=", "=="); - count += _tokens.replaceAll("<>", "!="); - count += _tokens.replaceAllCi("mod", "%"); - count += _tokens.replaceAllCi("shl", "<<"); - count += _tokens.replaceAllCi("shr", ">>"); - count += _tokens.replaceAllCi("and", "&&"); - count += _tokens.replaceAllCi("or", "||"); - count += _tokens.replaceAllCi("not", "!"); - count += _tokens.replaceAllCi("xor", "^"); - // START KGU#843 2020-04-11: Bugfix #847 Inconsistency in handling operators (we don't count this, though) - _tokens.replaceAllCi("DIV", "div"); - // END KGU#843 2020-04-11 - // START KGU#920 2021-02-03: Issue #920 Handle Infinity literal - _tokens.replaceAll("\u221E", "Infinity"); - // END KGU#920 2021-02-03 + count += _tokens.replaceAll("=", "=="); + count += _tokens.replaceAll("<>", "!="); + count += _tokens.replaceAllCi("mod", "%"); + count += _tokens.replaceAllCi("shl", "<<"); + count += _tokens.replaceAllCi("shr", ">>"); + count += _tokens.replaceAllCi("and", "&&"); + count += _tokens.replaceAllCi("or", "||"); + count += _tokens.replaceAllCi("not", "!"); + count += _tokens.replaceAllCi("xor", "^"); + // START KGU#843 2020-04-11: Bugfix #847 Inconsistency in handling operators (we don't count this, though) + _tokens.replaceAllCi("DIV", "div"); + // END KGU#843 2020-04-11 + // START KGU#920 2021-02-03: Issue #920 Handle Infinity literal + _tokens.replaceAll("\u221E", "Infinity"); + // END KGU#920 2021-02-03 } return count; } @@ -4509,29 +4513,28 @@ public static int unifyOperators(StringList _tokens, boolean _assignmentOnly) * Conventions of the intermediate language:
* Operators (note the surrounding spaces - no double spaces will exist): *
    - *
  • Assignment: " <- " - *
  • Comparison: " = ", " < ", " > ", " <= ", " >= ", " <> " - *
  • Logic: " && ", " || ", " §NOT§ ", " ^ " - *
  • Arithmetics: usual Java operators without padding - *
  • Control key words:
    - * - If, Case: none (wiped off)
    - * - While, Repeat: none (wiped off)
    - * - For: unchanged
    - * - Forever: none (wiped off)
  • + *
  • Assignment: " <- " + *
  • Comparison: " = ", " < ", " > ", " <= ", " >= ", " <> " + *
  • Logic: " && ", " || ", " §NOT§ ", " ^ " + *
  • Arithmetics: usual Java operators without padding + *
  • Control key words:
      + *
    • If, Case: none (wiped off)
    • + *
    • While, Repeat: none (wiped off)
    • + *
    • For: unchanged
    • + *
    • Forever: none (wiped off)
    • + *
  • *
- * * @return a padded intermediate language equivalent of the stored text */ - public StringList getIntermediateText() { - StringList interSl = new StringList(); - StringList lines = this.getUnbrokenText(); - for (int i = 0; i < lines.count(); i++) - { - interSl.add(transformIntermediate(lines.get(i))); - } - return interSl; + StringList interSl = new StringList(); + StringList lines = this.getUnbrokenText(); + for (int i = 0; i < lines.count(); i++) + { + interSl.add(transformIntermediate(lines.get(i))); + } + return interSl; } /** @@ -4550,7 +4553,7 @@ public static String transform_inc_dec(String code) } /** - * Creates a (hopefully) lossless representation of the _text String as a + * Creates a (hopefully) lossless representation of the {@code _text} String as a * tokens list of a common intermediate language (code generation phase 1). * This allows the language-specific Generator subclasses to concentrate * on the translation into their target language (code generation phase 2). @@ -4559,13 +4562,14 @@ public static String transform_inc_dec(String code) *
    *
  • Assignment: "<-"
  • *
  • Comparison: "=", "<", ">", "<=", ">=", "<>"
  • - *
  • Logic: "&&", "||", "!", "^"
  • + *
  • Logic: "&&", "||", "!", "^"
  • *
  • Arithmetics: usual Java operators
  • - *
  • Control key words:
    - * - If, Case: none (wiped off)
    - * - While, Repeat: none (wiped off)
    - * - For: unchanged
    - * - Forever: none (wiped off)
  • + *
  • Control key words:
      + *
    • If, Case: none (wiped off)
    • + *
    • While, Repeat: none (wiped off)
    • + *
    • For: unchanged
    • + *
    • Forever: none (wiped off)
    • + *
  • *
* @param _text - a line of the Structorizer element * //@return a padded intermediate language equivalent of the stored text @@ -4659,6 +4663,7 @@ public static void cutOutRedundantMarkers(StringList _tokens) // END KGU#162 2016-03-31 // START KGU#152 2016-03-02: Better self-description of Elements + @Override public String toString() { return getClass().getSimpleName() + '@' + Integer.toHexString(hashCode()) + @@ -4668,41 +4673,41 @@ public String toString() // END KGU#261 2017-01-19 } // END KGU#152 2016-03-02 - + // START KGU#258 2016-09-26: Enh. #253 - /** - * Returns a fixed array of names of parser preferences being relevant for - * the current type of Element (e.g. in case of refactoring) - * @return Arrays of key strings for CodeParser.keywordMap - */ - protected abstract String[] getRelevantParserKeys(); - - /** - * Looks up the associated token sequence in _splitOldKeywords for any of the parser preference names - * provided by getRelevantParserKeys(). If there is such a token sequence then it will be - * replaced throughout my text by the associated current parser preference for the respective name - * @param _oldKeywords - a map of tokenized former non-empty parser preference keywords to be replaced - * @param _ignoreCase - whether case is to be ignored on comparison. - */ - public void refactorKeywords(HashMap _splitOldKeywords, boolean _ignoreCase) - { - String[] relevantKeys = getRelevantParserKeys(); - if (relevantKeys != null && !_splitOldKeywords.isEmpty()) - { - StringList result = new StringList(); - for (int i = 0; i < this.text.count(); i++) - { - result.add(refactorLine(text.get(i), _splitOldKeywords, relevantKeys, _ignoreCase)); - } - this.text = result; - } + /** + * Returns a fixed array of names of parser preferences being relevant for + * the current type of Element (e.g. in case of refactoring) + * @return Arrays of key strings for CodeParser.keywordMap + */ + protected abstract String[] getRelevantParserKeys(); + + /** + * Looks up the associated token sequence in _splitOldKeywords for any of the parser preference names + * provided by getRelevantParserKeys(). If there is such a token sequence then it will be + * replaced throughout my text by the associated current parser preference for the respective name + * @param _oldKeywords - a map of tokenized former non-empty parser preference keywords to be replaced + * @param _ignoreCase - whether case is to be ignored on comparison. + */ + public void refactorKeywords(HashMap _splitOldKeywords, boolean _ignoreCase) + { + String[] relevantKeys = getRelevantParserKeys(); + if (relevantKeys != null && !_splitOldKeywords.isEmpty()) + { + StringList result = new StringList(); + for (int i = 0; i < this.text.count(); i++) + { + result.add(refactorLine(text.get(i), _splitOldKeywords, relevantKeys, _ignoreCase)); + } + this.text = result; + } } /** - * Looks up the associated token sequence in _splitOldKeys for any of the parser - * preference names provided by _prefNames. If there is such a token sequence - * then it will be replaced throughout {@code _line} by the associated current - * parser preference for the respective name. + * Looks up the associated token sequence in _splitOldKeys for any of the parser + * preference names provided by _prefNames. If there is such a token sequence + * then it will be replaced throughout {@code _line} by the associated current + * parser preference for the respective name. * @param _line - line of element text * @param _splitOldKeys - a map of tokenized former non-empty parser preference keywords to be replaced * @param _prefNames - Array of parser preference names being relevant for this kind of element diff --git a/src/lu/fisch/structorizer/elements/Root.java b/src/lu/fisch/structorizer/elements/Root.java index e4042f83..4d01fe84 100644 --- a/src/lu/fisch/structorizer/elements/Root.java +++ b/src/lu/fisch/structorizer/elements/Root.java @@ -170,6 +170,8 @@ * to static methods also usable by e.g. Call elements representing method * declarations * Kay Gürtzig 2021-02-28 Issue #947: Enhanced cyclic inclusion detection implemented + * Kay Gürtzig 2021-10-02 Bugfix #990: Fields returnsValue and alwaysReturns introduced to support export + * Kay Gürtzig 2021-10-03 Issue #991: Inconsistent Analyser check for result mechanism (case-ignorant) * ****************************************************************************************************** * @@ -366,6 +368,10 @@ public enum DiagramType {DT_MAIN, DT_SUB, DT_INCL, DT_INCL_DIAGRCTRL}; public String licenseText = null; public String origin = "Structorizer " + E_VERSION; + // START KGU#990 2021-10-02: Bugfix #990 + public Boolean returnsValue = null; + // END KGU#990 2021-10-02 + // START KGU#371 2019-03-07: Enh. #385 for performance reasons, we cache the parameter list here /** Cached parameter list, each entry is composed of name, type, and default, each as Strings (defaults may be null) */ private ArrayList parameterList = null; @@ -2049,9 +2055,9 @@ public void addUndo() /** * Adds a new entry to the undo stack, including a snapshot of the editable Root attributes (like author name, * license data etc.) if {@code _cacheAttributes} is true. Only to be called before changes to the attributes - * are expected. Otherwise {@link #addUndo()} should be used. + * are expected. Otherwise {@link #addUndo()} should be used.
* Clears the redo stack. - * @param _cacheAttributes - pecifies whether diagram attributes are also to be cached. + * @param _cacheAttributes - specifies whether diagram attributes are also to be cached. * @see #addUndo() */ public void addUndo(boolean _cacheAttributes) @@ -2071,6 +2077,9 @@ public void addUndo(boolean _cacheAttributes) this.modifiedby0 = this.modifiedby; } // END KGU#363 3018-09-12 + // START KGU#990 2021-10-02: Bugfix #990 New fields for export facilitation + this.returnsValue = null; + // END KGU#990 2021-10-02 // START KGU#376 2017-07-01: Enh. #389 if (this.includeList != null) { oldChildren.diagramRefs = this.includeList.concatenate(","); @@ -3089,8 +3098,8 @@ public StringList getVarNames(StringList lines, HashMap constant } /** - * Extract all variable names of the entire program and store them in - * this.variables. + * Extracts all variable names of the entire program and stores them in + * {@link #variables}, ignoring previously cached results. * @return list of variable names * @see #getVarNames() */ @@ -3117,8 +3126,11 @@ public StringList getVarNames() { } /** - * Extract the names of all variables assigned or introduced within passed-in element _ele. + * Extracts the names of all variables assigned or introduced within passed-in element + * {@code _ele} and its possible substructure. + * @param _ele - the element to be scanned for introduced variables * @return list of variable names + * @see #getVarNames(Element, boolean) */ public StringList getVarNames(Element _ele) { @@ -3126,18 +3138,48 @@ public StringList getVarNames(Element _ele) return getVarNames(_ele, true, false); } + /** + * Extracts the names of all variables assigned or introduced within passed-in element + * {@code _ele}, possibly ignoring its substructure or not. + * @param _ele - the element to be scanned for introduced variables + * @param _onlyEle - whether possible substructure is to be ignored + * @return list of variable names + * @see #getVarNames(Element, boolean, boolean) + */ public StringList getVarNames(Element _ele, boolean _onlyEle) { - // All variables, not only those from body (sub-structure) - return getVarNames(_ele, _onlyEle, false); + // All variables, not only those from body (i.e. sub-structure) + return getVarNames(_ele, _onlyEle, false); } + /** + * Extracts the names of all variables assigned or introduced within passed-in element + * {@code _ele}, possibly either ignoring its substructure or only regarding its + * substructure, e.g. in case of loops.
+ * Note that {@code _onlyEle} and {@code _onlyBody} may not both be {@code true}! + * @param _ele - the element to be scanned for introduced variables + * @param _onlyEle - whether possible substructure of {@code _ele} is to be ignored + * @param _onlyBody - whether only the substructure of {@code _ele} is to be scanned + * @return list of variable names + * @see #getVarNames(Element, boolean, boolean, boolean) + */ public StringList getVarNames(Element _ele, boolean _onlyEle, boolean _onlyBody) { - - return getVarNames(_ele, _onlyEle, _onlyBody, false); + return getVarNames(_ele, _onlyEle, _onlyBody, false); } + /** + * Extracts the names of all variables assigned or introduced within passed-in element + * {@code _ele}, possibly either ignoring its substructure or only regarding its + * substructure, e.g. in case of loops.
+ * Note that {@code _onlyEle} and {@code _onlyBody} may not both be {@code true}! + * @param _ele - the element to be scanned for introduced variables + * @param _onlyEle - whether possible substructure of {@code _ele} is to be ignored + * @param _onlyBody - whether only the substructure of {@code _ele} is to be scanned + * @param _entireProg - relevant for the case {@code _ele} is {@code this} and + * {@code _onlyEle <> true} or {@code _onlyBody = true} + * @return list of variable names + */ private StringList getVarNames(Element _ele, boolean _onlyEle, boolean _onlyBody, boolean _entireProg) { @@ -3161,48 +3203,49 @@ private StringList getVarNames(Element _ele, boolean _onlyEle, boolean _onlyBody } } - // get body text + // get relevant text StringList lines; if (_onlyEle && !_onlyBody) { - // START KGU#388/KGU#413 2017-09-13: Enh. #416, #423 - //lines = _ele.getText().copy(); - lines = _ele.getUnbrokenText(); - if (_ele instanceof Instruction) { - int i = 0; - while (i < lines.count()) { - if (Instruction.isTypeDefinition(lines.get(i), null)) { - // START KGU#542 2019-11-17: Enh. #739 We must extract enumerators here - HashMap constVals = this.extractEnumerationConstants(lines.get(i)); - if (constVals != null) { - // We simply generate singular constant definition lines - for (Entry enumItem: constVals.entrySet()) { - lines.insert("const " + enumItem.getKey() + " <- " + enumItem.getValue(), i++); - } - } - // END KGU#542 2019-11-17 - lines.remove(i); - } - else { - i++; - } - } - } - // END KGU#388/KGU#413 2017-09-13: Enh. #416, #423 + // START KGU#388/KGU#413 2017-09-13: Enh. #416, #423 + //lines = _ele.getText().copy(); + lines = _ele.getUnbrokenText(); + if (_ele instanceof Instruction) { + // Get rid of lines that may not introduce variables + int i = 0; + while (i < lines.count()) { + if (Instruction.isTypeDefinition(lines.get(i), null)) { + // START KGU#542 2019-11-17: Enh. #739 We must extract enumerators here + HashMap constVals = this.extractEnumerationConstants(lines.get(i)); + if (constVals != null) { + // We simply generate singular constant definition lines + for (Entry enumItem: constVals.entrySet()) { + lines.insert("const " + enumItem.getKey() + " <- " + enumItem.getValue(), i++); + } + } + // END KGU#542 2019-11-17 + lines.remove(i); + } + else { + i++; + } + } + } + // END KGU#388/KGU#413 2017-09-13: Enh. #416, #423 } else if (_entireProg) { - // START KGU#39 2015-10-16: Use object methods now - //lines = getFullText(); - lines = this.getFullText(_onlyBody); - // END KGU#39 2015-10-16 + // START KGU#39 2015-10-16: Use object methods now + //lines = getFullText(); + lines = this.getFullText(_onlyBody); + // END KGU#39 2015-10-16 } else { - // START KGU#39 2015-10-16: Use object methods now - //lines = getFullText(_ele); - lines = _ele.getFullText(true); - // START KGU#39 2015-10-16 + // START KGU#39 2015-10-16: Use object methods now + //lines = getFullText(_ele); + lines = _ele.getFullText(true); + // START KGU#39 2015-10-16 } varNames.add(getVarNames(lines, this.constants)); @@ -3410,6 +3453,9 @@ public void clearVarAndTypeInfo(boolean clearDrawInfo) this.variables = null; this.constants.clear(); this.clearTypeInfo(); + // START KGU#990 2021-10-02: Bugfix #990 - new fields to facilitate export + this.returnsValue = null; + // END KGU#990 2021-10-02 if (clearDrawInfo || E_VARHIGHLIGHT) { this.resetDrawingInfoDown(); } @@ -4069,7 +4115,7 @@ else if (!Function.testIdentifier(myVar, true, null)) { //error = new DetectedError("Your function seems to use several competitive return mechanisms!",(Element) _node.getElement(i)); - addError(_errors, new DetectedError(errorMsg(Menu.error13_3, myVar), ele), 13); + addError(_errors, new DetectedError(errorMsg(Menu.error13_3, myVar), ele), 13); } } else if (this.isSubroutine() && myVar.equals(getMethodName())) @@ -4079,7 +4125,7 @@ else if (this.isSubroutine() && myVar.equals(getMethodName())) { //error = new DetectedError("Your functions seems to use several competitive return mechanisms!",(Element) _node.getElement(i)); - addError(_errors, new DetectedError(errorMsg(Menu.error13_3, myVar), ele), 13); + addError(_errors, new DetectedError(errorMsg(Menu.error13_3, myVar), ele), 13); } } // END KGU#78 2015-11-25 @@ -4375,14 +4421,15 @@ else if (isReturn) if (!line.substring(preReturn.length()).trim().isEmpty()) { _resultFlags[0] = true; _myVars.addIfNew("§ANALYSER§RETURNS"); + // START KGU#78 2015-11-25: Different result mechanisms? + if (_resultFlags[1] || _resultFlags[2]) + { + //error = new DetectedError("Your function seems to use several competitive return mechanisms!",(Element) _node.getElement(i)); + addError(_errors, new DetectedError(errorMsg(Menu.error13_3, preReturn), ele), 13); + } + // END KGU#78 2015-11-25 } // END KGU#343 2017-02-07 - // START KGU#78 2015-11-25: Different result mechanisms? - if (_resultFlags[1] || _resultFlags[2]) - { - //error = new DetectedError("Your function seems to use several competitive return mechanisms!",(Element) _node.getElement(i)); - addError(_errors, new DetectedError(errorMsg(Menu.error13_3, preReturn), ele), 13); - } // Check if we are inside a Parallel construct while (parent != null && !(parent instanceof Root) && !(parent instanceof Parallel)) { @@ -6269,7 +6316,10 @@ else if (!Function.testIdentifier(programName, true, null)) { // setsResultUc = vars.contains("RESULT", true); // setsResultWc = vars.contains("Result", true); // } - boolean setsProcNameCi = vars.contains(programName,false); // Why case-independent? + // START KGU#991 2021-10-03: Issue #991 case-aware check needed. + //boolean setsProcNameCi = vars.contains(programName,false); // Why case-independent? + boolean setsProcName = vars.contains(programName); + // END KGU#991 2021-10-03 boolean maySetResultCi = uncertainVars.contains("result", false); // boolean maySetResultLc = false, maySetResultUc = false, maySetResultWc = false; // if (maySetResultCi) @@ -6278,30 +6328,44 @@ else if (!Function.testIdentifier(programName, true, null)) { // maySetResultUc = uncertainVars.contains("RESULT", true); // maySetResultWc = uncertainVars.contains("Result", true); // } - boolean maySetProcNameCi = uncertainVars.contains(programName,false); // Why case-independent? + // START KGU#991 2021-10-03: Issue #991 case-aware check needed. + //boolean maySetProcNameCi = uncertainVars.contains(programName,false); // Why case-independent? + boolean maySetProcName = uncertainVars.contains(programName); // Why case-independent? + // END KGU#991 2021-10-03 // END KGU#78 2015-11-25 // START KGU#343 2017-02-07: Ignore pseudo-variables (markers) boolean doesReturn = vars.contains("§ANALYSER§RETURNS"); boolean mayReturn = resultFlags[0]; // END KGU#343 2017-02-07 + // START KGU#990 2021-10-02: Bugfix #990 new flag fields to facilitate export + returnsValue = mayReturn; + // END KGU#990 2021-10-02 - - if (!setsResultCi && !setsProcNameCi && !doesReturn && - !maySetResultCi && !maySetProcNameCi && !mayReturn) + // START KGU#991 2021-10-03: Issue #991 case-aware check needed. + //if (!setsResultCi && !setsProcNameCi && !doesReturn && + // !maySetResultCi && !maySetProcNameCi && !mayReturn) + if (!setsResultCi && !setsProcName && !doesReturn && + !maySetResultCi && !maySetProcName && !mayReturn) + // END KGU#991 2021-10-03 { //error = new DetectedError("Your function does not return any result!",this); error = new DetectedError(errorMsg(Menu.error13_1,""),this); addError(errors,error,13); } - else if (!setsResultCi && !setsProcNameCi && !doesReturn && - (maySetResultCi || maySetProcNameCi || mayReturn)) + // START KGU#991 2021-10-03: Issue #991 case-aware check needed. + //else if (!setsResultCi && !setsProcNameCi && !doesReturn && + // (maySetResultCi || maySetProcNameCi || mayReturn)) + else if (!setsResultCi && !setsProcName && !doesReturn && + (maySetResultCi || maySetProcName || mayReturn)) + // END KGU#991 2021-10-03 { //error = new DetectedError("Your function may not return a result!",this); error = new DetectedError(errorMsg(Menu.error13_2,""),this); addError(errors,error,13); } // START KGU#78 2015-11-25: Check competitive approaches - else if (maySetResultCi && maySetProcNameCi) + //else if (maySetResultCi && maySetProcNameCi) + else if (maySetResultCi && maySetProcName) { //error = new DetectedError("Your functions seems to use several competitive return mechanisms!",this); error = new DetectedError(errorMsg(Menu.error13_3,"RESULT <-> " + programName),this); diff --git a/src/lu/fisch/structorizer/generators/BASHGenerator.java b/src/lu/fisch/structorizer/generators/BASHGenerator.java index 35fe0dae..bf306fe3 100644 --- a/src/lu/fisch/structorizer/generators/BASHGenerator.java +++ b/src/lu/fisch/structorizer/generators/BASHGenerator.java @@ -94,6 +94,7 @@ * Kay Gürtzig 2020-03-23 Issue #840: Adaptations w.r.t. disabled elements using File API * Kay Gürtzig 2020-03-27/29 Enh. #828: Modifications tpo supporet group export * Kay Gürtzig 2021-02-03 Issue #920: Transformation for "Infinity" literal + * Kay Gürtzig 2021-10-03 Issue #990: Precautions against wrong result type associations * ****************************************************************************************************** * @@ -1759,6 +1760,9 @@ public String generateCode(Root _root, String _indent, boolean _public) { this.returns = false; // END KGU#828 2020-03-18 boolean alwaysReturns = mapJumps(_root.children); + // START KGU#990 2021-10-03: Bugfix #990 + _root.returnsValue = this.returns; + // END KGU#990 2021-10-03 boolean isSubroutine = _root.isSubroutine(); // END KGU#803 2020-02-16 // START KGU#705 2019-09-23: Enh. #738 diff --git a/src/lu/fisch/structorizer/generators/CGenerator.java b/src/lu/fisch/structorizer/generators/CGenerator.java index 1ba501c6..4364ca92 100644 --- a/src/lu/fisch/structorizer/generators/CGenerator.java +++ b/src/lu/fisch/structorizer/generators/CGenerator.java @@ -110,6 +110,7 @@ * Kay Gürtzig 2020-10-16 Bugfix #874: Nullpointer exception on Calls with non-ASCII letters in name * Kay Gürtzig 2021-02-03 Issue #920: Transformation for "Infinity" literal * Kay Gürtzig 2021-10-01 Bugfix #989: No expression translation in EXIT elements to C, C++, etc. + * Kay Gürtzig 2021-10-03 Bugfix #990: Made-up result types on exported procedures * ****************************************************************************************************** * @@ -403,8 +404,14 @@ protected int insertPrototype(Root _root, String _indent, boolean _withComment, StringList paramNames = new StringList(); StringList paramTypes = new StringList(); _root.collectParameters(paramNames, paramTypes, null); + // START KGU#990 2021-10-02: Bugfix #990 _root is not necessarily the current Root + StringList vars = _root.getVarNames(); + // END KGU#990 2021-10-02 fnHeader = transformTypeWithLookup(_root.getResultType(), - ((this.returns || this.isResultSet || this.isFunctionNameSet) ? "int" : "void")); + // START KGU#990 2021-10-02: Bugfix #990 These values could be from a different root + //((this.returns || this.isResultSet || this.isFunctionNameSet) ? "int" : "void")); + ((_root.returnsValue == Boolean.TRUE || vars.contains("result", false) || vars.contains(fnName)) ? "int" : "void")); + // END KGU#990 2021-10-02 // START KGU#140 2017-01-31: Enh. #113 - improved type recognition and transformation returnsArray = fnHeader.toLowerCase().contains("array") || fnHeader.contains("]"); if (returnsArray) { @@ -2091,28 +2098,28 @@ protected void generateCode(Jump _jump, String _indent) //if (line.matches(preReturnMatch)) if (_jump.isReturn()) { - // START KGU#988 2021-10-01: Bugfix #989 missing expression translation + // START KGU#989 2021-10-01: Bugfix #989 missing expression translation //addCode("return " + line.substring(preReturn.length()).trim() + ";", addCode("return " + transform(line.substring(preReturn.length()).trim()) + ";", - // END KGU#988 2021-10-01 + // END KGU#989 2021-10-01 _indent, isDisabled); } //else if (line.matches(preExitMatch)) else if (_jump.isExit()) { - // START KGU#988 2021-10-01: Bugfix #989 missing expression translation + // START KGU#989 2021-10-01: Bugfix #989 missing expression translation //appendExitInstr(line.substring(preExit.length()).trim(), _indent, isDisabled); appendExitInstr(transform(line.substring(preExit.length()).trim()), _indent, isDisabled); - // END KGU#988 2021-10-01 + // END KGU#989 2021-10-01 } // START KGU#686 2019-03-20: Enh. #56 Throw has to be implemented else if (_jump.isThrow() && this.getTryCatchLevel() != TryCatchSupportLevel.TC_NO_TRY) { - // START KGU#988 2021-10-01: Bugfix #989 missing expression translation + // START KGU#989 2021-10-01: Bugfix #989 missing expression translation //this.generateThrowWith(line.substring( // CodeParser.getKeywordOrDefault("preThrow", "throw").length()).trim(), _indent, isDisabled); this.generateThrowWith(transform(line.substring( CodeParser.getKeywordOrDefault("preThrow", "throw").length()).trim()), _indent, isDisabled); - // END KGU#988 2021-10-01 + // END KGU#989 2021-10-01 } // END KGU#686 2019-03-20 // Has it already been matched with a loop? Then syntax must have been okay... diff --git a/src/lu/fisch/structorizer/generators/CPlusPlusGenerator.java b/src/lu/fisch/structorizer/generators/CPlusPlusGenerator.java index e371b46b..2b08325e 100644 --- a/src/lu/fisch/structorizer/generators/CPlusPlusGenerator.java +++ b/src/lu/fisch/structorizer/generators/CPlusPlusGenerator.java @@ -62,6 +62,7 @@ * Kay Gürtzig 2019-12-02 KGU#784 Defective type descriptions in argument lists and thread function operators * Kay Gürtzig 2020-03-20/23 Enh. #828 bugfix #836: Group export implemented, batch export improved * Kay Gürtzig 2020-03-23 Issue #840: Adaptations w.r.t. disabled elements using File API + * Kay Gürtzig 2021-10-03 Bugfix #990: Made-up result types on exported procedures * ****************************************************************************************************** * @@ -199,9 +200,15 @@ protected int insertPrototype(Root _root, String _indent, boolean _withComment, StringList paramNames = new StringList(); StringList paramTypes = new StringList(); _root.collectParameters(paramNames, paramTypes, null); + // START KGU#990 2021-10-02: Bugfix #990 These values could be from a different root + StringList vars = _root.getVarNames(); + // END KGU#990 2021-10-02 // Start with the result type fnHeader = transformType(_root.getResultType(), - ((returns || isResultSet || isFunctionNameSet) ? "int" : "void")); + // START KGU#990 2021-10-02: Bugfix #990 These values could be from a different root + //((returns || isResultSet || isFunctionNameSet) ? "int" : "void")); + ((_root.returnsValue == Boolean.TRUE || vars.contains("result", false) || vars.contains(fnName)) ? "int" : "void")); + // END KGU#990 2021-10-02 // START KGU#140 2017-01-31: Enh. #113 - improved type recognition and transformation returnsArray = fnHeader.toLowerCase().contains("array") || fnHeader.contains("]"); if (returnsArray) { diff --git a/src/lu/fisch/structorizer/generators/Generator.java b/src/lu/fisch/structorizer/generators/Generator.java index 9e8f7f53..6c0ee2de 100644 --- a/src/lu/fisch/structorizer/generators/Generator.java +++ b/src/lu/fisch/structorizer/generators/Generator.java @@ -113,6 +113,7 @@ * Kay Gürtzig 2020-04-28 Bugfix #828: Unreferenced subroutines were missing on group export with 1 main * Kay Gürtzig 2021-02-13 Bugfix #937: Endless loop precaution in topological sorting * Kay Gürtzig 2021-06-08 Enh. #953: Export option adaptations for LaTeX algorithm export + * Kay Gürtzig 2021-10-03 Issue #990: Precaution against fake result type associations * ****************************************************************************************************** * @@ -3147,6 +3148,9 @@ public String generateCode(Root _root, String _indent, boolean _public) this.returns = false; // END KGU#828 2020-03-18 boolean alwaysReturns = mapJumps(_root.children); + // START KGU#990 2021-10-03: Bugfix #990 - precaution against fake result type association + _root.returnsValue = this.returns; + // END KGU#990 2021-10-03 StringList paramNames = new StringList(); StringList paramTypes = new StringList(); _root.collectParameters(paramNames, paramTypes, null); @@ -3473,7 +3477,7 @@ protected boolean generateInitRoutine(Root incl, String _indent) { init.setComment("Automatically created initialization procedure for " + incl.getMethodName()); init.setProgram(false); /* Since this initialisation procedure is not used for a library as a whole, - * it will never required to be public - the library initialisation routine + * it is never required to be public - the library initialisation routine * will call the specific initialisation procedures for all involved Includables * internally. */ diff --git a/src/lu/fisch/structorizer/generators/KSHGenerator.java b/src/lu/fisch/structorizer/generators/KSHGenerator.java index 3fe68b5e..e9e28ea2 100644 --- a/src/lu/fisch/structorizer/generators/KSHGenerator.java +++ b/src/lu/fisch/structorizer/generators/KSHGenerator.java @@ -59,6 +59,7 @@ * Kay Gürtzig 2020-02-24 Issues #816,#821: generateCode(Root) partially decomposed * Kay Gürtzig 2020-03-18 Bugfix #839 - sticky returns flag mended * Kay Gürtzig 2020-03-19/29 Enh. #828: Modifications to support group export + * Kay Gürtzig 2021-10-03 Bugfix #990: returnsValue field of the handled root filled * ****************************************************************************************************** * @@ -251,6 +252,9 @@ public String generateCode(Root _root, String _indent, boolean _public) { // END KGU#828 2020-03-18 boolean alwaysReturns = mapJumps(_root.children); // END KGU#803 2020-02-16 + // START KGU#990 2021-10-03: Bugfix #990 + _root.returnsValue = this.returns; + // END KGU#990 2021-10-03 // START KGU#178 2016-07-20: Enh. #160 diff --git a/src/lu/fisch/structorizer/generators/PasGenerator.java b/src/lu/fisch/structorizer/generators/PasGenerator.java index 52dc225d..de0e84a5 100644 --- a/src/lu/fisch/structorizer/generators/PasGenerator.java +++ b/src/lu/fisch/structorizer/generators/PasGenerator.java @@ -94,6 +94,7 @@ * 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 * Kay Gürtzig 2021-09-21 Bugfix #987: Duplicate comments for subroutines, inconsistent multi-line comments + * Kay Gürtzig 2021-10-03 Bugfix #990: Made-up result types on exported procedures * ****************************************************************************************************** * @@ -353,7 +354,11 @@ else if (_sl.count() == 1 && !_sl.get(0).contains("\n")) { @Override protected int insertPrototype(Root _root, String _indent, boolean _withComment, int _atLine) { - String signature = _root.getMethodName(); + // START KGU#990 2021-10-02: Bugfix #990 we need the method name for a comparison + //String signature = _root.getMethodName(); + String fnName = _root.getMethodName(); + String signature = fnName; + // END KGU#990 2021-10-02 StringList paramNames = new StringList(); StringList paramTypes = new StringList(); _root.collectParameters(paramNames, paramTypes, null); @@ -381,7 +386,13 @@ protected int insertPrototype(Root _root, String _indent, boolean _withComment, // END KGU#371 2019-03-08 } signature += ")"; - if (resultType != null || this.returns || this.isResultSet || this.isFunctionNameSet) + // START KGU#990 2021-10-02: Bugfix #990 _root is not necessarily the current Root + StringList vars = _root.getVarNames(); + // END KGU#990 2021-10-02 + // START KGU#990 2021-10-02: Bugfix #990 These values could be from a different root + //if (resultType != null || this.returns || this.isResultSet || this.isFunctionNameSet) + if (resultType != null || _root.returnsValue == Boolean.TRUE || vars.contains("result", false) || vars.contains(fnName)) + // END KGU#990 2021-10-02 { resultType = transformType(_root.getResultType(), "Integer"); signature += ": " + resultType; @@ -482,6 +493,11 @@ protected String transformTypeFromEntry(TypeMapEntry typeInfo, TypeMapEntry defi int maxIndex = typeInfo.getMaxIndex(i); // START KGU#854 2020-04-22: Enh. #855 if (maxIndex < 0) { + // START KGU#994 2021-10-03 We must not risk a negative start index + if (minIndex < 0) { + minIndex = 0; + } + // END KGU#994 2021-10-03 maxIndex = minIndex + this.optionDefaultArraySize() - 1; } // END KGU#854 2020-04-22 @@ -2077,12 +2093,20 @@ protected boolean generateVarDecls(Root _root, String _indent, StringList _varNa //HashMap typeMap = _root.getTypeInfo(); // KGU 2018-07-22: became obsolete by new field typeMap // END KGU#261 2017-01-16 // START KGU#593 2018-10-05: Bugfix #619 - the function result variable must not be declared (again) here! - String functionName = null; + // START KGU#990 2021-10-03: Bugfix #990 _root may not be the current root + //String functionName = null; + String functionName = _root.getMethodName(); + // END KGU#990 2021-10-03 // START KGU 2020-03-25: This seemed to be too slacky //if (_root.getResultType() != null) { - if (_root.getResultType() != null || this.returns || this.isResultSet || this.isFunctionNameSet) { + // START KGU#990 2021-10-03: Bugfix #990 _root may not be the current root + //if (_root.getResultType() != null || this.returns || this.isResultSet || this.isFunctionNameSet) { + if (_root.getResultType() == null && _root.returnsValue != Boolean.TRUE && !_varNames.contains("result", false) && !_varNames.contains(functionName)) { + // END KGU#990 2021-10-03 // END KGU 2020-03-25 - functionName = _root.getMethodName(); + // START KGU#990 2021-10-03: Bugfix #990 _root may not be the current root + functionName = null; + // END KGU#990 2021-10-03 } // END KGU#593 2018-10-05 for (int v = 0; v < _varNames.count(); v++) { diff --git a/src/lu/fisch/structorizer/gui/changelog.txt b/src/lu/fisch/structorizer/gui/changelog.txt index 0271256e..0879d1f3 100644 --- a/src/lu/fisch/structorizer/gui/changelog.txt +++ b/src/lu/fisch/structorizer/gui/changelog.txt @@ -19,10 +19,12 @@ Known issues: - Shell export neither copes with nested array/record initialisers and component access nor with cleanly handling usual and associative arrays as parameters or results. -Current development version 3.32-01 (2021-10-01) +Current development version 3.32-01 (2021-10-03) - 01: Bugfix #987: Duplicate subroutine comment export by Pascal generator <2> - 01: Bugfix #988: Syntax error in Structorizer.bat fixed <2> - 01: Bugfix #989: Missing translation of EXIT expressions on export to C etc. <2> +- 01: Bugfix #990: Procedures could obtain made-up result types on group export <2> +- 01: Bugfix #991: Analyser check for ensured function results was defective <2> Version 3.32 (2021-09-19) requiring Java 11 or newer - 01: Bugfix #851/2: COBOL import: SPECIAL-NAMES sections caused parser abort <2> diff --git a/src/lu/fisch/structorizer/parsers/D7Parser.java b/src/lu/fisch/structorizer/parsers/D7Parser.java index 959782e8..2ae8c364 100644 --- a/src/lu/fisch/structorizer/parsers/D7Parser.java +++ b/src/lu/fisch/structorizer/parsers/D7Parser.java @@ -73,6 +73,7 @@ * by a modification of the block comment in PasGenerator. * Kay Gürtzig 2021-02-15/16 Unicode import enabled after eliminating a grammar ambiguity, comment * processing no longer necessary, either, hence \n substitution also dropped + * Kay Gürtzig 2021-10-03 Mechanism to ensure case-sensitive matching of result variables with function name * ****************************************************************************************************** * @@ -802,72 +803,72 @@ private interface RuleConstants }; // END KGU#358 2017-03-29 - // START KGU#407 2017-06-22: Enh. #420 - rule ids representing statements, used as stoppers for comment rerieval - private static final int[] statementIds = new int[]{ - RuleConstants.PROD_PACKAGEHEADER_PACKAGE_SEMI, - RuleConstants.PROD_OPTREQUIRESCLAUSE_REQUIRES_SEMI, - RuleConstants.PROD_OPTCONTAINSCLAUSE_CONTAINS_SEMI, - RuleConstants.PROD_EXPORTDECLLIST, - RuleConstants.PROD_EXPORTDECLLIST2, - RuleConstants.PROD_EXPORTDECLITEM, - RuleConstants.PROD_EXPORTDECLITEM2, - RuleConstants.PROD_EXPORTDECLITEM3, - RuleConstants.PROD_EXPORTDECLITEM4, - RuleConstants.PROD_EXPORTDECLITEM_FORWARD_SEMI, - RuleConstants.PROD_CALLSECTION, - RuleConstants.PROD_CALLSECTION2, - RuleConstants.PROD_IMPLEMENTATIONSECTION_IMPLEMENTATION, - RuleConstants.PROD_INITSECTION_INITIALIZATION_END, - RuleConstants.PROD_INITSECTION_INITIALIZATION_FINALIZATION_END, - RuleConstants.PROD_INITSECTION, - RuleConstants.PROD_INITSECTION_END, - RuleConstants.PROD_STATEMENT, - RuleConstants.PROD_STATEMENT2, - RuleConstants.PROD_STATEMENT3, - RuleConstants.PROD_STATEMENT4, - RuleConstants.PROD_STATEMENT5, - RuleConstants.PROD_STATEMENT6, - RuleConstants.PROD_STATEMENT7, - RuleConstants.PROD_STATEMENT8, - RuleConstants.PROD_STATEMENT9, - RuleConstants.PROD_STATEMENT10, - RuleConstants.PROD_STATEMENT11, - RuleConstants.PROD_STATEMENT12, - RuleConstants.PROD_STATEMENT13, - RuleConstants.PROD_STATEMENT14, - RuleConstants.PROD_STATEMENT15, - RuleConstants.PROD_ASSIGNMENTSTMT, - RuleConstants.PROD_ASSIGNMENTSTMT_AT_COLONEQ, - RuleConstants.PROD_CALLSTMT, - RuleConstants.PROD_CALLSTMT_WRITE_LPAREN_RPAREN, - RuleConstants.PROD_CALLSTMT_WRITELN_LPAREN_RPAREN, - RuleConstants.PROD_CALLSTMT_INHERITED, - RuleConstants.PROD_GOTOSTATEMENT_GOTO, - RuleConstants.PROD_GOTOSTATEMENT_GOTO2, - RuleConstants.PROD_COMPOUNDSTMT_BEGIN_END, - RuleConstants.PROD_IFSTATEMENT_IF_THEN_ELSE, - RuleConstants.PROD_IFSTATEMENT_IF_THEN, - RuleConstants.PROD_IFSTATEMENT_IF_SYNERROR_THEN, - RuleConstants.PROD_CASESTATEMENT_CASE_OF_END, - RuleConstants.PROD_FORSTATEMENT_FOR_COLONEQ_DO, - RuleConstants.PROD_WHILESTATEMENT_WHILE_DO, - RuleConstants.PROD_WITHSTATEMENT_WITH_DO, - RuleConstants.PROD_REPEATSTATEMENT_REPEAT_UNTIL, - RuleConstants.PROD_ASSEMBLERSTMT_ASM_END, - RuleConstants.PROD_RAISESTMT_RAISE_SYNERROR, - RuleConstants.PROD_RAISESTMT_RAISE, - RuleConstants.PROD_RAISESTMT_RAISE_AT, - RuleConstants.PROD_OPTEXCEPTIONELSE_ELSE, - }; - // END KGU#407 2017-06-22 - // END KGU#387 2021-02-15 - - // START KGU#843 2020-04-11: Bugfix #847 - We must convert all operator names to lower-case - /** Production rule heads designating operator symbols */ - private static final StringList OPR_RULE_HEADS = StringList.explode(",,", ","); - /** Identifiers belonging to literals or functions the names of which will only be accepted in lowercase by Structorizer */ - private static final StringList NAMES_TO_LOWER = StringList.explode("FALSE,TRUE,CHR,ORD,POS,COPY,DELETE,INSERT,UPPERCASE,LOWERCASE", ","); - // END KGU#843 2020-04-11 + // START KGU#407 2017-06-22: Enh. #420 - rule ids representing statements, used as stoppers for comment rerieval + private static final int[] statementIds = new int[]{ + RuleConstants.PROD_PACKAGEHEADER_PACKAGE_SEMI, + RuleConstants.PROD_OPTREQUIRESCLAUSE_REQUIRES_SEMI, + RuleConstants.PROD_OPTCONTAINSCLAUSE_CONTAINS_SEMI, + RuleConstants.PROD_EXPORTDECLLIST, + RuleConstants.PROD_EXPORTDECLLIST2, + RuleConstants.PROD_EXPORTDECLITEM, + RuleConstants.PROD_EXPORTDECLITEM2, + RuleConstants.PROD_EXPORTDECLITEM3, + RuleConstants.PROD_EXPORTDECLITEM4, + RuleConstants.PROD_EXPORTDECLITEM_FORWARD_SEMI, + RuleConstants.PROD_CALLSECTION, + RuleConstants.PROD_CALLSECTION2, + RuleConstants.PROD_IMPLEMENTATIONSECTION_IMPLEMENTATION, + RuleConstants.PROD_INITSECTION_INITIALIZATION_END, + RuleConstants.PROD_INITSECTION_INITIALIZATION_FINALIZATION_END, + RuleConstants.PROD_INITSECTION, + RuleConstants.PROD_INITSECTION_END, + RuleConstants.PROD_STATEMENT, + RuleConstants.PROD_STATEMENT2, + RuleConstants.PROD_STATEMENT3, + RuleConstants.PROD_STATEMENT4, + RuleConstants.PROD_STATEMENT5, + RuleConstants.PROD_STATEMENT6, + RuleConstants.PROD_STATEMENT7, + RuleConstants.PROD_STATEMENT8, + RuleConstants.PROD_STATEMENT9, + RuleConstants.PROD_STATEMENT10, + RuleConstants.PROD_STATEMENT11, + RuleConstants.PROD_STATEMENT12, + RuleConstants.PROD_STATEMENT13, + RuleConstants.PROD_STATEMENT14, + RuleConstants.PROD_STATEMENT15, + RuleConstants.PROD_ASSIGNMENTSTMT, + RuleConstants.PROD_ASSIGNMENTSTMT_AT_COLONEQ, + RuleConstants.PROD_CALLSTMT, + RuleConstants.PROD_CALLSTMT_WRITE_LPAREN_RPAREN, + RuleConstants.PROD_CALLSTMT_WRITELN_LPAREN_RPAREN, + RuleConstants.PROD_CALLSTMT_INHERITED, + RuleConstants.PROD_GOTOSTATEMENT_GOTO, + RuleConstants.PROD_GOTOSTATEMENT_GOTO2, + RuleConstants.PROD_COMPOUNDSTMT_BEGIN_END, + RuleConstants.PROD_IFSTATEMENT_IF_THEN_ELSE, + RuleConstants.PROD_IFSTATEMENT_IF_THEN, + RuleConstants.PROD_IFSTATEMENT_IF_SYNERROR_THEN, + RuleConstants.PROD_CASESTATEMENT_CASE_OF_END, + RuleConstants.PROD_FORSTATEMENT_FOR_COLONEQ_DO, + RuleConstants.PROD_WHILESTATEMENT_WHILE_DO, + RuleConstants.PROD_WITHSTATEMENT_WITH_DO, + RuleConstants.PROD_REPEATSTATEMENT_REPEAT_UNTIL, + RuleConstants.PROD_ASSEMBLERSTMT_ASM_END, + RuleConstants.PROD_RAISESTMT_RAISE_SYNERROR, + RuleConstants.PROD_RAISESTMT_RAISE, + RuleConstants.PROD_RAISESTMT_RAISE_AT, + RuleConstants.PROD_OPTEXCEPTIONELSE_ELSE, + }; + // END KGU#407 2017-06-22 + // END KGU#387 2021-02-15 + + // START KGU#843 2020-04-11: Bugfix #847 - We must convert all operator names to lower-case + /** Production rule heads designating operator symbols */ + private static final StringList OPR_RULE_HEADS = StringList.explode(",,", ","); + /** Identifiers belonging to literals or functions the names of which will only be accepted in lowercase by Structorizer */ + private static final StringList NAMES_TO_LOWER = StringList.explode("FALSE,TRUE,CHR,ORD,POS,COPY,DELETE,INSERT,UPPERCASE,LOWERCASE", ","); + // END KGU#843 2020-04-11 // START KGU#387 2021-02-16: Issue #939 workaround no longer necessary // // START KGU#575 2018-09-17: Issue #594 - replace obsolete 3rd-party regex library @@ -890,6 +891,14 @@ private interface RuleConstants private String unitName = null; // END KGU#194 2016-05-08 + // START KGU#991 2021-10-03: Issue #991 Ensure exact spelling of result variables + /** + * Holds the function name within a function declaration to adopt its exact case- + * aware spelling for the result variable. + */ + private String functionName = null; + // END KGU#991 2021-10-03 + // START KGU#821 2020-03-07: Issue #833 We must process parameterless routines /** List of the names of detected parameterless routines (in order to add parentheses) */ private StringList paramlessRoutineNames = new StringList(); @@ -1424,6 +1433,9 @@ else if ( // FIXME transfer declarations to a global includable if prevRoot // END KGU#376 2017-09-22 + // START KGU#991 2021-10-03: Issue #991 Uncache the function name on leaving definition context + functionName = null; + // END KGU#991 2021-10-03 root = prevRoot; } // END KGU#194 2016-05-08 @@ -1448,15 +1460,24 @@ else if ( ) { content = new String(); + // Get the routine name content = getContent_R(_reduction.get(1).asReduction(), content); + // START KGU#991 2021-10-03: Issue #991 Cache the exact name spelling to coerce the result variable + if (ruleHead.equals("")) { + functionName = content.trim(); + // This will be cleared at the end of + } + // END KGU#991 2021-10-03 Reduction secReduc = _reduction.get(2).asReduction(); - if (secReduc.size()!=0) + if (secReduc.size() != 0) { - content = getContent_R(secReduc,content); + // Append the parameter list + content = getContent_R(secReduc, content); } // START KGU#821 2020-03-08 Issue #833 - parameterless routine must get parentheses else { + // No parameter list -> ensure parentheses paramlessRoutineNames.add(content); content += "()"; } @@ -2045,9 +2066,20 @@ protected String getContent_R(Reduction _reduction, String _content) throws Pars // // END KGU#192 2016-05-02 // tokenData.trim().equalsIgnoreCase("div")) String ruleHead = _reduction.getParent().getHead().toString(); - if (tokenIsId && ruleHead.equals("") && NAMES_TO_LOWER.contains(tokenData, false)) { - tokenData = tokenData.toLowerCase(); + // START KGU#991 2021-10-03 Issue #991 Inside a function definition coerce result var spelling + //if (tokenIsId && ruleHead.equals("") && NAMES_TO_LOWER.contains(tokenData, false)) { + // tokenData = tokenData.toLowerCase(); + //} + if (tokenIsId && ruleHead.equals("")) { + if (NAMES_TO_LOWER.contains(tokenData, false)) { + tokenData = tokenData.toLowerCase(); + } + else if (functionName != null && functionName.equalsIgnoreCase(tokenData)) { + // Make sure that function name and result variable exactly match + tokenData = functionName; + } } + // END KGU#991 2021-10-03 if (OPR_RULE_HEADS.contains(ruleHead)) // END KGU#843 2020-04-11 { From de49f06472e3176df48866ff044c05bad71a68cf Mon Sep 17 00:00:00 2001 From: codemanyak Date: Mon, 4 Oct 2021 07:37:30 +0200 Subject: [PATCH 06/14] Fixes #993 (also updating all manual exports) --- samples/export/BASIC0/ComputeSum.bas | 4 +- samples/export/BASIC0/DrawRandomHistogram.bas | 6 +- samples/export/BASIC0/ELIZA_2.2.bas | 393 ++++++----- samples/export/BASIC0/SORTING_TEST_MAIN.bas | 2 +- samples/export/BASIC0/TextDemo.bas | 4 +- samples/export/BASIC1/ComputeSum.bas | 12 +- samples/export/BASIC1/DrawRandomHistogram.bas | 24 +- samples/export/BASIC1/ELIZA_2.2.bas | 57 +- samples/export/BASIC1/SORTING_TEST_MAIN.bas | 8 +- samples/export/BASIC1/TextDemo.bas | 8 +- samples/export/C#/ComputeSum.cs | 10 +- samples/export/C#/DrawRandomHistogram.cs | 19 +- samples/export/C#/ELIZA_2.2.cs | 13 +- samples/export/C#/SORTING_TEST_MAIN.cs | 73 +- samples/export/C#/TextDemo.cs | 4 +- samples/export/C++/ComputeSum.cpp | 2 +- samples/export/C++/DrawRandomHistogram.cpp | 11 +- samples/export/C++/ELIZA_2.2.cpp | 13 +- samples/export/C++/SORTING_TEST_MAIN.cpp | 53 +- samples/export/C++/TextDemo.cpp | 4 +- samples/export/C/ComputeSum.c | 2 +- samples/export/C/DrawRandomHistogram.c | 8 +- samples/export/C/ELIZA_2.2.c | 47 +- samples/export/C/SORTING_TEST_MAIN.c | 8 +- samples/export/C/TextDemo.c | 4 +- samples/export/Java/ComputeSum.java | 12 +- samples/export/Java/DrawRandomHistogram.java | 21 +- samples/export/Java/ELIZA_2.2.java | 13 +- samples/export/Java/SORTING_TEST_MAIN.java | 53 +- samples/export/Java/TextDemo.java | 4 +- samples/export/Js/ComputeSum.js | 12 +- samples/export/Js/DrawRandomHistogram.js | 12 +- samples/export/Js/SORTING_TEST_MAIN.js | 2 +- samples/export/Js/TextDemo.js | 6 +- samples/export/Oberon/ComputeSum.Mod | 2 +- samples/export/Oberon/DrawRandomHistogram.Mod | 8 +- samples/export/Oberon/ELIZA_2.2.Mod | 52 +- samples/export/Oberon/SORTING_TEST_MAIN.Mod | 8 +- samples/export/Oberon/TextDemo.Mod | 6 +- samples/export/PHP/ComputeSum.php | 10 +- samples/export/PHP/DrawRandomHistogram.php | 10 +- samples/export/PHP/SORTING_TEST_MAIN.php | 6 +- samples/export/PHP/TextDemo.php | 4 +- samples/export/Pascal/ComputeSum.pas | 8 +- samples/export/Pascal/DrawRandomHistogram.pas | 22 +- samples/export/Pascal/ELIZA_2.2.pas | 34 +- samples/export/Pascal/SORTING_TEST_MAIN.pas | 62 +- samples/export/Pascal/TextDemo.pas | 226 +++--- samples/export/Perl/ComputeSum.pl | 8 +- samples/export/Perl/DrawRandomHistogram.pl | 8 +- samples/export/Perl/ELIZA_2.2.pl | 14 +- samples/export/Perl/SORTING_TEST_MAIN.pl | 22 +- samples/export/Perl/TextDemo.pl | 4 +- samples/export/Python/ComputeSum.py | 2 +- samples/export/Python/DrawRandomHistogram.py | 10 +- samples/export/Python/SORTING_TEST_MAIN.py | 32 +- samples/export/Python/TextDemo.py | 464 ++++++------ samples/export/StrukTeX/ComputeSum.tex | 8 +- .../export/StrukTeX/DrawRandomHistogram.tex | 10 +- samples/export/StrukTeX/ELIZA_2.2.tex | 58 +- samples/export/StrukTeX/SORTING_TEST_MAIN.tex | 22 +- samples/export/StrukTeX/TextDemo.tex | 104 +-- samples/export/bash/ComputeSum.sh | 6 +- samples/export/bash/DrawRandomHistogram.sh | 14 +- samples/export/bash/ELIZA_2.2.sh | 48 +- samples/export/bash/SORTING_TEST_MAIN.sh | 36 +- samples/export/bash/TextDemo.sh | 4 +- samples/export/ksh/ComputeSum.ksh | 6 +- samples/export/ksh/DrawRandomHistogram.ksh | 18 +- samples/export/ksh/ELIZA_2.2.ksh | 48 +- samples/export/ksh/SORTING_TEST_MAIN.ksh | 36 +- samples/export/ksh/TextDemo.ksh | 4 +- .../export_group/BASIC0/ELIZA_2_2_arrz.bas | 623 ++++++++--------- .../export_group/BASIC0/ELIZA_2_3_arrz.bas | 661 +++++++++--------- .../BASIC0/FileApiGroupTest_arrz.bas | 12 +- .../export_group/BASIC0/SORTING_TEST_arrz.bas | 2 +- .../export_group/BASIC0/TextWriter_arrz.bas | 4 +- .../export_group/BASIC1/ELIZA_2_2_arrz.bas | 57 +- .../export_group/BASIC1/ELIZA_2_3_arrz.bas | 57 +- .../BASIC1/FileApiGroupTest_arrz.bas | 40 +- .../export_group/BASIC1/SORTING_TEST_arrz.bas | 8 +- .../export_group/BASIC1/TextWriter_arrz.bas | 8 +- samples/export_group/C#/ELIZA_2_2_arrz.cs | 13 +- samples/export_group/C#/ELIZA_2_3_arrz.cs | 11 +- .../export_group/C#/FileApiGroupTest_arrz.cs | 35 +- samples/export_group/C#/SORTING_TEST_arrz.cs | 73 +- samples/export_group/C#/TextWriter_arrz.cs | 4 +- samples/export_group/C++/ELIZA_2_2_arrz.cpp | 13 +- samples/export_group/C++/ELIZA_2_3_arrz.cpp | 11 +- .../C++/FileApiGroupTest_arrz.cpp | 21 +- .../export_group/C++/SORTING_TEST_arrz.cpp | 53 +- samples/export_group/C++/TextWriter_arrz.cpp | 4 +- samples/export_group/C/ELIZA_2_2_arrz.c | 44 +- samples/export_group/C/ELIZA_2_3_arrz.c | 42 +- .../export_group/C/FileApiGroupTest_arrz.c | 18 +- samples/export_group/C/SORTING_TEST_arrz.c | 8 +- samples/export_group/C/TextWriter_arrz.c | 4 +- samples/export_group/Java/ELIZA_2_2_arrz.java | 13 +- samples/export_group/Java/ELIZA_2_3_arrz.java | 11 +- .../Java/FileApiGroupTest_arrz.java | 37 +- .../export_group/Java/SORTING_TEST_arrz.java | 53 +- .../export_group/Java/TextWriter_arrz.java | 4 +- samples/export_group/Js/ELIZA_2_2_arrz.js | 3 +- samples/export_group/Js/ELIZA_2_3_arrz.js | 3 +- .../export_group/Js/FileApiGroupTest_arrz.js | 26 +- samples/export_group/Js/SORTING_TEST_arrz.js | 2 +- samples/export_group/Js/TextWriter_arrz.js | 6 +- .../export_group/Oberon/ELIZA_2_2_arrz.Mod | 52 +- .../export_group/Oberon/ELIZA_2_3_arrz.Mod | 52 +- .../Oberon/FileApiGroupTest_arrz.Mod | 16 +- .../export_group/Oberon/SORTING_TEST_arrz.Mod | 8 +- .../export_group/Oberon/TextWriter_arrz.Mod | 6 +- samples/export_group/PHP/ELIZA_2_2_arrz.php | 2 +- samples/export_group/PHP/ELIZA_2_3_arrz.php | 2 +- .../PHP/FileApiGroupTest_arrz.php | 26 +- .../export_group/PHP/SORTING_TEST_arrz.php | 6 +- samples/export_group/PHP/TextWriter_arrz.php | 4 +- .../export_group/Pascal/ELIZA_2_2_arrz.pas | 83 ++- .../export_group/Pascal/ELIZA_2_3_arrz.pas | 391 +++++------ .../Pascal/FileApiGroupTest_arrz.pas | 36 +- .../export_group/Pascal/SORTING_TEST_arrz.pas | 62 +- .../export_group/Pascal/TextWriter_arrz.pas | 226 +++--- samples/export_group/Perl/ELIZA_2_2_arrz.pl | 14 +- samples/export_group/Perl/ELIZA_2_3_arrz.pl | 14 +- .../Perl/FileApiGroupTest_arrz.pl | 20 +- .../export_group/Perl/SORTING_TEST_arrz.pl | 22 +- samples/export_group/Perl/TextWriter_arrz.pl | 4 +- samples/export_group/Python/ELIZA_2_2_arrz.py | 2 +- samples/export_group/Python/ELIZA_2_3_arrz.py | 2 +- .../Python/FileApiGroupTest_arrz.py | 16 +- .../export_group/Python/SORTING_TEST_arrz.py | 32 +- .../export_group/Python/TextWriter_arrz.py | 464 ++++++------ .../export_group/StrukTex/ELIZA_2_2_arrz.tex | 58 +- .../export_group/StrukTex/ELIZA_2_3_arrz.tex | 54 +- .../StrukTex/FileApiGroupTest_arrz.tex | 14 +- .../StrukTex/SORTING_TEST_arrz.tex | 22 +- .../export_group/StrukTex/TextWriter_arrz.tex | 104 +-- samples/export_group/bash/ELIZA_2_2_arrz.sh | 48 +- samples/export_group/bash/ELIZA_2_3_arrz.sh | 48 +- .../bash/FileApiGroupTest_arrz.sh | 28 +- .../export_group/bash/SORTING_TEST_arrz.sh | 36 +- samples/export_group/bash/TextWriter_arrz.sh | 4 +- samples/export_group/ksh/ELIZA_2_2_arrz.ksh | 48 +- samples/export_group/ksh/ELIZA_2_3_arrz.ksh | 48 +- .../ksh/FileApiGroupTest_arrz.ksh | 32 +- .../export_group/ksh/SORTING_TEST_arrz.ksh | 36 +- samples/export_group/ksh/TextWriter_arrz.ksh | 4 +- .../structorizer/generators/BasGenerator.java | 71 +- .../structorizer/generators/CGenerator.java | 24 +- .../generators/CPlusPlusGenerator.java | 11 +- .../generators/CSharpGenerator.java | 11 +- .../generators/JavaGenerator.java | 11 +- .../generators/OberonGenerator.java | 24 +- .../structorizer/generators/PasGenerator.java | 24 +- src/lu/fisch/structorizer/gui/changelog.txt | 3 +- 155 files changed, 3426 insertions(+), 3251 deletions(-) diff --git a/samples/export/BASIC0/ComputeSum.bas b/samples/export/BASIC0/ComputeSum.bas index 62d13681..5e29846c 100644 --- a/samples/export/BASIC0/ComputeSum.bas +++ b/samples/export/BASIC0/ComputeSum.bas @@ -6,7 +6,7 @@ 60 REM The input check loop has been disabled (replaced by a simple unchecked input 70 REM instruction) in order to test the effect of indirect FileAPI dependency (only the 80 REM called subroutine directly requires FileAPI now). -90 REM Generated by Structorizer 3.30-11 +90 REM Generated by Structorizer 3.32-01 100 110 REM Copyright (C) 2020-03-21 Kay Gürtzig 120 REM License: GPLv3-link @@ -53,7 +53,7 @@ 530 REM from file fileName into the given array numbers. 540 REM Returns the number of the actually read numbers. May cause an exception. 550 REM TODO: Add type-specific suffixes where necessary! -560 FUNCTION readNumbers(fileName AS String, numbers AS array of integer, maxNumbers AS integer) AS integer +560 FUNCTION readNumbers(fileName AS String, numbers AS integer(50), maxNumbers AS integer) AS integer 570 REM TODO: add the respective type suffixes to your variable names if required 580 LET nNumbers = 0 590 LET fileNo = fileOpen(fileName) diff --git a/samples/export/BASIC0/DrawRandomHistogram.bas b/samples/export/BASIC0/DrawRandomHistogram.bas index dde82068..04f7f40b 100644 --- a/samples/export/BASIC0/DrawRandomHistogram.bas +++ b/samples/export/BASIC0/DrawRandomHistogram.bas @@ -1,6 +1,6 @@ 10 REM Reads a random number file and draws a histogram accotrding to the 20 REM user specifications -30 REM Generated by Structorizer 3.30-11 +30 REM Generated by Structorizer 3.32-01 40 50 REM Copyright (C) 2020-03-21 Kay Gürtzig 60 REM License: GPLv3-link @@ -76,7 +76,7 @@ 760 REM 500 x 500 pixels 770 REM Note: The function is not robust against empty array or totally equal values. 780 REM TODO: Add type-specific suffixes where necessary! -790 SUB drawBarChart(values AS array of double, nValues) +790 SUB drawBarChart(values AS double(50), nValues) 800 REM TODO: add the respective type suffixes to your variable names if required 810 REM Used range of the Turtleizer screen 820 LET xSize = 500 @@ -143,7 +143,7 @@ 1430 REM from file fileName into the given array numbers. 1440 REM Returns the number of the actually read numbers. May cause an exception. 1450 REM TODO: Add type-specific suffixes where necessary! -1460 FUNCTION readNumbers(fileName AS String, numbers AS array of integer, maxNumbers AS integer) AS integer +1460 FUNCTION readNumbers(fileName AS String, numbers AS integer(50), maxNumbers AS integer) AS integer 1470 REM TODO: add the respective type suffixes to your variable names if required 1480 LET nNumbers = 0 1490 LET fileNo = fileOpen(fileName) diff --git a/samples/export/BASIC0/ELIZA_2.2.bas b/samples/export/BASIC0/ELIZA_2.2.bas index 7ea96b04..0876bf6d 100644 --- a/samples/export/BASIC0/ELIZA_2.2.bas +++ b/samples/export/BASIC0/ELIZA_2.2.bas @@ -8,7 +8,7 @@ 80 REM 2019-03-14 Replies and mapping reorganised for easier maintenance 90 REM 2019-03-15 key map joined from keyword array and index map 100 REM 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") -110 REM Generated by Structorizer 3.30-11 +110 REM Generated by Structorizer 3.32-01 120 130 REM Copyright (C) 2018-05-14 ??? 140 REM License: GPLv3-link @@ -104,8 +104,8 @@ 1040 delete(result, 1, position) 1050 insert(uppercase(start), result, 1) 1060 END IF -1070 DIM arrayd52b53f() AS String = {" i ", " i\'"} -1080 FOR EACH word IN arrayd52b53f +1070 DIM arrayf3864169() AS String = {" i ", " i\'"} +1080 FOR EACH word IN arrayf3864169 1090 LET position = pos(word, result) 1100 DO WHILE position > 0 1110 delete(result, position+1, 1) @@ -121,7 +121,7 @@ 1210 REM and if so writes a correspding good-bye message and 1220 REM returns true, otherwise false 1230 REM TODO: Add type-specific suffixes where necessary! -1240 FUNCTION checkGoodBye(text AS String, phrases AS array of array[0..1] of string) AS boolean +1240 FUNCTION checkGoodBye(text AS String, phrases AS String(50,0 TO 1)) AS boolean 1250 REM TODO: add the respective type suffixes to your variable names if required 1260 FOR EACH pair IN phrases 1270 IF pos(pair(0), text) > 0 THEN @@ -153,7 +153,7 @@ 1530 END FUNCTION 1540 REM 1550 REM TODO: Add type-specific suffixes where necessary! -1560 FUNCTION conjugateStrings(sentence AS String, key AS String, keyPos AS integer, flexions AS array of array[0..1] of string) AS String +1560 FUNCTION conjugateStrings(sentence AS String, key AS String, keyPos AS integer, flexions AS String(50,0 TO 1)) AS String 1570 REM TODO: add the respective type suffixes to your variable names if required 1580 LET result = " " + copy(sentence, keyPos + length(key), length(sentence)) + " " 1590 FOR EACH pair IN flexions @@ -183,7 +183,7 @@ 1830 REM 0: the index of the first identified keyword (if any, otherwise -1), 1840 REM 1: the position inside sentence (0 if not found) 1850 REM TODO: Add type-specific suffixes where necessary! -1860 FUNCTION findKeyword(keyMap AS const array of KeyMapEntry, sentence AS String) AS array[0..1] of integer +1860 FUNCTION findKeyword(CONST keyMap AS KeyMapEntry(50), sentence AS String) AS integer(0 TO 1) 1870 REM TODO: add the respective type suffixes to your variable names if required 1880 REM Contains the index of the keyword and its position in sentence 1890 REM TODO: Check indexBase value (automatically generated) @@ -211,8 +211,8 @@ 2110 REM TODO: add the respective type suffixes to your variable names if required 2120 LET sentence = lowercase(sentence) 2130 REM TODO: Specify an appropriate element type for the array! -2140 DIM array80b588f9() AS FIXME_80b588f9 = {'.', ',', ';', '!', '?'} -2150 FOR EACH symbol IN array80b588f9 +2140 DIM arrayd975144d() AS FIXME_d975144d = {'.', ',', ';', '!', '?'} +2150 FOR EACH symbol IN arrayd975144d 2160 LET position = pos(symbol, sentence) 2170 DO WHILE position > 0 2180 LET sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence)) @@ -224,7 +224,7 @@ 2240 END FUNCTION 2250 REM 2260 REM TODO: Add type-specific suffixes where necessary! -2270 FUNCTION setupGoodByePhrases() AS array of array[0..1] of string +2270 FUNCTION setupGoodByePhrases() AS String(50,0 TO 1) 2280 REM TODO: add the respective type suffixes to your variable names if required 2290 REM TODO: Check indexBase value (automatically generated) 2300 LET indexBase = 0 @@ -241,7 +241,7 @@ 2410 REM The index of the first keyword found in a user sentence maps to a respective 2420 REM reply ring as defined in `setupReplies()´. 2430 REM TODO: Add type-specific suffixes where necessary! -2440 FUNCTION setupKeywords() AS array of KeyMapEntry +2440 FUNCTION setupKeywords() AS KeyMapEntry(50) 2450 REM TODO: add the respective type suffixes to your variable names if required 2460 REM The empty key string (last entry) is the default clause - will always be found 2470 LET keywords(39).keyword = "" @@ -329,7 +329,7 @@ 3290 REM 3300 REM Returns an array of pairs of mutualy substitutable 3310 REM TODO: Add type-specific suffixes where necessary! -3320 FUNCTION setupReflexions() AS array of array[0..1] of string +3320 FUNCTION setupReflexions() AS String(50,0 TO 1) 3330 REM TODO: add the respective type suffixes to your variable names if required 3340 REM TODO: Check indexBase value (automatically generated) 3350 LET indexBase = 0 @@ -378,190 +378,189 @@ 3780 REM routine `setupKeywords()´ and mapped hitherto by the cross table defined 3790 REM in `setupMapping()´ 3800 REM TODO: Add type-specific suffixes where necessary! -3810 FUNCTION setupReplies() AS array of array of string +3810 FUNCTION setupReplies() AS String(50,50) 3820 REM TODO: add the respective type suffixes to your variable names if required -3830 var replies: array of array of String -3840 REM We start with the highest index for performance reasons -3850 REM (is to avoid frequent array resizing) -3860 REM TODO: Check indexBase value (automatically generated) -3870 LET indexBase = 0 -3880 LET replies(29)(indexBase + 0) = "Say, do you have any psychological problems?" -3890 LET replies(29)(indexBase + 1) = "What does that suggest to you?" -3900 LET replies(29)(indexBase + 2) = "I see." -3910 LET replies(29)(indexBase + 3) = "I'm not sure I understand you fully." -3920 LET replies(29)(indexBase + 4) = "Come come elucidate your thoughts." -3930 LET replies(29)(indexBase + 5) = "Can you elaborate on that?" -3940 LET replies(29)(indexBase + 6) = "That is quite interesting." -3950 REM TODO: Check indexBase value (automatically generated) -3960 LET indexBase = 0 -3970 LET replies(0)(indexBase + 0) = "Don't you believe that I can*?" -3980 LET replies(0)(indexBase + 1) = "Perhaps you would like to be like me?" -3990 LET replies(0)(indexBase + 2) = "You want me to be able to*?" -4000 REM TODO: Check indexBase value (automatically generated) -4010 LET indexBase = 0 -4020 LET replies(1)(indexBase + 0) = "Perhaps you don't want to*?" -4030 LET replies(1)(indexBase + 1) = "Do you want to be able to*?" -4040 REM TODO: Check indexBase value (automatically generated) -4050 LET indexBase = 0 -4060 LET replies(2)(indexBase + 0) = "What makes you think I am*?" -4070 LET replies(2)(indexBase + 1) = "Does it please you to believe I am*?" -4080 LET replies(2)(indexBase + 2) = "Perhaps you would like to be*?" -4090 LET replies(2)(indexBase + 3) = "Do you sometimes wish you were*?" -4100 REM TODO: Check indexBase value (automatically generated) -4110 LET indexBase = 0 -4120 LET replies(3)(indexBase + 0) = "Don't you really*?" -4130 LET replies(3)(indexBase + 1) = "Why don't you*?" -4140 LET replies(3)(indexBase + 2) = "Do you wish to be able to*?" -4150 LET replies(3)(indexBase + 3) = "Does that trouble you*?" -4160 REM TODO: Check indexBase value (automatically generated) -4170 LET indexBase = 0 -4180 LET replies(4)(indexBase + 0) = "Do you often feel*?" -4190 LET replies(4)(indexBase + 1) = "Are you afraid of feeling*?" -4200 LET replies(4)(indexBase + 2) = "Do you enjoy feeling*?" -4210 REM TODO: Check indexBase value (automatically generated) -4220 LET indexBase = 0 -4230 LET replies(5)(indexBase + 0) = "Do you really believe I don't*?" -4240 LET replies(5)(indexBase + 1) = "Perhaps in good time I will*." -4250 LET replies(5)(indexBase + 2) = "Do you want me to*?" -4260 REM TODO: Check indexBase value (automatically generated) -4270 LET indexBase = 0 -4280 LET replies(6)(indexBase + 0) = "Do you think you should be able to*?" -4290 LET replies(6)(indexBase + 1) = "Why can't you*?" -4300 REM TODO: Check indexBase value (automatically generated) -4310 LET indexBase = 0 -4320 LET replies(7)(indexBase + 0) = "Why are you interested in whether or not I am*?" -4330 LET replies(7)(indexBase + 1) = "Would you prefer if I were not*?" -4340 LET replies(7)(indexBase + 2) = "Perhaps in your fantasies I am*?" -4350 REM TODO: Check indexBase value (automatically generated) -4360 LET indexBase = 0 -4370 LET replies(8)(indexBase + 0) = "How do you know you can't*?" -4380 LET replies(8)(indexBase + 1) = "Have you tried?" -4390 LET replies(8)(indexBase + 2) = "Perhaps you can now*." -4400 REM TODO: Check indexBase value (automatically generated) -4410 LET indexBase = 0 -4420 LET replies(9)(indexBase + 0) = "Did you come to me because you are*?" -4430 LET replies(9)(indexBase + 1) = "How long have you been*?" -4440 LET replies(9)(indexBase + 2) = "Do you believe it is normal to be*?" -4450 LET replies(9)(indexBase + 3) = "Do you enjoy being*?" -4460 REM TODO: Check indexBase value (automatically generated) -4470 LET indexBase = 0 -4480 LET replies(10)(indexBase + 0) = "We were discussing you--not me." -4490 LET replies(10)(indexBase + 1) = "Oh, I*." -4500 LET replies(10)(indexBase + 2) = "You're not really talking about me, are you?" -4510 REM TODO: Check indexBase value (automatically generated) -4520 LET indexBase = 0 -4530 LET replies(11)(indexBase + 0) = "What would it mean to you if you got*?" -4540 LET replies(11)(indexBase + 1) = "Why do you want*?" -4550 LET replies(11)(indexBase + 2) = "Suppose you soon got*..." -4560 LET replies(11)(indexBase + 3) = "What if you never got*?" -4570 LET replies(11)(indexBase + 4) = "I sometimes also want*." -4580 REM TODO: Check indexBase value (automatically generated) -4590 LET indexBase = 0 -4600 LET replies(12)(indexBase + 0) = "Why do you ask?" -4610 LET replies(12)(indexBase + 1) = "Does that question interest you?" -4620 LET replies(12)(indexBase + 2) = "What answer would please you the most?" -4630 LET replies(12)(indexBase + 3) = "What do you think?" -4640 LET replies(12)(indexBase + 4) = "Are such questions on your mind often?" -4650 LET replies(12)(indexBase + 5) = "What is it that you really want to know?" -4660 LET replies(12)(indexBase + 6) = "Have you asked anyone else?" -4670 LET replies(12)(indexBase + 7) = "Have you asked such questions before?" -4680 LET replies(12)(indexBase + 8) = "What else comes to mind when you ask that?" -4690 REM TODO: Check indexBase value (automatically generated) -4700 LET indexBase = 0 -4710 LET replies(13)(indexBase + 0) = "Names don't interest me." -4720 LET replies(13)(indexBase + 1) = "I don't care about names -- please go on." -4730 REM TODO: Check indexBase value (automatically generated) -4740 LET indexBase = 0 -4750 LET replies(14)(indexBase + 0) = "Is that the real reason?" -4760 LET replies(14)(indexBase + 1) = "Don't any other reasons come to mind?" -4770 LET replies(14)(indexBase + 2) = "Does that reason explain anything else?" -4780 LET replies(14)(indexBase + 3) = "What other reasons might there be?" -4790 REM TODO: Check indexBase value (automatically generated) -4800 LET indexBase = 0 -4810 LET replies(15)(indexBase + 0) = "Please don't apologize!" -4820 LET replies(15)(indexBase + 1) = "Apologies are not necessary." -4830 LET replies(15)(indexBase + 2) = "What feelings do you have when you apologize?" -4840 LET replies(15)(indexBase + 3) = "Don't be so defensive!" -4850 REM TODO: Check indexBase value (automatically generated) -4860 LET indexBase = 0 -4870 LET replies(16)(indexBase + 0) = "What does that dream suggest to you?" -4880 LET replies(16)(indexBase + 1) = "Do you dream often?" -4890 LET replies(16)(indexBase + 2) = "What persons appear in your dreams?" -4900 LET replies(16)(indexBase + 3) = "Are you disturbed by your dreams?" -4910 REM TODO: Check indexBase value (automatically generated) -4920 LET indexBase = 0 -4930 LET replies(17)(indexBase + 0) = "How do you do ...please state your problem." -4940 REM TODO: Check indexBase value (automatically generated) -4950 LET indexBase = 0 -4960 LET replies(18)(indexBase + 0) = "You don't seem quite certain." -4970 LET replies(18)(indexBase + 1) = "Why the uncertain tone?" -4980 LET replies(18)(indexBase + 2) = "Can't you be more positive?" -4990 LET replies(18)(indexBase + 3) = "You aren't sure?" -5000 LET replies(18)(indexBase + 4) = "Don't you know?" -5010 REM TODO: Check indexBase value (automatically generated) -5020 LET indexBase = 0 -5030 LET replies(19)(indexBase + 0) = "Are you saying no just to be negative?" -5040 LET replies(19)(indexBase + 1) = "You are being a bit negative." -5050 LET replies(19)(indexBase + 2) = "Why not?" -5060 LET replies(19)(indexBase + 3) = "Are you sure?" -5070 LET replies(19)(indexBase + 4) = "Why no?" -5080 REM TODO: Check indexBase value (automatically generated) -5090 LET indexBase = 0 -5100 LET replies(20)(indexBase + 0) = "Why are you concerned about my*?" -5110 LET replies(20)(indexBase + 1) = "What about your own*?" -5120 REM TODO: Check indexBase value (automatically generated) -5130 LET indexBase = 0 -5140 LET replies(21)(indexBase + 0) = "Can you think of a specific example?" -5150 LET replies(21)(indexBase + 1) = "When?" -5160 LET replies(21)(indexBase + 2) = "What are you thinking of?" -5170 LET replies(21)(indexBase + 3) = "Really, always?" -5180 REM TODO: Check indexBase value (automatically generated) -5190 LET indexBase = 0 -5200 LET replies(22)(indexBase + 0) = "Do you really think so?" -5210 LET replies(22)(indexBase + 1) = "But you are not sure you*?" -5220 LET replies(22)(indexBase + 2) = "Do you doubt you*?" -5230 REM TODO: Check indexBase value (automatically generated) -5240 LET indexBase = 0 -5250 LET replies(23)(indexBase + 0) = "In what way?" -5260 LET replies(23)(indexBase + 1) = "What resemblance do you see?" -5270 LET replies(23)(indexBase + 2) = "What does the similarity suggest to you?" -5280 LET replies(23)(indexBase + 3) = "What other connections do you see?" -5290 LET replies(23)(indexBase + 4) = "Could there really be some connection?" -5300 LET replies(23)(indexBase + 5) = "How?" -5310 LET replies(23)(indexBase + 6) = "You seem quite positive." -5320 REM TODO: Check indexBase value (automatically generated) -5330 LET indexBase = 0 -5340 LET replies(24)(indexBase + 0) = "Are you sure?" -5350 LET replies(24)(indexBase + 1) = "I see." -5360 LET replies(24)(indexBase + 2) = "I understand." -5370 REM TODO: Check indexBase value (automatically generated) -5380 LET indexBase = 0 -5390 LET replies(25)(indexBase + 0) = "Why do you bring up the topic of friends?" -5400 LET replies(25)(indexBase + 1) = "Do your friends worry you?" -5410 LET replies(25)(indexBase + 2) = "Do your friends pick on you?" -5420 LET replies(25)(indexBase + 3) = "Are you sure you have any friends?" -5430 LET replies(25)(indexBase + 4) = "Do you impose on your friends?" -5440 LET replies(25)(indexBase + 5) = "Perhaps your love for friends worries you." -5450 REM TODO: Check indexBase value (automatically generated) -5460 LET indexBase = 0 -5470 LET replies(26)(indexBase + 0) = "Do computers worry you?" -5480 LET replies(26)(indexBase + 1) = "Are you talking about me in particular?" -5490 LET replies(26)(indexBase + 2) = "Are you frightened by machines?" -5500 LET replies(26)(indexBase + 3) = "Why do you mention computers?" -5510 LET replies(26)(indexBase + 4) = "What do you think machines have to do with your problem?" -5520 LET replies(26)(indexBase + 5) = "Don't you think computers can help people?" -5530 LET replies(26)(indexBase + 6) = "What is it about machines that worries you?" -5540 REM TODO: Check indexBase value (automatically generated) -5550 LET indexBase = 0 -5560 LET replies(27)(indexBase + 0) = "Do you sometimes feel uneasy without a smartphone?" -5570 LET replies(27)(indexBase + 1) = "Have you had these phantasies before?" -5580 LET replies(27)(indexBase + 2) = "Does the world seem more real for you via apps?" -5590 REM TODO: Check indexBase value (automatically generated) -5600 LET indexBase = 0 -5610 LET replies(28)(indexBase + 0) = "Tell me more about your family." -5620 LET replies(28)(indexBase + 1) = "Who else in your family*?" -5630 LET replies(28)(indexBase + 2) = "What does family relations mean for you?" -5640 LET replies(28)(indexBase + 3) = "Come on, How old are you?" -5650 LET setupReplies = replies -5660 RETURN setupReplies -5670 END FUNCTION +3830 REM We start with the highest index for performance reasons +3840 REM (is to avoid frequent array resizing) +3850 REM TODO: Check indexBase value (automatically generated) +3860 LET indexBase = 0 +3870 LET replies(29)(indexBase + 0) = "Say, do you have any psychological problems?" +3880 LET replies(29)(indexBase + 1) = "What does that suggest to you?" +3890 LET replies(29)(indexBase + 2) = "I see." +3900 LET replies(29)(indexBase + 3) = "I'm not sure I understand you fully." +3910 LET replies(29)(indexBase + 4) = "Come come elucidate your thoughts." +3920 LET replies(29)(indexBase + 5) = "Can you elaborate on that?" +3930 LET replies(29)(indexBase + 6) = "That is quite interesting." +3940 REM TODO: Check indexBase value (automatically generated) +3950 LET indexBase = 0 +3960 LET replies(0)(indexBase + 0) = "Don't you believe that I can*?" +3970 LET replies(0)(indexBase + 1) = "Perhaps you would like to be like me?" +3980 LET replies(0)(indexBase + 2) = "You want me to be able to*?" +3990 REM TODO: Check indexBase value (automatically generated) +4000 LET indexBase = 0 +4010 LET replies(1)(indexBase + 0) = "Perhaps you don't want to*?" +4020 LET replies(1)(indexBase + 1) = "Do you want to be able to*?" +4030 REM TODO: Check indexBase value (automatically generated) +4040 LET indexBase = 0 +4050 LET replies(2)(indexBase + 0) = "What makes you think I am*?" +4060 LET replies(2)(indexBase + 1) = "Does it please you to believe I am*?" +4070 LET replies(2)(indexBase + 2) = "Perhaps you would like to be*?" +4080 LET replies(2)(indexBase + 3) = "Do you sometimes wish you were*?" +4090 REM TODO: Check indexBase value (automatically generated) +4100 LET indexBase = 0 +4110 LET replies(3)(indexBase + 0) = "Don't you really*?" +4120 LET replies(3)(indexBase + 1) = "Why don't you*?" +4130 LET replies(3)(indexBase + 2) = "Do you wish to be able to*?" +4140 LET replies(3)(indexBase + 3) = "Does that trouble you*?" +4150 REM TODO: Check indexBase value (automatically generated) +4160 LET indexBase = 0 +4170 LET replies(4)(indexBase + 0) = "Do you often feel*?" +4180 LET replies(4)(indexBase + 1) = "Are you afraid of feeling*?" +4190 LET replies(4)(indexBase + 2) = "Do you enjoy feeling*?" +4200 REM TODO: Check indexBase value (automatically generated) +4210 LET indexBase = 0 +4220 LET replies(5)(indexBase + 0) = "Do you really believe I don't*?" +4230 LET replies(5)(indexBase + 1) = "Perhaps in good time I will*." +4240 LET replies(5)(indexBase + 2) = "Do you want me to*?" +4250 REM TODO: Check indexBase value (automatically generated) +4260 LET indexBase = 0 +4270 LET replies(6)(indexBase + 0) = "Do you think you should be able to*?" +4280 LET replies(6)(indexBase + 1) = "Why can't you*?" +4290 REM TODO: Check indexBase value (automatically generated) +4300 LET indexBase = 0 +4310 LET replies(7)(indexBase + 0) = "Why are you interested in whether or not I am*?" +4320 LET replies(7)(indexBase + 1) = "Would you prefer if I were not*?" +4330 LET replies(7)(indexBase + 2) = "Perhaps in your fantasies I am*?" +4340 REM TODO: Check indexBase value (automatically generated) +4350 LET indexBase = 0 +4360 LET replies(8)(indexBase + 0) = "How do you know you can't*?" +4370 LET replies(8)(indexBase + 1) = "Have you tried?" +4380 LET replies(8)(indexBase + 2) = "Perhaps you can now*." +4390 REM TODO: Check indexBase value (automatically generated) +4400 LET indexBase = 0 +4410 LET replies(9)(indexBase + 0) = "Did you come to me because you are*?" +4420 LET replies(9)(indexBase + 1) = "How long have you been*?" +4430 LET replies(9)(indexBase + 2) = "Do you believe it is normal to be*?" +4440 LET replies(9)(indexBase + 3) = "Do you enjoy being*?" +4450 REM TODO: Check indexBase value (automatically generated) +4460 LET indexBase = 0 +4470 LET replies(10)(indexBase + 0) = "We were discussing you--not me." +4480 LET replies(10)(indexBase + 1) = "Oh, I*." +4490 LET replies(10)(indexBase + 2) = "You're not really talking about me, are you?" +4500 REM TODO: Check indexBase value (automatically generated) +4510 LET indexBase = 0 +4520 LET replies(11)(indexBase + 0) = "What would it mean to you if you got*?" +4530 LET replies(11)(indexBase + 1) = "Why do you want*?" +4540 LET replies(11)(indexBase + 2) = "Suppose you soon got*..." +4550 LET replies(11)(indexBase + 3) = "What if you never got*?" +4560 LET replies(11)(indexBase + 4) = "I sometimes also want*." +4570 REM TODO: Check indexBase value (automatically generated) +4580 LET indexBase = 0 +4590 LET replies(12)(indexBase + 0) = "Why do you ask?" +4600 LET replies(12)(indexBase + 1) = "Does that question interest you?" +4610 LET replies(12)(indexBase + 2) = "What answer would please you the most?" +4620 LET replies(12)(indexBase + 3) = "What do you think?" +4630 LET replies(12)(indexBase + 4) = "Are such questions on your mind often?" +4640 LET replies(12)(indexBase + 5) = "What is it that you really want to know?" +4650 LET replies(12)(indexBase + 6) = "Have you asked anyone else?" +4660 LET replies(12)(indexBase + 7) = "Have you asked such questions before?" +4670 LET replies(12)(indexBase + 8) = "What else comes to mind when you ask that?" +4680 REM TODO: Check indexBase value (automatically generated) +4690 LET indexBase = 0 +4700 LET replies(13)(indexBase + 0) = "Names don't interest me." +4710 LET replies(13)(indexBase + 1) = "I don't care about names -- please go on." +4720 REM TODO: Check indexBase value (automatically generated) +4730 LET indexBase = 0 +4740 LET replies(14)(indexBase + 0) = "Is that the real reason?" +4750 LET replies(14)(indexBase + 1) = "Don't any other reasons come to mind?" +4760 LET replies(14)(indexBase + 2) = "Does that reason explain anything else?" +4770 LET replies(14)(indexBase + 3) = "What other reasons might there be?" +4780 REM TODO: Check indexBase value (automatically generated) +4790 LET indexBase = 0 +4800 LET replies(15)(indexBase + 0) = "Please don't apologize!" +4810 LET replies(15)(indexBase + 1) = "Apologies are not necessary." +4820 LET replies(15)(indexBase + 2) = "What feelings do you have when you apologize?" +4830 LET replies(15)(indexBase + 3) = "Don't be so defensive!" +4840 REM TODO: Check indexBase value (automatically generated) +4850 LET indexBase = 0 +4860 LET replies(16)(indexBase + 0) = "What does that dream suggest to you?" +4870 LET replies(16)(indexBase + 1) = "Do you dream often?" +4880 LET replies(16)(indexBase + 2) = "What persons appear in your dreams?" +4890 LET replies(16)(indexBase + 3) = "Are you disturbed by your dreams?" +4900 REM TODO: Check indexBase value (automatically generated) +4910 LET indexBase = 0 +4920 LET replies(17)(indexBase + 0) = "How do you do ...please state your problem." +4930 REM TODO: Check indexBase value (automatically generated) +4940 LET indexBase = 0 +4950 LET replies(18)(indexBase + 0) = "You don't seem quite certain." +4960 LET replies(18)(indexBase + 1) = "Why the uncertain tone?" +4970 LET replies(18)(indexBase + 2) = "Can't you be more positive?" +4980 LET replies(18)(indexBase + 3) = "You aren't sure?" +4990 LET replies(18)(indexBase + 4) = "Don't you know?" +5000 REM TODO: Check indexBase value (automatically generated) +5010 LET indexBase = 0 +5020 LET replies(19)(indexBase + 0) = "Are you saying no just to be negative?" +5030 LET replies(19)(indexBase + 1) = "You are being a bit negative." +5040 LET replies(19)(indexBase + 2) = "Why not?" +5050 LET replies(19)(indexBase + 3) = "Are you sure?" +5060 LET replies(19)(indexBase + 4) = "Why no?" +5070 REM TODO: Check indexBase value (automatically generated) +5080 LET indexBase = 0 +5090 LET replies(20)(indexBase + 0) = "Why are you concerned about my*?" +5100 LET replies(20)(indexBase + 1) = "What about your own*?" +5110 REM TODO: Check indexBase value (automatically generated) +5120 LET indexBase = 0 +5130 LET replies(21)(indexBase + 0) = "Can you think of a specific example?" +5140 LET replies(21)(indexBase + 1) = "When?" +5150 LET replies(21)(indexBase + 2) = "What are you thinking of?" +5160 LET replies(21)(indexBase + 3) = "Really, always?" +5170 REM TODO: Check indexBase value (automatically generated) +5180 LET indexBase = 0 +5190 LET replies(22)(indexBase + 0) = "Do you really think so?" +5200 LET replies(22)(indexBase + 1) = "But you are not sure you*?" +5210 LET replies(22)(indexBase + 2) = "Do you doubt you*?" +5220 REM TODO: Check indexBase value (automatically generated) +5230 LET indexBase = 0 +5240 LET replies(23)(indexBase + 0) = "In what way?" +5250 LET replies(23)(indexBase + 1) = "What resemblance do you see?" +5260 LET replies(23)(indexBase + 2) = "What does the similarity suggest to you?" +5270 LET replies(23)(indexBase + 3) = "What other connections do you see?" +5280 LET replies(23)(indexBase + 4) = "Could there really be some connection?" +5290 LET replies(23)(indexBase + 5) = "How?" +5300 LET replies(23)(indexBase + 6) = "You seem quite positive." +5310 REM TODO: Check indexBase value (automatically generated) +5320 LET indexBase = 0 +5330 LET replies(24)(indexBase + 0) = "Are you sure?" +5340 LET replies(24)(indexBase + 1) = "I see." +5350 LET replies(24)(indexBase + 2) = "I understand." +5360 REM TODO: Check indexBase value (automatically generated) +5370 LET indexBase = 0 +5380 LET replies(25)(indexBase + 0) = "Why do you bring up the topic of friends?" +5390 LET replies(25)(indexBase + 1) = "Do your friends worry you?" +5400 LET replies(25)(indexBase + 2) = "Do your friends pick on you?" +5410 LET replies(25)(indexBase + 3) = "Are you sure you have any friends?" +5420 LET replies(25)(indexBase + 4) = "Do you impose on your friends?" +5430 LET replies(25)(indexBase + 5) = "Perhaps your love for friends worries you." +5440 REM TODO: Check indexBase value (automatically generated) +5450 LET indexBase = 0 +5460 LET replies(26)(indexBase + 0) = "Do computers worry you?" +5470 LET replies(26)(indexBase + 1) = "Are you talking about me in particular?" +5480 LET replies(26)(indexBase + 2) = "Are you frightened by machines?" +5490 LET replies(26)(indexBase + 3) = "Why do you mention computers?" +5500 LET replies(26)(indexBase + 4) = "What do you think machines have to do with your problem?" +5510 LET replies(26)(indexBase + 5) = "Don't you think computers can help people?" +5520 LET replies(26)(indexBase + 6) = "What is it about machines that worries you?" +5530 REM TODO: Check indexBase value (automatically generated) +5540 LET indexBase = 0 +5550 LET replies(27)(indexBase + 0) = "Do you sometimes feel uneasy without a smartphone?" +5560 LET replies(27)(indexBase + 1) = "Have you had these phantasies before?" +5570 LET replies(27)(indexBase + 2) = "Does the world seem more real for you via apps?" +5580 REM TODO: Check indexBase value (automatically generated) +5590 LET indexBase = 0 +5600 LET replies(28)(indexBase + 0) = "Tell me more about your family." +5610 LET replies(28)(indexBase + 1) = "Who else in your family*?" +5620 LET replies(28)(indexBase + 2) = "What does family relations mean for you?" +5630 LET replies(28)(indexBase + 3) = "Come on, How old are you?" +5640 LET setupReplies = replies +5650 RETURN setupReplies +5660 END FUNCTION diff --git a/samples/export/BASIC0/SORTING_TEST_MAIN.bas b/samples/export/BASIC0/SORTING_TEST_MAIN.bas index 41c142a6..743af4cb 100644 --- a/samples/export/BASIC0/SORTING_TEST_MAIN.bas +++ b/samples/export/BASIC0/SORTING_TEST_MAIN.bas @@ -2,7 +2,7 @@ 20 REM to allow performance comparison via execution counting ("Collect Runtime Data" should 30 REM sensibly be switched on). 40 REM Requested input data are: Number of elements (size) and filing mode. -50 REM Generated by Structorizer 3.30-11 +50 REM Generated by Structorizer 3.32-01 60 70 REM Copyright (C) 2019-10-02 Kay Gürtzig 80 REM License: GPLv3-link diff --git a/samples/export/BASIC0/TextDemo.bas b/samples/export/BASIC0/TextDemo.bas index 4382b585..59b95216 100644 --- a/samples/export/BASIC0/TextDemo.bas +++ b/samples/export/BASIC0/TextDemo.bas @@ -2,7 +2,7 @@ 20 REM Asks the user to enter a text, a wanted text height and colour, 30 REM and then draws this string onto the turtle screen. Places every 40 REM entered text to a new line. -50 REM Generated by Structorizer 3.30-13 +50 REM Generated by Structorizer 3.32-01 60 70 REM Copyright (C) 2019-10-10 Kay Gürtzig 80 REM License: GPLv3-link @@ -873,7 +873,7 @@ 8730 REM TODO: add the respective type suffixes to your variable names if required 8740 REM Octagon edge length 8750 LET b = h * 0.5 / (sqrt(2.0) + 1) -8760 REM Cathetus of the outer trinagle at the octagon corner +8760 REM Cathetus of the outer triangle at the octagon corner 8770 LET c = b / sqrt(2.0) 8780 REM 360°/8 8790 LET rotAngle = 45 diff --git a/samples/export/BASIC1/ComputeSum.bas b/samples/export/BASIC1/ComputeSum.bas index 0671a743..c6989f03 100644 --- a/samples/export/BASIC1/ComputeSum.bas +++ b/samples/export/BASIC1/ComputeSum.bas @@ -6,7 +6,7 @@ Rem #828) with FileAPI dependency. Rem The input check loop has been disabled (replaced by a simple unchecked input Rem instruction) in order to test the effect of indirect FileAPI dependency (only the Rem called subroutine directly requires FileAPI now). -Rem Generated by Structorizer 3.30-11 +Rem Generated by Structorizer 3.32-01 Rem Copyright (C) 2020-03-21 Kay Gürtzig Rem License: GPLv3-link @@ -40,8 +40,8 @@ Rem fileClose(fileNo) nValues = 0 Try nValues = readNumbers(file_name, values, 1000) - Catch ex4cd19982 As Exception - Dim failure As String = ex4cd19982.ToString() + Catch ex416be80b As Exception + Dim failure As String = ex416be80b.ToString() PRINT failure Stop End Try @@ -58,7 +58,7 @@ Rem Tries to read as many integer values as possible upto maxNumbers Rem from file fileName into the given array numbers. Rem Returns the number of the actually read numbers. May cause an exception. Rem TODO: Check (and specify if needed) the argument and result types! -Function readNumbers(fileName AS String, numbers AS array of integer, maxNumbers AS integer) As integer +Function readNumbers(fileName As String, numbers As integer(50), maxNumbers As integer) As integer Rem TODO: Check and accomplish your variable declarations here: Dim number As Integer Dim nNumbers As Integer @@ -75,8 +75,8 @@ Function readNumbers(fileName AS String, numbers AS array of integer, maxNumbers numbers(nNumbers) = number nNumbers = nNumbers + 1 Loop - Catch ex3fadfdca As Exception - Dim error As String = ex3fadfdca.ToString() + Catch ex75fbd788 As Exception + Dim error As String = ex75fbd788.ToString() Throw New Exception() Finally fileClose(fileNo) diff --git a/samples/export/BASIC1/DrawRandomHistogram.bas b/samples/export/BASIC1/DrawRandomHistogram.bas index f806b918..4fde906b 100644 --- a/samples/export/BASIC1/DrawRandomHistogram.bas +++ b/samples/export/BASIC1/DrawRandomHistogram.bas @@ -1,6 +1,6 @@ Rem Reads a random number file and draws a histogram accotrding to the Rem user specifications -Rem Generated by Structorizer 3.30-11 +Rem Generated by Structorizer 3.32-01 Rem Copyright (C) 2020-03-21 Kay Gürtzig Rem License: GPLv3-link @@ -22,7 +22,7 @@ Dim kMaxCount As Integer Dim k As Integer Dim i As Integer Dim file_name As ??? -Dim fileNo As ??? +Dim fileNo As Integer Dim count() As Integer Rem fileNo = -10 @@ -43,8 +43,8 @@ If fileNo > 0 Then nObtained = 0 Try nObtained = readNumbers(file_name, numberArray, 10000) - Catch exc8e7b4f7 As Exception - Dim failure As String = exc8e7b4f7.ToString() + Catch ex1679c3ee As Exception + Dim failure As String = ex1679c3ee.ToString() PRINT failure End Try If nObtained > 0 Then @@ -88,14 +88,14 @@ Rem Turtleizer must be activated and will scale the chart into a square of Rem 500 x 500 pixels Rem Note: The function is not robust against empty array or totally equal values. Rem TODO: Check (and specify if needed) the argument and result types! -Sub drawBarChart(values AS array of double, nValues) +Sub drawBarChart(values As double(50), nValues) Rem TODO: Check and accomplish your variable declarations here: Dim ySize As Integer Dim yScale As ??? Dim yAxis As ??? Dim xSize As Integer - Dim valMin As ??? - Dim valMax As ??? + Dim valMin As double + Dim valMax As double Dim stripeWidth As ??? Dim stripeHeight As ??? Dim kMin As Integer @@ -103,8 +103,8 @@ Sub drawBarChart(values AS array of double, nValues) Dim k As Integer Rem Rem Used range of the Turtleizer screen - const xSize = 500 - const ySize = 500 + Const xSize = 500 + Const ySize = 500 kMin = 0 kMax = 0 For k = 1 To nValues-1 @@ -167,7 +167,7 @@ Rem Tries to read as many integer values as possible upto maxNumbers Rem from file fileName into the given array numbers. Rem Returns the number of the actually read numbers. May cause an exception. Rem TODO: Check (and specify if needed) the argument and result types! -Function readNumbers(fileName AS String, numbers AS array of integer, maxNumbers AS integer) As integer +Function readNumbers(fileName As String, numbers As integer(50), maxNumbers As integer) As integer Rem TODO: Check and accomplish your variable declarations here: Dim number As Integer Dim nNumbers As Integer @@ -184,8 +184,8 @@ Function readNumbers(fileName AS String, numbers AS array of integer, maxNumbers numbers(nNumbers) = number nNumbers = nNumbers + 1 Loop - Catch ex3fadfdca As Exception - Dim error As String = ex3fadfdca.ToString() + Catch ex75fbd788 As Exception + Dim error As String = ex75fbd788.ToString() Throw New Exception() Finally fileClose(fileNo) diff --git a/samples/export/BASIC1/ELIZA_2.2.bas b/samples/export/BASIC1/ELIZA_2.2.bas index 63ec6836..d8767362 100644 --- a/samples/export/BASIC1/ELIZA_2.2.bas +++ b/samples/export/BASIC1/ELIZA_2.2.bas @@ -8,7 +8,7 @@ Rem 2017-03-29 More keywords and replies added Rem 2019-03-14 Replies and mapping reorganised for easier maintenance Rem 2019-03-15 key map joined from keyword array and index map Rem 2019-03-28 Keyword "bot" inserted (same reply ring as "computer") -Rem Generated by Structorizer 3.30-11 +Rem Generated by Structorizer 3.32-01 Rem Copyright (C) 2018-05-14 ??? Rem License: GPLv3-link @@ -21,20 +21,20 @@ Rem program ELIZA Rem TODO: Check and accomplish your variable declarations here: Dim varPart As String Dim userInput As String -Dim replyRing As ??? +Dim replyRing() As String Dim reply As String -Dim replies()() As String -Dim reflexions()() As String +Dim replies(,) As String +Dim reflexions(,) As String Dim posAster As Integer Dim offsets() As Integer Dim keyMap() As KeyMapEntry -Dim keyIndex As ??? +Dim keyIndex As Integer Dim isRepeated As boolean Dim isGone As boolean Dim history() As ??? Dim findInfo() As integer Dim entry As KeyMapEntry -Dim byePhrases()() As String +Dim byePhrases(,) As String Rem Rem Title information PRINT "************* ELIZA **************" @@ -51,10 +51,10 @@ PRINT "**********************************" Rem Stores the last five inputs of the user in a ring buffer, Rem the first element is the current insertion index Let history = Array(0, "", "", "", "", "") -const replies = setupReplies() -const reflexions = setupReflexions() -const byePhrases = setupGoodByePhrases() -const keyMap = setupKeywords() +Const replies = setupReplies() +Const reflexions = setupReflexions() +Const byePhrases = setupGoodByePhrases() +Const keyMap = setupKeywords() offsets(length(keyMap)-1) = 0 isGone = false Rem Starter @@ -102,7 +102,7 @@ End Rem Rem Cares for correct letter case among others Rem TODO: Check (and specify if needed) the argument and result types! -Function adjustSpelling(sentence AS String) As String +Function adjustSpelling(sentence As String) As String Rem TODO: Check and accomplish your variable declarations here: Dim word As String Dim start As String @@ -119,8 +119,8 @@ Function adjustSpelling(sentence AS String) As String delete(result, 1, position) insert(uppercase(start), result, 1) End If - Dim array74593207() As String = {" i ", " i\'"} - For Each word In array74593207 + Dim arrayf3864169() As String = {" i ", " i\'"} + For Each word In arrayf3864169 position = pos(word, result) Do While position > 0 delete(result, position+1, 1) @@ -136,7 +136,7 @@ Rem good-bye phrase inducing the end of the conversation Rem and if so writes a correspding good-bye message and Rem returns true, otherwise false Rem TODO: Check (and specify if needed) the argument and result types! -Function checkGoodBye(text AS String, phrases AS array of array[0..1] of string) As boolean +Function checkGoodBye(text As String, phrases As String(50,0 To 1)) As boolean Rem TODO: Check and accomplish your variable declarations here: Dim saidBye As boolean Dim pair() As String @@ -154,7 +154,7 @@ Rem Rem Checks whether newInput has occurred among the last Rem length(history) - 1 input strings and updates the history Rem TODO: Check (and specify if needed) the argument and result types! -Function checkRepetition(history AS array, newInput AS String) As boolean +Function checkRepetition(history As array, newInput As String) As boolean Rem TODO: Check and accomplish your variable declarations here: Dim i As Integer Dim hasOccurred As boolean @@ -175,7 +175,7 @@ Function checkRepetition(history AS array, newInput AS String) As boolean End Function Rem Rem TODO: Check (and specify if needed) the argument and result types! -Function conjugateStrings(sentence AS String, key AS String, keyPos AS integer, flexions AS array of array[0..1] of string) As String +Function conjugateStrings(sentence As String, key As String, keyPos As integer, flexions As String(50,0 To 1)) As String Rem TODO: Check and accomplish your variable declarations here: Dim right As String Dim result As String @@ -211,7 +211,7 @@ Rem Returns an array of Rem 0: the index of the first identified keyword (if any, otherwise -1), Rem 1: the position inside sentence (0 if not found) Rem TODO: Check (and specify if needed) the argument and result types! -Function findKeyword(keyMap AS const array of KeyMapEntry, sentence AS String) As array[0..1] of integer +Function findKeyword(Const keyMap As KeyMapEntry(50), sentence As String) As integer(0 To 1) Rem TODO: Check and accomplish your variable declarations here: Dim result() As Integer Dim position As Integer @@ -237,7 +237,7 @@ Rem Converts the sentence to lowercase, eliminates all Rem interpunction (i.e. ',', '.', ';'), and pads the Rem sentence among blanks Rem TODO: Check (and specify if needed) the argument and result types! -Function normalizeInput(sentence AS String) As String +Function normalizeInput(sentence As String) As String Rem TODO: Check and accomplish your variable declarations here: Dim symbol As char Dim result As String @@ -245,8 +245,8 @@ Function normalizeInput(sentence AS String) As String Rem sentence = lowercase(sentence) Rem TODO: Specify an appropriate element type for the array! - Dim arrayad60b0f8() As FIXME_ad60b0f8 = {'.', ',', ';', '!', '?'} - For Each symbol In arrayad60b0f8 + Dim arrayd975144d() As FIXME_d975144d = {'.', ',', ';', '!', '?'} + For Each symbol In arrayd975144d position = pos(symbol, sentence) Do While position > 0 sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence)) @@ -258,9 +258,9 @@ Function normalizeInput(sentence AS String) As String End Function Rem Rem TODO: Check (and specify if needed) the argument and result types! -Function setupGoodByePhrases() As array of array[0..1] of string +Function setupGoodByePhrases() As String(50,0 To 1) Rem TODO: Check and accomplish your variable declarations here: - Dim phrases()() As String + Dim phrases(,) As String Rem Let phrases(0) = Array(" shut", "Okay. If you feel that way I\'ll shut up. ... Your choice.") Let phrases(1) = Array("bye", "Well, let\'s end our talk for now. See you later. Bye.") @@ -271,7 +271,7 @@ Rem The lower the index the higher the rank of the keyword (search is sequential Rem The index of the first keyword found in a user sentence maps to a respective Rem reply ring as defined in `setupReplies()´. Rem TODO: Check (and specify if needed) the argument and result types! -Function setupKeywords() As array of KeyMapEntry +Function setupKeywords() As KeyMapEntry(50) Rem TODO: Check and accomplish your variable declarations here: Dim keywords() As KeyMapEntry Rem @@ -361,9 +361,9 @@ End Function Rem Rem Returns an array of pairs of mutualy substitutable Rem TODO: Check (and specify if needed) the argument and result types! -Function setupReflexions() As array of array[0..1] of string +Function setupReflexions() As String(50,0 To 1) Rem TODO: Check and accomplish your variable declarations here: - Dim reflexions()() As String + Dim reflexions(,) As String Rem Let reflexions(0) = Array(" are ", " am ") Let reflexions(1) = Array(" were ", " was ") @@ -382,12 +382,11 @@ Rem This routine sets up the reply rings addressed by the key words defined in Rem routine `setupKeywords()´ and mapped hitherto by the cross table defined Rem in `setupMapping()´ Rem TODO: Check (and specify if needed) the argument and result types! -Function setupReplies() As array of array of string +Function setupReplies() As String(50,50) Rem TODO: Check and accomplish your variable declarations here: - Dim setupReplies()() As String - Dim replies()() As String + Dim setupReplies(,) As String + Dim replies(,) As String Rem - var replies: array of array of String Rem We start with the highest index for performance reasons Rem (is to avoid frequent array resizing) Let replies(29) = Array( "Say, do you have any psychological problems?", "What does that suggest to you?", "I see.", "I'm not sure I understand you fully.", "Come come elucidate your thoughts.", "Can you elaborate on that?", "That is quite interesting.") diff --git a/samples/export/BASIC1/SORTING_TEST_MAIN.bas b/samples/export/BASIC1/SORTING_TEST_MAIN.bas index 3e77bbfe..12191a40 100644 --- a/samples/export/BASIC1/SORTING_TEST_MAIN.bas +++ b/samples/export/BASIC1/SORTING_TEST_MAIN.bas @@ -2,7 +2,7 @@ Rem Creates three equal arrays of numbers and has them sorted with different sor Rem to allow performance comparison via execution counting ("Collect Runtime Data" should Rem sensibly be switched on). Rem Requested input data are: Number of elements (size) and filing mode. -Rem Generated by Structorizer 3.30-11 +Rem Generated by Structorizer 3.32-01 Rem Copyright (C) 2019-10-02 Kay Gürtzig Rem License: GPLv3-link @@ -13,8 +13,8 @@ Rem http://www.gnu.de/documents/gpl.de.html Rem Rem program SORTING_TEST_MAIN Rem TODO: Check and accomplish your variable declarations here: -Dim values3() As ??? -Dim values2() As ??? +Dim values3() As Integer +Dim values2() As Integer Dim values1() As Integer Dim show As ??? Dim ok3 As bool @@ -99,7 +99,7 @@ Rem TODO: Check (and specify if needed) the argument and result types! Sub bubbleSort(values) Rem TODO: Check and accomplish your variable declarations here: Dim temp As ??? - Dim posSwapped As ??? + Dim posSwapped As Integer Dim i As Integer Dim ende As ??? Rem diff --git a/samples/export/BASIC1/TextDemo.bas b/samples/export/BASIC1/TextDemo.bas index 22354b83..1a031956 100644 --- a/samples/export/BASIC1/TextDemo.bas +++ b/samples/export/BASIC1/TextDemo.bas @@ -2,7 +2,7 @@ Rem Demo program for routine drawText() Rem Asks the user to enter a text, a wanted text height and colour, Rem and then draws this string onto the turtle screen. Places every Rem entered text to a new line. -Rem Generated by Structorizer 3.30-13 +Rem Generated by Structorizer 3.32-01 Rem Copyright (C) 2019-10-10 Kay Gürtzig Rem License: GPLv3-link @@ -564,7 +564,7 @@ Rem Rem Draws nEdges edges of a regular n-polygon with edge length a Rem counter-clockwise, if ctrclkws is true, or clockwise if ctrclkws is false. Rem TODO: Check (and specify if needed) the argument and result types! -Sub polygonPart(a AS double, n AS integer, ctrclkws AS boolean, nEdges AS integer, color AS Integer) +Sub polygonPart(a As double, n As integer, ctrclkws As boolean, nEdges As integer, color As Integer) Rem TODO: Check and accomplish your variable declarations here: Dim rotAngle As ??? Dim k As Integer @@ -990,7 +990,7 @@ Sub letterC(h, colorNo) Rem Rem Octagon edge length b = h * 0.5 / (sqrt(2.0) + 1) - Rem Cathetus of the outer trinagle at the octagon corner + Rem Cathetus of the outer triangle at the octagon corner c = b / sqrt(2.0) Rem 360°/8 rotAngle = 45 @@ -1447,7 +1447,7 @@ Rem the set of representable special characters is: decimal digits, Rem '.', ',', '!', '?', 'Ä', 'Ö', 'Ü'. Other characters will be shown as a small Rem centred square (dummy character). Rem TODO: Check (and specify if needed) the argument and result types! -Sub drawText(text AS String, h AS integer, c AS integer) +Sub drawText(text As String, h As integer, c As integer) Rem TODO: Check and accomplish your variable declarations here: Dim letter As String Dim k As Integer diff --git a/samples/export/C#/ComputeSum.cs b/samples/export/C#/ComputeSum.cs index f8c4f658..f83d4155 100644 --- a/samples/export/C#/ComputeSum.cs +++ b/samples/export/C#/ComputeSum.cs @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2020-03-21 Kay Gürtzig // License: GPLv3-link @@ -52,8 +52,8 @@ public static void Main(string[] args) { try { nValues = readNumbers(file_name, values, 1000); } - catch(Exception ex4cd19982) { - string failure = ex4cd19982.ToString() + catch(Exception ex416be80b) { + string failure = ex416be80b.ToString() Console.WriteLine(failure); if (System.Windows.Forms.Application.MessageLoop) { // WinForms app @@ -101,8 +101,8 @@ private static int readNumbers(string fileName, int[] numbers, int maxNumbers) { nNumbers = nNumbers + 1; } } - catch(Exception ex3fadfdca) { - string error = ex3fadfdca.ToString() + catch(Exception ex75fbd788) { + string error = ex75fbd788.ToString() throw; } finally { diff --git a/samples/export/C#/DrawRandomHistogram.cs b/samples/export/C#/DrawRandomHistogram.cs index de4ea69d..92ff145d 100644 --- a/samples/export/C#/DrawRandomHistogram.cs +++ b/samples/export/C#/DrawRandomHistogram.cs @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2020-03-21 Kay Gürtzig // License: GPLv3-link @@ -452,6 +452,7 @@ public static void Main(string[] args) { ??? nIntervals; int kMaxCount; ??? file_name; + int fileNo; int[] count; // TODO: You may have to modify input instructions, @@ -459,7 +460,7 @@ public static void Main(string[] args) { // Parse methods according to the variable type, e.g.: // i = int.Parse(Console.ReadLine()); - ??? fileNo = -10; + fileNo = -10; do { Console.Write("Name/path of the number file"); file_name = Console.ReadLine(); fileNo = StructorizerFileAPI.fileOpen(file_name); @@ -478,8 +479,8 @@ public static void Main(string[] args) { try { nObtained = readNumbers(file_name, numberArray, 10000); } - catch(Exception exc8e7b4f7) { - string failure = exc8e7b4f7.ToString() + catch(Exception ex1679c3ee) { + string failure = ex1679c3ee.ToString() Console.WriteLine(failure); } if (nObtained > 0) { @@ -530,6 +531,8 @@ public static void Main(string[] args) { /// TODO private static void drawBarChart(double[] values, ??? nValues) { // TODO: Check and accomplish variable declarations: + double valMin; + double valMax; int kMin; int kMax; @@ -548,8 +551,8 @@ private static void drawBarChart(double[] values, ??? nValues) { } } } - ??? valMin = values[kMin]; - ??? valMax = values[kMax]; + valMin = values[kMin]; + valMax = values[kMax]; ??? yScale = valMax * 1.0 / (ySize - 1); ??? yAxis = ySize - 1; if (valMin < 0) { @@ -627,8 +630,8 @@ private static int readNumbers(string fileName, int[] numbers, int maxNumbers) { nNumbers = nNumbers + 1; } } - catch(Exception ex3fadfdca) { - string error = ex3fadfdca.ToString() + catch(Exception ex75fbd788) { + string error = ex75fbd788.ToString() throw; } finally { diff --git a/samples/export/C#/ELIZA_2.2.cs b/samples/export/C#/ELIZA_2.2.cs index 7da486e7..2c2f918b 100644 --- a/samples/export/C#/ELIZA_2.2.cs +++ b/samples/export/C#/ELIZA_2.2.cs @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2018-05-14 ??? // License: GPLv3-link @@ -43,9 +43,12 @@ public static void Main(string[] args) { // Converts the input to lowercase, cuts out interpunctation // and pads the string string userInput; + string[] replyRing; string reply; int posAster; int[] offsets; + // Should never happen... + int keyIndex; bool isRepeated; bool isGone; // Stores the last five inputs of the user in a ring buffer, @@ -94,7 +97,7 @@ public static void Main(string[] args) { isRepeated = checkRepetition(history, userInput); if (! isRepeated) { findInfo = findKeyword(keyMap, userInput); - ??? keyIndex = findInfo[0]; + keyIndex = findInfo[0]; if (keyIndex < 0) { // Should never happen... keyIndex = length(keyMap)-1; @@ -105,7 +108,7 @@ public static void Main(string[] args) { if (length(entry.keyword) > 0) { varPart = conjugateStrings(userInput, entry.keyword, findInfo[1], reflexions); } - ??? replyRing = replies[entry.index]; + replyRing = replies[entry.index]; reply = replyRing[offsets[keyIndex]]; offsets[keyIndex] = (offsets[keyIndex] + 1) % length(replyRing); posAster = pos("*", reply); @@ -199,7 +202,7 @@ private static bool checkGoodBye(string text, string[,] phrases) { /// TODO /// TODO /// TODO - private static bool checkRepetition(array[] history, string newInput) { + private static bool checkRepetition(???[] history, string newInput) { // TODO: Check and accomplish variable declarations: bool hasOccurred; @@ -265,7 +268,7 @@ private static string conjugateStrings(string sentence, string key, int keyPos, /// TODO /// TODO /// TODO - private static int[] findKeyword(const array of KeyMapEntry keyMap, string sentence) { + private static int[] findKeyword(const KeyMapEntry[] keyMap, string sentence) { initialize_KeyMapEntry(); // TODO: Check and accomplish variable declarations: diff --git a/samples/export/C#/SORTING_TEST_MAIN.cs b/samples/export/C#/SORTING_TEST_MAIN.cs index e7a77928..7a8f9321 100644 --- a/samples/export/C#/SORTING_TEST_MAIN.cs +++ b/samples/export/C#/SORTING_TEST_MAIN.cs @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2019-10-02 Kay Gürtzig // License: GPLv3-link @@ -18,10 +18,10 @@ public class SORTING_TEST_MAIN { // =========== START PARALLEL WORKER DEFINITIONS ============ - class Workerce3f34d1_0{ + class Worker465fbb06_0{ // TODO: Check and accomplish the member declarations here private int[] values1; - public Workerce3f34d1_0(int[] values1) + public Worker465fbb06_0(int[] values1) { this.values1 = values1; } @@ -31,11 +31,11 @@ public void DoWork() } }; - class Workerce3f34d1_1{ + class Worker465fbb06_1{ // TODO: Check and accomplish the member declarations here - private ???[] values2; + private int[] values2; private ??? elementCount; - public Workerce3f34d1_1(???[] values2, ??? elementCount) + public Worker465fbb06_1(int[] values2, ??? elementCount) { this.values2 = values2; this.elementCount = elementCount; @@ -46,10 +46,10 @@ public void DoWork() } }; - class Workerce3f34d1_2{ + class Worker465fbb06_2{ // TODO: Check and accomplish the member declarations here - private ???[] values3; - public Workerce3f34d1_2(???[] values3) + private int[] values3; + public Worker465fbb06_2(int[] values3) { this.values3 = values3; } @@ -61,12 +61,12 @@ public void DoWork() // ============ END PARALLEL WORKER DEFINITIONS ============= // =========== START PARALLEL WORKER DEFINITIONS ============ - class Worker68b9aebd_0{ + class Worker98a2d384_0{ // TODO: Check and accomplish the member declarations here private ??? values; private ??? start; private ??? p; - public Worker68b9aebd_0(??? values, ??? start, ??? p) + public Worker98a2d384_0(??? values, ??? start, ??? p) { this.values = values; this.start = start; @@ -79,12 +79,12 @@ public void DoWork() } }; - class Worker68b9aebd_1{ + class Worker98a2d384_1{ // TODO: Check and accomplish the member declarations here private ??? values; private ??? p; private ??? stop; - public Worker68b9aebd_1(??? values, ??? p, ??? stop) + public Worker98a2d384_1(??? values, ??? p, ??? stop) { this.values = values; this.p = p; @@ -102,8 +102,8 @@ public void DoWork() public static void Main(string[] args) { // TODO: Check and accomplish variable declarations: - ???[] values3; - ???[] values2; + int[] values3; + int[] values2; int[] values1; ??? show; bool ok3; @@ -146,21 +146,21 @@ public static void Main(string[] args) { // ================= START PARALLEL SECTION ================= // ========================================================== { - Workerce3f34d1_0 workerce3f34d1_0 = new Workerce3f34d1_0(values1); - Thread thrce3f34d1_0 = new Thread(workerce3f34d1_0.DoWork); - thrce3f34d1_0.Start(); + Worker465fbb06_0 worker465fbb06_0 = new Worker465fbb06_0(values1); + Thread thr465fbb06_0 = new Thread(worker465fbb06_0.DoWork); + thr465fbb06_0.Start(); - Workerce3f34d1_1 workerce3f34d1_1 = new Workerce3f34d1_1(values2, elementCount); - Thread thrce3f34d1_1 = new Thread(workerce3f34d1_1.DoWork); - thrce3f34d1_1.Start(); + Worker465fbb06_1 worker465fbb06_1 = new Worker465fbb06_1(values2, elementCount); + Thread thr465fbb06_1 = new Thread(worker465fbb06_1.DoWork); + thr465fbb06_1.Start(); - Workerce3f34d1_2 workerce3f34d1_2 = new Workerce3f34d1_2(values3); - Thread thrce3f34d1_2 = new Thread(workerce3f34d1_2.DoWork); - thrce3f34d1_2.Start(); + Worker465fbb06_2 worker465fbb06_2 = new Worker465fbb06_2(values3); + Thread thr465fbb06_2 = new Thread(worker465fbb06_2.DoWork); + thr465fbb06_2.Start(); - thrce3f34d1_0.Join(); - thrce3f34d1_1.Join(); - thrce3f34d1_2.Join(); + thr465fbb06_0.Join(); + thr465fbb06_1.Join(); + thr465fbb06_2.Join(); } // ========================================================== // ================== END PARALLEL SECTION ================== @@ -197,11 +197,12 @@ public static void Main(string[] args) { /// TODO private static void bubbleSort(??? values) { // TODO: Check and accomplish variable declarations: + int posSwapped; ??? ende = length(values) - 2; do { // The index of the most recent swapping (-1 means no swapping done). - ??? posSwapped = -1; + posSwapped = -1; for (int i = 0; i <= ende; i += (1)) { if (values[i] > values[i+1]) { ??? temp = values[i]; @@ -371,16 +372,16 @@ private static void quickSort(??? values, ??? start, ??? stop) { // ================= START PARALLEL SECTION ================= // ========================================================== { - Worker68b9aebd_0 worker68b9aebd_0 = new Worker68b9aebd_0(values, start, p); - Thread thr68b9aebd_0 = new Thread(worker68b9aebd_0.DoWork); - thr68b9aebd_0.Start(); + Worker98a2d384_0 worker98a2d384_0 = new Worker98a2d384_0(values, start, p); + Thread thr98a2d384_0 = new Thread(worker98a2d384_0.DoWork); + thr98a2d384_0.Start(); - Worker68b9aebd_1 worker68b9aebd_1 = new Worker68b9aebd_1(values, p, stop); - Thread thr68b9aebd_1 = new Thread(worker68b9aebd_1.DoWork); - thr68b9aebd_1.Start(); + Worker98a2d384_1 worker98a2d384_1 = new Worker98a2d384_1(values, p, stop); + Thread thr98a2d384_1 = new Thread(worker98a2d384_1.DoWork); + thr98a2d384_1.Start(); - thr68b9aebd_0.Join(); - thr68b9aebd_1.Join(); + thr98a2d384_0.Join(); + thr98a2d384_1.Join(); } // ========================================================== // ================== END PARALLEL SECTION ================== diff --git a/samples/export/C#/TextDemo.cs b/samples/export/C#/TextDemo.cs index 98692899..5f8e8749 100644 --- a/samples/export/C#/TextDemo.cs +++ b/samples/export/C#/TextDemo.cs @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-13 +// Generated by Structorizer 3.32-01 // Copyright (C) 2019-10-10 Kay Gürtzig // License: GPLv3-link @@ -1076,7 +1076,7 @@ private static void letterC(??? h, ??? colorNo) { // Octagon edge length ??? b = h * 0.5 / (sqrt(2.0) + 1); - // Cathetus of the outer trinagle at the octagon corner + // Cathetus of the outer triangle at the octagon corner ??? c = b / sqrt(2.0); // 360°/8 rotAngle = 45; diff --git a/samples/export/C++/ComputeSum.cpp b/samples/export/C++/ComputeSum.cpp index 3c15c939..f9d463a6 100644 --- a/samples/export/C++/ComputeSum.cpp +++ b/samples/export/C++/ComputeSum.cpp @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2020-03-21 Kay Gürtzig // License: GPLv3-link diff --git a/samples/export/C++/DrawRandomHistogram.cpp b/samples/export/C++/DrawRandomHistogram.cpp index 3b52c574..09cd8476 100644 --- a/samples/export/C++/DrawRandomHistogram.cpp +++ b/samples/export/C++/DrawRandomHistogram.cpp @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2020-03-21 Kay Gürtzig // License: GPLv3-link @@ -24,6 +24,8 @@ using std::string; void drawBarChart(double values[50], ??? nValues) { // TODO: Check and accomplish variable declarations: + double valMin; + double valMax; int kMin; int kMax; @@ -42,8 +44,8 @@ void drawBarChart(double values[50], ??? nValues) } } } - ??? valMin = values[kMin]; - ??? valMax = values[kMax]; + valMin = values[kMin]; + valMax = values[kMax]; ??? yScale = valMax * 1.0 / (ySize - 1); ??? yAxis = ySize - 1; if (valMin < 0) { @@ -138,9 +140,10 @@ int main(void) ??? nIntervals; int kMaxCount; ??? file_name; + int fileNo; int count[50]; - ??? fileNo = -10; + fileNo = -10; do { std::cout << "Name/path of the number file"; std::cin >> file_name; fileNo = StructorizerFileAPI::fileOpen(file_name); diff --git a/samples/export/C++/ELIZA_2.2.cpp b/samples/export/C++/ELIZA_2.2.cpp index 290fc278..81e464d3 100644 --- a/samples/export/C++/ELIZA_2.2.cpp +++ b/samples/export/C++/ELIZA_2.2.cpp @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2018-05-14 ??? // License: GPLv3-link @@ -89,7 +89,7 @@ bool checkGoodBye(string text, string phrases[50][2]) // Checks whether newInput has occurred among the last // length(history) - 1 input strings and updates the history // TODO: Revise the return type and declare the parameters. -bool checkRepetition(array history[50], string newInput) +bool checkRepetition(??? history[50], string newInput) { // TODO: Check and accomplish variable declarations: bool hasOccurred; @@ -152,7 +152,7 @@ string conjugateStrings(string sentence, string key, int keyPos, string flexions // 1: the position inside sentence (0 if not found) // TODO: Revise the return type and declare the parameters. // C++ may not permit to return arrays like this - find an other way to pass the result! -int[2] findKeyword(const array of KeyMapEntry keyMap, string sentence) +int[2] findKeyword(const KeyMapEntry keyMap[50], string sentence) { // TODO: Check and accomplish variable declarations: int result[2]; @@ -506,9 +506,12 @@ int main(void) // Converts the input to lowercase, cuts out interpunctation // and pads the string string userInput; + string replyRing[50]; string reply; int posAster; int offsets[50]; + // Should never happen... + int keyIndex; bool isRepeated; bool isGone; // Stores the last five inputs of the user in a ring buffer, @@ -557,7 +560,7 @@ int main(void) isRepeated = checkRepetition(history, userInput); if (! isRepeated) { findInfo = findKeyword(keyMap, userInput); - ??? keyIndex = findInfo[0]; + keyIndex = findInfo[0]; if (keyIndex < 0) { // Should never happen... keyIndex = length(keyMap)-1; @@ -568,7 +571,7 @@ int main(void) if (length(entry.keyword) > 0) { varPart = conjugateStrings(userInput, entry.keyword, findInfo[1], reflexions); } - ??? replyRing = replies[entry.index]; + replyRing = replies[entry.index]; reply = replyRing[offsets[keyIndex]]; offsets[keyIndex] = (offsets[keyIndex] + 1) % length(replyRing); posAster = pos("*", reply); diff --git a/samples/export/C++/SORTING_TEST_MAIN.cpp b/samples/export/C++/SORTING_TEST_MAIN.cpp index 80e20266..682e6240 100644 --- a/samples/export/C++/SORTING_TEST_MAIN.cpp +++ b/samples/export/C++/SORTING_TEST_MAIN.cpp @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2019-10-02 Kay Gürtzig // License: GPLv3-link @@ -23,11 +23,12 @@ using std::string; void bubbleSort(??? values) { // TODO: Check and accomplish variable declarations: + int posSwapped; ??? ende = length(values) - 2; do { // The index of the most recent swapping (-1 means no swapping done). - ??? posSwapped = -1; + posSwapped = -1; for (int i = 0; i <= ende; i += (1)) { if (values[i] > values[i+1]) { ??? temp = values[i]; @@ -175,7 +176,7 @@ void buildMaxHeap(??? heap) // TODO: Revise the return type and declare the parameters. void quickSort(??? values, ??? start, ??? stop) { - class ThrFunc68b9aebd_0{ + class ThrFunc98a2d384_0{ public: void operator()(???& values, ???& start, ???& p) { // Sort left (lower) array part @@ -183,7 +184,7 @@ void quickSort(??? values, ??? start, ??? stop) } }; - class ThrFunc68b9aebd_1{ + class ThrFunc98a2d384_1{ public: void operator()(???& values, ???& p, ???& stop) { // Sort right (higher) array part @@ -207,14 +208,14 @@ void quickSort(??? values, ??? start, ??? stop) // Parallel section { - ThrFunc68b9aebd_0 thrfunc68b9aebd_0; - std::thread thr68b9aebd_0(thrfunc68b9aebd_0, values, start, p); + ThrFunc98a2d384_0 thrfunc98a2d384_0; + std::thread thr98a2d384_0(thrfunc98a2d384_0, values, start, p); - ThrFunc68b9aebd_1 thrfunc68b9aebd_1; - std::thread thr68b9aebd_1(thrfunc68b9aebd_1, values, p, stop); + ThrFunc98a2d384_1 thrfunc98a2d384_1; + std::thread thr98a2d384_1(thrfunc98a2d384_1, values, p, stop); - thr68b9aebd_0.join(); - thr68b9aebd_1.join(); + thr98a2d384_0.join(); + thr98a2d384_1.join(); } } @@ -249,30 +250,30 @@ void heapSort(??? values) // Requested input data are: Number of elements (size) and filing mode. int main(void) { - class ThrFuncce3f34d1_0{ + class ThrFunc465fbb06_0{ public: void operator()(int values1[50]) { bubbleSort(values1); } }; - class ThrFuncce3f34d1_1{ + class ThrFunc465fbb06_1{ public: - void operator()(??? values2[50], ???& elementCount) { + void operator()(int values2[50], ???& elementCount) { quickSort(values2, 0, elementCount); } }; - class ThrFuncce3f34d1_2{ + class ThrFunc465fbb06_2{ public: - void operator()(??? values3[50]) { + void operator()(int values3[50]) { heapSort(values3); } }; // TODO: Check and accomplish variable declarations: - ??? values3[50]; - ??? values2[50]; + int values3[50]; + int values2[50]; int values1[50]; ??? show; bool ok3; @@ -308,18 +309,18 @@ int main(void) // Parallel section { - ThrFuncce3f34d1_0 thrfuncce3f34d1_0; - std::thread thrce3f34d1_0(thrfuncce3f34d1_0, values1); + ThrFunc465fbb06_0 thrfunc465fbb06_0; + std::thread thr465fbb06_0(thrfunc465fbb06_0, values1); - ThrFuncce3f34d1_1 thrfuncce3f34d1_1; - std::thread thrce3f34d1_1(thrfuncce3f34d1_1, values2, elementCount); + ThrFunc465fbb06_1 thrfunc465fbb06_1; + std::thread thr465fbb06_1(thrfunc465fbb06_1, values2, elementCount); - ThrFuncce3f34d1_2 thrfuncce3f34d1_2; - std::thread thrce3f34d1_2(thrfuncce3f34d1_2, values3); + ThrFunc465fbb06_2 thrfunc465fbb06_2; + std::thread thr465fbb06_2(thrfunc465fbb06_2, values3); - thrce3f34d1_0.join(); - thrce3f34d1_1.join(); - thrce3f34d1_2.join(); + thr465fbb06_0.join(); + thr465fbb06_1.join(); + thr465fbb06_2.join(); } ok1 = testSorted(values1); diff --git a/samples/export/C++/TextDemo.cpp b/samples/export/C++/TextDemo.cpp index 635b2277..a6e84de6 100644 --- a/samples/export/C++/TextDemo.cpp +++ b/samples/export/C++/TextDemo.cpp @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-13 +// Generated by Structorizer 3.32-01 // Copyright (C) 2019-10-10 Kay Gürtzig // License: GPLv3-link @@ -1029,7 +1029,7 @@ void letterC(??? h, ??? colorNo) // Octagon edge length ??? b = h * 0.5 / (sqrt(2.0) + 1); - // Cathetus of the outer trinagle at the octagon corner + // Cathetus of the outer triangle at the octagon corner ??? c = b / sqrt(2.0); // 360°/8 rotAngle = 45; diff --git a/samples/export/C/ComputeSum.c b/samples/export/C/ComputeSum.c index 44467312..2e504066 100644 --- a/samples/export/C/ComputeSum.c +++ b/samples/export/C/ComputeSum.c @@ -1,5 +1,5 @@ // program ComputeSum -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2020-03-21 Kay Gürtzig // License: GPLv3-link diff --git a/samples/export/C/DrawRandomHistogram.c b/samples/export/C/DrawRandomHistogram.c index 944cd51b..74e0ba3c 100644 --- a/samples/export/C/DrawRandomHistogram.c +++ b/samples/export/C/DrawRandomHistogram.c @@ -1,5 +1,5 @@ // program DrawRandomHistogram -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2020-03-21 Kay Gürtzig // License: GPLv3-link @@ -501,8 +501,8 @@ void drawBarChart(double values[50], ??? nValues) const int ySize = 500; ??? yScale; ??? yAxis; - ??? valMin; - ??? valMax; + double valMin; + double valMax; ??? stripeWidth; ??? stripeHeight; int kMin; @@ -627,7 +627,7 @@ int main(void) int k; int i; ??? file_name; - ??? fileNo; + int fileNo; int count[50]; // TODO: diff --git a/samples/export/C/ELIZA_2.2.c b/samples/export/C/ELIZA_2.2.c index fe23ccb2..d9ee9257 100644 --- a/samples/export/C/ELIZA_2.2.c +++ b/samples/export/C/ELIZA_2.2.c @@ -1,5 +1,5 @@ // program ELIZA -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2018-05-14 ??? // License: GPLv3-link @@ -11,9 +11,6 @@ #include #include -#include -#include "example.h" - struct KeyMapEntry { char* keyword; int index; @@ -54,10 +51,10 @@ char* adjustSpelling(char* sentence) insert(uppercase(start), result, 1); } { - char* array74593207[2] = {" i ", " i\'"}; - int index74593207; - for (index74593207 = 0; index74593207 < 2; index74593207++) { - char* word = array74593207[index74593207]; + char* arrayf3864169[2] = {" i ", " i\'"}; + int indexf3864169; + for (indexf3864169 = 0; indexf3864169 < 2; indexf3864169++) { + char* word = arrayf3864169[indexf3864169]; position = pos(word, result); while (position > 0) { delete(result, position+1, 1); @@ -89,10 +86,10 @@ bool checkGoodBye(char* text, char* phrases[50][2]) { // TODO: Find out and fill in the number of elements of the array phrases here! - int countfe0883ee = ???; - int indexfe0883ee; - for (indexfe0883ee = 0; indexfe0883ee < countfe0883ee; indexfe0883ee++) { - char* pair[] = phrases[indexfe0883ee]; + int count42e6601e = ???; + int index42e6601e; + for (index42e6601e = 0; index42e6601e < count42e6601e; index42e6601e++) { + char* pair[] = phrases[index42e6601e]; if (pos(pair[0], text) > 0) { saidBye = true; // TODO: check format specifiers, replace all '?'! @@ -109,7 +106,7 @@ bool checkGoodBye(char* text, char* phrases[50][2]) // Checks whether newInput has occurred among the last // length(history) - 1 input strings and updates the history // TODO: Revise the return type and declare the parameters. -bool checkRepetition(array history[50], char* newInput) +bool checkRepetition(??? history[50], char* newInput) { // TODO: Check and accomplish variable declarations: int i; @@ -145,10 +142,10 @@ char* conjugateStrings(char* sentence, char* key, int keyPos, char* flexions[50] result = " " + copy(sentence, keyPos + length(key), length(sentence)) + " "; { // TODO: Find out and fill in the number of elements of the array flexions here! - int count1e5e571 = ???; - int index1e5e571; - for (index1e5e571 = 0; index1e5e571 < count1e5e571; index1e5e571++) { - char* pair[] = flexions[index1e5e571]; + int count80a88ce1 = ???; + int index80a88ce1; + for (index80a88ce1 = 0; index80a88ce1 < count80a88ce1; index80a88ce1++) { + char* pair[] = flexions[index80a88ce1]; left = ""; right = result; position = pos(pair[0], right); @@ -180,10 +177,9 @@ char* conjugateStrings(char* sentence, char* key, int keyPos, char* flexions[50] // 1: the position inside sentence (0 if not found) // TODO: Revise the return type and declare the parameters. // C does not permit to return arrays - find an other way to pass the result! -int[2] findKeyword(const array of KeyMapEntry keyMap, char* sentence) +int[2] findKeyword(const KeyMapEntry keyMap[50], char* sentence) { // TODO: Check and accomplish variable declarations: - const array of KeyMapEntry keyMap; int result[2]; int position; int i; @@ -222,10 +218,10 @@ char* normalizeInput(char* sentence) sentence = lowercase(sentence); { - char arrayad60b0f8[5] = {'.', ',', ';', '!', '?'}; - int indexad60b0f8; - for (indexad60b0f8 = 0; indexad60b0f8 < 5; indexad60b0f8++) { - char symbol = arrayad60b0f8[indexad60b0f8]; + char arrayd975144d[5] = {'.', ',', ';', '!', '?'}; + int indexd975144d; + for (indexd975144d = 0; indexd975144d < 5; indexd975144d++) { + char symbol = arrayd975144d[indexd975144d]; position = pos(symbol, sentence); while (position > 0) { sentence = copy(sentence, 1, position-1) + copy(sentence, position+1, length(sentence)); @@ -545,11 +541,12 @@ int main(void) // Converts the input to lowercase, cuts out interpunctation // and pads the string char* userInput; - ??? replyRing; + char* replyRing[50]; char* reply; int posAster; int offsets[50]; - ??? keyIndex; + // Should never happen... + int keyIndex; bool isRepeated; bool isGone; // Stores the last five inputs of the user in a ring buffer, diff --git a/samples/export/C/SORTING_TEST_MAIN.c b/samples/export/C/SORTING_TEST_MAIN.c index db94c5a0..6b069562 100644 --- a/samples/export/C/SORTING_TEST_MAIN.c +++ b/samples/export/C/SORTING_TEST_MAIN.c @@ -1,5 +1,5 @@ // program SORTING_TEST_MAIN -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2019-10-02 Kay Gürtzig // License: GPLv3-link @@ -24,7 +24,7 @@ void bubbleSort(??? values) { // TODO: Check and accomplish variable declarations: ??? temp; - ??? posSwapped; + int posSwapped; int i; ??? ende; @@ -262,8 +262,8 @@ void heapSort(??? values) int main(void) { // TODO: Check and accomplish variable declarations: - ??? values3[50]; - ??? values2[50]; + int values3[50]; + int values2[50]; int values1[50]; ??? show; bool ok3; diff --git a/samples/export/C/TextDemo.c b/samples/export/C/TextDemo.c index 3de7a781..d4fdc592 100644 --- a/samples/export/C/TextDemo.c +++ b/samples/export/C/TextDemo.c @@ -1,5 +1,5 @@ // program TextDemo -// Generated by Structorizer 3.30-13 +// Generated by Structorizer 3.32-01 // Copyright (C) 2019-10-10 Kay Gürtzig // License: GPLv3-link @@ -1086,7 +1086,7 @@ void letterC(??? h, ??? colorNo) // Octagon edge length b = h * 0.5 / (sqrt(2.0) + 1); - // Cathetus of the outer trinagle at the octagon corner + // Cathetus of the outer triangle at the octagon corner c = b / sqrt(2.0); // 360°/8 rotAngle = 45; diff --git a/samples/export/Java/ComputeSum.java b/samples/export/Java/ComputeSum.java index cb660f27..6923ef98 100644 --- a/samples/export/Java/ComputeSum.java +++ b/samples/export/Java/ComputeSum.java @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2020-03-21 Kay Gürtzig // License: GPLv3-link @@ -53,8 +53,8 @@ public static void main(String[] args) { try { nValues = readNumbers(file_name, values, 1000); } - catch (Exception ex4cd19982) { - String failure = ex4cd19982.getMessage() + catch (Exception ex416be80b) { + String failure = ex416be80b.getMessage() System.out.println(failure); System.exit(-7) } @@ -94,9 +94,9 @@ private static int readNumbers(String fileName, int[] numbers, int maxNumbers) { nNumbers = nNumbers + 1; } } - catch (Exception ex3fadfdca) { - String error = ex3fadfdca.getMessage() - throw ex3fadfdca; + catch (Exception ex75fbd788) { + String error = ex75fbd788.getMessage() + throw ex75fbd788; } finally { fileClose(fileNo); diff --git a/samples/export/Java/DrawRandomHistogram.java b/samples/export/Java/DrawRandomHistogram.java index 6fb59e75..5c78b689 100644 --- a/samples/export/Java/DrawRandomHistogram.java +++ b/samples/export/Java/DrawRandomHistogram.java @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2020-03-21 Kay Gürtzig // License: GPLv3-link @@ -25,13 +25,14 @@ public static void main(String[] args) { ??? nIntervals; int kMaxCount; ??? file_name; + int fileNo; int[] count; // TODO: You may have to modify input instructions, // e.g. by replacing nextLine() with a more suitable call // according to the variable type, say nextInt(). - ??? fileNo = -10; + fileNo = -10; do { System.out.print("Name/path of the number file"); file_name = (new Scanner(System.in)).nextLine(); fileNo = fileOpen(file_name); @@ -50,8 +51,8 @@ public static void main(String[] args) { try { nObtained = readNumbers(file_name, numberArray, 10000); } - catch (Exception exc8e7b4f7) { - String failure = exc8e7b4f7.getMessage() + catch (Exception ex1679c3ee) { + String failure = ex1679c3ee.getMessage() System.out.println(failure); } if (nObtained > 0) { @@ -449,6 +450,8 @@ public static void fileWriteLine(int fileNo, java.lang.Object data) throws java. */ private static void drawBarChart(double[] values, ??? nValues) { // TODO: Check and accomplish variable declarations: + double valMin; + double valMax; int kMin; int kMax; @@ -467,8 +470,8 @@ private static void drawBarChart(double[] values, ??? nValues) { } } } - ??? valMin = values[kMin]; - ??? valMax = values[kMax]; + valMin = values[kMin]; + valMax = values[kMax]; ??? yScale = valMax * 1.0 / (ySize - 1); ??? yAxis = ySize - 1; if (valMin < 0) { @@ -545,9 +548,9 @@ private static int readNumbers(String fileName, int[] numbers, int maxNumbers) { nNumbers = nNumbers + 1; } } - catch (Exception ex3fadfdca) { - String error = ex3fadfdca.getMessage() - throw ex3fadfdca; + catch (Exception ex75fbd788) { + String error = ex75fbd788.getMessage() + throw ex75fbd788; } finally { fileClose(fileNo); diff --git a/samples/export/Java/ELIZA_2.2.java b/samples/export/Java/ELIZA_2.2.java index 784a186b..4d7d2df2 100644 --- a/samples/export/Java/ELIZA_2.2.java +++ b/samples/export/Java/ELIZA_2.2.java @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2018-05-14 ??? // License: GPLv3-link @@ -44,9 +44,12 @@ public static void main(String[] args) { // Converts the input to lowercase, cuts out interpunctation // and pads the string String userInput; + String[] replyRing; String reply; int posAster; int[] offsets; + // Should never happen... + int keyIndex; boolean isRepeated; boolean isGone; // Stores the last five inputs of the user in a ring buffer, @@ -94,7 +97,7 @@ public static void main(String[] args) { isRepeated = checkRepetition(history, userInput); if (! isRepeated) { findInfo = findKeyword(keyMap, userInput); - ??? keyIndex = findInfo[0]; + keyIndex = findInfo[0]; if (keyIndex < 0) { // Should never happen... keyIndex = length(keyMap)-1; @@ -105,7 +108,7 @@ public static void main(String[] args) { if (length(entry.keyword) > 0) { varPart = conjugateStrings(userInput, entry.keyword, findInfo[1], reflexions); } - ??? replyRing = replies[entry.index]; + replyRing = replies[entry.index]; reply = replyRing[offsets[keyIndex]]; offsets[keyIndex] = (offsets[keyIndex] + 1) % length(replyRing); posAster = pos("*", reply); @@ -199,7 +202,7 @@ private static boolean checkGoodBye(String text, String[][] phrases) { * @param newInput * @return */ - private static boolean checkRepetition(array[] history, String newInput) { + private static boolean checkRepetition(???[] history, String newInput) { // TODO: Check and accomplish variable declarations: boolean hasOccurred; @@ -265,7 +268,7 @@ private static String conjugateStrings(String sentence, String key, int keyPos, * @param sentence * @return */ - private static int[] findKeyword(final array of KeyMapEntry keyMap, String sentence) { + private static int[] findKeyword(final KeyMapEntry[] keyMap, String sentence) { initialize_KeyMapEntry(); // TODO: Check and accomplish variable declarations: diff --git a/samples/export/Java/SORTING_TEST_MAIN.java b/samples/export/Java/SORTING_TEST_MAIN.java index 60f4e0ec..7becbc58 100644 --- a/samples/export/Java/SORTING_TEST_MAIN.java +++ b/samples/export/Java/SORTING_TEST_MAIN.java @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-11 +// Generated by Structorizer 3.32-01 // Copyright (C) 2019-10-02 Kay Gürtzig // License: GPLv3-link @@ -26,9 +26,9 @@ public class SORTING_TEST_MAIN { public static void main(String[] args) { // =========== START PARALLEL WORKER DEFINITIONS ============ - class Workerce3f34d1_0 implements Callable { + class Worker465fbb06_0 implements Callable { private int[] values1; - public Workerce3f34d1_0(int[] values1) { + public Worker465fbb06_0(int[] values1) { this.values1 = values1; } public Object[] call() throws Exception { @@ -37,10 +37,10 @@ public Object[] call() throws Exception { } }; - class Workerce3f34d1_1 implements Callable { - private ???[] values2; + class Worker465fbb06_1 implements Callable { + private int[] values2; private ??? elementCount; - public Workerce3f34d1_1(???[] values2, ??? elementCount) { + public Worker465fbb06_1(int[] values2, ??? elementCount) { this.values2 = values2; this.elementCount = elementCount; } @@ -50,9 +50,9 @@ public Object[] call() throws Exception { } }; - class Workerce3f34d1_2 implements Callable { - private ???[] values3; - public Workerce3f34d1_2(???[] values3) { + class Worker465fbb06_2 implements Callable { + private int[] values3; + public Worker465fbb06_2(int[] values3) { this.values3 = values3; } public Object[] call() throws Exception { @@ -63,8 +63,8 @@ public Object[] call() throws Exception { // ============ END PARALLEL WORKER DEFINITIONS ============= // TODO: Check and accomplish variable declarations: - ???[] values3; - ???[] values2; + int[] values3; + int[] values2; int[] values1; ??? show; boolean ok3; @@ -109,20 +109,20 @@ public Object[] call() throws Exception { ExecutorService pool = Executors.newFixedThreadPool(3); // ----------------- START THREAD 0 ----------------- - Future futurece3f34d1_0 = pool.submit( new Workerce3f34d1_0(values1) ); + Future future465fbb06_0 = pool.submit( new Worker465fbb06_0(values1) ); // ----------------- START THREAD 1 ----------------- - Future futurece3f34d1_1 = pool.submit( new Workerce3f34d1_1(values2, elementCount) ); + Future future465fbb06_1 = pool.submit( new Worker465fbb06_1(values2, elementCount) ); // ----------------- START THREAD 2 ----------------- - Future futurece3f34d1_2 = pool.submit( new Workerce3f34d1_2(values3) ); + Future future465fbb06_2 = pool.submit( new Worker465fbb06_2(values3) ); // ----------------- AWAIT THREAD 0 ----------------- - futurece3f34d1_0.get(); + future465fbb06_0.get(); // ----------------- AWAIT THREAD 1 ----------------- - futurece3f34d1_1.get(); + future465fbb06_1.get(); // ----------------- AWAIT THREAD 2 ----------------- - futurece3f34d1_2.get(); + future465fbb06_2.get(); pool.shutdown(); } catch (Exception ex) { System.err.println(ex.getMessage()); ex.printStackTrace(); } @@ -161,11 +161,12 @@ public Object[] call() throws Exception { */ private static void bubbleSort(??? values) { // TODO: Check and accomplish variable declarations: + int posSwapped; ??? ende = length(values) - 2; do { // The index of the most recent swapping (-1 means no swapping done). - ??? posSwapped = -1; + posSwapped = -1; for (int i = 0; i <= ende; i += (1)) { if (values[i] > values[i+1]) { ??? temp = values[i]; @@ -318,11 +319,11 @@ private static void buildMaxHeap(??? heap) { */ private static void quickSort(??? values, ??? start, ??? stop) { // =========== START PARALLEL WORKER DEFINITIONS ============ - class Worker68b9aebd_0 implements Callable { + class Worker98a2d384_0 implements Callable { private ??? values; private ??? start; private ??? p; - public Worker68b9aebd_0(??? values, ??? start, ??? p) { + public Worker98a2d384_0(??? values, ??? start, ??? p) { this.values = values; this.start = start; this.p = p; @@ -334,11 +335,11 @@ public Object[] call() throws Exception { } }; - class Worker68b9aebd_1 implements Callable { + class Worker98a2d384_1 implements Callable { private ??? values; private ??? p; private ??? stop; - public Worker68b9aebd_1(??? values, ??? p, ??? stop) { + public Worker98a2d384_1(??? values, ??? p, ??? stop) { this.values = values; this.p = p; this.stop = stop; @@ -372,15 +373,15 @@ public Object[] call() throws Exception { ExecutorService pool = Executors.newFixedThreadPool(2); // ----------------- START THREAD 0 ----------------- - Future future68b9aebd_0 = pool.submit( new Worker68b9aebd_0(values, start, p) ); + Future future98a2d384_0 = pool.submit( new Worker98a2d384_0(values, start, p) ); // ----------------- START THREAD 1 ----------------- - Future future68b9aebd_1 = pool.submit( new Worker68b9aebd_1(values, p, stop) ); + Future future98a2d384_1 = pool.submit( new Worker98a2d384_1(values, p, stop) ); // ----------------- AWAIT THREAD 0 ----------------- - future68b9aebd_0.get(); + future98a2d384_0.get(); // ----------------- AWAIT THREAD 1 ----------------- - future68b9aebd_1.get(); + future98a2d384_1.get(); pool.shutdown(); } catch (Exception ex) { System.err.println(ex.getMessage()); ex.printStackTrace(); } diff --git a/samples/export/Java/TextDemo.java b/samples/export/Java/TextDemo.java index 690ff80a..9f389eaa 100644 --- a/samples/export/Java/TextDemo.java +++ b/samples/export/Java/TextDemo.java @@ -1,4 +1,4 @@ -// Generated by Structorizer 3.30-13 +// Generated by Structorizer 3.32-01 // Copyright (C) 2019-10-10 Kay Gürtzig // License: GPLv3-link @@ -1079,7 +1079,7 @@ private static void letterC(??? h, ??? colorNo) { // Octagon edge length ??? b = h * 0.5 / (Math.sqrt(2.0) + 1); - // Cathetus of the outer trinagle at the octagon corner + // Cathetus of the outer triangle at the octagon corner ??? c = b / Math.sqrt(2.0); // 360°/8 rotAngle = 45; diff --git a/samples/export/Js/ComputeSum.js b/samples/export/Js/ComputeSum.js index af6a0c9f..d6a51b4e 100644 --- a/samples/export/Js/ComputeSum.js +++ b/samples/export/Js/ComputeSum.js @@ -1,6 +1,6 @@