plainscript-lang 0.1.7 → 1.0.0-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 (49) hide show
  1. package/README.md +98 -40
  2. package/compiler/bundler.js +1 -1
  3. package/compiler/cli.js +166 -57
  4. package/compiler/generator.js +878 -19
  5. package/compiler/lexer.js +31 -2
  6. package/compiler/parser.js +668 -24
  7. package/compiler/version.js +1 -1
  8. package/docs/CAPABILITY_GAP_AUDIT.md +439 -0
  9. package/docs/PLINJS_SPEC.md +124 -24
  10. package/docs/index.html +555 -2220
  11. package/docs/website/script.js +889 -133
  12. package/docs/website/style.css +652 -1113
  13. package/examples/auth-api.ps +56 -0
  14. package/examples/{cache-and-jobs.pln → cache-and-jobs.ps} +1 -1
  15. package/examples/concurrency.ps +49 -0
  16. package/examples/{database.pln → database.ps} +1 -1
  17. package/examples/{deployment.pln → deployment.ps} +1 -1
  18. package/examples/{email-send.pln → email-send.ps} +1 -1
  19. package/examples/error-handling.ps +54 -0
  20. package/examples/file-uploads.ps +39 -0
  21. package/examples/files-and-config.ps +47 -0
  22. package/examples/http-client.ps +44 -0
  23. package/examples/modules/app.ps +16 -0
  24. package/examples/modules/math.ps +20 -0
  25. package/examples/record-kinds.ps +43 -0
  26. package/examples/{rest-api.pln → rest-api.ps} +1 -1
  27. package/examples/{scheduled-tasks.pln → scheduled-tasks.ps} +1 -1
  28. package/examples/search-and-filter.ps +34 -0
  29. package/examples/sessions-and-cookies.ps +54 -0
  30. package/examples/{websocket-server.pln → websocket-server.ps} +1 -1
  31. package/package.json +2 -2
  32. package/docs/website/index.html +0 -1500
  33. /package/examples/{arrays.pln → arrays.ps} +0 -0
  34. /package/examples/{day2.pln → day2.ps} +0 -0
  35. /package/examples/{day3.pln → day3.ps} +0 -0
  36. /package/examples/{expressions.pln → expressions.ps} +0 -0
  37. /package/examples/football-backend/{app.pln → app.ps} +0 -0
  38. /package/examples/{hello.pln → hello.ps} +0 -0
  39. /package/examples/id-verification/{app.pln → app.ps} +0 -0
  40. /package/examples/{loops.pln → loops.ps} +0 -0
  41. /package/examples/{objects.pln → objects.ps} +0 -0
  42. /package/examples/{rest-api-fetch.pln → rest-api-fetch.ps} +0 -0
  43. /package/examples/{server.pln → server.ps} +0 -0
  44. /package/examples/{start.pln → start.ps} +0 -0
  45. /package/examples/{stdlib.pln → stdlib.ps} +0 -0
  46. /package/examples/{telegram-bot.pln → telegram-bot.ps} +0 -0
  47. /package/examples/{web-app.pln → web-app.ps} +0 -0
  48. /package/examples/whatsapp-bot/{pairing.pln → pairing.ps} +0 -0
  49. /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-latest — 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[word]) {
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[word] || TOKEN.IDENTIFIER;
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;