drakongen 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +18 -0
- package/LICENSE +24 -0
- package/README.md +80 -0
- package/browser/drakongen.js +1303 -0
- package/browsertest.html +84 -0
- package/buildbrowser +4 -0
- package/buildexamples.js +61 -0
- package/examples/00.Empty.drakon +1 -0
- package/examples/00.Empty.txt +5 -0
- package/examples/01. /320/221/320/265/320/273/321/213/320/270/314/206.drakon" +13 -0
- package/examples/01. /320/221/320/265/320/273/321/213/320/271.json" +16 -0
- package/examples/01. /320/221/320/265/320/273/321/213/320/271.txt" +4 -0
- package/examples/02. /320/247/320/265/314/210/321/200/320/275/321/213/320/270/314/206.drakon" +28 -0
- package/examples/02. /320/247/321/221/321/200/320/275/321/213/320/271.json" +31 -0
- package/examples/02. /320/247/321/221/321/200/320/275/321/213/320/271.txt" +10 -0
- package/examples/03. /320/241/320/265/321/200/321/213/320/270/314/206.drakon" +20 -0
- package/examples/03. /320/241/320/265/321/200/321/213/320/271.json" +23 -0
- package/examples/03. /320/241/320/265/321/200/321/213/320/271.txt" +6 -0
- package/examples/04. /320/221/321/203/321/200/321/213/320/270/314/206.drakon" +25 -0
- package/examples/04. /320/221/321/203/321/200/321/213/320/271.json" +29 -0
- package/examples/04. /320/221/321/203/321/200/321/213/320/271.txt" +7 -0
- package/examples/05. /320/226/320/265/314/210/320/273/321/202/321/213/320/270/314/206.drakon" +25 -0
- package/examples/05. /320/226/321/221/320/273/321/202/321/213/320/271.json" +29 -0
- package/examples/05. /320/226/321/221/320/273/321/202/321/213/320/271.txt" +7 -0
- package/examples/06. /320/221/320/260/320/263/321/200/320/276/320/262/321/213/320/270/314/206.drakon" +30 -0
- package/examples/06. /320/221/320/260/320/263/321/200/320/276/320/262/321/213/320/271.json" +35 -0
- package/examples/06. /320/221/320/260/320/263/321/200/320/276/320/262/321/213/320/271.txt" +10 -0
- package/examples/07. /320/244/320/270/320/276/320/273/320/265/321/202/320/276/320/262/321/213/320/270/314/206.drakon" +42 -0
- package/examples/07. /320/244/320/270/320/276/320/273/320/265/321/202/320/276/320/262/321/213/320/271.json" +49 -0
- package/examples/07. /320/244/320/270/320/276/320/273/320/265/321/202/320/276/320/262/321/213/320/271.txt" +14 -0
- package/examples/08. /320/221/320/270/321/200/321/216/320/267/320/276/320/262/321/213/320/270/314/206.drakon" +27 -0
- package/examples/08. /320/221/320/270/321/200/321/216/320/267/320/276/320/262/321/213/320/271.json" +27 -0
- package/examples/08. /320/221/320/270/321/200/321/216/320/267/320/276/320/262/321/213/320/271.txt" +6 -0
- package/examples/09. /320/236/321/200/320/260/320/275/320/266/320/265/320/262/321/213/320/270/314/206.drakon" +37 -0
- package/examples/09. /320/236/321/200/320/260/320/275/320/266/320/265/320/262/321/213/320/271.json" +39 -0
- package/examples/09. /320/236/321/200/320/260/320/275/320/266/320/265/320/262/321/213/320/271.txt" +10 -0
- package/examples/10. /320/240/320/276/320/267/320/276/320/262/321/213/320/270/314/206.drakon" +42 -0
- package/examples/10. /320/240/320/276/320/267/320/276/320/262/321/213/320/271.json" +54 -0
- package/examples/10. /320/240/320/276/320/267/320/276/320/262/321/213/320/271.txt" +16 -0
- package/examples/11. /320/227/320/260/321/211/320/270/321/202/320/275/321/213/320/270/314/206.drakon" +37 -0
- package/examples/11. /320/227/320/260/321/211/320/270/321/202/320/275/321/213/320/271.json" +39 -0
- package/examples/11. /320/227/320/260/321/211/320/270/321/202/320/275/321/213/320/271.txt" +10 -0
- package/examples/12. /320/221/320/276/320/273/320/276/321/202/320/275/321/213/320/270/314/206.drakon" +44 -0
- package/examples/12. /320/221/320/276/320/273/320/276/321/202/320/275/321/213/320/271.json" +43 -0
- package/examples/12. /320/221/320/276/320/273/320/276/321/202/320/275/321/213/320/271.txt" +10 -0
- package/examples/13. /320/241/320/260/320/273/320/260/321/202/320/276/320/262/321/213/320/270/314/206.drakon" +54 -0
- package/examples/13. /320/241/320/260/320/273/320/260/321/202/320/276/320/262/321/213/320/271.json" +63 -0
- package/examples/13. /320/241/320/260/320/273/320/260/321/202/320/276/320/262/321/213/320/271.txt" +18 -0
- package/examples/14. /320/227/320/276/320/273/320/276/321/202/320/276/320/270/314/206.drakon" +64 -0
- package/examples/14. /320/227/320/276/320/273/320/276/321/202/320/276/320/271.json" +73 -0
- package/examples/14. /320/227/320/276/320/273/320/276/321/202/320/276/320/271.txt" +22 -0
- package/examples/15. /320/241/320/270/320/275/320/270/320/270/314/206.drakon" +54 -0
- package/examples/15. /320/241/320/270/320/275/320/270/320/271.json" +87 -0
- package/examples/15. /320/241/320/270/320/275/320/270/320/271.txt" +26 -0
- package/examples/16. /320/223/320/276/320/273/321/203/320/261/320/276/320/270/314/206.drakon" +37 -0
- package/examples/16. /320/223/320/276/320/273/321/203/320/261/320/276/320/271.json" +48 -0
- package/examples/16. /320/223/320/276/320/273/321/203/320/261/320/276/320/271.txt" +13 -0
- package/examples/17. /320/241/320/260/320/273/320/260/321/202/320/276/320/262/321/213/320/270/314/206.drakon" +39 -0
- package/examples/17. /320/241/320/260/320/273/320/260/321/202/320/276/320/262/321/213/320/271.json" +41 -0
- package/examples/17. /320/241/320/260/320/273/320/260/321/202/320/276/320/262/321/213/320/271.txt" +10 -0
- package/examples/18. /320/241/321/202/320/260/320/273/321/214/320/275/320/276/320/270/314/206.drakon" +49 -0
- package/examples/18. /320/241/321/202/320/260/320/273/321/214/320/275/320/276/320/271.json" +67 -0
- package/examples/18. /320/241/321/202/320/260/320/273/321/214/320/275/320/276/320/271.txt" +19 -0
- package/examples/19. Lilla.drakon +39 -0
- package/examples/19. Lilla.json +45 -0
- package/examples/19. Lilla.txt +11 -0
- package/examples/Adaptive design.drakon +116 -0
- package/examples/Adaptive design.json +153 -0
- package/examples/Adaptive design.txt +47 -0
- package/examples/And test.drakon +46 -0
- package/examples/And test.json +46 -0
- package/examples/And test.txt +10 -0
- package/examples/Arrow - double exit.drakon +41 -0
- package/examples/Arrow - double exit.json +62 -0
- package/examples/Arrow - double exit.txt +14 -0
- package/examples/Complex arrow.drakon +93 -0
- package/examples/Complex arrow.json +162 -0
- package/examples/Complex arrow.txt +43 -0
- package/examples/DoubleArrow.drakon +53 -0
- package/examples/DoubleArrow.json +86 -0
- package/examples/DoubleArrow.txt +18 -0
- package/examples/Find pointing nodes.drakon +104 -0
- package/examples/Find pointing nodes.json +137 -0
- package/examples/Find pointing nodes.txt +29 -0
- package/examples/How to tune PID on a quadcopter.drakon +488 -0
- package/examples/How to tune PID on a quadcopter.json +734 -0
- package/examples/How to tune PID on a quadcopter.txt +169 -0
- package/examples/Or test.drakon +47 -0
- package/examples/Or test.json +46 -0
- package/examples/Or test.txt +10 -0
- package/examples/Silhouette test 1.drakon +47 -0
- package/examples/Silhouette test 1.json +82 -0
- package/examples/Silhouette test 1.txt +24 -0
- package/examples/Work out action-check.drakon +30 -0
- package/examples/Work out action-check.json +45 -0
- package/examples/Work out action-check.txt +9 -0
- package/examples/Workout foreach.drakon +63 -0
- package/examples/Workout foreach.json +62 -0
- package/examples/Workout foreach.txt +14 -0
- package/examples/ar01.drakon +25 -0
- package/examples/ar01.json +40 -0
- package/examples/ar01.txt +7 -0
- package/examples/ar02.drakon +30 -0
- package/examples/ar02.json +45 -0
- package/examples/ar02.txt +10 -0
- package/examples/ar03.drakon +32 -0
- package/examples/ar03.json +44 -0
- package/examples/ar03.txt +7 -0
- package/examples/ar04.drakon +37 -0
- package/examples/ar04.json +49 -0
- package/examples/ar04.txt +10 -0
- package/examples/ar05.drakon +37 -0
- package/examples/ar05.json +59 -0
- package/examples/ar05.txt +11 -0
- package/examples/ar06.drakon +40 -0
- package/examples/ar06.json +70 -0
- package/examples/ar06.txt +13 -0
- package/examples/ar07.drakon +40 -0
- package/examples/ar07.json +70 -0
- package/examples/ar07.txt +13 -0
- package/examples/ar08.drakon +47 -0
- package/examples/ar08.json +81 -0
- package/examples/ar08.txt +16 -0
- package/examples/ar09.drakon +52 -0
- package/examples/ar09.json +87 -0
- package/examples/ar09.txt +17 -0
- package/examples/ar10.drakon +52 -0
- package/examples/ar10.json +88 -0
- package/examples/ar10.txt +18 -0
- package/examples/ar11.drakon +47 -0
- package/examples/ar11.json +82 -0
- package/examples/ar11.txt +17 -0
- package/examples/ar12.drakon +37 -0
- package/examples/ar12.json +49 -0
- package/examples/ar12.txt +10 -0
- package/examples/getToken.drakon +76 -0
- package/examples/getToken.json +88 -0
- package/examples/getToken.txt +41 -0
- package/examples/tmp.drakon +49 -0
- package/examples/tmp.json +82 -0
- package/examples/tmp.txt +37 -0
- package/package.json +21 -0
- package/prompts/drakonToPrompt.txt +139 -0
- package/prompts/index.txt +17 -0
- package/prompts/printPseudo.txt +116 -0
- package/src/browserTools.js +39 -0
- package/src/drakonToPromptStruct.js +44 -0
- package/src/drakonToStruct.js +416 -0
- package/src/drakongen.js +16 -0
- package/src/index.js +17 -0
- package/src/main.js +157 -0
- package/src/nodeTools.js +38 -0
- package/src/printPseudo.js +167 -0
- package/src/structFlow.js +382 -0
- package/src/technicalTree.js +84 -0
- package/src/tools.js +36 -0
- package/src/translate.js +108 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Launch Program",
|
|
11
|
+
"skipFiles": [
|
|
12
|
+
"<node_internals>/**"
|
|
13
|
+
],
|
|
14
|
+
"program": "${workspaceFolder}/src/index.js",
|
|
15
|
+
"args": ["examples/tmp.drakon"]
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# drakongen
|
|
2
|
+
|
|
3
|
+
**drakongen** generates pseudocode from drakon flowcharts built with [DrakonWidget](https://github.com/stepan-mitkin/drakonwidget) or [DrakonHub](https://github.com/stepan-mitkin/drakonhub_desktop).
|
|
4
|
+
|
|
5
|
+
One can use the output pseudocode as a prompt for AI applications like ChatGPT or CodePilot.
|
|
6
|
+
|
|
7
|
+
**drakongen** can also generate a generic AST from drakon flowcharts to generate source code in programming languages, for example, JavaScript.
|
|
8
|
+
**drakongen** turns a drakon flowchart into a tree in the JSON format that one can trivially transform into code in any programming language.
|
|
9
|
+
|
|
10
|
+
## How to use drakongen in the browser
|
|
11
|
+
|
|
12
|
+
Include the `drakongen.js` script on the web page.
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<script src="browser/drakongen.js"></script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Call `toPseudocode` or `toTree` functions.
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script>
|
|
22
|
+
var drakon = ... // Get the drakon chart from DrakonWidget
|
|
23
|
+
var name = "Diagram one"
|
|
24
|
+
var filename = "Diagram one.drakon"
|
|
25
|
+
|
|
26
|
+
var pseudo = toPseudocode(drakon, name, filename, "en")
|
|
27
|
+
console.log(pseudo)
|
|
28
|
+
|
|
29
|
+
var tree = toTree(drakon, name, filename, "en")
|
|
30
|
+
console.log(tree)
|
|
31
|
+
|
|
32
|
+
</script>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Available languages:
|
|
36
|
+
|
|
37
|
+
- en English
|
|
38
|
+
- no Norwegian
|
|
39
|
+
- ru Russian
|
|
40
|
+
|
|
41
|
+
## How to use drakongen in Node JS
|
|
42
|
+
|
|
43
|
+
Add the **drakongen** package to dependencies.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
npm i drakongen
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- Require the **drakongen** module.
|
|
50
|
+
- Call `toPseudocode` or `toTree` functions.
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
const {toTree, toPseudocode} = require("drakongen")
|
|
54
|
+
|
|
55
|
+
var drakon = ... // Get the drakon chart from DrakonWidget
|
|
56
|
+
var name = "Diagram one"
|
|
57
|
+
var filename = "Diagram one.drakon"
|
|
58
|
+
|
|
59
|
+
var pseudo = toPseudocode(drakon, name, filename, "en")
|
|
60
|
+
console.log(pseudo)
|
|
61
|
+
|
|
62
|
+
var tree = toTree(drakon, name, filename, "en")
|
|
63
|
+
console.log(tree)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## How to use drakongen as a command-line tool
|
|
67
|
+
|
|
68
|
+
Install **drakongen** globally.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
npm i --global drakongen
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Run the **drakongen** utility.
|
|
75
|
+
|
|
76
|
+
In this example, the language is Norwegian, the path to the output folder is **out**, the input file is **Hello.drakon**:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
drakongen --language no --output out Hello.drakon
|
|
80
|
+
```
|