plainscript-lang 1.0.0-latest → 1.0.1
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 +4 -4
- package/compiler/cli.js +1 -1
- package/compiler/generator.js +104 -118
- package/compiler/lexer.js +1 -1
- package/compiler/parser.js +10 -10
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +7 -7
- package/docs/PLINJS_SPEC.md +4 -4
- package/docs/index.html +3 -3
- package/docs/website/script.js +1 -1
- package/examples/auth-api.ps +2 -2
- package/examples/concurrency.ps +1 -1
- package/examples/error-handling.ps +1 -1
- package/examples/file-uploads.ps +1 -1
- package/examples/files-and-config.ps +1 -1
- package/examples/http-client.ps +1 -1
- package/examples/modules/app.ps +1 -1
- package/examples/modules/math.ps +1 -1
- package/examples/record-kinds.ps +1 -1
- package/examples/search-and-filter.ps +1 -1
- package/examples/sessions-and-cookies.ps +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
PlainScript is an Intent-Oriented Programming Language (IOPL). You describe **what** you want; the compiler decides **how** to implement it in JavaScript.
|
|
11
11
|
|
|
12
|
-
**Current version:** v1.0.
|
|
12
|
+
**Current version:** v1.0.1 — the `plainscript` npm package with a TypeScript-style production build (`plainscript build` → `dist/`, source names preserved).
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -26,7 +26,7 @@ node dist/app.js # or: npm start
|
|
|
26
26
|
Adding PlainScript to an existing project:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npm install --save-dev plainscript
|
|
29
|
+
npm install --save-dev plainscript-lang
|
|
30
30
|
# start writing src/*.ps files — plainscript build auto-discovers them
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -108,7 +108,7 @@ For projects that need custom output or source directories, add a
|
|
|
108
108
|
"build": "plainscript build",
|
|
109
109
|
"prepare": "plainscript build"
|
|
110
110
|
},
|
|
111
|
-
"devDependencies": { "plainscript": "^1.0.
|
|
111
|
+
"devDependencies": { "plainscript-lang": "^1.0.1" }
|
|
112
112
|
}
|
|
113
113
|
```
|
|
114
114
|
|
|
@@ -297,7 +297,7 @@ use node-fetch
|
|
|
297
297
|
use @scope/package-name
|
|
298
298
|
```
|
|
299
299
|
|
|
300
|
-
### TypeScript-parity capabilities (1.0.
|
|
300
|
+
### TypeScript-parity capabilities (1.0.1)
|
|
301
301
|
|
|
302
302
|
The full capability-gap audit lives in [`docs/CAPABILITY_GAP_AUDIT.md`](https://github.com/ayoistooslick/plainscript/blob/main/docs/CAPABILITY_GAP_AUDIT.md).
|
|
303
303
|
These features close it in PlainScript's own grammar:
|
package/compiler/cli.js
CHANGED
|
@@ -552,7 +552,7 @@ done
|
|
|
552
552
|
// deployment only needs the generated dist/ output.
|
|
553
553
|
fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({
|
|
554
554
|
name,
|
|
555
|
-
version: '1.0.
|
|
555
|
+
version: '1.0.1',
|
|
556
556
|
description: `A PlainScript v${VERSION} application`,
|
|
557
557
|
main: 'dist/app.js',
|
|
558
558
|
scripts: {
|
package/compiler/generator.js
CHANGED
|
@@ -40,7 +40,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
40
40
|
fs: `const fs = require('fs');`,
|
|
41
41
|
path: `const path = require('path');`,
|
|
42
42
|
crypto: `const crypto = require('crypto');`,
|
|
43
|
-
// v1.0.
|
|
43
|
+
// v1.0.1 — env-file runtime. Applies KEY=VALUE pairs from a .env file to
|
|
44
44
|
// process.env. Blank lines and `#` comment lines are skipped.
|
|
45
45
|
dotenv: [
|
|
46
46
|
`function __loadEnvFile(path) {`,
|
|
@@ -86,7 +86,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
86
86
|
` }`,
|
|
87
87
|
`}`,
|
|
88
88
|
].join('\n'),
|
|
89
|
-
// v1.0.
|
|
89
|
+
// v1.0.1 — shared runtime helpers for reflection, binary-size, YAML subset
|
|
90
90
|
// parsing/emitting, spread of timeouts, and set/map helpers. Injected lazily
|
|
91
91
|
// when any feature that needs them is used.
|
|
92
92
|
core: [
|
|
@@ -219,7 +219,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
219
219
|
` });`,
|
|
220
220
|
`}`,
|
|
221
221
|
].join('\n'),
|
|
222
|
-
// v1.0.
|
|
222
|
+
// v1.0.1 — process execution (child processes).
|
|
223
223
|
process: [
|
|
224
224
|
`const { execFile } = require('child_process');`,
|
|
225
225
|
`function __runCommand(command, args) {`,
|
|
@@ -230,7 +230,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
230
230
|
` });`,
|
|
231
231
|
`}`,
|
|
232
232
|
].join('\n'),
|
|
233
|
-
// v1.0.
|
|
233
|
+
// v1.0.1 — Map helpers.
|
|
234
234
|
mapset: [
|
|
235
235
|
`function __mapSet(map, key, value) { map.set(key, value); return map; }`,
|
|
236
236
|
].join('\n'),
|
|
@@ -277,7 +277,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
277
277
|
` return { items: slice, count: total, page, pages, perPage, hasNext: page < pages, hasPrev: page > 1 };`,
|
|
278
278
|
`}`,
|
|
279
279
|
].join('\n'),
|
|
280
|
-
// v1.0.
|
|
280
|
+
// v1.0.1 — dynamic module loader.
|
|
281
281
|
loadmodule: [
|
|
282
282
|
`function __loadModule(spec) {`,
|
|
283
283
|
` const path = require('path');`,
|
|
@@ -286,7 +286,7 @@ const BUILTIN_DECLARATIONS = {
|
|
|
286
286
|
` catch (e) { if (spec[0] !== '.') return require(spec); throw e; }`,
|
|
287
287
|
`}`,
|
|
288
288
|
].join('\n'),
|
|
289
|
-
// v1.0.
|
|
289
|
+
// v1.0.1 — recursive directory walker (returns full paths, files first).
|
|
290
290
|
walk: [
|
|
291
291
|
`function __walkFolder(dir) {`,
|
|
292
292
|
` const fs = require('fs');`,
|
|
@@ -1121,7 +1121,7 @@ const STDLIB = {
|
|
|
1121
1121
|
// v1.2 — Telegram runtime helpers
|
|
1122
1122
|
bot: (args, context) => {
|
|
1123
1123
|
ensureBuiltin(context, 'telegram');
|
|
1124
|
-
|
|
1124
|
+
markAsync(context);
|
|
1125
1125
|
return `BOT = await Telegram.createTelegramBot(${args.map(arg => generateExpr(arg, context)).join(', ')})`;
|
|
1126
1126
|
},
|
|
1127
1127
|
sendMessage: (args, context) => {
|
|
@@ -1261,7 +1261,7 @@ const STDLIB = {
|
|
|
1261
1261
|
padStart: (args, context) => `String(${generateExpr(args[0], context)}).padStart(${generateExpr(args[1], context)}, String(${args.length > 2 ? generateExpr(args[2], context) : '" "'}))`,
|
|
1262
1262
|
padEnd: (args, context) => `String(${generateExpr(args[0], context)}).padEnd(${generateExpr(args[1], context)}, String(${args.length > 2 ? generateExpr(args[2], context) : '" "'}))`,
|
|
1263
1263
|
|
|
1264
|
-
// ── v1.0.
|
|
1264
|
+
// ── v1.0.1 — nullable / regex / date helpers (IOPL-native).
|
|
1265
1265
|
// first non-null, non-undefined argument — IOPL null-coalescing.
|
|
1266
1266
|
coalesce: (args, context) =>
|
|
1267
1267
|
`(() => { const __vals = [${args.map(a => generateExpr(a, context)).join(', ')}]; for (const __v of __vals) if (__v !== null && __v !== undefined) return __v; return undefined; })()`,
|
|
@@ -1351,7 +1351,7 @@ const STDLIB = {
|
|
|
1351
1351
|
return `readToken(${args.map(arg => generateExpr(arg, context)).join(', ')})`;
|
|
1352
1352
|
},
|
|
1353
1353
|
|
|
1354
|
-
// ── v1.0.
|
|
1354
|
+
// ── v1.0.1 — capability-gap stdlib (reflection, binary, concurrency, ...) ──
|
|
1355
1355
|
|
|
1356
1356
|
// Reflection
|
|
1357
1357
|
typeOf: (args, context) => { ensureBuiltin(context, 'core'); return `__typeOf(${generateExpr(args[0], context)})`; },
|
|
@@ -1412,7 +1412,7 @@ const STDLIB = {
|
|
|
1412
1412
|
// Generators / iterables
|
|
1413
1413
|
spread: (args, context) => `[...${generateExpr(args[0], context)}]`,
|
|
1414
1414
|
|
|
1415
|
-
// v1.0.
|
|
1415
|
+
// v1.0.1 — dynamic module loading (the runtime companion to `import "./x.ps"`).
|
|
1416
1416
|
// Resolves relative to the bundler's CWD so `loadModule("./m")` behaves like
|
|
1417
1417
|
// `require.resolve` from the program root.
|
|
1418
1418
|
loadModule: (args, context) => {
|
|
@@ -1500,9 +1500,41 @@ const STDLIB = {
|
|
|
1500
1500
|
},
|
|
1501
1501
|
};
|
|
1502
1502
|
|
|
1503
|
-
// Mark the enclosing program async when a call awaits at the top level
|
|
1503
|
+
// Mark the enclosing program async when a call awaits at the top level, and
|
|
1504
|
+
// record that this scope emitted an `await` so handler and function bodies can
|
|
1505
|
+
// decide their own async-ness at generation time (see generateBlock). Routing
|
|
1506
|
+
// every await-emitting construct through this single function removes the need
|
|
1507
|
+
// for a separate hand-maintained registry of async statement types — so a new
|
|
1508
|
+
// async keyword can never silently break when used inside a route, listener, or
|
|
1509
|
+
// function.
|
|
1504
1510
|
function markAsync(context) {
|
|
1505
|
-
|
|
1511
|
+
context.emittedAwait = true;
|
|
1512
|
+
// Only a construct that awaits at the true top level needs the program
|
|
1513
|
+
// wrapped in an async IIFE. Awaits emitted inside a user function (inFunction)
|
|
1514
|
+
// or inside a route/listener/404 handler (inHandler) are handled by marking
|
|
1515
|
+
// that function/handler async instead — they must not drag the whole program
|
|
1516
|
+
// into an async wrapper, or "top-level use wraps the whole program" would be
|
|
1517
|
+
// the only safe nesting level for a new async keyword.
|
|
1518
|
+
if (!context.inFunction && !context.inHandler) context.needsAsync = true;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
// Generate a body of statements and report whether it emitted an `await`.
|
|
1522
|
+
//
|
|
1523
|
+
// This is the single source of truth for whether a route handler, listener,
|
|
1524
|
+
// 404 handler, or user function must be declared `async`. Previously this was
|
|
1525
|
+
// decided by a separate AST walker (containsAsyncBlock) that had to be kept in
|
|
1526
|
+
// sync by hand with every construct that compiles down to `await` — the exact
|
|
1527
|
+
// fragility that made "top-level use wraps the whole program" the only place
|
|
1528
|
+
// certain keywords (like ocr) were guaranteed to work. By observing the output
|
|
1529
|
+
// of generation instead, whatever a body contains is handled correctly, even if
|
|
1530
|
+
// it uses a brand-new async keyword.
|
|
1531
|
+
function generateBlock(statements, indent, context) {
|
|
1532
|
+
const prev = context.emittedAwait;
|
|
1533
|
+
context.emittedAwait = false;
|
|
1534
|
+
const out = statements.map(s => generateStatement(s, indent, context)).join('\n');
|
|
1535
|
+
const emitted = context.emittedAwait;
|
|
1536
|
+
context.emittedAwait = prev;
|
|
1537
|
+
return { out, emitted };
|
|
1506
1538
|
}
|
|
1507
1539
|
|
|
1508
1540
|
// v2.1.0 — generate a request accessor (param/query/header). These compile to
|
|
@@ -1574,6 +1606,7 @@ function emitSqlCall(kind, sql, params, indent, context) {
|
|
|
1574
1606
|
let n = 0;
|
|
1575
1607
|
const pgSql = String(sql).replace(/\?/g, () => (++n <= params.length ? `$${n}` : '?'));
|
|
1576
1608
|
const call = `${_sqlClientVar}.query(\`${pgSql}\`, [${args}])`;
|
|
1609
|
+
markAsync(context);
|
|
1577
1610
|
return kind === 'query' ? `(await ${call}).rows` : `await ${call}`;
|
|
1578
1611
|
}
|
|
1579
1612
|
switch (kind) {
|
|
@@ -1589,7 +1622,9 @@ function createGenerationContext() {
|
|
|
1589
1622
|
requires: new Set(),
|
|
1590
1623
|
pendingPrelude: [],
|
|
1591
1624
|
needsAsync: false, // true when top-level code emits await (js blocks / ask)
|
|
1625
|
+
emittedAwait: false, // true when the current generateBlock emitted an await
|
|
1592
1626
|
inFunction: false, // true while generating inside a function-like scope
|
|
1627
|
+
inHandler: false, // true while generating a route/listener/404 response body
|
|
1593
1628
|
loopDepth: 0, // >0 while generating inside a for-each / for-index / while loop
|
|
1594
1629
|
};
|
|
1595
1630
|
}
|
|
@@ -1654,72 +1689,6 @@ function ensureBuiltin(context, moduleName) {
|
|
|
1654
1689
|
}
|
|
1655
1690
|
}
|
|
1656
1691
|
|
|
1657
|
-
// Builtins whose calls await. A statement containing one of these anywhere in
|
|
1658
|
-
// its expressions must compile into an async context.
|
|
1659
|
-
const ASYNC_CALL_NAMES = new Set([
|
|
1660
|
-
// v2.1.0 — cache and email
|
|
1661
|
-
'cacheGet', 'cacheSet', 'cacheDelete', 'sendMail',
|
|
1662
|
-
// v2.2.0 — AI/ML calls await their model endpoint
|
|
1663
|
-
'chat', 'embedText',
|
|
1664
|
-
// v1.2 — Telegram helpers (await their API transport)
|
|
1665
|
-
'bot', 'sendMessage', 'sendPhoto', 'editMessage', 'getChat', 'getMyChats',
|
|
1666
|
-
]);
|
|
1667
|
-
|
|
1668
|
-
// Collect async builtin call names reachable from an AST fragment.
|
|
1669
|
-
function findAsyncCalls(node, found) {
|
|
1670
|
-
if (!node || typeof node !== 'object') return found;
|
|
1671
|
-
if (Array.isArray(node)) {
|
|
1672
|
-
for (const item of node) findAsyncCalls(item, found);
|
|
1673
|
-
return found;
|
|
1674
|
-
}
|
|
1675
|
-
if (node.type === 'CallExpression' && ASYNC_CALL_NAMES.has(node.name)) {
|
|
1676
|
-
found.add(node.name);
|
|
1677
|
-
}
|
|
1678
|
-
// v2.1.1 — HTTP client calls await; "wait for <expr>" awaits explicitly.
|
|
1679
|
-
if (node.type === 'HttpCall' || node.type === 'AwaitExpression') {
|
|
1680
|
-
found.add(node.type);
|
|
1681
|
-
}
|
|
1682
|
-
for (const value of Object.values(node)) {
|
|
1683
|
-
if (value && typeof value === 'object') findAsyncCalls(value, found);
|
|
1684
|
-
}
|
|
1685
|
-
return found;
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
// True when any statement in the block emits `await` (a JavaScript block,
|
|
1689
|
-
// `ask`, or `ocr`), including inside nested if / loop bodies. Nested PlainScript
|
|
1690
|
-
// function declarations are handled independently, so they are not descended
|
|
1691
|
-
// into.
|
|
1692
|
-
function containsAsyncBlock(statements) {
|
|
1693
|
-
for (const stmt of statements || []) {
|
|
1694
|
-
if (stmt.type === 'AskStatement' || stmt.type === 'JavaScriptBlock' || stmt.type === 'OcrStatement') return true;
|
|
1695
|
-
// v2.1.0 — transactions always await; PostgreSQL SQL statements await;
|
|
1696
|
-
// mail sends, cache setup and websocket handlers await.
|
|
1697
|
-
if (stmt.type === 'TransactionStatement') return true;
|
|
1698
|
-
if (stmt.type === 'SendMailStatement' || stmt.type === 'CacheStatement') return true;
|
|
1699
|
-
// v2.1.1 — opening the database awaits (native/wasm engine probe);
|
|
1700
|
-
// retry loops pause between attempts; try/recover recurse.
|
|
1701
|
-
if (stmt.type === 'DatabaseStatement' || stmt.type === 'RetryStatement') return true;
|
|
1702
|
-
if (stmt.type === 'TryStatement') {
|
|
1703
|
-
if (containsAsyncBlock(stmt.tryBody)) return true;
|
|
1704
|
-
if (stmt.recoverBody && containsAsyncBlock(stmt.recoverBody)) return true;
|
|
1705
|
-
continue;
|
|
1706
|
-
}
|
|
1707
|
-
if (_sqlDriver === 'pg' && (
|
|
1708
|
-
stmt.type === 'QueryStatement' || stmt.type === 'InsertStatement' ||
|
|
1709
|
-
stmt.type === 'UpdateStatement' || stmt.type === 'DeleteStatement' ||
|
|
1710
|
-
stmt.type === 'ExecuteStatement' || stmt.type === 'RememberSqlStatement'
|
|
1711
|
-
)) return true;
|
|
1712
|
-
if (findAsyncCalls(stmt, new Set()).size > 0) return true;
|
|
1713
|
-
if (stmt.type === 'IfStatement') {
|
|
1714
|
-
if (containsAsyncBlock(stmt.consequent)) return true;
|
|
1715
|
-
if (stmt.alternate && containsAsyncBlock(stmt.alternate)) return true;
|
|
1716
|
-
} else if (stmt.type !== 'FunctionDeclaration' && stmt.body && Array.isArray(stmt.body)) {
|
|
1717
|
-
if (containsAsyncBlock(stmt.body)) return true;
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
return false;
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
1692
|
// True when any statement in a block (recursively, skipping nested function
|
|
1724
1693
|
// declarations) contains a `yield`, which marks the enclosing function as a
|
|
1725
1694
|
// generator (function*).
|
|
@@ -1739,7 +1708,7 @@ function containsYield(statements) {
|
|
|
1739
1708
|
function generate(ast, context = createGenerationContext()) { if (ast.type !== 'Program') {
|
|
1740
1709
|
throw new Error(`Expected a Program node but got "${ast.type}".`);
|
|
1741
1710
|
}
|
|
1742
|
-
// v1.0.
|
|
1711
|
+
// v1.0.1 — reset per-program test bookkeeping so repeated generate() calls
|
|
1743
1712
|
// (build pipeline) start clean.
|
|
1744
1713
|
__testCount = 0;
|
|
1745
1714
|
__testCatchers = [];
|
|
@@ -1761,7 +1730,7 @@ function generate(ast, context = createGenerationContext()) { if (ast.type !==
|
|
|
1761
1730
|
lines.push(`if (typeof module !== 'undefined') { module.exports = { ${exported.join(', ')} }; }`);
|
|
1762
1731
|
}
|
|
1763
1732
|
|
|
1764
|
-
// v1.0.
|
|
1733
|
+
// v1.0.1 — native test runner. When any "test ... done" block exists, emit
|
|
1765
1734
|
// the runner helper, register each test after its function declaration, and
|
|
1766
1735
|
// execute them. Each failure prints a message and sets process.exitCode = 1.
|
|
1767
1736
|
if (__testCatchers.length > 0) {
|
|
@@ -1796,7 +1765,7 @@ function generate(ast, context = createGenerationContext()) { if (ast.type !==
|
|
|
1796
1765
|
return lines.join('\n');
|
|
1797
1766
|
}
|
|
1798
1767
|
|
|
1799
|
-
// ── v1.0.
|
|
1768
|
+
// ── v1.0.1 — test DSL bookkeeping ───────────────────────────────────────────
|
|
1800
1769
|
let __testCount = 0;
|
|
1801
1770
|
let __testCatchers = [];
|
|
1802
1771
|
let __inTest = false;
|
|
@@ -1849,7 +1818,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
1849
1818
|
case 'BecomeStatement':
|
|
1850
1819
|
return `${indent}${generateLValue(node.target, context)} = ${generateExpr(node.value, context)};`;
|
|
1851
1820
|
|
|
1852
|
-
// v1.0.
|
|
1821
|
+
// v1.0.1 — record kinds: `define a kind called "Person" with ... done`.
|
|
1853
1822
|
// Names are emitted as a JS factory that returns a fresh plain object with
|
|
1854
1823
|
// declared defaults. Constructors prompt for required fields at compile
|
|
1855
1824
|
// time via `create a Person with ...` (see GenerateExpr CreateKind).
|
|
@@ -1873,14 +1842,14 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
1873
1842
|
].join('\n');
|
|
1874
1843
|
}
|
|
1875
1844
|
|
|
1876
|
-
// v1.0.
|
|
1845
|
+
// v1.0.1 — load env file "<path>": apply KEY=VALUE pairs to process.env.
|
|
1877
1846
|
// Blank lines and `#` comments are skipped; values keep their text.
|
|
1878
1847
|
case 'LoadEnvFileStatement': {
|
|
1879
1848
|
ensureBuiltin(context, 'dotenv');
|
|
1880
1849
|
return `${indent}__loadEnvFile(${JSON.stringify(node.path)});`;
|
|
1881
1850
|
}
|
|
1882
1851
|
|
|
1883
|
-
// v1.0.
|
|
1852
|
+
// v1.0.1 — native test DSL. `test "<name>" ... done` registers a runnable
|
|
1884
1853
|
// unit; all tests are executed after the program body with a tiny runner.
|
|
1885
1854
|
case 'TestStatement': {
|
|
1886
1855
|
__testCount++;
|
|
@@ -1893,7 +1862,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
1893
1862
|
return `${indent}function ${fnName}() {\n${body}\n${indent}}`;
|
|
1894
1863
|
}
|
|
1895
1864
|
|
|
1896
|
-
// v1.0.
|
|
1865
|
+
// v1.0.1 — assertion `check <a> (equals|is|contains|raises) <b>`.
|
|
1897
1866
|
// For `raises`, `a` is wrapped in a thunk so the expression is evaluated
|
|
1898
1867
|
// inside the runner's try/catch (its thrown error is the subject).
|
|
1899
1868
|
case 'CheckStatement': {
|
|
@@ -1907,11 +1876,11 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
1907
1876
|
return `${indent}__check(${JSON.stringify(node.op)}, ${a}, ${b});`;
|
|
1908
1877
|
}
|
|
1909
1878
|
|
|
1910
|
-
// v1.0.
|
|
1879
|
+
// v1.0.1 — export <name>: mark a top-level symbol for module.exports.
|
|
1911
1880
|
case 'ExportStatement':
|
|
1912
1881
|
return `${indent}module.exports.${node.name} = ${node.name};`;
|
|
1913
1882
|
|
|
1914
|
-
// v1.0.
|
|
1883
|
+
// v1.0.1 — generators: `yield <expr>` (or bare `yield`).
|
|
1915
1884
|
case 'YieldStatement': {
|
|
1916
1885
|
if (!context.inFunction) {
|
|
1917
1886
|
throw new Error('"yield" can only be used inside a function created with "make".\n\nExample:\n make countUp(n)\n let i = 0\n while i less than n\n i = i + 1\n yield i\n done\n done');
|
|
@@ -1960,13 +1929,13 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
1960
1929
|
// body is emitted verbatim: JavaScript indentation, template literals,
|
|
1961
1930
|
// and line structure are preserved as written (RFC-0011 §31).
|
|
1962
1931
|
if (node.name) {
|
|
1963
|
-
|
|
1932
|
+
markAsync(context);
|
|
1964
1933
|
return `${indent}let ${node.name} = await (async () => {\n${node.body}\n${indent}})();`;
|
|
1965
1934
|
}
|
|
1966
1935
|
// Statement-level blocks inside functions/routes/loops, or that need
|
|
1967
1936
|
// top-level await, retain the async-context wrapper.
|
|
1968
1937
|
if (context.inFunction || hasTopLevelAwait) {
|
|
1969
|
-
|
|
1938
|
+
markAsync(context);
|
|
1970
1939
|
return `${indent}await (async () => {\n${node.body}\n${indent}})();`;
|
|
1971
1940
|
}
|
|
1972
1941
|
// Synchronous statement-level block: emit its body directly/verbatim.
|
|
@@ -1976,7 +1945,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
1976
1945
|
// ask name / ask "<prompt>" as name
|
|
1977
1946
|
case 'AskStatement': {
|
|
1978
1947
|
ensureBuiltin(context, 'ask');
|
|
1979
|
-
|
|
1948
|
+
markAsync(context);
|
|
1980
1949
|
const prompt = node.prompt != null ? JSON.stringify(node.prompt) : '"> "';
|
|
1981
1950
|
return `${indent}let ${node.variable} = await __ask(${prompt});`;
|
|
1982
1951
|
}
|
|
@@ -1984,14 +1953,18 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
1984
1953
|
// v2.0.1 — ocr "<image>" as <variable> [using "<lang>"]
|
|
1985
1954
|
case 'OcrStatement': {
|
|
1986
1955
|
ensureBuiltin(context, 'ocr');
|
|
1987
|
-
|
|
1956
|
+
markAsync(context);
|
|
1988
1957
|
const image = generateExpr(node.image, context);
|
|
1989
1958
|
const langArg = node.lang != null ? `, ${JSON.stringify(node.lang)}` : '';
|
|
1990
1959
|
return `${indent}let ${node.variable} = await __ocr(${image}${langArg});`;
|
|
1991
1960
|
}
|
|
1992
1961
|
|
|
1993
1962
|
case 'FunctionDeclaration': {
|
|
1994
|
-
const
|
|
1963
|
+
const prevInFunction = context.inFunction;
|
|
1964
|
+
context.inFunction = true;
|
|
1965
|
+
const block = generateBlock(node.body, indent + ' ', context);
|
|
1966
|
+
context.inFunction = prevInFunction;
|
|
1967
|
+
const isAsync = block.emitted ? 'async ' : '';
|
|
1995
1968
|
const isGen = containsYield(node.body) ? '*' : '';
|
|
1996
1969
|
const paramStr = node.params.map(p => {
|
|
1997
1970
|
if (typeof p === 'object') {
|
|
@@ -2000,11 +1973,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2000
1973
|
}
|
|
2001
1974
|
return p;
|
|
2002
1975
|
}).join(', ');
|
|
2003
|
-
|
|
2004
|
-
context.inFunction = true;
|
|
2005
|
-
const body = node.body.map(s => generateStatement(s, indent + ' ', context)).join('\n');
|
|
2006
|
-
context.inFunction = prevInFunction;
|
|
2007
|
-
return `${indent}${isAsync}function${isGen} ${node.name}(${paramStr}) {\n${body}\n${indent}}`;
|
|
1976
|
+
return `${indent}${isAsync}function${isGen} ${node.name}(${paramStr}) {\n${block.out}\n${indent}}`;
|
|
2008
1977
|
}
|
|
2009
1978
|
|
|
2010
1979
|
case 'IfStatement': {
|
|
@@ -2074,24 +2043,32 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2074
2043
|
// v0.3 — Express runtime
|
|
2075
2044
|
|
|
2076
2045
|
case 'ListenStatement': {
|
|
2077
|
-
const
|
|
2078
|
-
|
|
2079
|
-
|
|
2046
|
+
const prevInHandler = context.inHandler;
|
|
2047
|
+
context.inHandler = true;
|
|
2048
|
+
const block = generateBlock(node.body, indent + ' ', context);
|
|
2049
|
+
context.inHandler = prevInHandler;
|
|
2050
|
+
const handlerAsync = block.emitted ? 'async ' : '';
|
|
2051
|
+
return `${indent}app.listen(${generateExpr(node.port, context)}, ${handlerAsync}() => {\n${block.out}\n${indent}});`;
|
|
2080
2052
|
}
|
|
2081
2053
|
|
|
2082
2054
|
case 'RouteStatement': {
|
|
2083
2055
|
_inRoute = true;
|
|
2084
|
-
const
|
|
2085
|
-
|
|
2056
|
+
const prevInHandler = context.inHandler;
|
|
2057
|
+
context.inHandler = true;
|
|
2058
|
+
const block = generateBlock(node.body, indent + ' ', context);
|
|
2059
|
+
context.inHandler = prevInHandler;
|
|
2086
2060
|
_inRoute = false;
|
|
2087
|
-
|
|
2061
|
+
const handlerAsync = block.emitted ? 'async ' : '';
|
|
2062
|
+
return `${indent}app.get(${JSON.stringify(routePath(node.path))}, ${handlerAsync}(req, res) => {\n${block.out}\n${indent}});`;
|
|
2088
2063
|
}
|
|
2089
2064
|
|
|
2090
2065
|
case 'ReplyStatement':
|
|
2091
2066
|
if (_inTelegram) {
|
|
2067
|
+
markAsync(context);
|
|
2092
2068
|
return `${indent}await Telegram.sendMessage(ctx.chatId, ${generateExpr(node.value, context)});`;
|
|
2093
2069
|
}
|
|
2094
2070
|
if (_inWhatsApp) {
|
|
2071
|
+
markAsync(context);
|
|
2095
2072
|
ensureBuiltin(context, 'whatsapp');
|
|
2096
2073
|
return `${indent}await __whatsappReply(__waCtx.chat, ${generateExpr(node.value, context)});`;
|
|
2097
2074
|
}
|
|
@@ -2102,9 +2079,11 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2102
2079
|
.map(p => `${JSON.stringify(p.key)}: ${generateExpr(p.value, context)}`)
|
|
2103
2080
|
.join(', ');
|
|
2104
2081
|
if (_inTelegram) {
|
|
2082
|
+
markAsync(context);
|
|
2105
2083
|
return `${indent}await Telegram.sendMessage(ctx.chatId, JSON.stringify({ ${props} }));`;
|
|
2106
2084
|
}
|
|
2107
2085
|
if (_inWhatsApp) {
|
|
2086
|
+
markAsync(context);
|
|
2108
2087
|
ensureBuiltin(context, 'whatsapp');
|
|
2109
2088
|
return `${indent}await __whatsappReply(__waCtx.chat, JSON.stringify({ ${props} }));`;
|
|
2110
2089
|
}
|
|
@@ -2117,6 +2096,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2117
2096
|
// button is rendered as [text, data] and rows are merged into that list.
|
|
2118
2097
|
case 'ReplyWithButtonsStatement': {
|
|
2119
2098
|
ensureBuiltin(context, 'telegram');
|
|
2099
|
+
markAsync(context);
|
|
2120
2100
|
const pairs = node.buttons.flat().map(({ text, data }) => [text, data]);
|
|
2121
2101
|
return `${indent}await Telegram.sendMessage(ctx.chatId, ${generateExpr(node.value, context)}, ${JSON.stringify(pairs)});`;
|
|
2122
2102
|
}
|
|
@@ -2138,10 +2118,13 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2138
2118
|
|
|
2139
2119
|
case 'SimpleRouteStatement': {
|
|
2140
2120
|
_inRoute = true;
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2121
|
+
const prevInHandler = context.inHandler;
|
|
2122
|
+
context.inHandler = true;
|
|
2123
|
+
const block = generateBlock(node.body, indent + ' ', context);
|
|
2124
|
+
context.inHandler = prevInHandler;
|
|
2143
2125
|
_inRoute = false;
|
|
2144
|
-
|
|
2126
|
+
const handlerAsync = block.emitted ? 'async ' : '';
|
|
2127
|
+
return `${indent}app.${node.method}(${JSON.stringify(routePath(node.path))}, ${handlerAsync}(req, res) => {\n${block.out}\n${indent}});`;
|
|
2145
2128
|
}
|
|
2146
2129
|
|
|
2147
2130
|
// v2.1.0 — group "<prefix>" ... done: composes routes under a shared
|
|
@@ -2268,10 +2251,13 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2268
2251
|
// in registration order).
|
|
2269
2252
|
case 'NotFoundStatement': {
|
|
2270
2253
|
_inRoute = true;
|
|
2271
|
-
const
|
|
2272
|
-
|
|
2254
|
+
const prevInHandler = context.inHandler;
|
|
2255
|
+
context.inHandler = true;
|
|
2256
|
+
const block = generateBlock(node.body, indent + ' ', context);
|
|
2257
|
+
context.inHandler = prevInHandler;
|
|
2273
2258
|
_inRoute = false;
|
|
2274
|
-
|
|
2259
|
+
const handlerAsync = block.emitted ? 'async ' : '';
|
|
2260
|
+
return `${indent}app.use((${handlerAsync}req, res) => {\n${block.out}\n${indent}});`;
|
|
2275
2261
|
}
|
|
2276
2262
|
|
|
2277
2263
|
// ── v2.1.1 — error handling and retries
|
|
@@ -2364,7 +2350,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2364
2350
|
case 'PostgresStatement': {
|
|
2365
2351
|
_sqlDriver = 'pg';
|
|
2366
2352
|
_sqlClientVar = 'db';
|
|
2367
|
-
|
|
2353
|
+
markAsync(context);
|
|
2368
2354
|
return [
|
|
2369
2355
|
emitRequire(context, 'postgres'),
|
|
2370
2356
|
`${indent}const db = new Pool({ connectionString: ${generateExpr(node.connection, context)} });`,
|
|
@@ -2395,7 +2381,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2395
2381
|
if (_sqlDriver === 'pg') {
|
|
2396
2382
|
const prevClient = _sqlClientVar;
|
|
2397
2383
|
_sqlClientVar = '__txClient';
|
|
2398
|
-
|
|
2384
|
+
markAsync(context);
|
|
2399
2385
|
const body = node.body.map(s => generateStatement(s, indent + ' ', context)).join('\n');
|
|
2400
2386
|
_sqlClientVar = prevClient;
|
|
2401
2387
|
return [
|
|
@@ -2428,7 +2414,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2428
2414
|
|
|
2429
2415
|
case 'TelegramCommandStatement': {
|
|
2430
2416
|
ensureBuiltin(context, 'telegram');
|
|
2431
|
-
|
|
2417
|
+
markAsync(context);
|
|
2432
2418
|
_inTelegram = true;
|
|
2433
2419
|
const body = node.body.map(s => generateStatement(s, indent + ' ', context)).join('\n');
|
|
2434
2420
|
_inTelegram = false;
|
|
@@ -2440,7 +2426,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2440
2426
|
|
|
2441
2427
|
case 'TelegramCallbackStatement': {
|
|
2442
2428
|
ensureBuiltin(context, 'telegram');
|
|
2443
|
-
|
|
2429
|
+
markAsync(context);
|
|
2444
2430
|
_inTelegram = true;
|
|
2445
2431
|
const body = node.body.map(s => generateStatement(s, indent + ' ', context)).join('\n');
|
|
2446
2432
|
_inTelegram = false;
|
|
@@ -2449,7 +2435,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2449
2435
|
|
|
2450
2436
|
case 'TelegramStartStatement': {
|
|
2451
2437
|
ensureBuiltin(context, 'telegram');
|
|
2452
|
-
|
|
2438
|
+
markAsync(context);
|
|
2453
2439
|
return `${indent}await BOT.start();`;
|
|
2454
2440
|
}
|
|
2455
2441
|
|
|
@@ -2488,7 +2474,7 @@ function generateStatement(node, indent = '', context = createGenerationContext(
|
|
|
2488
2474
|
// WhatsApp message as a normalized PlainScript record on `message`.
|
|
2489
2475
|
case 'WhatsAppOnMessageStatement': {
|
|
2490
2476
|
ensureBuiltin(context, 'whatsapp');
|
|
2491
|
-
|
|
2477
|
+
markAsync(context);
|
|
2492
2478
|
const prevInWhatsApp = _inWhatsApp;
|
|
2493
2479
|
_inWhatsApp = true;
|
|
2494
2480
|
const body = node.body.map(s => generateStatement(s, indent + ' ', context)).join('\n');
|
|
@@ -2860,7 +2846,7 @@ function generateExpr(node, context = createGenerationContext()) {
|
|
|
2860
2846
|
ensureBuiltin(context, 'fs');
|
|
2861
2847
|
return `fs.writeFileSync(${generateExpr(node.data, context)}, ${generateExpr(node.file, context)}, 'utf8')`;
|
|
2862
2848
|
|
|
2863
|
-
// v1.0.
|
|
2849
|
+
// v1.0.1 — record constructor: `create a Person with name "Ada" and age 17`
|
|
2864
2850
|
// calls the kind factory that `define a kind called "Person"` registered.
|
|
2865
2851
|
case 'CreateKindExpression': {
|
|
2866
2852
|
const fields = node.pairs
|
|
@@ -2869,7 +2855,7 @@ function generateExpr(node, context = createGenerationContext()) {
|
|
|
2869
2855
|
return `${node.kind}({ ${fields} })`;
|
|
2870
2856
|
}
|
|
2871
2857
|
|
|
2872
|
-
// v1.0.
|
|
2858
|
+
// v1.0.1 — concurrency combinators: `all of [...]` / `any of [...]` /
|
|
2873
2859
|
// `settled of [...]`. All are awaited; `settled` returns status records.
|
|
2874
2860
|
case 'ConcurrencyExpression': {
|
|
2875
2861
|
markAsync(context);
|
|
@@ -2879,7 +2865,7 @@ function generateExpr(node, context = createGenerationContext()) {
|
|
|
2879
2865
|
return `(await Promise.all(${rhs}))`;
|
|
2880
2866
|
}
|
|
2881
2867
|
|
|
2882
|
-
// v1.0.
|
|
2868
|
+
// v1.0.1 — `spread of <collection>` → a fresh array from an iterable.
|
|
2883
2869
|
case 'SpreadExpression':
|
|
2884
2870
|
return `[...${generateExpr(node.collection, context)}]`;
|
|
2885
2871
|
|
package/compiler/lexer.js
CHANGED
|
@@ -76,7 +76,7 @@ const TOKEN = {
|
|
|
76
76
|
EMIT: 'EMIT', // emit "event.name" with data (event emitter)
|
|
77
77
|
HAPPENS: 'HAPPENS', // when "event.name" happens as data (event listener)
|
|
78
78
|
CATCHES: 'CATCHES', // recover when err catches "TypeError" (typed error recovery)
|
|
79
|
-
// v1.0.
|
|
79
|
+
// v1.0.1 — generators. "yield" is a JavaScript reserved word, so it becomes a
|
|
80
80
|
// real keyword token (a variable named `yield` is illegal in JS anyway).
|
|
81
81
|
YIELD: 'YIELD',
|
|
82
82
|
// Punctuation
|
package/compiler/parser.js
CHANGED
|
@@ -269,7 +269,7 @@ function parse(tokens) {
|
|
|
269
269
|
if (token.type === TOKEN.IF) return parseIf();
|
|
270
270
|
if (token.type === TOKEN.MAKE) return parseMake();
|
|
271
271
|
if (token.type === TOKEN.GIVE) return parseGive();
|
|
272
|
-
// v1.0.
|
|
272
|
+
// v1.0.1 — generators: `yield <expr>` is only meaningful inside a function
|
|
273
273
|
// body; the generator marks the enclosing `make ... done` as a function*.
|
|
274
274
|
if (token.type === TOKEN.YIELD) return parseYield();
|
|
275
275
|
if (token.type === TOKEN.FOR) return parseForEach();
|
|
@@ -578,7 +578,7 @@ function parse(tokens) {
|
|
|
578
578
|
return { type: 'GoogleOAuthStatement', options: parsePropertyList('"google oauth" block') };
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
-
// ── v1.0.
|
|
581
|
+
// ── v1.0.1 — capability-gap features (all contextual, IOPL-native) ──
|
|
582
582
|
|
|
583
583
|
// define a kind called "Person" with … done → record schema (classes)
|
|
584
584
|
if (token.value === 'define' &&
|
|
@@ -899,7 +899,7 @@ function parse(tokens) {
|
|
|
899
899
|
return { type: 'GiveStatement', value };
|
|
900
900
|
}
|
|
901
901
|
|
|
902
|
-
// v1.0.
|
|
902
|
+
// v1.0.1 — generators: `yield <expr>` (optionally bare `yield`).
|
|
903
903
|
function parseYield() {
|
|
904
904
|
consume(TOKEN.YIELD);
|
|
905
905
|
let value = null;
|
|
@@ -909,7 +909,7 @@ function parse(tokens) {
|
|
|
909
909
|
return { type: 'YieldStatement', value };
|
|
910
910
|
}
|
|
911
911
|
|
|
912
|
-
// v1.0.
|
|
912
|
+
// v1.0.1 — record kinds: `define a kind called "Person" with … done`
|
|
913
913
|
// The field block reuses the property-list grammar (`age is 0`), so each
|
|
914
914
|
// field gets a default expression just like an object literal.
|
|
915
915
|
function parseDefineKind() {
|
|
@@ -946,7 +946,7 @@ function parse(tokens) {
|
|
|
946
946
|
return { type: 'DefineKindStatement', name, fields };
|
|
947
947
|
}
|
|
948
948
|
|
|
949
|
-
// v1.0.
|
|
949
|
+
// v1.0.1 — record constructor (expression): `create a Person with name "Ada" and age 17`
|
|
950
950
|
function parseCreateKind() {
|
|
951
951
|
advance(); // create
|
|
952
952
|
advance(); // a / an
|
|
@@ -966,7 +966,7 @@ function parse(tokens) {
|
|
|
966
966
|
return { type: 'CreateKindExpression', kind, pairs };
|
|
967
967
|
}
|
|
968
968
|
|
|
969
|
-
// v1.0.
|
|
969
|
+
// v1.0.1 — native test DSL: `test "name" … done`
|
|
970
970
|
function parseTestStatement() {
|
|
971
971
|
advance(); // test
|
|
972
972
|
const name = consume(TOKEN.STRING, 'Expected a test name string after "test".').value;
|
|
@@ -974,7 +974,7 @@ function parse(tokens) {
|
|
|
974
974
|
return { type: 'TestStatement', name, body };
|
|
975
975
|
}
|
|
976
976
|
|
|
977
|
-
// v1.0.
|
|
977
|
+
// v1.0.1 — assertions: `check <a> (equals|is|contains|raises) <b>`
|
|
978
978
|
function parseCheckStatement() {
|
|
979
979
|
advance(); // check
|
|
980
980
|
const a = parseExpression();
|
|
@@ -1902,7 +1902,7 @@ function parse(tokens) {
|
|
|
1902
1902
|
|
|
1903
1903
|
// primary → itemExpr | atom (postfix)*
|
|
1904
1904
|
function parsePrimary() {
|
|
1905
|
-
// v1.0.
|
|
1905
|
+
// v1.0.1 — record constructor: `create a Person with name "Ada" and age 17`.
|
|
1906
1906
|
// `create` then an article ("a"/"an") then a kind name then "with" pairs.
|
|
1907
1907
|
if (peek().type === TOKEN.IDENTIFIER && peek().value === 'create') {
|
|
1908
1908
|
const a1 = peekAt(1);
|
|
@@ -1916,7 +1916,7 @@ function parse(tokens) {
|
|
|
1916
1916
|
}
|
|
1917
1917
|
}
|
|
1918
1918
|
|
|
1919
|
-
// v1.0.
|
|
1919
|
+
// v1.0.1 — concurrency combinators: `all of [a(), b()]`, `any of [...]`,
|
|
1920
1920
|
// `settled of [...]`. Guard on the identifier + "of" lookahead so plain
|
|
1921
1921
|
// property reads like `all of the_list` still work as well as prose.
|
|
1922
1922
|
if (peek().type === TOKEN.IDENTIFIER &&
|
|
@@ -1928,7 +1928,7 @@ function parse(tokens) {
|
|
|
1928
1928
|
return { type: 'ConcurrencyExpression', combo: comboKw, items };
|
|
1929
1929
|
}
|
|
1930
1930
|
|
|
1931
|
-
// v1.0.
|
|
1931
|
+
// v1.0.1 — `spread of <collection>` unfolds an iterable into a new array.
|
|
1932
1932
|
if (peek().type === TOKEN.IDENTIFIER && peek().value === 'spread' &&
|
|
1933
1933
|
peekAt(1).type === TOKEN.IDENTIFIER && peekAt(1).value === 'of') {
|
|
1934
1934
|
advance(); // spread
|
package/compiler/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# PlainScript 1.0.
|
|
1
|
+
# PlainScript 1.0.1 — Capability-Gap Audit vs. TypeScript / Node.js
|
|
2
2
|
|
|
3
3
|
> **Purpose.** PlainScript's goal is **capability parity**, not syntax parity, with
|
|
4
4
|
> modern TypeScript + Node.js. We do not clone TypeScript's syntax or its static
|
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
> (IOPL) — you describe *what* you want, and the deterministic compiler decides
|
|
7
7
|
> *how* to implement it in JavaScript.
|
|
8
8
|
>
|
|
9
|
-
> This document is the complete working audit for the 1.0.
|
|
9
|
+
> This document is the complete working audit for the 1.0.1 milestone. For every
|
|
10
10
|
> major TypeScript/Node.js capability area, it records:
|
|
11
11
|
>
|
|
12
|
-
> - **Status** — what PlainScript 1.0.
|
|
12
|
+
> - **Status** — what PlainScript 1.0.1 already does,
|
|
13
13
|
> - **Gap** — what is missing for real-world capability parity,
|
|
14
14
|
> - **Resolution** — either an *IOPL-native implementation* (shipped in this
|
|
15
15
|
> release and covered by tests) or an explicit *rationale* for why the
|
|
16
16
|
> capability is unnecessary / already supplied by the host runtime.
|
|
17
17
|
>
|
|
18
|
-
> **Gate:** PlainScript must NOT be declared 1.0.
|
|
18
|
+
> **Gate:** PlainScript must NOT be declared 1.0.1 "ready" until this audit is
|
|
19
19
|
> complete and its shipped resolutions are exercised by the test suite.
|
|
20
20
|
>
|
|
21
21
|
> ---
|
|
@@ -366,7 +366,7 @@ rows without reducing capability parity.
|
|
|
366
366
|
|
|
367
367
|
---
|
|
368
368
|
|
|
369
|
-
## 21. 1.0.
|
|
369
|
+
## 21. 1.0.1 readiness gate
|
|
370
370
|
|
|
371
371
|
The audit is **complete** only when:
|
|
372
372
|
|
|
@@ -376,13 +376,13 @@ The audit is **complete** only when:
|
|
|
376
376
|
3. The runtime stdlib table, knowledge base, and README document every new
|
|
377
377
|
capability.
|
|
378
378
|
|
|
379
|
-
Until then the package version remains **below 1.0.
|
|
379
|
+
Until then the package version remains **below 1.0.1**.
|
|
380
380
|
|
|
381
381
|
---
|
|
382
382
|
|
|
383
383
|
## 22. v2.2.0 — AI/ML, data/storage & web additions
|
|
384
384
|
|
|
385
|
-
The v2.0–v2.2 releases close further gaps beyond the 1.0.
|
|
385
|
+
The v2.0–v2.2 releases close further gaps beyond the 1.0.1 audit across the
|
|
386
386
|
AI/ML, data/storage and web/full-stack surface. All features below are
|
|
387
387
|
IOPL-native (intent-oriented) rather than TypeScript-syntax clones.
|
|
388
388
|
|
package/docs/PLINJS_SPEC.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# PlainScript Language Specification (v1.0.
|
|
1
|
+
# PlainScript Language Specification (v1.0.1)
|
|
2
2
|
|
|
3
3
|
Version: 2.1.1
|
|
4
4
|
Status: Stable
|
|
@@ -155,7 +155,7 @@ While:
|
|
|
155
155
|
|
|
156
156
|
---
|
|
157
157
|
|
|
158
|
-
## Record Kinds, Classes & Concurrency (v1.0.
|
|
158
|
+
## Record Kinds, Classes & Concurrency (v1.0.1)
|
|
159
159
|
|
|
160
160
|
These features close the capability-gap audit (`docs/CAPABILITY_GAP_AUDIT.md`) in
|
|
161
161
|
PlainScript's own intent-oriented grammar.
|
|
@@ -439,7 +439,7 @@ filesystem.
|
|
|
439
439
|
### Deployment workflow
|
|
440
440
|
|
|
441
441
|
```bash
|
|
442
|
-
npm install --save-dev plainscript
|
|
442
|
+
npm install --save-dev plainscript-lang
|
|
443
443
|
plainscript install
|
|
444
444
|
plainscript build app.ps
|
|
445
445
|
plainscript run app.ps
|
|
@@ -1147,5 +1147,5 @@ If a package is missing, the compiler prints a friendly error and stops:
|
|
|
1147
1147
|
|
|
1148
1148
|
---
|
|
1149
1149
|
|
|
1150
|
-
This document is the single source of truth for PlainScript v1.0.
|
|
1150
|
+
This document is the single source of truth for PlainScript v1.0.1.
|
|
1151
1151
|
Every compiler implementation must follow this specification.
|
package/docs/index.html
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<a href="#" class="nav-logo">
|
|
36
36
|
<img src="logo.jpg" alt="PlainScript Logo">
|
|
37
37
|
<span class="logo-word">PlainScript</span>
|
|
38
|
-
<span class="logo-ver">v1.0.
|
|
38
|
+
<span class="logo-ver">v1.0.1</span>
|
|
39
39
|
</a>
|
|
40
40
|
<div class="nav-links">
|
|
41
41
|
<a href="#language">Language</a>
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
<!-- Hero Section -->
|
|
86
86
|
<section class="hero">
|
|
87
87
|
<div class="hero-content">
|
|
88
|
-
<div class="hero-badge">v1.0.
|
|
88
|
+
<div class="hero-badge">v1.0.1 — intent-oriented, TypeScript-capable</div>
|
|
89
89
|
<h1 class="hero-title">
|
|
90
90
|
Write code that<br>
|
|
91
91
|
reads like <span class="green">Plain English</span>
|
|
@@ -607,7 +607,7 @@ use dotenv</code></pre>
|
|
|
607
607
|
</div>
|
|
608
608
|
<div class="footer-bottom">
|
|
609
609
|
<p>© 2026 PlainScript. Built by Ayokunle.</p>
|
|
610
|
-
<span class="footer-badge">v1.0.
|
|
610
|
+
<span class="footer-badge">v1.0.1</span>
|
|
611
611
|
</div>
|
|
612
612
|
</div>
|
|
613
613
|
</footer>
|
package/docs/website/script.js
CHANGED
|
@@ -766,7 +766,7 @@ var LIBRARY = [
|
|
|
766
766
|
{cat:"server",name:"404 Catch-All",desc:"Handle unmatched routes",ps:'when nothing matches\n status 404\n reply "Page not found"\ndone',js:'app.use((req, res) => {\n res.status(404);\n res.send("Page not found");\n});',skipRun:true},
|
|
767
767
|
{cat:"server",name:"Validate Request Body",desc:"Require specific fields in the request body",ps:'route post "/users"\n validate(body of request, ["name", "email"])\n reply "Created"\ndone',js:'app.post("/users", (req, res) => {\n __validate(req.body, ["name", "email"]);\n res.send("Created");\n});',skipRun:true},
|
|
768
768
|
{cat:"auth",name:"Google OAuth",desc:"Add Google login to your app",ps:'web app\ngoogle oauth\n id is env("GOOGLE_CLIENT_ID")\n secret is env("GOOGLE_CLIENT_SECRET")\n callback is "/auth/google/callback"\n landing is "/dashboard"\ndone',js:'__googleOAuth(app, {\n clientId: process.env["GOOGLE_CLIENT_ID"],\n clientSecret: process.env["GOOGLE_CLIENT_SECRET"],\n callbackUrl: "/auth/google/callback",\n afterLogin: "/dashboard"\n});'},
|
|
769
|
-
{cat:"cli",name:"CLI: version",desc:"Print the PlainScript version",ps:'plainscript version',js:'// Prints v1.0.
|
|
769
|
+
{cat:"cli",name:"CLI: version",desc:"Print the PlainScript version",ps:'plainscript version',js:'// Prints v1.0.1',skipRun:true},
|
|
770
770
|
{cat:"cli",name:"CLI: help",desc:"Show available commands",ps:'plainscript help',js:'// Lists all CLI commands',skipRun:true},
|
|
771
771
|
{cat:"cli",name:"CLI: info",desc:"Display platform and runtime info",ps:'plainscript info',js:'// Shows version, Node version, OS',skipRun:true},
|
|
772
772
|
{cat:"cli",name:"CLI: clean",desc:"Remove compiled output",ps:'plainscript clean',js:'// Deletes dist/ folder',skipRun:true},
|
package/examples/auth-api.ps
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// PlainScript v1.0.
|
|
1
|
+
// PlainScript v1.0.1 — API key protection, rate limits and tokens
|
|
2
2
|
//
|
|
3
3
|
// Run with: API_KEY=my-secret plainscript run examples/auth-api.ps
|
|
4
4
|
// Then try:
|
|
@@ -22,7 +22,7 @@ remember secret as env("TOKEN_SECRET")
|
|
|
22
22
|
route get "/status"
|
|
23
23
|
reply json
|
|
24
24
|
status is "ok"
|
|
25
|
-
version is "1.0.
|
|
25
|
+
version is "1.0.1"
|
|
26
26
|
done
|
|
27
27
|
done
|
|
28
28
|
|
package/examples/concurrency.ps
CHANGED
package/examples/file-uploads.ps
CHANGED
package/examples/http-client.ps
CHANGED
package/examples/modules/app.ps
CHANGED
package/examples/modules/math.ps
CHANGED
package/examples/record-kinds.ps
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plainscript-lang",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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 && 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"
|
|
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/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",
|