plainscript-lang 0.1.7-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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +815 -0
  3. package/compiler/bundler.js +86 -0
  4. package/compiler/cli.js +843 -0
  5. package/compiler/dependency-detector.js +173 -0
  6. package/compiler/formatter.js +170 -0
  7. package/compiler/generator.js +2032 -0
  8. package/compiler/lexer.js +413 -0
  9. package/compiler/parser.js +2077 -0
  10. package/compiler/version.js +6 -0
  11. package/docs/PLINJS_SPEC.md +1051 -0
  12. package/docs/index.html +2287 -0
  13. package/docs/logo.jpg +0 -0
  14. package/docs/website/index.html +1500 -0
  15. package/docs/website/script.js +197 -0
  16. package/docs/website/style.css +1117 -0
  17. package/examples/arrays.pln +13 -0
  18. package/examples/cache-and-jobs.pln +29 -0
  19. package/examples/database.pln +41 -0
  20. package/examples/day2.pln +7 -0
  21. package/examples/day3.pln +11 -0
  22. package/examples/deployment.pln +12 -0
  23. package/examples/email-send.pln +22 -0
  24. package/examples/expressions.pln +40 -0
  25. package/examples/football-backend/app.pln +90 -0
  26. package/examples/hello.pln +3 -0
  27. package/examples/id-verification/app.pln +29 -0
  28. package/examples/id-verification/make-sample-id.js +123 -0
  29. package/examples/loops.pln +17 -0
  30. package/examples/objects.pln +12 -0
  31. package/examples/rest-api-fetch.pln +94 -0
  32. package/examples/rest-api.pln +68 -0
  33. package/examples/scheduled-tasks.pln +23 -0
  34. package/examples/server.pln +25 -0
  35. package/examples/start.pln +2 -0
  36. package/examples/stdlib.pln +41 -0
  37. package/examples/telegram-bot.pln +42 -0
  38. package/examples/web-app.pln +20 -0
  39. package/examples/websocket-server.pln +27 -0
  40. package/examples/whatsapp-bot/pairing.pln +17 -0
  41. package/examples/whatsapp-bot/qr.pln +8 -0
  42. package/package.json +47 -0
@@ -0,0 +1,41 @@
1
+ // PlainScript v0.6 — Standard Library Examples
2
+
3
+ // print (alias for show, compiled to console.log)
4
+ print("Hello from print!")
5
+
6
+ // time and date
7
+ remember now as time()
8
+ remember today as date()
9
+ show now
10
+ show today
11
+
12
+ // JSON encoding and decoding
13
+ remember user as
14
+ name is "Ayokunle"
15
+ age is 17
16
+ done
17
+
18
+ remember encoded as jsonEncode(user)
19
+ show encoded
20
+
21
+ remember decoded as jsonDecode(encoded)
22
+ show decoded
23
+
24
+ // Environment variables
25
+ remember nodeEnv as env("NODE_ENV")
26
+ show nodeEnv
27
+
28
+ // File operations
29
+ writeFile("hello.txt", "Hello from PlainScript!")
30
+ remember exists as fileExists("hello.txt")
31
+ show exists
32
+
33
+ remember content as readFile("hello.txt")
34
+ show content
35
+
36
+ // UUID
37
+ remember id as uuid()
38
+ show id
39
+
40
+ // exit (commented out so this example can run fully)
41
+ // exit(0)
@@ -0,0 +1,42 @@
1
+ // Telegram bot with buttons and callbacks
2
+ //
3
+ // Creates a polling Telegram bot that answers commands and handles
4
+ // inline keyboard callbacks.
5
+
6
+ bot env("BOT_TOKEN")
7
+
8
+ // Start command: welcome message with an inline keyboard
9
+ when someone sends "/start"
10
+ reply "Welcome to the PlainScript bot!" with buttons
11
+ "Help" -> "help"
12
+ "About" -> "about"
13
+ "Status" -> "status"
14
+ done
15
+ done
16
+
17
+ // Help command
18
+ when someone sends "/help"
19
+ reply "Available commands:\n/start - Show menu\n/help - Show this help\n/status - Bot status"
20
+ done
21
+
22
+ // Status command
23
+ when someone sends "/status"
24
+ remember now as date()
25
+ reply "Current time: " + now
26
+ done
27
+
28
+ // Callback handlers for the inline keyboard buttons
29
+ when someone clicks "help"
30
+ reply "This bot demonstrates the Telegram integration."
31
+ done
32
+
33
+ when someone clicks "about"
34
+ reply "Built with PlainScript - an Intent-Oriented Programming Language."
35
+ done
36
+
37
+ when someone clicks "status"
38
+ reply "The bot is running."
39
+ done
40
+
41
+ // Boot long polling
42
+ start telegram bot
@@ -0,0 +1,20 @@
1
+ // PlainScript v0.6 — Web App (Express shorthand)
2
+
3
+ web app
4
+
5
+ route "/"
6
+ reply "Hello from PlainScript!"
7
+ done
8
+
9
+ route "/about"
10
+ reply "About PlainScript"
11
+ done
12
+
13
+ route "/api/status"
14
+ reply json
15
+ status is "ok"
16
+ version is "0.6"
17
+ done
18
+ done
19
+
20
+ start 3000
@@ -0,0 +1,27 @@
1
+ // PlainScript v2.1 — WebSocket chat server
2
+ //
3
+ // Run with: plainscript run examples/websocket-server.pln
4
+ // Then connect any ws client to ws://localhost:8080 and start typing.
5
+ // Every message a client sends is echoed back to it and broadcast to
6
+ // everyone else.
7
+
8
+ websocket server on 8080
9
+
10
+ when socket connects
11
+ send socket "Welcome to the PlainScript chat server!"
12
+ broadcast "Someone new joined the chat"
13
+ done
14
+
15
+ when socket sends message
16
+ show "Got: " + message
17
+ send socket "You said: " + message
18
+ broadcast message
19
+ done
20
+
21
+ when socket disconnects
22
+ broadcast "Someone left the chat"
23
+ done
24
+
25
+ done
26
+
27
+ show "Chat server listening on port 8080"
@@ -0,0 +1,17 @@
1
+ whatsapp bot
2
+ auth "session"
3
+ login pairing "2348012345678"
4
+
5
+ on message
6
+ log message
7
+
8
+ if message.text is "/start"
9
+ reply "Welcome!"
10
+ done
11
+
12
+ if message.text is "/help"
13
+ reply `Available commands:
14
+ /start /help`
15
+ done
16
+ done
17
+ done
@@ -0,0 +1,8 @@
1
+ whatsapp bot
2
+ auth "session"
3
+ login qr
4
+
5
+ on message
6
+ log message
7
+ done
8
+ done
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "plainscript-lang",
3
+ "version": "0.1.7-latest",
4
+ "description": "PlainScript — an Intent-Oriented Programming Language. When even a simple sentence can be code.",
5
+ "main": "compiler/cli.js",
6
+ "bin": {
7
+ "plainscript": "./compiler/cli.js"
8
+ },
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"
11
+ },
12
+ "files": [
13
+ "compiler",
14
+ "docs",
15
+ "examples",
16
+ "LICENSE",
17
+ "README.md"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "keywords": [
23
+ "plainscript",
24
+ "language",
25
+ "compiler",
26
+ "iopl"
27
+ ],
28
+ "license": "MIT",
29
+ "engines": {
30
+ "node": ">=18.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@whiskeysockets/baileys": "^7.0.0-rc14",
34
+ "better-sqlite3": "^13.0.3",
35
+ "croner": "^10.0.1",
36
+ "express": "^5.2.1",
37
+ "multer": "^2.0.2",
38
+ "nodemailer": "^9.0.5",
39
+ "qrcode-terminal": "^0.12.0",
40
+ "redis": "^6.2.1",
41
+ "sql.js": "^1.13.0",
42
+ "ws": "^8.21.3"
43
+ },
44
+ "dependencies": {
45
+ "tesseract.js": "^7.0.0"
46
+ }
47
+ }