plainscript-lang 0.1.7 → 1.0.0-beta
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 +61 -36
- package/compiler/bundler.js +1 -1
- package/compiler/cli.js +42 -42
- package/compiler/generator.js +623 -10
- package/compiler/lexer.js +31 -2
- package/compiler/parser.js +539 -22
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +379 -0
- package/docs/PLINJS_SPEC.md +124 -24
- package/docs/index.html +535 -2205
- package/docs/website/script.js +889 -133
- package/docs/website/style.css +652 -1113
- package/examples/{cache-and-jobs.pln → cache-and-jobs.ps} +1 -1
- package/examples/{database.pln → database.ps} +1 -1
- package/examples/{deployment.pln → deployment.ps} +1 -1
- package/examples/{email-send.pln → email-send.ps} +1 -1
- package/examples/{rest-api.pln → rest-api.ps} +1 -1
- package/examples/{scheduled-tasks.pln → scheduled-tasks.ps} +1 -1
- package/examples/{websocket-server.pln → websocket-server.ps} +1 -1
- package/package.json +2 -2
- package/docs/website/index.html +0 -1500
- /package/examples/{arrays.pln → arrays.ps} +0 -0
- /package/examples/{day2.pln → day2.ps} +0 -0
- /package/examples/{day3.pln → day3.ps} +0 -0
- /package/examples/{expressions.pln → expressions.ps} +0 -0
- /package/examples/football-backend/{app.pln → app.ps} +0 -0
- /package/examples/{hello.pln → hello.ps} +0 -0
- /package/examples/id-verification/{app.pln → app.ps} +0 -0
- /package/examples/{loops.pln → loops.ps} +0 -0
- /package/examples/{objects.pln → objects.ps} +0 -0
- /package/examples/{rest-api-fetch.pln → rest-api-fetch.ps} +0 -0
- /package/examples/{server.pln → server.ps} +0 -0
- /package/examples/{start.pln → start.ps} +0 -0
- /package/examples/{stdlib.pln → stdlib.ps} +0 -0
- /package/examples/{telegram-bot.pln → telegram-bot.ps} +0 -0
- /package/examples/{web-app.pln → web-app.ps} +0 -0
- /package/examples/whatsapp-bot/{pairing.pln → pairing.ps} +0 -0
- /package/examples/whatsapp-bot/{qr.pln → qr.ps} +0 -0
package/compiler/lexer.js
CHANGED
|
@@ -65,6 +65,20 @@ const TOKEN = {
|
|
|
65
65
|
ASK: 'ASK', // interactive input: ask name / ask "prompt" as name
|
|
66
66
|
OCR_KW: 'OCR_KW', // v2.0.1 — ocr "<image>" as <name> [using "<lang>"]
|
|
67
67
|
PACKAGE: 'PACKAGE', // bare npm package name after "use" (may contain -, _, ., /, @)
|
|
68
|
+
GATHER: 'GATHER', // gather each item in list giving expr (functional map)
|
|
69
|
+
FILTER_KW: 'FILTER_KW', // filter each item in list when condition (functional filter)
|
|
70
|
+
TOTAL: 'TOTAL', // total each item in list giving expr (functional reduce)
|
|
71
|
+
MATCH: 'MATCH', // match expr against ... done (pattern matching)
|
|
72
|
+
AGAINST: 'AGAINST', // match ... against keyword
|
|
73
|
+
PATTERN_KW: 'PATTERN_KW', // match pattern "regex" in text (regex matching)
|
|
74
|
+
PARALLEL: 'PARALLEL', // run in parallel ... done (worker threads)
|
|
75
|
+
STREAM: 'STREAM', // stream "file" as line ... done (line-by-line processing)
|
|
76
|
+
EMIT: 'EMIT', // emit "event.name" with data (event emitter)
|
|
77
|
+
HAPPENS: 'HAPPENS', // when "event.name" happens as data (event listener)
|
|
78
|
+
CATCHES: 'CATCHES', // recover when err catches "TypeError" (typed error recovery)
|
|
79
|
+
// v1.0.0 — generators. "yield" is a JavaScript reserved word, so it becomes a
|
|
80
|
+
// real keyword token (a variable named `yield` is illegal in JS anyway).
|
|
81
|
+
YIELD: 'YIELD',
|
|
68
82
|
// Punctuation
|
|
69
83
|
LBRACE: 'LBRACE', // { — inline object literal (v1.2)
|
|
70
84
|
RBRACE: 'RBRACE', // }
|
|
@@ -157,6 +171,19 @@ const KEYWORDS = {
|
|
|
157
171
|
ask: TOKEN.ASK,
|
|
158
172
|
// v2.0.1 — OCR capability
|
|
159
173
|
ocr: TOKEN.OCR_KW,
|
|
174
|
+
// IOPL-native features
|
|
175
|
+
gather: TOKEN.GATHER,
|
|
176
|
+
filter: TOKEN.FILTER_KW,
|
|
177
|
+
total: TOKEN.TOTAL,
|
|
178
|
+
match: TOKEN.MATCH,
|
|
179
|
+
against: TOKEN.AGAINST,
|
|
180
|
+
pattern: TOKEN.PATTERN_KW,
|
|
181
|
+
parallel: TOKEN.PARALLEL,
|
|
182
|
+
stream: TOKEN.STREAM,
|
|
183
|
+
emit: TOKEN.EMIT,
|
|
184
|
+
happens: TOKEN.HAPPENS,
|
|
185
|
+
catches: TOKEN.CATCHES,
|
|
186
|
+
yield: TOKEN.YIELD,
|
|
160
187
|
};
|
|
161
188
|
|
|
162
189
|
// Keywords that introduce raw SQL blocks (content up to "done" is collected verbatim).
|
|
@@ -297,7 +324,7 @@ function tokenize(source) {
|
|
|
297
324
|
while (i < source.length && /[a-zA-Z0-9_]/.test(source[i])) word += source[i++];
|
|
298
325
|
|
|
299
326
|
// SQL block keywords: collect raw content up to "done"
|
|
300
|
-
if (SQL_BLOCK_WORDS
|
|
327
|
+
if (Object.prototype.hasOwnProperty.call(SQL_BLOCK_WORDS, word)) {
|
|
301
328
|
const kwType = SQL_BLOCK_WORDS[word];
|
|
302
329
|
tokens.push({ type: kwType, value: word, line: tokenLine, col: tokenCol });
|
|
303
330
|
|
|
@@ -377,7 +404,9 @@ function tokenize(source) {
|
|
|
377
404
|
continue;
|
|
378
405
|
}
|
|
379
406
|
|
|
380
|
-
const type = KEYWORDS
|
|
407
|
+
const type = Object.prototype.hasOwnProperty.call(KEYWORDS, word)
|
|
408
|
+
? KEYWORDS[word]
|
|
409
|
+
: TOKEN.IDENTIFIER;
|
|
381
410
|
if (type === TOKEN.USE) pendingUse = true;
|
|
382
411
|
tokens.push({ type, value: word, line: tokenLine, col: tokenCol });
|
|
383
412
|
continue;
|