plainscript-lang 1.0.0 → 1.0.2-latest
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 +194 -729
- package/compiler/bundler.js +2 -2
- package/compiler/cli.js +182 -79
- package/compiler/dependency-detector.js +5 -0
- package/compiler/formatter.js +1 -1
- package/compiler/generator.js +1083 -206
- package/compiler/lexer.js +130 -54
- package/compiler/parser.js +1117 -156
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +98 -435
- package/docs/PLAINSCRIPT-SPEC.md +335 -0
- package/docs/index.html +103 -605
- package/docs/website/script.js +59 -943
- package/docs/website/style.css +74 -656
- package/examples/ai-providers.pln +7 -0
- package/examples/arrays.pln +4 -0
- package/examples/async-errors.pln +18 -0
- package/examples/auth-api.pln +9 -0
- package/examples/auth-sessions.pln +32 -0
- package/examples/basics.pln +14 -0
- package/examples/bots.pln +13 -0
- package/examples/cache-and-jobs.pln +7 -0
- package/examples/cache-schedule.pln +22 -0
- package/examples/collections.pln +15 -0
- package/examples/concurrency.pln +18 -0
- package/examples/conditions.pln +22 -0
- package/examples/database.pln +8 -0
- package/examples/day2.pln +7 -0
- package/examples/day3.pln +5 -0
- package/examples/deployment.pln +6 -0
- package/examples/email-send.pln +3 -0
- package/examples/error-handling.pln +7 -0
- package/examples/expressions.pln +7 -0
- package/examples/file-uploads.pln +10 -0
- package/examples/files-and-config.pln +6 -0
- package/examples/files.pln +12 -0
- package/examples/football-backend/{app.ps → app.pln} +22 -21
- package/examples/functions.pln +17 -0
- package/examples/hello.pln +2 -0
- package/examples/http-client.pln +3 -0
- package/examples/http.pln +11 -0
- package/examples/id-verification/{app.ps → app.pln} +5 -4
- package/examples/id-verification/make-sample-id.js +29 -42
- package/examples/json.pln +11 -0
- package/examples/loops.pln +18 -0
- package/examples/modules/app.pln +3 -0
- package/examples/modules/main.pln +4 -0
- package/examples/modules/math.pln +9 -0
- package/examples/mongo.pln +33 -0
- package/examples/objects.pln +4 -0
- package/examples/ocr.pln +22 -0
- package/examples/packages.pln +6 -0
- package/examples/record-kinds.pln +7 -0
- package/examples/records.pln +15 -0
- package/examples/rest-api-fetch.pln +10 -0
- package/examples/rest-api.pln +8 -0
- package/examples/scheduled-tasks.pln +4 -0
- package/examples/search-and-filter.pln +4 -0
- package/examples/server.pln +6 -0
- package/examples/sessions-and-cookies.pln +8 -0
- package/examples/sqlite.pln +23 -0
- package/examples/start.pln +2 -0
- package/examples/stdlib.pln +4 -0
- package/examples/telegram-ai-bot.pln +19 -0
- package/examples/telegram-bot.pln +6 -0
- package/examples/testing.pln +13 -0
- package/examples/web-api.pln +27 -0
- package/examples/web-app.pln +8 -0
- package/examples/websocket-server.pln +6 -0
- package/examples/websocket.pln +13 -0
- package/examples/whatsapp-bot/{pairing.ps → pairing.pln} +4 -5
- package/examples/whatsapp-bot/qr.pln +12 -0
- package/package.json +3 -2
- package/docs/PLINJS_SPEC.md +0 -1151
- package/examples/arrays.ps +0 -13
- package/examples/auth-api.ps +0 -56
- package/examples/cache-and-jobs.ps +0 -29
- package/examples/concurrency.ps +0 -49
- package/examples/database.ps +0 -41
- package/examples/day2.ps +0 -7
- package/examples/day3.ps +0 -11
- package/examples/deployment.ps +0 -12
- package/examples/email-send.ps +0 -22
- package/examples/error-handling.ps +0 -54
- package/examples/expressions.ps +0 -40
- package/examples/file-uploads.ps +0 -39
- package/examples/files-and-config.ps +0 -47
- package/examples/hello.ps +0 -3
- package/examples/http-client.ps +0 -44
- package/examples/loops.ps +0 -17
- package/examples/modules/app.ps +0 -16
- package/examples/modules/math.ps +0 -20
- package/examples/objects.ps +0 -12
- package/examples/record-kinds.ps +0 -43
- package/examples/rest-api-fetch.ps +0 -94
- package/examples/rest-api.ps +0 -68
- package/examples/scheduled-tasks.ps +0 -23
- package/examples/search-and-filter.ps +0 -34
- package/examples/server.ps +0 -25
- package/examples/sessions-and-cookies.ps +0 -54
- package/examples/start.ps +0 -2
- package/examples/stdlib.ps +0 -41
- package/examples/telegram-bot.ps +0 -42
- package/examples/web-app.ps +0 -20
- package/examples/websocket-server.ps +0 -27
- package/examples/whatsapp-bot/qr.ps +0 -8
package/examples/ocr.pln
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// PlainScript 1.0.2-latest: upload handling and OCR.
|
|
2
|
+
|
|
3
|
+
web app
|
|
4
|
+
accept uploads limit "5 MB" allow list with "image/png", "image/jpeg" folder "uploads"
|
|
5
|
+
|
|
6
|
+
route post "/scan"
|
|
7
|
+
remember files as uploads("document")
|
|
8
|
+
if length(files) is 0
|
|
9
|
+
status 400
|
|
10
|
+
reply json
|
|
11
|
+
error is "document is required"
|
|
12
|
+
done
|
|
13
|
+
otherwise
|
|
14
|
+
remember document as upload("document")
|
|
15
|
+
ocr path of document as text
|
|
16
|
+
reply json
|
|
17
|
+
text is text
|
|
18
|
+
done
|
|
19
|
+
done
|
|
20
|
+
done
|
|
21
|
+
|
|
22
|
+
start 0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// PlainScript 1.0.2-latest: record kinds and record values.
|
|
2
|
+
|
|
3
|
+
define a kind called "Player" with
|
|
4
|
+
name is ""
|
|
5
|
+
goals is 0
|
|
6
|
+
done
|
|
7
|
+
|
|
8
|
+
remember player as create a Player with name "Ada" and goals 4
|
|
9
|
+
show player.name
|
|
10
|
+
if player has field "goals"
|
|
11
|
+
show "goals are present"
|
|
12
|
+
done
|
|
13
|
+
|
|
14
|
+
remember team as record with name "Harbor City" and founded 2020 done
|
|
15
|
+
show team.name
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// PlainScript 1.0.2-latest: SQLite, SQL blocks, parameters, and transactions.
|
|
2
|
+
|
|
3
|
+
database "plain-script-demo.db" using "wasm"
|
|
4
|
+
remember personName as "Ada"
|
|
5
|
+
|
|
6
|
+
execute
|
|
7
|
+
CREATE TABLE IF NOT EXISTS people (name TEXT, age INTEGER)
|
|
8
|
+
done
|
|
9
|
+
|
|
10
|
+
insert
|
|
11
|
+
INSERT INTO people (name, age) VALUES ({personName}, 36)
|
|
12
|
+
done
|
|
13
|
+
|
|
14
|
+
remember people as query
|
|
15
|
+
SELECT name, age FROM people ORDER BY name
|
|
16
|
+
done
|
|
17
|
+
show people
|
|
18
|
+
|
|
19
|
+
transaction
|
|
20
|
+
update
|
|
21
|
+
UPDATE people SET age = 37 WHERE name = {personName}
|
|
22
|
+
done
|
|
23
|
+
done
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// PlainScript 1.0.2-latest: fixed and provider-backed Telegram replies.
|
|
2
|
+
|
|
3
|
+
bot env("TELEGRAM_BOT_TOKEN")
|
|
4
|
+
|
|
5
|
+
when someone sends "/start"
|
|
6
|
+
reply "Welcome. Use /status or /ask <question>."
|
|
7
|
+
done
|
|
8
|
+
|
|
9
|
+
when someone sends "/status"
|
|
10
|
+
reply "All systems are operational."
|
|
11
|
+
done
|
|
12
|
+
|
|
13
|
+
when someone sends matching "/ask (.+)"
|
|
14
|
+
telegramCall("sendChatAction", {chat_id: chatId, action: "typing"})
|
|
15
|
+
remember answer as chatWith("groq", "llama-3.3-70b-versatile", message)
|
|
16
|
+
reply answer
|
|
17
|
+
done
|
|
18
|
+
|
|
19
|
+
start telegram bot
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// PlainScript 1.0.2-latest: web apps, routes, JSON, and status codes.
|
|
2
|
+
|
|
3
|
+
web app
|
|
4
|
+
allow cors
|
|
5
|
+
|
|
6
|
+
route get "/health"
|
|
7
|
+
reply json
|
|
8
|
+
ok is true
|
|
9
|
+
service is "plain-script"
|
|
10
|
+
done
|
|
11
|
+
done
|
|
12
|
+
|
|
13
|
+
route post "/echo"
|
|
14
|
+
remember incoming as body of request
|
|
15
|
+
reply json
|
|
16
|
+
received is incoming
|
|
17
|
+
done
|
|
18
|
+
done
|
|
19
|
+
|
|
20
|
+
when nothing matches
|
|
21
|
+
status 404
|
|
22
|
+
reply json
|
|
23
|
+
error is "not found"
|
|
24
|
+
done
|
|
25
|
+
done
|
|
26
|
+
|
|
27
|
+
start 0
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// PlainScript 1.0.2-latest: WebSocket server handlers.
|
|
2
|
+
|
|
3
|
+
websocket server on 8080
|
|
4
|
+
when socket connects
|
|
5
|
+
send socket "connected"
|
|
6
|
+
done
|
|
7
|
+
when socket sends message
|
|
8
|
+
broadcast message
|
|
9
|
+
done
|
|
10
|
+
when socket disconnects
|
|
11
|
+
show "socket closed"
|
|
12
|
+
done
|
|
13
|
+
done
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
// PlainScript 1.0.2-latest: WhatsApp pairing login.
|
|
2
|
+
|
|
1
3
|
whatsapp bot
|
|
2
|
-
auth "
|
|
4
|
+
auth "plain-script-whatsapp"
|
|
3
5
|
login pairing "2348012345678"
|
|
4
|
-
|
|
5
6
|
on message
|
|
6
7
|
log message
|
|
7
|
-
|
|
8
8
|
if message.text is "/start"
|
|
9
9
|
reply "Welcome!"
|
|
10
10
|
done
|
|
11
|
-
|
|
12
11
|
if message.text is "/help"
|
|
13
12
|
reply `Available commands:
|
|
14
13
|
/start /help`
|
|
15
14
|
done
|
|
16
15
|
done
|
|
17
|
-
done
|
|
16
|
+
done
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plainscript-lang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2-latest",
|
|
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
7
|
"plainscript": "./compiler/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"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/backend.test.js && node tests/runtime.test.js && node tests/acceptance.test.js && node tests/whatsapp.test.js && node tests/audit.test.js"
|
|
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/acceptance.test.js && node tests/whatsapp.test.js && node tests/audit.test.js && node tests/docs.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
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"compiler",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"ws": "^8.21.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"mongodb": "^7.6.0",
|
|
45
46
|
"tesseract.js": "^7.0.0"
|
|
46
47
|
}
|
|
47
48
|
}
|