From 6ff79fe09381bd4632c064ec3d7e7264ff24761e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Tue, 11 Jul 2023 20:39:47 +0200 Subject: [PATCH 1/4] [mod] lib:plankton --- lib/plankton/plankton.d.ts | 209 +++++++ lib/plankton/plankton.js | 1082 +++++++++++++++++++++++++++++++++++- tools/get-plankton | 1 + 3 files changed, 1267 insertions(+), 25 deletions(-) diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index ffc5761..7f1bf51 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -925,6 +925,215 @@ 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_function_application extends struct_expression { + head: struct_expression; + arguments: Array; + constructor(head: struct_expression, arguments_: Array); + } +} +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 { + /** + */ + abstract class struct_type { + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_literal extends struct_type { + value: struct_expression; + constructor(value: struct_expression); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_boolean extends struct_type { + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_integer extends struct_type { + constructor(); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_string extends struct_type { + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_list extends struct_type { + element: struct_type; + constructor(element: struct_type); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_map extends struct_type { + key: struct_type; + value: struct_type; + constructor(key: struct_type, value: struct_type); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_record extends struct_type { + fields: Array<{ + name: string; + type: struct_type; + mandatory: boolean; + }>; + constructor(fields: Array<{ + name: string; + type: struct_type; + mandatory: boolean; + }>); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_function extends struct_type { + arguments: Array; + target: struct_type; + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_construction extends struct_type { + name: string; + arguments: (null | Array); + constructor(name: string, arguments_: (null | Array)); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_union extends struct_type { + left: struct_type; + right: struct_type; + constructor(left: struct_type, right: struct_type); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_intersection extends struct_type { + left: struct_type; + right: struct_type; + } +} +declare namespace lib_plankton.prog { + /** + */ + abstract class struct_statement { + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_statement_type_definition extends struct_statement { + name: string; + type: struct_type; + constructor(name: string, type: struct_type); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_statement_declaration extends struct_statement { + constant: boolean; + name: string; + type: (null | struct_type); + value: (null | struct_expression); + constructor(constant: boolean, name: string, type: (null | struct_type), value: (null | struct_expression)); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_statement_assignment extends struct_statement { + name: string; + value: (null | struct_expression); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_program { + statements: Array; + constructor(statements: Array); + } +} +declare namespace lib_plankton.prog { + /** + */ + type type_output = { + render_expression: ((expression: struct_expression) => string); + render_type: ((type: struct_type) => string); + render_statement: ((program: struct_statement) => string); + render_program: ((program: struct_program) => string); + }; +} +declare namespace lib_plankton.prog { + /** + */ + function render_expression(expression: struct_expression): string; + /** + */ + function render_type(type: struct_type): string; + /** + */ + function render_statement(statement: struct_statement): string; + /** + */ + function render_program(program: struct_program): string; + /** + */ + function output_typescript(): type_output; +} declare namespace lib_plankton.args { /** */ diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index 7c895a7..780aa43 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -2729,7 +2729,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 +2748,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 +2785,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 +2812,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); @@ -2826,6 +2826,1038 @@ var lib_plankton; file.write_buffer = write_buffer; })(file = lib_plankton.file || (lib_plankton.file = {})); })(lib_plankton || (lib_plankton = {})); +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +/* +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 = /** @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_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_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_type = /** @class */ (function () { + function struct_type() { + } + return struct_type; + }()); + prog.struct_type = struct_type; + })(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_type_literal = /** @class */ (function (_super) { + __extends(struct_type_literal, _super); + function struct_type_literal(value) { + var _this = _super.call(this) || this; + _this.value = value; + return _this; + } + return struct_type_literal; + }(prog.struct_type)); + prog.struct_type_literal = struct_type_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_type_boolean = /** @class */ (function (_super) { + __extends(struct_type_boolean, _super); + function struct_type_boolean() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_boolean; + }(prog.struct_type)); + prog.struct_type_boolean = struct_type_boolean; + })(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_type_integer = /** @class */ (function (_super) { + __extends(struct_type_integer, _super); + function struct_type_integer() { + return _super.call(this) || this; + } + return struct_type_integer; + }(prog.struct_type)); + prog.struct_type_integer = struct_type_integer; + })(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_type_string = /** @class */ (function (_super) { + __extends(struct_type_string, _super); + function struct_type_string() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_string; + }(prog.struct_type)); + prog.struct_type_string = struct_type_string; + })(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_type_list = /** @class */ (function (_super) { + __extends(struct_type_list, _super); + function struct_type_list(element) { + var _this = _super.call(this) || this; + _this.element = element; + return _this; + } + return struct_type_list; + }(prog.struct_type)); + prog.struct_type_list = struct_type_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_type_map = /** @class */ (function (_super) { + __extends(struct_type_map, _super); + function struct_type_map(key, value) { + var _this = _super.call(this) || this; + _this.key = key; + _this.value = value; + return _this; + } + return struct_type_map; + }(prog.struct_type)); + prog.struct_type_map = struct_type_map; + })(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_type_record = /** @class */ (function (_super) { + __extends(struct_type_record, _super); + function struct_type_record(fields) { + var _this = _super.call(this) || this; + _this.fields = fields; + return _this; + } + return struct_type_record; + }(prog.struct_type)); + prog.struct_type_record = struct_type_record; + })(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_type_function = /** @class */ (function (_super) { + __extends(struct_type_function, _super); + function struct_type_function() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_function; + }(prog.struct_type)); + prog.struct_type_function = struct_type_function; + })(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_type_construction = /** @class */ (function (_super) { + __extends(struct_type_construction, _super); + function struct_type_construction(name, arguments_) { + var _this = _super.call(this) || this; + _this.name = name; + _this.arguments = arguments_; + return _this; + } + return struct_type_construction; + }(prog.struct_type)); + prog.struct_type_construction = struct_type_construction; + })(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_type_union = /** @class */ (function (_super) { + __extends(struct_type_union, _super); + function struct_type_union(left, right) { + var _this = _super.call(this) || this; + _this.left = left; + _this.right = right; + return _this; + } + return struct_type_union; + }(prog.struct_type)); + prog.struct_type_union = struct_type_union; + })(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_type_intersection = /** @class */ (function (_super) { + __extends(struct_type_intersection, _super); + function struct_type_intersection() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_intersection; + }(prog.struct_type)); + prog.struct_type_intersection = struct_type_intersection; + })(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_statement = /** @class */ (function () { + function struct_statement() { + } + return struct_statement; + }()); + prog.struct_statement = struct_statement; + })(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_statement_type_definition = /** @class */ (function (_super) { + __extends(struct_statement_type_definition, _super); + function struct_statement_type_definition(name, type) { + var _this = _super.call(this) || this; + _this.name = name; + _this.type = type; + return _this; + } + return struct_statement_type_definition; + }(prog.struct_statement)); + prog.struct_statement_type_definition = struct_statement_type_definition; + })(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_statement_declaration = /** @class */ (function (_super) { + __extends(struct_statement_declaration, _super); + function struct_statement_declaration(constant, name, type, value) { + var _this = _super.call(this) || this; + _this.constant = constant; + _this.name = name; + _this.type = type; + _this.value = value; + return _this; + } + return struct_statement_declaration; + }(prog.struct_statement)); + prog.struct_statement_declaration = struct_statement_declaration; + })(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_statement_assignment = /** @class */ (function (_super) { + __extends(struct_statement_assignment, _super); + function struct_statement_assignment() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_statement_assignment; + }(prog.struct_statement)); + prog.struct_statement_assignment = struct_statement_assignment; + })(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_program = /** @class */ (function () { + function struct_program(statements) { + this.statements = statements; + } + return struct_program; + }()); + prog.struct_program = struct_program; + })(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 . + */ +/* +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) { + /** + */ + function render_expression(expression) { + if (expression instanceof prog.struct_expression_variable) { + var expression_variable = expression; + return expression.name; + } + else if (expression instanceof prog.struct_expression_literal) { + var expression_literal = expression; + return JSON.stringify(expression_literal.value); + } + else if (expression instanceof prog.struct_expression_function_application) { + var expression_function_application = expression; + return lib_plankton.string.coin("{{name}}({{arguments}})", { + "name": render_expression(expression_function_application.head), + "arguments": (expression_function_application.arguments + .map(function (argument) { return render_expression(argument); }) + .join(", ")) + }); + } + else if (expression instanceof prog.struct_expression_operation_comparison) { + var expression_operation_comparison = expression; + return lib_plankton.string.coin("({{left}} === {{right}})", { + "left": render_expression(expression_operation_comparison.left), + "right": render_expression(expression_operation_comparison.right) + }); + } + else { + throw (new Error("unhandled expression: " + String(expression))); + } + } + prog.render_expression = render_expression; + /** + */ + function render_type(type) { + if (type instanceof prog.struct_type_literal) { + var type_literal = type; + return render_expression(type_literal.value); + } + else if (type instanceof prog.struct_type_boolean) { + var type_boolean = type; + return "boolean"; + } + else if (type instanceof prog.struct_type_integer) { + var type_integer = type; + return "number"; + } + else if (type instanceof prog.struct_type_string) { + var type_string = type; + return "string"; + } + else if (type instanceof prog.struct_type_list) { + var type_list = type; + return lib_plankton.string.coin("Array<{{element}}>", { + "element": render_type(type_list.element) + }); + } + else if (type instanceof prog.struct_type_map) { + var type_map = type; + return lib_plankton.string.coin("Record<{{key}}, {{value}}>", { + "key": render_type(type_map.key), + "value": render_type(type_map.value) + }); + } + else if (type instanceof prog.struct_type_record) { + var type_record = type; + return lib_plankton.string.coin("{{{fields}}}", { + "fields": (type_record.fields + .map(function (field) { return lib_plankton.string.coin("{{name}} {{assignment}} {{type}}", { + "name": field.name, + "assignment": (field.mandatory ? ":" : "?:"), + "type": render_type(field.type) + }); }) + .join("; ")) + }); + } + else if (type instanceof prog.struct_type_function) { + var type_function = type; + return lib_plankton.string.coin("(({{arguments}}) => {{target}})", { + "arguments": (type_function.arguments + .map(function (argument) { return render_type(argument); }) + .join(", ")), + "target": render_type(type_function.target) + }); + } + else if (type instanceof prog.struct_type_construction) { + var type_construction = type; + return lib_plankton.string.coin("{{name}}{{macro_arguments}}", { + "name": type_construction.name, + "macro_arguments": ((type_construction.arguments === null) + ? "" + : lib_plankton.string.coin("<{{arguments}}>", { + "arguments": (type_construction.arguments + .map(function (argument) { return render_type(argument); }) + .join(", ")) + })) + }); + } + else if (type instanceof prog.struct_type_union) { + var type_union = type; + return lib_plankton.string.coin("({{left}} | {{right}}", { + "left": render_type(type_union.left), + "right": render_type(type_union.right) + }); + } + else if (type instanceof prog.struct_type_intersection) { + var type_intersection = type; + return lib_plankton.string.coin("({{left}} | {{right}}", { + "left": render_type(type_intersection.left), + "right": render_type(type_intersection.right) + }); + } + else { + throw (new Error("unhandled type kind: " + String(type))); + } + } + prog.render_type = render_type; + /** + */ + function render_statement(statement) { + if (statement instanceof prog.struct_statement_type_definition) { + var statement_type_definition = statement; + return lib_plankton.string.coin("type {{name}} = {{type}};\n", { + "name": statement_type_definition.name, + "type": render_type(statement_type_definition.type) + }); + } + if (statement instanceof prog.struct_statement_declaration) { + var statement_declaration = statement; + return lib_plankton.string.coin("{{kind}} {{name}}{{macro_type}}{{macro_value}};\n", { + "kind": (statement_declaration.constant + ? "const" + : "let"), + "name": statement_declaration.name, + "macro_type": ((statement_declaration.type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(statement_declaration.type) + })), + "macro_value": ((statement_declaration.value === null) + ? "" + : lib_plankton.string.coin(" = {{value}}", { + "value": render_expression(statement_declaration.value) + })) + }); + } + if (statement instanceof prog.struct_statement_assignment) { + var statement_assignment = statement; + return lib_plankton.string.coin("{{name}} = {{value}};\n", { + "name": statement_assignment.name, + "value": render_expression(statement_assignment.value) + }); + } + else { + throw (new Error("unhandled statement: " + String(statement))); + } + } + prog.render_statement = render_statement; + /** + */ + function render_program(program) { + return (program.statements + .map(function (statement) { return render_statement(statement); }) + .join("")); + } + prog.render_program = render_program; + /** + */ + function output_typescript() { + return { + "render_expression": render_expression, + "render_type": render_type, + "render_statement": render_statement, + "render_program": render_program + }; + } + prog.output_typescript = output_typescript; + })(prog = lib_plankton.prog || (lib_plankton.prog = {})); +})(lib_plankton || (lib_plankton = {})); /* This file is part of »bacterio-plankton:args«. @@ -2949,8 +3981,8 @@ var lib_plankton; "info": info, "hidden": hidden, "parameters": { - "index": index, - }, + "index": index + } })); }; /** @@ -2968,8 +4000,8 @@ var lib_plankton; "hidden": hidden, "parameters": { "indicators_short": indicators_short, - "indicators_long": indicators_long, - }, + "indicators_long": indicators_long + } })); }; /** @@ -3215,17 +4247,17 @@ var lib_plankton; "symbols": { "delimiter": " ", "prefix": "--", - "assignment": "=", - }, + "assignment": "=" + } }, "url": { "symbols": { "delimiter": "&", "prefix": "", - "assignment": "=", + "assignment": "=" } } - }, + } }; /** * @author fenris @@ -3302,14 +4334,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 @@ -3320,18 +4352,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 = ""; { @@ -3350,12 +4382,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 @@ -3369,7 +4401,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++) { @@ -3380,7 +4412,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 = ""; { @@ -3389,12 +4421,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; @@ -3411,7 +4443,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 }); } }); diff --git a/tools/get-plankton b/tools/get-plankton index 673b026..2c286ca 100755 --- a/tools/get-plankton +++ b/tools/get-plankton @@ -6,6 +6,7 @@ modules="${modules} base" modules="${modules} string" modules="${modules} json" modules="${modules} file" +modules="${modules} prog" modules="${modules} args" mkdir -p lib/plankton From e25cb5915b12fcb3885f21f62b201bd058ea2c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Tue, 11 Jul 2023 20:40:04 +0200 Subject: [PATCH 2/4] [fix] makefile --- tools/makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/makefile b/tools/makefile index 148b489..db02ea5 100644 --- a/tools/makefile +++ b/tools/makefile @@ -5,6 +5,7 @@ cmd_typescript_compile := tsc cmd_concatenate := cat cmd_chmod := chmod cmd_echo := echo -e +cmd_echox := echo cmd_log := echo -e "--" @@ -29,7 +30,7 @@ source/main.ts build/sindri: lib/plankton/plankton.js temp/sindri-unlinked.js @ ${cmd_log} "linking …" @ ${cmd_create_directory} build - @ ${cmd_echo} "#!/usr/bin/env node\n" > temp/head.js + @ ${cmd_echox} "#!/usr/bin/env node\n" > temp/head.js @ ${cmd_concatenate} temp/head.js $^ > $@ @ ${cmd_chmod} +x $@ From ed4c81def097467988d4984732773dda549561b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Tue, 11 Jul 2023 20:40:12 +0200 Subject: [PATCH 3/4] [mod] output:typescript --- source/outputs/typescript.ts | 122 ++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 59 deletions(-) diff --git a/source/outputs/typescript.ts b/source/outputs/typescript.ts index a7af22b..3887bc5 100644 --- a/source/outputs/typescript.ts +++ b/source/outputs/typescript.ts @@ -1,73 +1,77 @@ const output_typescript : type_output = { "render": function (input_data) { - return ( - input_data["domains"] - .map( - (domain) => lib_plankton.string.coin( - "type type_{{name}} = {\n{{fields}}\n};\nlet collection_{{name}} : {{collection_type}} = {{collection_value}};\n", - { - "name": domain.name, - "fields": ( - domain.data_fields - .map( - (data_field) => lib_plankton.string.coin( - "\t{{name}} : {{type}};{{macro_comment}}", - { + const map_primitive_type = function (typename : string) : lib_plankton.prog.struct_type { + const mymap : Record = { + "boolean": new lib_plankton.prog.struct_type_boolean(), + "integer": new lib_plankton.prog.struct_type_integer(), + // "float": new lib_plankton.prog.struct_type_integer(), + "string_short": new lib_plankton.prog.struct_type_string(), + "string_medium": new lib_plankton.prog.struct_type_string(), + "string_long": new lib_plankton.prog.struct_type_string(), + }; + return mymap[typename]; + }; + const name_type : string = ("type_" + domain.name); + const name_collection : string = ("collection_" + domain.name); + const prog_output : lib_plankton.prog.type_output = lib_plankton.prog.output_typescript(); + return prog_output.render_program( + new lib_plankton.prog.struct_program( + input_data["domains"] + .map( + (domain) => ([ + new lib_plankton.prog.struct_statement_type_definition( + name_type, + new lib_plankton.prog.struct_type_record( + domain.data_fields + .map( + (data_field) => ({ "name": data_field.name, - "type": lib_plankton.string.coin( - (data_field.nullable ? "(null | {{core}})" : "{{core}}"), - { - "core": { - "boolean": "boolean", - "integer": "number", - "float": "number", - "string_short": "string", - "string_medium": "string", - "string_long": "string", - }[data_field["type"]], - } - ), - "macro_comment": ( - (data_field.description !== null) - ? lib_plankton.string.coin( - " // {{comment}}", - { - "comment": data_field.description, - } + "type": ( + data_field.nullable + ? new lib_plankton.prog.struct_type_union( + new lib_plankton.prog.struct_type_literal( + new lib_plankton.prog.struct_expression_literal( + null + ) + ), + map_primitive_type(data_field["type"]) ) - : "" + : map_primitive_type(data_field["type"]) ), - } + "mandatory": true, + }) ) ) - // .map(x => ("\t" + x)) - .join("\n") ), - "collection_type": ( - (domain.key_field === null) - ? lib_plankton.string.coin( - "Array", - { - "name": domain.name, - } + new lib_plankton.prog.struct_statement_declaration( + false, + name_collection, + ( + (domain.key_field === null) + ? new lib_plankton.prog.struct_type_list( + new lib_plankton.prog.struct_type_construction( + name_type, + null + ) + ) + : new lib_plankton.prog.struct_type_map( + new lib_plankton.prog.struct_type_integer(), + new lib_plankton.prog.struct_type_construction( + name_type, + null + ) + ) + ), + ( + (domain.key_field === null) + ? new lib_plankton.prog.struct_expression_literal([]) + : new lib_plankton.prog.struct_expression_literal({}) ) - : lib_plankton.string.coin( - "Record", - { - "name": domain.name, - } - ) - ), - "collection_value": ( - (domain.key_field === null) - ? "[]" - : "{}" - ), - } + ) + ]) ) + .reduce((x, y) => x.concat(y), []) ) - .map(x => (x + "\n")) - .join("\n") ); }, }; From cf1d5b65c35fd210fae421469d18648543f26eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Sun, 23 Jul 2023 14:55:32 +0200 Subject: [PATCH 4/4] [int] --- doc/examples/calendar.sindri.json | 142 +++++++++ doc/sindri.schema.json | 2 +- lib/plankton/plankton.d.ts | 35 ++- lib/plankton/plankton.js | 169 ++++++++++- source/main.ts | 8 +- source/outputs/backend_typescript.ts | 280 ++++++++++++++++++ .../outputs/{mysql.ts => database_mysql.ts} | 6 +- .../outputs/{sqlite.ts => database_sqlite.ts} | 6 +- source/outputs/typescript.ts | 77 ----- tools/makefile | 6 +- 10 files changed, 632 insertions(+), 99 deletions(-) create mode 100644 doc/examples/calendar.sindri.json create mode 100644 source/outputs/backend_typescript.ts rename source/outputs/{mysql.ts => database_mysql.ts} (96%) rename source/outputs/{sqlite.ts => database_sqlite.ts} (95%) delete mode 100644 source/outputs/typescript.ts diff --git a/doc/examples/calendar.sindri.json b/doc/examples/calendar.sindri.json new file mode 100644 index 0000000..84aaf25 --- /dev/null +++ b/doc/examples/calendar.sindri.json @@ -0,0 +1,142 @@ +{ + "domains": [ + { + "name": "calendar", + "key_field": { + "name": "id" + }, + "data_fields": [ + { + "name": "name", + "nullable": false, + "type": "string_short" + }, + { + "name": "description", + "nullable": true, + "type": "string_long" + }, + { + "name": "color", + "nullable": true, + "type": "string_short" + } + ] + }, + { + "name": "calendar_appointment", + "key_field": { + "name": "id" + }, + "data_fields": [ + { + "name": "calendar_id", + "nullable": false, + "type": "integer" + }, + { + "name": "title", + "nullable": false, + "type": "string_short" + }, + { + "name": "description", + "nullable": true, + "type": "string_long" + }, + { + "name": "location", + "nullable": true, + "type": "string_short" + }, + { + "name": "begin", + "description": "UNIX timestamp", + "nullable": false, + "type": "integer" + }, + { + "name": "end", + "description": "UNIX timestamp", + "nullable": true, + "type": "integer" + }, + { + "name": "contact", + "nullable": true, + "type": "string_short" + } + ], + "constraints": [ + { + "kind": "foreign_key", + "parameters": { + "fields": [ + "calendar_id" + ], + "reference": { + "name": "calendar", + "fields": [ + "id" + ] + } + } + } + ] + }, + { + "name": "organization", + "key_field": { + "name": "id" + }, + "data_fields": [ + ] + }, + { + "name": "organization_calendars", + "data_fields": [ + { + "name": "organization_id", + "nullable": false, + "type": "integer" + }, + { + "name": "calendar_id", + "nullable": false, + "type": "integer" + } + ], + "constraints": [ + { + "kind": "foreign_key", + "parameters": { + "fields": [ + "organization_id" + ], + "reference": { + "name": "organization", + "fields": [ + "id" + ] + } + } + }, + { + "kind": "foreign_key", + "parameters": { + "fields": [ + "calendar_id" + ], + "reference": { + "name": "calendar", + "fields": [ + "id" + ] + } + } + } + ] + } + ] +} + diff --git a/doc/sindri.schema.json b/doc/sindri.schema.json index 12b5c80..08f529d 100644 --- a/doc/sindri.schema.json +++ b/doc/sindri.schema.json @@ -126,4 +126,4 @@ "required": [ "domains" ] -} \ No newline at end of file +} diff --git a/lib/plankton/plankton.d.ts b/lib/plankton/plankton.d.ts index 7f1bf51..32d9f01 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -979,6 +979,12 @@ declare namespace lib_plankton.prog { constructor(value: struct_expression); } } +declare namespace lib_plankton.prog { + /** + */ + class struct_type_void extends struct_type { + } +} declare namespace lib_plankton.prog { /** */ @@ -1099,6 +1105,31 @@ declare namespace lib_plankton.prog { value: (null | struct_expression); } } +declare namespace lib_plankton.prog { + /** + */ + class struct_statement_function_definition extends struct_statement { + name: string; + arguments: Array<{ + name: string; + type: (null | struct_type); + }>; + output_type: (null | struct_type); + body: struct_statement; + constructor(name: string, arguments_: Array<{ + name: string; + type: (null | struct_type); + }>, output_type: (null | struct_type), body: struct_statement); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_statement_return extends struct_statement { + expression: struct_expression; + constructor(expression: struct_expression); + } +} declare namespace lib_plankton.prog { /** */ @@ -1126,7 +1157,9 @@ declare namespace lib_plankton.prog { function render_type(type: struct_type): string; /** */ - function render_statement(statement: struct_statement): string; + function render_statement(statement: struct_statement, options?: { + indentation?: int; + }): string; /** */ function render_program(program: struct_program): string; diff --git a/lib/plankton/plankton.js b/lib/plankton/plankton.js index 780aa43..8260d1e 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -3110,6 +3110,41 @@ 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_type_void = /** @class */ (function (_super) { + __extends(struct_type_void, _super); + function struct_type_void() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_void; + }(prog.struct_type)); + prog.struct_type_void = struct_type_void; + })(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 . */ @@ -3619,6 +3654,83 @@ 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_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; + _this.name = name; + _this.arguments = arguments_; + _this.output_type = output_type; + _this.body = body; + return _this; + } + return struct_statement_function_definition; + }(prog.struct_statement)); + prog.struct_statement_function_definition = struct_statement_function_definition; + })(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_statement_return = /** @class */ (function (_super) { + __extends(struct_statement_return, _super); + function struct_statement_return(expression) { + var _this = _super.call(this) || this; + _this.expression = expression; + return _this; + } + return struct_statement_return; + }(prog.struct_statement)); + prog.struct_statement_return = struct_statement_return; + })(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 . */ @@ -3718,6 +3830,10 @@ var lib_plankton; var type_literal = type; return render_expression(type_literal.value); } + else if (type instanceof prog.struct_type_void) { + var type_void = type; + return "void"; + } else if (type instanceof prog.struct_type_boolean) { var type_boolean = type; return "boolean"; @@ -3798,17 +3914,23 @@ var lib_plankton; prog.render_type = render_type; /** */ - function render_statement(statement) { + function render_statement(statement, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "indentation": 0 + }, options); if (statement instanceof prog.struct_statement_type_definition) { var statement_type_definition = statement; - return lib_plankton.string.coin("type {{name}} = {{type}};\n", { + return lib_plankton.string.coin("{{indentation}}type {{name}} = {{type}};\n", { + "indentation": "\t".repeat(options.indentation), "name": statement_type_definition.name, "type": render_type(statement_type_definition.type) }); } - if (statement instanceof prog.struct_statement_declaration) { + else if (statement instanceof prog.struct_statement_declaration) { var statement_declaration = statement; - return lib_plankton.string.coin("{{kind}} {{name}}{{macro_type}}{{macro_value}};\n", { + return lib_plankton.string.coin("{{indentation}}{{kind}} {{name}}{{macro_type}}{{macro_value}};\n", { + "indentation": "\t".repeat(options.indentation), "kind": (statement_declaration.constant ? "const" : "let"), @@ -3825,13 +3947,46 @@ var lib_plankton; })) }); } - if (statement instanceof prog.struct_statement_assignment) { + else if (statement instanceof prog.struct_statement_assignment) { var statement_assignment = statement; - return lib_plankton.string.coin("{{name}} = {{value}};\n", { + return lib_plankton.string.coin("{{indentation}}{{name}} = {{value}};\n", { + "indentation": "\t".repeat(options.indentation), "name": statement_assignment.name, "value": render_expression(statement_assignment.value) }); } + else if (statement instanceof prog.struct_statement_function_definition) { + var statement_function_definition = statement; + return lib_plankton.string.coin("{{indentation}}function {{name}}({{arguments}}){{macro_output_type}} {\n{{body}}}\n", { + "indentation": "\t".repeat(options.indentation), + "name": statement_function_definition.name, + "arguments": (statement_function_definition.arguments + .map(function (argument) { return lib_plankton.string.coin("{{name}}{{macro_type}}", { + "name": argument.name, + "macro_type": ((argument.type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(argument.type) + })) + }); }) + .join(", ")), + "macro_output_type": ((statement_function_definition.output_type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(statement_function_definition.output_type) + })), + "body": render_statement(statement_function_definition.body, { + "indentation": (options.indentation + 1) + }) + }); + } + else if (statement instanceof prog.struct_statement_return) { + var statement_return = statement; + return lib_plankton.string.coin("{{indentation}}return {{expression}};\n", { + "indentation": "\t".repeat(options.indentation), + "expression": render_expression(statement_return.expression) + }); + } else { throw (new Error("unhandled statement: " + String(statement))); } @@ -3842,7 +3997,7 @@ var lib_plankton; function render_program(program) { return (program.statements .map(function (statement) { return render_statement(statement); }) - .join("")); + .join("\n")); } prog.render_program = render_program; /** diff --git a/source/main.ts b/source/main.ts index 4a757ef..5aaa8ae 100644 --- a/source/main.ts +++ b/source/main.ts @@ -5,10 +5,10 @@ async function main( ) : Promise { const outputs : Record = { - "sqlite": output_sqlite, - "mysql": output_mysql, - "typescript": output_typescript, "jsonschema": output_jsonschema, + "database-sqlite": output_database_sqlite, + "database-mysql": output_database_mysql, + "backend-typescript": output_backend_typescript, }; const arg_handler = new lib_plankton.args.class_handler( @@ -18,7 +18,7 @@ async function main( "type": lib_plankton.args.enum_type.string, "kind": lib_plankton.args.enum_kind.volatile, "mode": lib_plankton.args.enum_mode.replace, - "default": "sqlite", + "default": "database-sqlite", "parameters": { "indicators_long": ["format"], "indicators_short": ["f"], diff --git a/source/outputs/backend_typescript.ts b/source/outputs/backend_typescript.ts new file mode 100644 index 0000000..053c959 --- /dev/null +++ b/source/outputs/backend_typescript.ts @@ -0,0 +1,280 @@ +const output_backend_typescript : type_output = { + "render": function (input_data) { + const map_primitive_type = function (typename : string) : lib_plankton.prog.struct_type { + const mymap : Record = { + "boolean": new lib_plankton.prog.struct_type_boolean(), + "integer": new lib_plankton.prog.struct_type_integer(), + // "float": new lib_plankton.prog.struct_type_integer(), + "string_short": new lib_plankton.prog.struct_type_string(), + "string_medium": new lib_plankton.prog.struct_type_string(), + "string_long": new lib_plankton.prog.struct_type_string(), + }; + return mymap[typename]; + }; + const prog_output : lib_plankton.prog.type_output = lib_plankton.prog.output_typescript(); + const name_type = function (domain) : string {return ("type_" + domain.name);}; + const name_collection = function (domain) : string {return ("collection_" + domain.name);}; + const name_repository_function_list = function (domain) : string { + return lib_plankton.string.coin( + "repository_{{name}}_list", + { + "name": domain.name + } + ); + }; + const name_repository_function_read = function (domain) : string { + return lib_plankton.string.coin( + "repository_{{name}}_read", + { + "name": domain.name + } + ); + }; + const name_repository_function_create = function (domain) : string { + return lib_plankton.string.coin( + "repository_{{name}}_create", + { + "name": domain.name + } + ); + }; + const name_repository_function_update = function (domain) : string { + return lib_plankton.string.coin( + "repository_{{name}}_update", + { + "name": domain.name + } + ); + }; + const name_repository_function_delete = function (domain) : string { + return lib_plankton.string.coin( + "repository_{{name}}_delete", + { + "name": domain.name + } + ); + }; + return prog_output.render_program( + new lib_plankton.prog.struct_program( + [] + // base + .concat( + [] + ) + // lib (database) + .concat( + [] + ) + // entities + .concat( + input_data["domains"] + .map( + (domain) => new lib_plankton.prog.struct_statement_type_definition( + name_type(domain), + new lib_plankton.prog.struct_type_record( + domain.data_fields + .map( + (data_field) => ({ + "name": data_field.name, + "type": ( + data_field.nullable + ? new lib_plankton.prog.struct_type_union( + new lib_plankton.prog.struct_type_literal( + new lib_plankton.prog.struct_expression_literal( + null + ) + ), + map_primitive_type(data_field["type"]) + ) + : map_primitive_type(data_field["type"]) + ), + "mandatory": true, + }) + ) + ) + ) + ) + ) + // repositories + .concat( + input_data["domains"] + .map( + (domain) => ( + (domain.key_field === null) + ? [ + // TODO + ] + : [ + /* + // data + new lib_plankton.prog.struct_statement_declaration( + false, + name_collection(domain), + ( + (domain.key_field === null) + ? new lib_plankton.prog.struct_type_list( + new lib_plankton.prog.struct_type_construction( + name_type(domain), + null + ) + ) + : new lib_plankton.prog.struct_type_map( + new lib_plankton.prog.struct_type_integer(), + new lib_plankton.prog.struct_type_construction( + name_type(domain), + null + ) + ) + ), + ( + (domain.key_field === null) + ? new lib_plankton.prog.struct_expression_literal([]) + : new lib_plankton.prog.struct_expression_literal({}) + ) + ), + */ + // list + new lib_plankton.prog.struct_statement_function_definition( + name_repository_function_list(domain), + [], + new lib_plankton.prog.struct_type_construction( + "Promise", + [ + new lib_plankton.prog.struct_type_construction( + "Array", + [ + new lib_plankton.prog.struct_type_construction( + name_type(domain), + null + ), + ] + ) + ] + ), + new lib_plankton.prog.struct_statement_return( + // TODO + new lib_plankton.prog.struct_expression_literal(null) + ), + ), + // read + new lib_plankton.prog.struct_statement_function_definition( + name_repository_function_read(domain), + [ + { + "name": "key", + "type": new lib_plankton.prog.struct_type_integer( + ), + }, + ], + new lib_plankton.prog.struct_type_construction( + "Promise", + [ + new lib_plankton.prog.struct_type_construction( + name_type(domain), + null + ), + ] + ), + new lib_plankton.prog.struct_statement_return( + // TODO + new lib_plankton.prog.struct_expression_literal(null) + ), + ), + // create + new lib_plankton.prog.struct_statement_function_definition( + name_repository_function_create(domain), + [ + { + "name": "value", + "type": new lib_plankton.prog.struct_type_construction( + name_type(domain), + null + ), + }, + ], + new lib_plankton.prog.struct_type_construction( + "Promise", + [ + new lib_plankton.prog.struct_type_integer( + ), + ] + ), + new lib_plankton.prog.struct_statement_return( + // TODO + new lib_plankton.prog.struct_expression_literal(null) + ), + ), + // update + new lib_plankton.prog.struct_statement_function_definition( + name_repository_function_update(domain), + [ + { + "name": "key", + "type": new lib_plankton.prog.struct_type_integer( + ), + }, + { + "name": "value", + "type": new lib_plankton.prog.struct_type_construction( + name_type(domain), + null + ), + }, + ], + new lib_plankton.prog.struct_type_construction( + "Promise", + [ + new lib_plankton.prog.struct_type_void( + ), + ] + ), + new lib_plankton.prog.struct_statement_return( + // TODO + new lib_plankton.prog.struct_expression_literal(null) + ), + ), + // delete + new lib_plankton.prog.struct_statement_function_definition( + name_repository_function_delete(domain), + [ + { + "name": "key", + "type": new lib_plankton.prog.struct_type_integer( + ), + }, + ], + new lib_plankton.prog.struct_type_construction( + "Promise", + [ + new lib_plankton.prog.struct_type_void(), + ] + ), + new lib_plankton.prog.struct_statement_return( + // TODO + new lib_plankton.prog.struct_expression_literal(null) + ), + ), + ] + ) + ) + .reduce( + (x, y) => x.concat(y), + [] + ) + ) + // services + .concat( + [] + ) + // api + .concat( + [] + ) + // server + .concat( + [] + ) + ) + ); + }, +}; diff --git a/source/outputs/mysql.ts b/source/outputs/database_mysql.ts similarity index 96% rename from source/outputs/mysql.ts rename to source/outputs/database_mysql.ts index 6c8639d..9f6b354 100644 --- a/source/outputs/mysql.ts +++ b/source/outputs/database_mysql.ts @@ -1,4 +1,4 @@ -function mysql_value_encode( +function database_mysql_value_encode( value : any ) : string { @@ -27,7 +27,7 @@ function mysql_value_encode( } } -const output_mysql : type_output = { +const output_database_mysql : type_output = { "render": function (input_data) { return ( input_data.domains @@ -114,7 +114,7 @@ const output_mysql : type_output = { lib_plankton.string.coin( "DEFAULT {{value}}", { - "value": mysql_value_encode(data_field.default), + "value": database_mysql_value_encode(data_field.default), } ), ] diff --git a/source/outputs/sqlite.ts b/source/outputs/database_sqlite.ts similarity index 95% rename from source/outputs/sqlite.ts rename to source/outputs/database_sqlite.ts index 334420a..b13877b 100644 --- a/source/outputs/sqlite.ts +++ b/source/outputs/database_sqlite.ts @@ -1,4 +1,4 @@ -function sqlite_value_encode( +function database_sqlite_value_encode( value : any ) : string { @@ -27,7 +27,7 @@ function sqlite_value_encode( } } -const output_sqlite : type_output = { +const output_database_sqlite : type_output = { "render": function (input_data) { return ( input_data["domains"] @@ -92,7 +92,7 @@ const output_sqlite : type_output = { lib_plankton.string.coin( "DEFAULT {{value}}", { - "value": sqlite_value_encode(data_field.default), + "value": database_sqlite_value_encode(data_field.default), } ), ] diff --git a/source/outputs/typescript.ts b/source/outputs/typescript.ts deleted file mode 100644 index 3887bc5..0000000 --- a/source/outputs/typescript.ts +++ /dev/null @@ -1,77 +0,0 @@ -const output_typescript : type_output = { - "render": function (input_data) { - const map_primitive_type = function (typename : string) : lib_plankton.prog.struct_type { - const mymap : Record = { - "boolean": new lib_plankton.prog.struct_type_boolean(), - "integer": new lib_plankton.prog.struct_type_integer(), - // "float": new lib_plankton.prog.struct_type_integer(), - "string_short": new lib_plankton.prog.struct_type_string(), - "string_medium": new lib_plankton.prog.struct_type_string(), - "string_long": new lib_plankton.prog.struct_type_string(), - }; - return mymap[typename]; - }; - const name_type : string = ("type_" + domain.name); - const name_collection : string = ("collection_" + domain.name); - const prog_output : lib_plankton.prog.type_output = lib_plankton.prog.output_typescript(); - return prog_output.render_program( - new lib_plankton.prog.struct_program( - input_data["domains"] - .map( - (domain) => ([ - new lib_plankton.prog.struct_statement_type_definition( - name_type, - new lib_plankton.prog.struct_type_record( - domain.data_fields - .map( - (data_field) => ({ - "name": data_field.name, - "type": ( - data_field.nullable - ? new lib_plankton.prog.struct_type_union( - new lib_plankton.prog.struct_type_literal( - new lib_plankton.prog.struct_expression_literal( - null - ) - ), - map_primitive_type(data_field["type"]) - ) - : map_primitive_type(data_field["type"]) - ), - "mandatory": true, - }) - ) - ) - ), - new lib_plankton.prog.struct_statement_declaration( - false, - name_collection, - ( - (domain.key_field === null) - ? new lib_plankton.prog.struct_type_list( - new lib_plankton.prog.struct_type_construction( - name_type, - null - ) - ) - : new lib_plankton.prog.struct_type_map( - new lib_plankton.prog.struct_type_integer(), - new lib_plankton.prog.struct_type_construction( - name_type, - null - ) - ) - ), - ( - (domain.key_field === null) - ? new lib_plankton.prog.struct_expression_literal([]) - : new lib_plankton.prog.struct_expression_literal({}) - ) - ) - ]) - ) - .reduce((x, y) => x.concat(y), []) - ) - ); - }, -}; diff --git a/tools/makefile b/tools/makefile index db02ea5..75cd6ec 100644 --- a/tools/makefile +++ b/tools/makefile @@ -17,10 +17,10 @@ all: build/sindri temp/sindri-unlinked.js: \ lib/plankton/plankton.d.ts \ source/types.ts \ -source/outputs/sqlite.ts \ -source/outputs/mysql.ts \ -source/outputs/typescript.ts \ source/outputs/jsonschema.ts \ +source/outputs/database_sqlite.ts \ +source/outputs/database_mysql.ts \ +source/outputs/backend_typescript.ts \ source/conf.ts \ source/main.ts @ ${cmd_log} "compiling …"