diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index 0a02167..cfb40c7 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -564,6 +564,10 @@ declare namespace lib_plankton.string { * @author fenris */ function generate(prefix?: string): string; + /** + * @author fenris + */ + function join(parts: Array, glue?: string): string; /** * @desc splits a string, but returns an empty list, if the string is empty * @param {string} chain @@ -645,8 +649,15 @@ declare namespace lib_plankton.string { }): string; /** * @author fenris + * @deprecated use limit */ function cut(str: string, length: int, delimiter?: string): string; + /** + */ + function limit(str: string, options?: { + length?: int; + indicator?: string; + }): string; } /** * @deprecated @@ -925,94 +936,6 @@ declare namespace lib_plankton.file { */ function write_buffer(path: string, content: Buffer, options?: {}): Promise; } -declare namespace lib_plankton.prog { - /** - */ - abstract class struct_expression { - } -} -declare namespace lib_plankton.prog { - /** - */ - class struct_expression_variable extends struct_expression { - name: string; - constructor(name: string); - } -} -declare namespace lib_plankton.prog { - /** - */ - class struct_expression_literal extends struct_expression { - value: any; - constructor(value: any); - } -} -declare namespace lib_plankton.prog { - /** - */ - class struct_expression_dict extends struct_expression { - fields: Array<{ - key: string; - value: struct_expression; - }>; - constructor(fields: Array<{ - key: string; - value: struct_expression; - }>); - } -} -declare namespace lib_plankton.prog { - /** - */ - class struct_expression_abstraction extends struct_expression { - arguments: Array<{ - name: string; - type: (null | struct_type); - }>; - output_type: (null | struct_type); - body: Array; - constructor(arguments_: Array<{ - name: string; - type: (null | struct_type); - }>, output_type: (null | struct_type), body: Array); - } -} -declare namespace lib_plankton.prog { - /** - */ - class struct_expression_function_application extends struct_expression { - head: struct_expression; - arguments: Array; - constructor(head: struct_expression, arguments_: Array); - } -} -declare namespace lib_plankton.prog { - /** - */ - class struct_expression_projection extends struct_expression { - source: struct_expression; - index: struct_expression; - constructor(source: struct_expression, index: struct_expression); - } -} -declare namespace lib_plankton.prog { - /** - */ - class struct_expression_fieldaccess extends struct_expression { - structure: struct_expression; - fieldname: string; - constructor(structure: struct_expression, fieldname: string); - } -} -declare namespace lib_plankton.prog { - /** - */ - class struct_expression_operation_comparison extends struct_expression { - left: struct_expression; - right: struct_expression; - constructor(left: struct_expression, right: struct_expression); - } -} declare namespace lib_plankton.prog { /** */ @@ -1125,12 +1048,138 @@ declare namespace lib_plankton.prog { right: struct_type; } } +declare namespace lib_plankton.prog { + /** + */ + abstract class struct_expression { + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_variable extends struct_expression { + name: string; + constructor(name: string); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_literal extends struct_expression { + value: any; + constructor(value: any); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_list extends struct_expression { + elements: Array; + constructor(elements: Array); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_dict extends struct_expression { + fields: Array<{ + key: string; + value: struct_expression; + }>; + constructor(fields: Array<{ + key: string; + value: struct_expression; + }>); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_abstraction extends struct_expression { + arguments: Array<{ + name: string; + type: (null | struct_type); + }>; + output_type: (null | struct_type); + body: Array; + async_: boolean; + constructor(arguments_: Array<{ + name: string; + type: (null | struct_type); + }>, output_type: (null | struct_type), body: Array, options?: { + async?: boolean; + }); + } +} +declare namespace lib_plankton.prog { + /** + * @todo rename to function_call + */ + class struct_expression_function_application extends struct_expression { + head: struct_expression; + arguments: Array; + constructor(head: struct_expression, arguments_: Array); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_projection extends struct_expression { + source: struct_expression; + index: struct_expression; + constructor(source: struct_expression, index: struct_expression); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_fieldaccess extends struct_expression { + structure: struct_expression; + fieldname: string; + constructor(structure: struct_expression, fieldname: string); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_operation_comparison extends struct_expression { + left: struct_expression; + right: struct_expression; + constructor(left: struct_expression, right: struct_expression); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_await extends struct_expression { + target: struct_expression; + constructor(target: struct_expression); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_expression_cast extends struct_expression { + expression: struct_expression; + type: struct_type; + constructor(expression: struct_expression, type: struct_type); + } +} declare namespace lib_plankton.prog { /** */ abstract class struct_statement { } } +declare namespace lib_plankton.prog { + /** + */ + class struct_statement_comment extends struct_statement { + block: boolean; + lines: Array; + constructor(block: boolean, lines: Array); + } +} declare namespace lib_plankton.prog { /** */ @@ -1168,6 +1217,15 @@ declare namespace lib_plankton.prog { constructor(name: string, value: (null | struct_expression)); } } +declare namespace lib_plankton.prog { + /** + */ + class struct_statement_procedure_call extends struct_statement { + head: struct_expression; + arguments: Array; + constructor(head: struct_expression, arguments_: Array); + } +} declare namespace lib_plankton.prog { /** */ @@ -1179,10 +1237,13 @@ declare namespace lib_plankton.prog { }>; output_type: (null | struct_type); body: Array; + async_: boolean; constructor(name: string, arguments_: Array<{ name: string; type: (null | struct_type); - }>, output_type: (null | struct_type), body: Array); + }>, output_type: (null | struct_type), body: Array, options?: { + async?: boolean; + }); } } declare namespace lib_plankton.prog { diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index 40a9389..d78690c 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -1504,6 +1504,18 @@ var lib_plankton; } } string.generate = generate; + /** + * @author fenris + */ + function join(parts, glue = " ") { + if (parts.length == 0) { + return ""; + } + else { + return parts.join(glue); + } + } + string.join = join; /** * @desc splits a string, but returns an empty list, if the string is empty * @param {string} chain @@ -1740,6 +1752,7 @@ var lib_plankton; string.coin = coin; /** * @author fenris + * @deprecated use limit */ function cut(str, length, delimiter = "…") { if (str.length <= length) { @@ -1750,6 +1763,18 @@ var lib_plankton; } } string.cut = cut; + /** + */ + function limit(str, options = {}) { + options = Object.assign({ + "length": 120, + "indicator": "…", + }, options); + return ((str.length <= options.length) + ? str + : (str.slice(0, options.length - options.indicator.length) + options.indicator)); + } + string.limit = limit; })(string = lib_plankton.string || (lib_plankton.string = {})); })(lib_plankton || (lib_plankton = {})); /** @@ -2729,7 +2754,7 @@ var lib_plankton; return (new Promise(function (resolve, reject) { nm_fs.readFile(path, { "encoding": "utf8", - "flag": "r", + "flag": "r" }, function (error, content) { if (error == null) { resolve(content); @@ -2748,7 +2773,7 @@ var lib_plankton; var nm_fs = require("fs"); return (new Promise(function (resolve, reject) { nm_fs.readFile(path, { - "flag": "r", + "flag": "r" }, function (error, content) { if (error == null) { resolve(content); @@ -2785,13 +2810,13 @@ var lib_plankton; function write(path, content, options) { if (options === void 0) { options = {}; } options = Object.assign({ - "encoding": "utf-8", + "encoding": "utf-8" }, options); var nm_fs = require("fs"); return (new Promise(function (resolve, reject) { nm_fs.writeFile(path, content, { "encoding": options.encoding, - "flag": "w", + "flag": "w" }, function (error) { if (error == null) { resolve(undefined); @@ -2812,7 +2837,7 @@ var lib_plankton; var nm_fs = require("fs"); return (new Promise(function (resolve, reject) { nm_fs.writeFile(path, content, { - "flag": "w", + "flag": "w" }, function (error) { if (error == null) { resolve(undefined); @@ -2857,341 +2882,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression = /** @class */ (function () { - function struct_expression() { - } - return struct_expression; - }()); - prog.struct_expression = struct_expression; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression_variable = /** @class */ (function (_super) { - __extends(struct_expression_variable, _super); - function struct_expression_variable(name) { - var _this = _super.call(this) || this; - _this.name = name; - return _this; - } - return struct_expression_variable; - }(prog.struct_expression)); - prog.struct_expression_variable = struct_expression_variable; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression_literal = /** @class */ (function (_super) { - __extends(struct_expression_literal, _super); - function struct_expression_literal(value) { - var _this = _super.call(this) || this; - _this.value = value; - return _this; - } - return struct_expression_literal; - }(prog.struct_expression)); - prog.struct_expression_literal = struct_expression_literal; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression_dict = /** @class */ (function (_super) { - __extends(struct_expression_dict, _super); - function struct_expression_dict(fields) { - var _this = _super.call(this) || this; - _this.fields = fields; - return _this; - } - return struct_expression_dict; - }(prog.struct_expression)); - prog.struct_expression_dict = struct_expression_dict; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression_abstraction = /** @class */ (function (_super) { - __extends(struct_expression_abstraction, _super); - function struct_expression_abstraction(arguments_, output_type, body) { - var _this = _super.call(this) || this; - _this.arguments = arguments_; - _this.output_type = output_type; - _this.body = body; - return _this; - } - return struct_expression_abstraction; - }(prog.struct_expression)); - prog.struct_expression_abstraction = struct_expression_abstraction; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression_function_application = /** @class */ (function (_super) { - __extends(struct_expression_function_application, _super); - function struct_expression_function_application(head, arguments_) { - var _this = _super.call(this) || this; - _this.head = head; - _this.arguments = arguments_; - return _this; - } - return struct_expression_function_application; - }(prog.struct_expression)); - prog.struct_expression_function_application = struct_expression_function_application; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression_projection = /** @class */ (function (_super) { - __extends(struct_expression_projection, _super); - function struct_expression_projection(source, index) { - var _this = _super.call(this) || this; - _this.source = source; - _this.index = index; - return _this; - } - return struct_expression_projection; - }(prog.struct_expression)); - prog.struct_expression_projection = struct_expression_projection; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression_fieldaccess = /** @class */ (function (_super) { - __extends(struct_expression_fieldaccess, _super); - function struct_expression_fieldaccess(structure, fieldname) { - var _this = _super.call(this) || this; - _this.structure = structure; - _this.fieldname = fieldname; - return _this; - } - return struct_expression_fieldaccess; - }(prog.struct_expression)); - prog.struct_expression_fieldaccess = struct_expression_fieldaccess; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with »bacterio-plankton:prog«. If not, see . - */ -var lib_plankton; -(function (lib_plankton) { - var prog; - (function (prog) { - /** - */ - var struct_expression_operation_comparison = /** @class */ (function (_super) { - __extends(struct_expression_operation_comparison, _super); - function struct_expression_operation_comparison(left, right) { - var _this = _super.call(this) || this; - _this.left = left; - _this.right = right; - return _this; - } - return struct_expression_operation_comparison; - }(prog.struct_expression)); - prog.struct_expression_operation_comparison = struct_expression_operation_comparison; - })(prog = lib_plankton.prog || (lib_plankton.prog = {})); -})(lib_plankton || (lib_plankton = {})); -/* -This file is part of »bacterio-plankton:prog«. - -Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' - - -»bacterio-plankton:prog« is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -»bacterio-plankton:prog« is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:prog«. If not, see . */ @@ -3695,6 +3385,460 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression = /** @class */ (function () { + function struct_expression() { + } + return struct_expression; + }()); + prog.struct_expression = struct_expression; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_variable = /** @class */ (function (_super) { + __extends(struct_expression_variable, _super); + function struct_expression_variable(name) { + var _this = _super.call(this) || this; + _this.name = name; + return _this; + } + return struct_expression_variable; + }(prog.struct_expression)); + prog.struct_expression_variable = struct_expression_variable; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_literal = /** @class */ (function (_super) { + __extends(struct_expression_literal, _super); + function struct_expression_literal(value) { + var _this = _super.call(this) || this; + _this.value = value; + return _this; + } + return struct_expression_literal; + }(prog.struct_expression)); + prog.struct_expression_literal = struct_expression_literal; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_list = /** @class */ (function (_super) { + __extends(struct_expression_list, _super); + function struct_expression_list(elements) { + var _this = _super.call(this) || this; + _this.elements = elements; + return _this; + } + return struct_expression_list; + }(prog.struct_expression)); + prog.struct_expression_list = struct_expression_list; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_dict = /** @class */ (function (_super) { + __extends(struct_expression_dict, _super); + function struct_expression_dict(fields) { + var _this = _super.call(this) || this; + _this.fields = fields; + return _this; + } + return struct_expression_dict; + }(prog.struct_expression)); + prog.struct_expression_dict = struct_expression_dict; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_abstraction = /** @class */ (function (_super) { + __extends(struct_expression_abstraction, _super); + function struct_expression_abstraction(arguments_, output_type, body, options) { + if (options === void 0) { options = {}; } + var _this = this; + options = Object.assign({ + "async": false + }, options); + _this = _super.call(this) || this; + _this.arguments = arguments_; + _this.output_type = output_type; + _this.body = body; + _this.async_ = options.async; + return _this; + } + return struct_expression_abstraction; + }(prog.struct_expression)); + prog.struct_expression_abstraction = struct_expression_abstraction; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + * @todo rename to function_call + */ + var struct_expression_function_application = /** @class */ (function (_super) { + __extends(struct_expression_function_application, _super); + function struct_expression_function_application(head, arguments_) { + var _this = _super.call(this) || this; + _this.head = head; + _this.arguments = arguments_; + return _this; + } + return struct_expression_function_application; + }(prog.struct_expression)); + prog.struct_expression_function_application = struct_expression_function_application; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_projection = /** @class */ (function (_super) { + __extends(struct_expression_projection, _super); + function struct_expression_projection(source, index) { + var _this = _super.call(this) || this; + _this.source = source; + _this.index = index; + return _this; + } + return struct_expression_projection; + }(prog.struct_expression)); + prog.struct_expression_projection = struct_expression_projection; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_fieldaccess = /** @class */ (function (_super) { + __extends(struct_expression_fieldaccess, _super); + function struct_expression_fieldaccess(structure, fieldname) { + var _this = _super.call(this) || this; + _this.structure = structure; + _this.fieldname = fieldname; + return _this; + } + return struct_expression_fieldaccess; + }(prog.struct_expression)); + prog.struct_expression_fieldaccess = struct_expression_fieldaccess; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_operation_comparison = /** @class */ (function (_super) { + __extends(struct_expression_operation_comparison, _super); + function struct_expression_operation_comparison(left, right) { + var _this = _super.call(this) || this; + _this.left = left; + _this.right = right; + return _this; + } + return struct_expression_operation_comparison; + }(prog.struct_expression)); + prog.struct_expression_operation_comparison = struct_expression_operation_comparison; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_await = /** @class */ (function (_super) { + __extends(struct_expression_await, _super); + function struct_expression_await(target) { + var _this = _super.call(this) || this; + _this.target = target; + return _this; + } + return struct_expression_await; + }(prog.struct_expression)); + prog.struct_expression_await = struct_expression_await; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_expression_cast = /** @class */ (function (_super) { + __extends(struct_expression_cast, _super); + function struct_expression_cast(expression, type) { + var _this = _super.call(this) || this; + _this.expression = expression; + _this.type = type; + return _this; + } + return struct_expression_cast; + }(prog.struct_expression)); + prog.struct_expression_cast = struct_expression_cast; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:prog«. If not, see . */ @@ -3728,6 +3872,44 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_comment = /** @class */ (function (_super) { + __extends(struct_statement_comment, _super); + function struct_statement_comment(block, lines) { + var _this = _super.call(this) || this; + _this.block = block; + _this.lines = lines; + return _this; + } + return struct_statement_comment; + }(prog.struct_statement)); + prog.struct_statement_comment = struct_statement_comment; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:prog«. If not, see . */ @@ -3881,6 +4063,44 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +You should have received a copy of the GNU Lesser General Public License +along with »bacterio-plankton:prog«. If not, see . + */ +var lib_plankton; +(function (lib_plankton) { + var prog; + (function (prog) { + /** + */ + var struct_statement_procedure_call = /** @class */ (function (_super) { + __extends(struct_statement_procedure_call, _super); + function struct_statement_procedure_call(head, arguments_) { + var _this = _super.call(this) || this; + _this.head = head; + _this.arguments = arguments_; + return _this; + } + return struct_statement_procedure_call; + }(prog.struct_statement)); + prog.struct_statement_procedure_call = struct_statement_procedure_call; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); +/* +This file is part of »bacterio-plankton:prog«. + +Copyright 2016-2023 'Christian Fraß, Christian Neubauer, Martin Springwald GbR' + + +»bacterio-plankton:prog« is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +»bacterio-plankton:prog« is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with »bacterio-plankton:prog«. If not, see . */ @@ -3892,12 +4112,18 @@ var lib_plankton; */ var struct_statement_function_definition = /** @class */ (function (_super) { __extends(struct_statement_function_definition, _super); - function struct_statement_function_definition(name, arguments_, output_type, body) { - var _this = _super.call(this) || this; + function struct_statement_function_definition(name, arguments_, output_type, body, options) { + if (options === void 0) { options = {}; } + var _this = this; + options = Object.assign({ + "async": false + }, options); + _this = _super.call(this) || this; _this.name = name; _this.arguments = arguments_; _this.output_type = output_type; _this.body = body; + _this.async_ = options.async; return _this; } return struct_statement_function_definition; @@ -4031,45 +4257,45 @@ var lib_plankton; if (options === void 0) { options = {}; } options = Object.assign({ "indent": true, - "level": 0, + "level": 0 }, options); if (type instanceof prog.struct_type_literal) { var type_literal = type; return lib_plankton.string.coin("{{indentation}}{{value}}", { "indentation": indentation(options.indent, options.level), "value": render_expression(type_literal.value, { - "level": (options.level + 1), - }), + "level": (options.level + 1) + }) }); } else if (type instanceof prog.struct_type_any) { var type_any = type; return lib_plankton.string.coin("{{indentation}}any", { - "indentation": indentation(options.indent, options.level), + "indentation": indentation(options.indent, options.level) }); } else if (type instanceof prog.struct_type_void) { var type_void = type; return lib_plankton.string.coin("{{indentation}}void", { - "indentation": indentation(options.indent, options.level), + "indentation": indentation(options.indent, options.level) }); } else if (type instanceof prog.struct_type_boolean) { var type_boolean = type; return lib_plankton.string.coin("{{indentation}}boolean", { - "indentation": indentation(options.indent, options.level), + "indentation": indentation(options.indent, options.level) }); } else if (type instanceof prog.struct_type_integer) { var type_integer = type; return lib_plankton.string.coin("{{indentation}}number", { - "indentation": indentation(options.indent, options.level), + "indentation": indentation(options.indent, options.level) }); } else if (type instanceof prog.struct_type_string) { var type_string = type; return lib_plankton.string.coin("{{indentation}}string", { - "indentation": indentation(options.indent, options.level), + "indentation": indentation(options.indent, options.level) }); } else if (type instanceof prog.struct_type_list) { @@ -4097,10 +4323,10 @@ var lib_plankton; "assignment": (field.mandatory ? ":" : "?:"), "type": render_type(field.type, { "indent": false, - "level": (options.level + 1), - }), + "level": (options.level + 1) + }) }); }) - .join(";\n")), + .join(";\n")) }); } else if (type instanceof prog.struct_type_function) { @@ -4110,12 +4336,12 @@ var lib_plankton; "indentation2": indentation(true, options.level), "arguments": (type_function.arguments .map(function (argument) { return render_type(argument, { - "level": (options.level + 1), + "level": (options.level + 1) }); }) .join(", ")), "target": render_type(type_function.target, { - "level": (options.level + 1), - }), + "level": (options.level + 1) + }) }); } else if (type instanceof prog.struct_type_construction) { @@ -4129,10 +4355,10 @@ var lib_plankton; "indentation": indentation(true, options.level), "arguments": (type_construction.arguments .map(function (argument) { return render_type(argument, { - "level": (options.level + 1), + "level": (options.level + 1) }); }) - .join(",\n")), - })), + .join(",\n")) + })) }); } else if (type instanceof prog.struct_type_union) { @@ -4142,11 +4368,11 @@ var lib_plankton; "indentation2": indentation(true, options.level), "indentation3": indentation(true, options.level + 1), "left": render_type(type_union.left, { - "level": (options.level + 1), + "level": (options.level + 1) }), "right": render_type(type_union.right, { - "level": (options.level + 1), - }), + "level": (options.level + 1) + }) }); } else if (type instanceof prog.struct_type_intersection) { @@ -4155,11 +4381,11 @@ var lib_plankton; "indentation1": indentation(options.indent, options.level), "indentation2": indentation(true, options.level + 1), "left": render_type(type_intersection.left, { - "level": (options.level + 1), + "level": (options.level + 1) }), "right": render_type(type_intersection.right, { - "level": (options.level + 1), - }), + "level": (options.level + 1) + }) }); } else { @@ -4173,20 +4399,36 @@ var lib_plankton; if (options === void 0) { options = {}; } options = Object.assign({ "indent": false, - "level": 0, + "level": 0 }, options); if (expression instanceof prog.struct_expression_variable) { var expression_variable = expression; return lib_plankton.string.coin("{{indentation}}{{name}}", { "indentation": indentation(options.indent, options.level), - "name": expression.name, + "name": expression.name }); } else if (expression instanceof prog.struct_expression_literal) { var expression_literal = expression; return lib_plankton.string.coin("{{indentation}}{{value}}", { "indentation": indentation(options.indent, options.level), - "value": JSON.stringify(expression_literal.value), + "value": JSON.stringify(expression_literal.value) + }); + } + else if (expression instanceof prog.struct_expression_list) { + var expression_list = expression; + return lib_plankton.string.coin("{{indentation1}}[\n{{elements}}\n{{indentation2}}]", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "elements": (expression_list.elements + .map(function (element) { return lib_plankton.string.coin("{{indentation}}{{value}}", { + "indentation": indentation(true, options.level + 1), + "value": render_expression(element, { + "indent": false, + "level": (options.level + 1) + }) + }); }) + .join(",\n")) }); } else if (expression instanceof prog.struct_expression_dict) { @@ -4200,17 +4442,20 @@ var lib_plankton; "key": field.key, "value": render_expression(field.value, { "indent": false, - "level": (options.level + 1), - }), + "level": (options.level + 1) + }) }); }) - .join(",\n")), + .join(",\n")) }); } else if (expression instanceof prog.struct_expression_abstraction) { var expression_abstraction = expression; - return lib_plankton.string.coin("{{indentation1}}function ({{arguments}}){{macro_output_type}} {\n{{body}}{{indentation2}}}", { + return lib_plankton.string.coin("{{indentation1}}{{macro_async}}function ({{arguments}}){{macro_output_type}} {\n{{body}}{{indentation2}}}", { "indentation1": indentation(options.indent, options.level), "indentation2": indentation(true, options.level), + "macro_async": (expression_abstraction.async_ + ? "async " + : ""), "arguments": (expression_abstraction.arguments .map(function (argument) { return lib_plankton.string.coin("{{name}}{{macro_type}}", { "name": argument.name, @@ -4218,7 +4463,7 @@ var lib_plankton; ? "" : lib_plankton.string.coin(" : {{type}}", { "type": render_type(argument.type) - })), + })) }); }) .join(", ")), "macro_output_type": ((expression_abstraction.output_type === null) @@ -4226,14 +4471,14 @@ var lib_plankton; : lib_plankton.string.coin(" : {{type}}", { "type": render_type(expression_abstraction.output_type, { "indent": false, - "level": (options.level + 1), + "level": (options.level + 1) }) })), "body": (expression_abstraction.body .map(function (statement) { return render_statement(statement, { - "level": (options.level + 1), + "level": (options.level + 1) }); }) - .join("")), + .join("")) }); } else if (expression instanceof prog.struct_expression_function_application) { @@ -4241,15 +4486,18 @@ var lib_plankton; return lib_plankton.string.coin("{{indentation1}}{{name}}(\n{{arguments}}\n{{indentation2}})", { "indentation1": indentation(options.indent, options.level), "indentation2": indentation(true, options.level), - "name": render_expression(expression_function_application.head), + "name": render_expression(expression_function_application.head, { + "indent": false, + "level": (options.level + 0) + }), "arguments": (expression_function_application.arguments .map(function (argument) { return lib_plankton.string.coin("{{argument}}", { "argument": render_expression(argument, { "indent": true, - "level": (options.level + 1), - }), + "level": (options.level + 1) + }) }); }) - .join(",\n")), + .join(",\n")) }); } else if (expression instanceof prog.struct_expression_projection) { @@ -4257,24 +4505,55 @@ var lib_plankton; return lib_plankton.string.coin("{{indentation}}{{source}}[{{index}}]", { "indentation": indentation(options.indent, options.level), "source": render_expression(expression_projection.source), - "index": render_expression(expression_projection.index), + "index": render_expression(expression_projection.index) }); } else if (expression instanceof prog.struct_expression_fieldaccess) { var expression_fieldaccess = expression; - return lib_plankton.string.coin("{{structure}}.{{fieldname}}", { + return lib_plankton.string.coin("{{indentation}}{{structure}}.{{fieldname}}", { + "indentation": indentation(options.indent, options.level), "structure": render_expression(expression_fieldaccess.structure, { - "level": (options.level + 1), + "level": (options.level + 1) }), - "fieldname": expression_fieldaccess.fieldname, + "fieldname": expression_fieldaccess.fieldname }); } else if (expression instanceof prog.struct_expression_operation_comparison) { var expression_operation_comparison = expression; return lib_plankton.string.coin("{{indentation}}({{left}} === {{right}})", { "indentation": indentation(options.indent, options.level), - "left": render_expression(expression_operation_comparison.left), - "right": render_expression(expression_operation_comparison.right), + "left": render_expression(expression_operation_comparison.left, { + "indent": false, + "level": (options.level + 0) + }), + "right": render_expression(expression_operation_comparison.right, { + "indent": false, + "level": (options.level + 0) + }) + }); + } + else if (expression instanceof prog.struct_expression_await) { + var expression_await = expression; + return lib_plankton.string.coin("{{indentation}}await {{target}}", { + "indentation": indentation(options.indent, options.level), + "target": render_expression(expression_await.target, { + "indent": false, + "level": (options.level + 0) + }) + }); + } + else if (expression instanceof prog.struct_expression_cast) { + var expression_cast = expression; + return lib_plankton.string.coin("{{indentation}}({{expression}} as {{type}})", { + "indentation": indentation(options.indent, options.level), + "expression": render_expression(expression_cast.expression, { + "indent": false, + "level": (options.level + 0) + }), + "type": render_type(expression_cast.type, { + "indent": false, + "level": (options.level + 0) + }) }); } else { @@ -4288,18 +4567,28 @@ var lib_plankton; if (options === void 0) { options = {}; } options = Object.assign({ "indent": true, - "level": 0, + "level": 0 }, options); - if (statement instanceof prog.struct_statement_type_definition) { - var statement_type_definition = statement; - return lib_plankton.string.coin("{{indentation}}type {{name}} = {{type}};\n", { - "indentation": indentation(options.indent, options.level), - "name": statement_type_definition.name, - "type": render_type(statement_type_definition.type, { - "indent": false, - "level": (options.level + 0), - }), - }); + if (statement instanceof prog.struct_statement_comment) { + var statement_comment = statement; + return (statement_comment.block + ? lib_plankton.string.coin("{{indentation}}/**\n{{lines}}{{indentation}} */\n", { + "indentation": indentation(options.indent, options.level), + "lines": (statement_comment.lines + .map(function (line) { return lib_plankton.string.coin("{{indentation}} * {{line}}\n", { + "indentation": indentation(options.indent, options.level), + "line": line + }); }) + .join("")) + }) + : lib_plankton.string.coin("{{lines}}", { + "lines": (statement_comment.lines + .map(function (line) { return lib_plankton.string.coin("{{indentation}}// {{line}}\n", { + "indentation": indentation(options.indent, options.level), + "line": line + }); }) + .join("")) + })); } else if (statement instanceof prog.struct_statement_block) { var statement_block = statement; @@ -4307,9 +4596,20 @@ var lib_plankton; "indentation": indentation(options.indent, options.level), "statements": (statement_block.statements .map(function (statement) { return render_statement(statement, { - "level": (options.level + 1), + "level": (options.level + 1) }); }) - .join("")), + .join("")) + }); + } + else if (statement instanceof prog.struct_statement_type_definition) { + var statement_type_definition = statement; + return lib_plankton.string.coin("{{indentation}}type {{name}} = {{type}};\n", { + "indentation": indentation(options.indent, options.level), + "name": statement_type_definition.name, + "type": render_type(statement_type_definition.type, { + "indent": false, + "level": (options.level + 0) + }) }); } else if (statement instanceof prog.struct_statement_declaration) { @@ -4325,17 +4625,17 @@ var lib_plankton; : lib_plankton.string.coin(" : {{type}}", { "type": render_type(statement_declaration.type, { "indent": false, - "level": (options.level + 1), - }), + "level": (options.level + 0) + }) })), "macro_value": ((statement_declaration.value === null) ? "" : lib_plankton.string.coin(" = {{value}}", { "value": render_expression(statement_declaration.value, { "indent": false, - "level": (options.level + 1), - }), - })), + "level": (options.level + 0) + }) + })) }); } else if (statement instanceof prog.struct_statement_assignment) { @@ -4345,15 +4645,37 @@ var lib_plankton; "name": statement_assignment.name, "value": render_expression(statement_assignment.value, { "indent": false, - "level": (options.level + 1), + "level": (options.level + 1) + }) + }); + } + else if (statement instanceof prog.struct_statement_procedure_call) { + var statement_procedure_call = statement; + return lib_plankton.string.coin("{{indentation1}}{{name}}(\n{{arguments}}\n{{indentation2}});\n", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "name": render_expression(statement_procedure_call.head, { + "indent": false, + "level": (options.level + 0) }), + "arguments": (statement_procedure_call.arguments + .map(function (argument) { return lib_plankton.string.coin("{{argument}}", { + "argument": render_expression(argument, { + "indent": true, + "level": (options.level + 1) + }) + }); }) + .join(",\n")) }); } else if (statement instanceof prog.struct_statement_function_definition) { var statement_function_definition = statement; - return lib_plankton.string.coin("{{indentation1}}function {{name}}(\n{{arguments}}\n{{indentation2}}){{macro_output_type}}\n{{indentation2}}{\n{{body}}{{indentation2}}}\n", { + return lib_plankton.string.coin("{{indentation1}}{{macro_async}}function {{name}}(\n{{arguments}}\n{{indentation2}}){{macro_output_type}}\n{{indentation2}}{\n{{body}}{{indentation2}}}\n", { "indentation1": indentation(options.indent, options.level), "indentation2": indentation(true, options.level), + "macro_async": (statement_function_definition.async_ + ? "async " + : ""), "name": statement_function_definition.name, "arguments": (statement_function_definition.arguments .map(function (argument) { return lib_plankton.string.coin("{{indentation}}{{name}}{{macro_type}}", { @@ -4364,9 +4686,9 @@ var lib_plankton; : lib_plankton.string.coin(" : {{type}}", { "type": render_type(argument.type, { "indent": false, - "level": (options.level + 2), + "level": (options.level + 2) }) - })), + })) }); }) .join(",\n")), "macro_output_type": ((statement_function_definition.output_type === null) @@ -4374,15 +4696,15 @@ var lib_plankton; : lib_plankton.string.coin(" : {{type}}", { "type": render_type(statement_function_definition.output_type, { "indent": false, - "level": (options.level + 0), + "level": (options.level + 0) }) })), "body": (statement_function_definition.body .map(function (statement) { return render_statement(statement, { "indent": true, - "level": (options.level + 1), + "level": (options.level + 1) }); }) - .join("")), + .join("")) }); } else if (statement instanceof prog.struct_statement_return) { @@ -4391,12 +4713,12 @@ var lib_plankton; "indentation": indentation(options.indent, options.level), "expression": render_expression(statement_return.expression, { "indent": false, - "level": (options.level + 0), - }), + "level": (options.level + 0) + }) }); } else { - throw (new Error("unhandled statement: " + String(statement))); + throw (new Error("unhandled statement: " + (statement.constructor.name))); } } prog.render_statement = render_statement; @@ -4406,7 +4728,7 @@ var lib_plankton; return (program.statements .map(function (statement) { return render_statement(statement, { "indent": true, - "level": 0, + "level": 0 }); }) .join("\n")); } @@ -4418,7 +4740,7 @@ var lib_plankton; "render_expression": render_expression, "render_type": render_type, "render_statement": render_statement, - "render_program": render_program, + "render_program": render_program }; } prog.output_typescript = output_typescript; @@ -4547,8 +4869,8 @@ var lib_plankton; "info": info, "hidden": hidden, "parameters": { - "index": index, - }, + "index": index + } })); }; /** @@ -4566,8 +4888,8 @@ var lib_plankton; "hidden": hidden, "parameters": { "indicators_short": indicators_short, - "indicators_long": indicators_long, - }, + "indicators_long": indicators_long + } })); }; /** @@ -4813,17 +5135,17 @@ var lib_plankton; "symbols": { "delimiter": " ", "prefix": "--", - "assignment": "=", - }, + "assignment": "=" + } }, "url": { "symbols": { "delimiter": "&", "prefix": "", - "assignment": "=", + "assignment": "=" } } - }, + } }; /** * @author fenris @@ -4900,14 +5222,14 @@ var lib_plankton; "pattern_from": pattern_from, "pattern_to": pattern_to, "input": input, - "result": result, + "result": result }); input = result; } } } lib_plankton.log.debug("lib_args:read:current_input", { - "input": input, + "input": input }); } // parsing @@ -4918,18 +5240,18 @@ var lib_plankton; var index_expected_1 = 0; parts.forEach(function (part) { lib_plankton.log.debug("lib_args:read:analyzing", { - "part": part, + "part": part }); var found = [ function () { lib_plankton.log.debug("lib_args:read:probing_as_volatile", { - "part": part, + "part": part }); for (var _i = 0, _a = Object.entries(_this.filter(args.enum_kind.volatile)); _i < _a.length; _i++) { var _b = _a[_i], name = _b[0], argument = _b[1]; lib_plankton.log.debug("lib_args:read:probing_as_volatile:trying", { "part": part, - "argument": argument.toString(), + "argument": argument.toString() }); var pattern = ""; { @@ -4948,12 +5270,12 @@ var lib_plankton; pattern += pattern_back; } lib_plankton.log.debug("lib_args:read:probing_as_volatile:pattern", { - "pattern": pattern, + "pattern": pattern }); var regexp = new RegExp(pattern); var matching = regexp.exec(part); lib_plankton.log.debug("lib_args:read:probing_as_volatile:matching", { - "matching": matching, + "matching": matching }); if (matching == null) { // do nothing @@ -4967,7 +5289,7 @@ var lib_plankton; }, function () { lib_plankton.log.debug("lib_args:read:probing_as_positional", { - "part": part, + "part": part }); var positional = _this.filter(args.enum_kind.positional); for (var _i = 0, _a = Object.entries(positional); _i < _a.length; _i++) { @@ -4978,7 +5300,7 @@ var lib_plankton; else { lib_plankton.log.debug("lib_args:read:probing_as_positional:trying", { "part": part, - "argument": argument.toString(), + "argument": argument.toString() }); var pattern = ""; { @@ -4987,12 +5309,12 @@ var lib_plankton; pattern += pattern_back; } lib_plankton.log.debug("lib_args:read:probing_as_positional:pattern", { - "pattern": pattern, + "pattern": pattern }); var regexp = new RegExp(pattern); var matching = regexp.exec(part); lib_plankton.log.debug("lib_args:read:probing_as_positional:matching", { - "matching": matching, + "matching": matching }); if (matching == null) { return false; @@ -5009,7 +5331,7 @@ var lib_plankton; ].some(function (x) { return x(); }); if (!found) { lib_plankton.log.warning("lib_args:read:could_not_parse", { - "part": part, + "part": part }); } });