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 ffc5761..0a02167 100644 --- a/lib/plankton/plankton.d.ts +++ b/lib/plankton/plankton.d.ts @@ -925,6 +925,318 @@ 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 { + /** + */ + 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_any extends struct_type { + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_type_void extends struct_type { + } +} +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_block extends struct_statement { + statements: Array; + constructor(statements: Array); + } +} +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); + constructor(name: string, 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: Array; + constructor(name: string, arguments_: Array<{ + name: string; + type: (null | struct_type); + }>, output_type: (null | struct_type), body: Array); + } +} +declare namespace lib_plankton.prog { + /** + */ + class struct_statement_return extends struct_statement { + expression: struct_expression; + constructor(expression: 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_type(type: struct_type, options?: { + indent?: boolean; + level?: int; + }): string; + /** + */ + function render_expression(expression: struct_expression, options?: { + indent?: boolean; + level?: int; + }): string; + /** + */ + function render_statement(statement: struct_statement, options?: { + indent?: boolean; + level?: int; + }): 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..40a9389 100644 --- a/lib/plankton/plankton.js +++ b/lib/plankton/plankton.js @@ -2826,6 +2826,1604 @@ 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_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 . + */ +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_any = /** @class */ (function (_super) { + __extends(struct_type_any, _super); + function struct_type_any() { + return _super !== null && _super.apply(this, arguments) || this; + } + return struct_type_any; + }(prog.struct_type)); + prog.struct_type_any = struct_type_any; + })(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_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 . + */ +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_block = /** @class */ (function (_super) { + __extends(struct_statement_block, _super); + function struct_statement_block(statements) { + var _this = _super.call(this) || this; + _this.statements = statements; + return _this; + } + return struct_statement_block; + }(prog.struct_statement)); + prog.struct_statement_block = struct_statement_block; + })(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(name, value) { + var _this = _super.call(this) || this; + _this.name = name; + _this.value = value; + return _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_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 . + */ +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 indentation(active, level) { + return (active + ? "\t".repeat(level) + : ""); + } + /** + */ + function render_type(type, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "indent": true, + "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), + }), + }); + } + 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), + }); + } + 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), + }); + } + 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), + }); + } + 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), + }); + } + 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), + }); + } + else if (type instanceof prog.struct_type_list) { + var type_list = type; + return render_type(new prog.struct_type_construction("Array", [ + type_list.element, + ])); + } + else if (type instanceof prog.struct_type_map) { + var type_map = type; + return render_type(new prog.struct_type_construction("Record", [ + type_map.key, + type_map.value, + ])); + } + else if (type instanceof prog.struct_type_record) { + var type_record = type; + return lib_plankton.string.coin("{{indentation1}}{\n{{fields}}\n{{indentation2}}}", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "fields": (type_record.fields + .map(function (field) { return lib_plankton.string.coin("{{indentation}}{{name}} {{assignment}} {{type}}", { + "indentation": indentation(true, options.level + 1), + "name": field.name, + "assignment": (field.mandatory ? ":" : "?:"), + "type": render_type(field.type, { + "indent": false, + "level": (options.level + 1), + }), + }); }) + .join(";\n")), + }); + } + else if (type instanceof prog.struct_type_function) { + var type_function = type; + return lib_plankton.string.coin("{{indentation1}}(({{arguments}})\n{{indentation2}}=>\n{{target}})", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "arguments": (type_function.arguments + .map(function (argument) { return render_type(argument, { + "level": (options.level + 1), + }); }) + .join(", ")), + "target": render_type(type_function.target, { + "level": (options.level + 1), + }), + }); + } + else if (type instanceof prog.struct_type_construction) { + var type_construction = type; + return lib_plankton.string.coin("{{indentation}}{{name}}{{macro_arguments}}", { + "indentation": indentation(options.indent, options.level), + "name": type_construction.name, + "macro_arguments": ((type_construction.arguments === null) + ? "" + : lib_plankton.string.coin("<\n{{arguments}}\n{{indentation}}>", { + "indentation": indentation(true, options.level), + "arguments": (type_construction.arguments + .map(function (argument) { return render_type(argument, { + "level": (options.level + 1), + }); }) + .join(",\n")), + })), + }); + } + else if (type instanceof prog.struct_type_union) { + var type_union = type; + return lib_plankton.string.coin("{{indentation1}}(\n{{left}}\n{{indentation3}}|\n{{right}}\n{{indentation2}})", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "indentation3": indentation(true, options.level + 1), + "left": render_type(type_union.left, { + "level": (options.level + 1), + }), + "right": render_type(type_union.right, { + "level": (options.level + 1), + }), + }); + } + else if (type instanceof prog.struct_type_intersection) { + var type_intersection = type; + return lib_plankton.string.coin("{{indentation1}}(\n{{left}}\n{{indentation2}}&\n{{right}}\n{{indentation2}})", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level + 1), + "left": render_type(type_intersection.left, { + "level": (options.level + 1), + }), + "right": render_type(type_intersection.right, { + "level": (options.level + 1), + }), + }); + } + else { + throw (new Error("unhandled type kind: " + String(type))); + } + } + prog.render_type = render_type; + /** + */ + function render_expression(expression, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "indent": false, + "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, + }); + } + 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), + }); + } + else if (expression instanceof prog.struct_expression_dict) { + var expression_dict = expression; + return lib_plankton.string.coin("{{indentation1}}{\n{{fields}}\n{{indentation2}}}", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "fields": (expression_dict.fields + .map(function (field) { return lib_plankton.string.coin("{{indentation}}\"{{key}}\": {{value}}", { + "indentation": indentation(true, options.level + 1), + "key": field.key, + "value": render_expression(field.value, { + "indent": false, + "level": (options.level + 1), + }), + }); }) + .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}}}", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "arguments": (expression_abstraction.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": ((expression_abstraction.output_type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(expression_abstraction.output_type, { + "indent": false, + "level": (options.level + 1), + }) + })), + "body": (expression_abstraction.body + .map(function (statement) { return render_statement(statement, { + "level": (options.level + 1), + }); }) + .join("")), + }); + } + else if (expression instanceof prog.struct_expression_function_application) { + var expression_function_application = expression; + 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), + "arguments": (expression_function_application.arguments + .map(function (argument) { return lib_plankton.string.coin("{{argument}}", { + "argument": render_expression(argument, { + "indent": true, + "level": (options.level + 1), + }), + }); }) + .join(",\n")), + }); + } + else if (expression instanceof prog.struct_expression_projection) { + var expression_projection = expression; + 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), + }); + } + else if (expression instanceof prog.struct_expression_fieldaccess) { + var expression_fieldaccess = expression; + return lib_plankton.string.coin("{{structure}}.{{fieldname}}", { + "structure": render_expression(expression_fieldaccess.structure, { + "level": (options.level + 1), + }), + "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), + }); + } + else { + throw (new Error("unhandled expression: " + String(expression))); + } + } + prog.render_expression = render_expression; + /** + */ + function render_statement(statement, options) { + if (options === void 0) { options = {}; } + options = Object.assign({ + "indent": true, + "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), + }), + }); + } + else if (statement instanceof prog.struct_statement_block) { + var statement_block = statement; + return lib_plankton.string.coin("{{indentation}}{\n{{statements}}{{indentation}}}\n", { + "indentation": indentation(options.indent, options.level), + "statements": (statement_block.statements + .map(function (statement) { return render_statement(statement, { + "level": (options.level + 1), + }); }) + .join("")), + }); + } + else if (statement instanceof prog.struct_statement_declaration) { + var statement_declaration = statement; + return lib_plankton.string.coin("{{indentation}}{{kind}} {{name}}{{macro_type}}{{macro_value}};\n", { + "indentation": indentation(options.indent, options.level), + "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, { + "indent": false, + "level": (options.level + 1), + }), + })), + "macro_value": ((statement_declaration.value === null) + ? "" + : lib_plankton.string.coin(" = {{value}}", { + "value": render_expression(statement_declaration.value, { + "indent": false, + "level": (options.level + 1), + }), + })), + }); + } + else if (statement instanceof prog.struct_statement_assignment) { + var statement_assignment = statement; + return lib_plankton.string.coin("{{indentation}}{{name}} = {{value}};\n", { + "indentation": indentation(options.indent, options.level), + "name": statement_assignment.name, + "value": render_expression(statement_assignment.value, { + "indent": false, + "level": (options.level + 1), + }), + }); + } + 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", { + "indentation1": indentation(options.indent, options.level), + "indentation2": indentation(true, options.level), + "name": statement_function_definition.name, + "arguments": (statement_function_definition.arguments + .map(function (argument) { return lib_plankton.string.coin("{{indentation}}{{name}}{{macro_type}}", { + "indentation": indentation(true, (options.level + 1)), + "name": argument.name, + "macro_type": ((argument.type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(argument.type, { + "indent": false, + "level": (options.level + 2), + }) + })), + }); }) + .join(",\n")), + "macro_output_type": ((statement_function_definition.output_type === null) + ? "" + : lib_plankton.string.coin(" : {{type}}", { + "type": render_type(statement_function_definition.output_type, { + "indent": false, + "level": (options.level + 0), + }) + })), + "body": (statement_function_definition.body + .map(function (statement) { return render_statement(statement, { + "indent": true, + "level": (options.level + 1), + }); }) + .join("")), + }); + } + else if (statement instanceof prog.struct_statement_return) { + var statement_return = statement; + return lib_plankton.string.coin("{{indentation}}return {{expression}};\n", { + "indentation": indentation(options.indent, options.level), + "expression": render_expression(statement_return.expression, { + "indent": false, + "level": (options.level + 0), + }), + }); + } + 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, { + "indent": true, + "level": 0, + }); }) + .join("\n")); + } + 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«. diff --git a/source/main.ts b/source/main.ts index 0200958..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, - "backend-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..9cf3ebd --- /dev/null +++ b/source/outputs/backend_typescript.ts @@ -0,0 +1,646 @@ +namespace _sindri.outputs.backend.typescript +{ + + /** + */ + export function render( + input_data + ) : string + { + 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_table = function (domain) : string {return (domain.name);}; + 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( + [ + new lib_plankton.prog.struct_statement_function_definition( + "sql_query_get", + [ + { + "name": "template", + "type": new lib_plankton.prog.struct_type_string(), + }, + { + "name": "arguments", + "type": new lib_plankton.prog.struct_type_map( + new lib_plankton.prog.struct_type_string(), + new lib_plankton.prog.struct_type_any() + ), + } + ], + new lib_plankton.prog.struct_type_construction( + "Promise", + [ + new lib_plankton.prog.struct_type_construction( + "Array", + [ + new lib_plankton.prog.struct_type_construction( + "Record", + [ + new lib_plankton.prog.struct_type_string(), + new lib_plankton.prog.struct_type_any(), + ] + ) + ] + ), + ] + ), + [ + // TODO + new lib_plankton.prog.struct_statement_return( + new lib_plankton.prog.struct_expression_literal(null) + ), + ] + ), + new lib_plankton.prog.struct_statement_function_definition( + "sql_query_put", + [ + { + "name": "template", + "type": new lib_plankton.prog.struct_type_string(), + }, + { + "name": "arguments", + "type": new lib_plankton.prog.struct_type_map( + new lib_plankton.prog.struct_type_string(), + new lib_plankton.prog.struct_type_any() + ), + } + ], + new lib_plankton.prog.struct_type_construction( + "Promise", + [ + new lib_plankton.prog.struct_type_integer(), + ] + ), + [ + // TODO + new lib_plankton.prog.struct_statement_return( + new lib_plankton.prog.struct_expression_literal(null) + ), + ] + ), + new lib_plankton.prog.struct_statement_function_definition( + "sql_query_set", + [ + { + "name": "template", + "type": new lib_plankton.prog.struct_type_string(), + }, + { + "name": "arguments", + "type": new lib_plankton.prog.struct_type_map( + new lib_plankton.prog.struct_type_string(), + new lib_plankton.prog.struct_type_any() + ), + } + ], + new lib_plankton.prog.struct_type_construction( + "Promise", + [ + new lib_plankton.prog.struct_type_void(), + ] + ), + [ + // TODO + new lib_plankton.prog.struct_statement_return( + new lib_plankton.prog.struct_expression_literal(null) + ), + ] + ), + ] + ) + // 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 + ] + : [ + // 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_record( + [ + { + "name": "key", + "type": new lib_plankton.prog.struct_type_integer(), + "mandatory": true, + }, + { + "name": "value", + "type": new lib_plankton.prog.struct_type_construction( + name_type(domain), + null + ), + "mandatory": true, + }, + ] + ), + ] + ) + ] + ), + [ + new lib_plankton.prog.struct_statement_return( + // TODO + new lib_plankton.prog.struct_expression_function_application( + new lib_plankton.prog.struct_expression_fieldaccess( + new lib_plankton.prog.struct_expression_function_application( + new lib_plankton.prog.struct_expression_variable("sql_query_get"), + [ + new lib_plankton.prog.struct_expression_literal( + lib_plankton.string.coin( + "SELECT {{fields}} FROM {{name}};", + { + "fields": ( + [domain.key_field.name] + .concat(domain.data_fields.map(field => field.name)) + .join(",") + ), + "name": name_table(domain), + } + ) + ), + new lib_plankton.prog.struct_expression_dict( + [ + ] + ), + ] + ), + "then" + ), + [ + new lib_plankton.prog.struct_expression_abstraction( + [ + { + "name": "rows", + "type": null, + }, + ], + null, + [ + new lib_plankton.prog.struct_statement_return( + new lib_plankton.prog.struct_expression_function_application( + new lib_plankton.prog.struct_expression_fieldaccess( + new lib_plankton.prog.struct_expression_variable( + "rows" + ), + "map" + ), + [ + new lib_plankton.prog.struct_expression_abstraction( + [ + { + "name": "row", + "type": null, + }, + ], + null, + [ + new lib_plankton.prog.struct_statement_return( + new lib_plankton.prog.struct_expression_dict( + [ + { + "key": "key", + "value": new lib_plankton.prog.struct_expression_projection( + new lib_plankton.prog.struct_expression_variable("row"), + new lib_plankton.prog.struct_expression_literal(domain.key_field.name) + ), + }, + { + "key": "value", + "value": new lib_plankton.prog.struct_expression_dict( + domain.data_fields + .map( + field => ({ + "key": field.name, + "value": new lib_plankton.prog.struct_expression_projection( + new lib_plankton.prog.struct_expression_variable("row"), + new lib_plankton.prog.struct_expression_literal(field.name) + ) + }) + ) + ), + }, + ] + ) + ), + ] + ), + ] + ) + ), + ] + ), + ] + ), + ), + ] + ), + // 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_function_application( + new lib_plankton.prog.struct_expression_fieldaccess( + new lib_plankton.prog.struct_expression_function_application( + new lib_plankton.prog.struct_expression_variable("sql_query_get"), + [ + new lib_plankton.prog.struct_expression_literal( + lib_plankton.string.coin( + "SELECT {{fields}} FROM {{name}} WHERE ({{key}} = :key);", + { + "fields": ( + [] + .concat(domain.data_fields.map(field => field.name)) + .join(",") + ), + "name": name_table(domain), + "key": domain.key_field.name, + } + ) + ), + new lib_plankton.prog.struct_expression_dict( + [ + { + "key": "key", + "value": new lib_plankton.prog.struct_expression_variable("key"), + }, + ] + ), + ] + ), + "then" + ), + [ + new lib_plankton.prog.struct_expression_abstraction( + [ + { + "name": "rows", + "type": null, + }, + ], + null, + [ + new lib_plankton.prog.struct_statement_declaration( + true, + "row", + null, + new lib_plankton.prog.struct_expression_projection( + new lib_plankton.prog.struct_expression_variable("rows"), + new lib_plankton.prog.struct_expression_literal(0), + ) + ), + new lib_plankton.prog.struct_statement_return( + new lib_plankton.prog.struct_expression_dict( + domain.data_fields + .map( + field => ({ + "key": field.name, + "value": new lib_plankton.prog.struct_expression_projection( + new lib_plankton.prog.struct_expression_variable("row"), + new lib_plankton.prog.struct_expression_literal(field.name) + ) + }) + ) + ) + ), + ] + ), + ] + ) + ), + ] + ), + // 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_function_application( + new lib_plankton.prog.struct_expression_variable("sql_query_put"), + [ + new lib_plankton.prog.struct_expression_literal( + lib_plankton.string.coin( + "INSERT INTO {{name}}({{fields}}) VALUES ({{values}});", + { + "name": name_table(domain), + "fields": ( + domain.data_fields + .map(field => field.name) + .join(",") + ), + "values": ( + domain.data_fields + .map(field => (":" + field.name)) + .join(",") + ), + } + ) + ), + new lib_plankton.prog.struct_expression_dict( + domain.data_fields + .map( + field => ({ + "key": field.name, + "value": new lib_plankton.prog.struct_expression_fieldaccess( + new lib_plankton.prog.struct_expression_variable("value"), + field.name, + ), + }) + ) + ), + ] + ) + ), + ] + ), + // 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_function_application( + new lib_plankton.prog.struct_expression_variable("sql_query_set"), + [ + new lib_plankton.prog.struct_expression_literal( + lib_plankton.string.coin( + "UPDATE {{name}} SET {{settings}} WHERE ({{key}} = :key);", + { + "name": name_table(domain), + "key": domain.key_field.name, + "settings": ( + domain.data_fields + .map( + field => lib_plankton.string.coin( + "{{key}} = {{value}}", + { + "key": field.name, + "value": (":" + field.name), + } + ) + ) + .join(", ") + ), + } + ) + ), + new lib_plankton.prog.struct_expression_dict( + [] + .concat( + [ + { + "key": "key", + "value": new lib_plankton.prog.struct_expression_variable("key"), + }, + ] + ) + .concat( + domain.data_fields + .map( + field => ({ + "key": field.name, + "value": new lib_plankton.prog.struct_expression_fieldaccess( + new lib_plankton.prog.struct_expression_variable("value"), + field.name, + ), + }) + ) + ) + ), + ] + ) + ), + ] + ), + // 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_function_application( + new lib_plankton.prog.struct_expression_variable("sql_query_set"), + [ + new lib_plankton.prog.struct_expression_literal( + lib_plankton.string.coin( + "DELETE FROM {{name}} WHERE ({{key}} = :key);", + { + "name": name_table(domain), + "key": domain.key_field.name, + } + ) + ), + new lib_plankton.prog.struct_expression_dict( + [ + { + "key": "key", + "value": new lib_plankton.prog.struct_expression_variable("key"), + }, + ] + ), + ] + ) + ), + ] + ), + ] + ) + ) + .reduce( + (x, y) => x.concat(y), + [] + ) + ) + // services + .concat( + [] + ) + // api + .concat( + [] + ) + // server + .concat( + [] + ) + ) + ); + } + +} + +const output_backend_typescript : type_output = { + "render": _sindri.outputs.backend.typescript.render, +}; diff --git a/source/outputs/mysql.ts b/source/outputs/database_mysql.ts similarity index 97% rename from source/outputs/mysql.ts rename to source/outputs/database_mysql.ts index 7d40027..0f1f0b3 100644 --- a/source/outputs/mysql.ts +++ b/source/outputs/database_mysql.ts @@ -1,4 +1,4 @@ -namespace _sindri.outputs.mysql +namespace _sindri.outputs.database.mysql { /** @@ -212,6 +212,6 @@ namespace _sindri.outputs.mysql /** */ -const output_mysql : type_output = { - "render": _sindri.outputs.mysql.render, +const output_database_mysql : type_output = { + "render": _sindri.outputs.database.mysql.render, }; diff --git a/source/outputs/sqlite.ts b/source/outputs/database_sqlite.ts similarity index 96% rename from source/outputs/sqlite.ts rename to source/outputs/database_sqlite.ts index a6bcaa8..f4b1351 100644 --- a/source/outputs/sqlite.ts +++ b/source/outputs/database_sqlite.ts @@ -1,4 +1,4 @@ -namespace _sindri.outputs.sqlite +namespace _sindri.outputs.database.sqlite { /** @@ -174,6 +174,6 @@ namespace _sindri.outputs.sqlite } -const output_sqlite : type_output = { - "render": _sindri.outputs.sqlite.render, +const output_database_sqlite : type_output = { + "render": _sindri.outputs.database.sqlite.render, }; diff --git a/source/outputs/typescript.ts b/source/outputs/typescript.ts deleted file mode 100644 index 9d9f1dd..0000000 --- a/source/outputs/typescript.ts +++ /dev/null @@ -1,173 +0,0 @@ -namespace _sindri.outputs.typescript -{ - - /** - */ - function render_entity_type( - domain - ) : string - { - return lib_plankton.string.coin( - "type type_{{name}} = {\n{{fields}}\n};\n", - { - "name": domain.name, - "fields": ( - domain.data_fields - .map( - (data_field) => lib_plankton.string.coin( - "\t{{name}} : {{type}};{{macro_comment}}", - { - "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, - } - ) - : "" - ), - } - ) - ) - // .map(x => ("\t" + x)) - .join("\n") - ), - } - ); - } - - - /** - */ - function render_entity_collection( - domain - ) : string - { - return lib_plankton.string.coin( - "let collection_{{name}} : {{collection_type}} = {{collection_value}};\n", - { - "name": domain.name, - "collection_type": ( - (domain.key_field === null) - ? lib_plankton.string.coin( - "Array", - { - "name": domain.name, - } - ) - : lib_plankton.string.coin( - "Record", - { - "name": domain.name, - } - ) - ), - "collection_value": ( - (domain.key_field === null) - ? "[]" - : "{}" - ), - } - ); - } - - - /** - */ - function render_entity( - domain - ) : string - { - return ( - render_entity_type(domain) - + - render_entity_collection(domain) - ); - } - - - /** - */ - function render_functions( - domain - ) : string - { - return ( - [ - // list - "function {{name}}_list() : Promise {return sql_query_get(\"SELECT * FROM {{name}};\");}", - // read - "", - // create - "", - // update - "", - // delete - "", - ] - .join("\n\n") - ); - } - - - /** - */ - function render_api_actions( - domain - ) : string - { - return ( - [ - // list - "", - // read - "", - // create - "", - // update - "", - // delete - "", - ] - .join("\n\n") - ); - } - - - /** - */ - export function render( - input_data - ) : string - { - return ( - input_data["domains"] - .map( - (domain) => render_entity(domain) - ) - .map(x => (x + "\n")) - .join("\n") - ); - } - -} - - -const output_typescript : type_output = { - "render": _sindri.outputs.typescript.render, -}; 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 diff --git a/tools/makefile b/tools/makefile index c077c03..edce9ff 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 "--" @@ -16,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/jsonschema.ts \ -source/outputs/typescript.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 …" @@ -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_echo} "#!/usr/bin/env node" > temp/head.js @ ${cmd_concatenate} temp/head.js $^ > $@ @ ${cmd_chmod} +x $@