plainscript-lang 1.0.361 → 1.0.363
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/README.md +383 -55
- package/compiler/bundler.js +78 -3
- package/compiler/cli.js +224 -30
- package/compiler/formatter.js +21 -1
- package/compiler/generator.js +490 -114
- package/compiler/ir.js +61 -0
- package/compiler/lexer.js +42 -7
- package/compiler/lsp.js +234 -0
- package/compiler/parser.js +780 -110
- package/compiler/type-checker.js +246 -0
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +19 -3
- package/docs/GAME-PROMPT.md +3 -3
- package/docs/PLAINSCRIPT-GRAMMAR.md +308 -0
- package/docs/PLAINSCRIPT-SPEC.md +231 -5
- package/docs/index.html +5 -5
- package/docs/website/script.js +1 -1
- package/examples/ai-memory-cli.pln +221 -0
- package/examples/ai-memory.json +1 -0
- package/examples/ai-providers.pln +1 -1
- package/examples/arrays.pln +1 -1
- package/examples/async-errors.pln +1 -1
- package/examples/auth-api.pln +1 -1
- package/examples/auth-sessions.pln +1 -1
- package/examples/basics.pln +1 -1
- package/examples/bots.pln +1 -1
- package/examples/browser-interactive/README.md +1 -1
- package/examples/browser-interactive/src/interactive.pln +1 -1
- package/examples/cache-and-jobs.pln +1 -1
- package/examples/cache-schedule.pln +1 -1
- package/examples/canvas-game/README.md +1 -1
- package/examples/canvas-game/src/game.pln +1 -1
- package/examples/collections.pln +1 -1
- package/examples/compound-assignments.pln +24 -0
- package/examples/concurrency.pln +2 -2
- package/examples/conditions.pln +1 -1
- package/examples/database.pln +1 -1
- package/examples/day2.pln +1 -1
- package/examples/day3.pln +1 -1
- package/examples/deployment.pln +1 -1
- package/examples/email-send.pln +1 -1
- package/examples/error-handling.pln +1 -1
- package/examples/expressions.pln +1 -1
- package/examples/file-manager-cli.pln +51 -0
- package/examples/file-uploads.pln +1 -1
- package/examples/files-and-config.pln +1 -1
- package/examples/files.pln +1 -1
- package/examples/football-backend/app.pln +1 -1
- package/examples/functions.pln +1 -1
- package/examples/hello.pln +1 -1
- package/examples/http-client.pln +1 -1
- package/examples/http.pln +1 -1
- package/examples/id-verification/app.pln +1 -1
- package/examples/interactive-cli.pln +34 -0
- package/examples/javascript-library/README.md +1 -1
- package/examples/javascript-library/src/interop.pln +1 -1
- package/examples/json.pln +1 -1
- package/examples/loops.pln +1 -1
- package/examples/memoize-demo.pln +31 -0
- package/examples/modules/app.pln +1 -1
- package/examples/modules/main.pln +1 -1
- package/examples/modules/math.pln +1 -1
- package/examples/mongo.pln +1 -1
- package/examples/normalization-forms.pln +22 -0
- package/examples/objects.pln +1 -1
- package/examples/ocr.pln +1 -1
- package/examples/packages.pln +1 -1
- package/examples/random-cli.pln +32 -0
- package/examples/record-kinds.pln +1 -1
- package/examples/records.pln +1 -1
- package/examples/rest-api-fetch.pln +1 -1
- package/examples/rest-api.pln +1 -1
- package/examples/run-in-parallel.pln +25 -0
- package/examples/scheduled-tasks.pln +1 -1
- package/examples/search-and-filter.pln +1 -1
- package/examples/server.pln +1 -1
- package/examples/sessions-and-cookies.pln +1 -1
- package/examples/sqlite.pln +1 -1
- package/examples/start.pln +1 -1
- package/examples/stats-cli.pln +29 -0
- package/examples/stdlib.pln +1 -1
- package/examples/string-helpers.pln +23 -0
- package/examples/string-verbs.pln +1 -1
- package/examples/telegram-ai-bot.pln +1 -1
- package/examples/telegram-bot.pln +1 -1
- package/examples/terminal-cli.pln +11 -0
- package/examples/testing.pln +1 -1
- package/examples/three-dimensional/README.md +1 -1
- package/examples/three-dimensional/src/scene.pln +1 -1
- package/examples/todo-cli.pln +98 -0
- package/examples/web-api.pln +1 -1
- package/examples/web-app.pln +1 -1
- package/examples/websocket-server.pln +1 -1
- package/examples/websocket.pln +1 -1
- package/examples/whatsapp-bot/pairing.pln +1 -1
- package/examples/whatsapp-bot/qr.pln +1 -1
- package/package.json +16 -6
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// PlainScript 1.0.363 — a persistent to-do CLI.
|
|
2
|
+
// State lives in todos.json next to where you run the script.
|
|
3
|
+
//
|
|
4
|
+
// Usage:
|
|
5
|
+
// plainscript run examples/todo-cli.pln add "Write the release notes"
|
|
6
|
+
// plainscript run examples/todo-cli.pln list
|
|
7
|
+
// plainscript run examples/todo-cli.pln done 0
|
|
8
|
+
// plainscript run examples/todo-cli.pln remove 0
|
|
9
|
+
|
|
10
|
+
remember storeFile as "todos.json"
|
|
11
|
+
|
|
12
|
+
make loadTodos()
|
|
13
|
+
if fileExists(storeFile) is true
|
|
14
|
+
give jsonDecode(readFile(storeFile))
|
|
15
|
+
otherwise
|
|
16
|
+
give []
|
|
17
|
+
done
|
|
18
|
+
done
|
|
19
|
+
|
|
20
|
+
make saveTodos(todos)
|
|
21
|
+
writeFile(storeFile, jsonEncode(todos))
|
|
22
|
+
done
|
|
23
|
+
|
|
24
|
+
make label(todo)
|
|
25
|
+
if completed of todo is true
|
|
26
|
+
give "[x] " + text of todo
|
|
27
|
+
otherwise
|
|
28
|
+
give "[ ] " + text of todo
|
|
29
|
+
done
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
make showList(todos)
|
|
33
|
+
if count of todos is 0
|
|
34
|
+
show "nothing to do"
|
|
35
|
+
otherwise
|
|
36
|
+
remember i as 0
|
|
37
|
+
for each todo in todos
|
|
38
|
+
show i + ": " + label(todo)
|
|
39
|
+
i += 1
|
|
40
|
+
done
|
|
41
|
+
done
|
|
42
|
+
done
|
|
43
|
+
|
|
44
|
+
make main()
|
|
45
|
+
remember argv as args()
|
|
46
|
+
remember todos as loadTodos()
|
|
47
|
+
if count of argv is 0
|
|
48
|
+
show "usage: todo-cli.pln <add|list|done|remove> [text|index]"
|
|
49
|
+
exit(0)
|
|
50
|
+
done
|
|
51
|
+
remember command as argv at position 0
|
|
52
|
+
if command is "add"
|
|
53
|
+
if count of argv is at least 2
|
|
54
|
+
push(todos, { text: argv at position 1, completed: false })
|
|
55
|
+
saveTodos(todos)
|
|
56
|
+
show "added: " + argv at position 1
|
|
57
|
+
otherwise
|
|
58
|
+
show "usage: ... add <text>"
|
|
59
|
+
done
|
|
60
|
+
otherwise if command is "list"
|
|
61
|
+
showList(todos)
|
|
62
|
+
otherwise if command is "done"
|
|
63
|
+
if count of argv is at least 2
|
|
64
|
+
remember target as parseInt(argv at position 1, 10)
|
|
65
|
+
remember i as 0
|
|
66
|
+
for each todo in todos
|
|
67
|
+
if i is target
|
|
68
|
+
completed of todo becomes true
|
|
69
|
+
done
|
|
70
|
+
i += 1
|
|
71
|
+
done
|
|
72
|
+
saveTodos(todos)
|
|
73
|
+
show "completed item " + target
|
|
74
|
+
otherwise
|
|
75
|
+
show "usage: ... done <index>"
|
|
76
|
+
done
|
|
77
|
+
otherwise if command is "remove"
|
|
78
|
+
if count of argv is at least 2
|
|
79
|
+
remember target as parseInt(argv at position 1, 10)
|
|
80
|
+
remember kept as []
|
|
81
|
+
remember i as 0
|
|
82
|
+
for each todo in todos
|
|
83
|
+
if i different from target
|
|
84
|
+
push(kept, todo)
|
|
85
|
+
done
|
|
86
|
+
i += 1
|
|
87
|
+
done
|
|
88
|
+
saveTodos(kept)
|
|
89
|
+
show "removed item " + target
|
|
90
|
+
otherwise
|
|
91
|
+
show "usage: ... remove <index>"
|
|
92
|
+
done
|
|
93
|
+
otherwise
|
|
94
|
+
show "unknown command: " + command
|
|
95
|
+
done
|
|
96
|
+
done
|
|
97
|
+
|
|
98
|
+
main()
|
package/examples/web-api.pln
CHANGED
package/examples/web-app.pln
CHANGED
package/examples/websocket.pln
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plainscript-lang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.363",
|
|
4
4
|
"description": "PlainScript - an Intent-Oriented Programming Language. When even a simple sentence can be code.",
|
|
5
5
|
"main": "compiler/cli.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"plainscript": "./compiler/cli.js"
|
|
7
|
+
"plainscript": "./compiler/cli.js",
|
|
8
|
+
"plainscript-lsp": "./compiler/lsp.js"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
|
-
"test": "node tests/compiler.test.js && node tests/build.test.js && node tests/telegram.test.js && node tests/ocr.test.js && node tests/nesting.test.js && node tests/backend.test.js && node tests/runtime.test.js && node tests/browser.test.js && node tests/acceptance.test.js && node tests/whatsapp.test.js && node tests/audit.test.js && node tests/sourcemap.test.js && node tests/modules.test.js && node tests/repeat.test.js && node tests/datastructures.test.js && node tests/kernel.test.js && node tests/docs.test.js && node tests/compat/browser-interop.test.js && node tests/compat/language.test.js && node tests/compat/node.test.js && node tests/compat/binary.test.js && node tests/compat/errors.test.js && node tests/compat/async.test.js && node tests/compat/modules.test.js && node tests/compat/npm.test.js && node tests/compat/web.test.js && node tests/compat/real-world.test.js"
|
|
11
|
+
"test": "node tests/compiler.test.js && node tests/build.test.js && node tests/telegram.test.js && node tests/ocr.test.js && node tests/nesting.test.js && node tests/backend.test.js && node tests/runtime.test.js && node tests/browser.test.js && node tests/acceptance.test.js && node tests/whatsapp.test.js && node tests/audit.test.js && node tests/sourcemap.test.js && node tests/modules.test.js && node tests/repeat.test.js && node tests/datastructures.test.js && node tests/kernel.test.js && node tests/assignment.test.js && node tests/primitives.test.js && node tests/concurrency.test.js && node tests/terminal.test.js && node tests/cli.test.js && node tests/docs.test.js && node tests/types.test.js && node tests/ir.test.js && node tests/lsp.test.js && node tests/parser-robustness.test.js && node tests/compat/browser-interop.test.js && node tests/compat/language.test.js && node tests/compat/node.test.js && node tests/compat/binary.test.js && node tests/compat/errors.test.js && node tests/compat/async.test.js && node tests/compat/modules.test.js && node tests/compat/npm.test.js && node tests/compat/web.test.js && node tests/compat/real-world.test.js && node tests/torture.test.js && node tests/packaging.test.js && node tools/verify-all-docs.js",
|
|
12
|
+
"docs:check": "node tools/verify-all-docs.js"
|
|
11
13
|
},
|
|
12
14
|
"files": [
|
|
13
15
|
"compiler",
|
|
@@ -40,9 +42,17 @@
|
|
|
40
42
|
"ws": "^8.21.3"
|
|
41
43
|
},
|
|
42
44
|
"dependencies": {
|
|
45
|
+
"@whiskeysockets/baileys": "^7.0.0-rc14",
|
|
46
|
+
"axios": "^1.20.0",
|
|
47
|
+
"mrz": "^5.0.2",
|
|
48
|
+
"pg": "^8.23.0",
|
|
49
|
+
"qrcode-terminal": "^0.12.0",
|
|
50
|
+
"three": "^0.186.0"
|
|
51
|
+
},
|
|
52
|
+
"optionalDependencies": {
|
|
53
|
+
"better-sqlite3": "^11.10.0",
|
|
43
54
|
"mongodb": "^6.20.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"three": "^0.185.1"
|
|
55
|
+
"sql.js": "^1.13.0",
|
|
56
|
+
"tesseract.js": "^7.0.0"
|
|
47
57
|
}
|
|
48
58
|
}
|