plainscript-lang 1.0.0 → 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 +6 -6
- package/compiler/cli.js +125 -18
- package/compiler/generator.js +155 -120
- package/compiler/lexer.js +1 -1
- package/compiler/parser.js +130 -12
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +9 -9
- package/docs/PLINJS_SPEC.md +4 -4
- package/docs/index.html +25 -20
- 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/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' &&
|
|
@@ -617,6 +617,29 @@ function parse(tokens) {
|
|
|
617
617
|
return { type: 'ExportStatement', name };
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
+
// throw <value> → raise an error for the caller's try/recover to catch.
|
|
621
|
+
// "throw(...)" calls and "throw becomes x" keep their ordinary meaning.
|
|
622
|
+
if (token.value === 'throw' &&
|
|
623
|
+
peekAt(1).type !== TOKEN.LPAREN && peekAt(1).type !== TOKEN.BECOMES) {
|
|
624
|
+
advance(); // throw
|
|
625
|
+
const value = parseExpression();
|
|
626
|
+
return { type: 'ThrowStatement', value };
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// break / continue → loop control flow. Contextual keywords: a variable
|
|
630
|
+
// literally named break/continue is rejected by the teaching guard in
|
|
631
|
+
// generateStatement when not inside a loop.
|
|
632
|
+
if (token.value === 'break' &&
|
|
633
|
+
peekAt(1).type !== TOKEN.BECOMES && peekAt(1).type !== TOKEN.LPAREN) {
|
|
634
|
+
advance(); // break
|
|
635
|
+
return { type: 'BreakStatement' };
|
|
636
|
+
}
|
|
637
|
+
if (token.value === 'continue' &&
|
|
638
|
+
peekAt(1).type !== TOKEN.BECOMES && peekAt(1).type !== TOKEN.LPAREN) {
|
|
639
|
+
advance(); // continue
|
|
640
|
+
return { type: 'ContinueStatement' };
|
|
641
|
+
}
|
|
642
|
+
|
|
620
643
|
const expr = parsePrimary();
|
|
621
644
|
|
|
622
645
|
if (peek().type === TOKEN.BECOMES) {
|
|
@@ -876,7 +899,7 @@ function parse(tokens) {
|
|
|
876
899
|
return { type: 'GiveStatement', value };
|
|
877
900
|
}
|
|
878
901
|
|
|
879
|
-
// v1.0.
|
|
902
|
+
// v1.0.1 — generators: `yield <expr>` (optionally bare `yield`).
|
|
880
903
|
function parseYield() {
|
|
881
904
|
consume(TOKEN.YIELD);
|
|
882
905
|
let value = null;
|
|
@@ -886,7 +909,7 @@ function parse(tokens) {
|
|
|
886
909
|
return { type: 'YieldStatement', value };
|
|
887
910
|
}
|
|
888
911
|
|
|
889
|
-
// v1.0.
|
|
912
|
+
// v1.0.1 — record kinds: `define a kind called "Person" with … done`
|
|
890
913
|
// The field block reuses the property-list grammar (`age is 0`), so each
|
|
891
914
|
// field gets a default expression just like an object literal.
|
|
892
915
|
function parseDefineKind() {
|
|
@@ -923,7 +946,7 @@ function parse(tokens) {
|
|
|
923
946
|
return { type: 'DefineKindStatement', name, fields };
|
|
924
947
|
}
|
|
925
948
|
|
|
926
|
-
// v1.0.
|
|
949
|
+
// v1.0.1 — record constructor (expression): `create a Person with name "Ada" and age 17`
|
|
927
950
|
function parseCreateKind() {
|
|
928
951
|
advance(); // create
|
|
929
952
|
advance(); // a / an
|
|
@@ -943,7 +966,7 @@ function parse(tokens) {
|
|
|
943
966
|
return { type: 'CreateKindExpression', kind, pairs };
|
|
944
967
|
}
|
|
945
968
|
|
|
946
|
-
// v1.0.
|
|
969
|
+
// v1.0.1 — native test DSL: `test "name" … done`
|
|
947
970
|
function parseTestStatement() {
|
|
948
971
|
advance(); // test
|
|
949
972
|
const name = consume(TOKEN.STRING, 'Expected a test name string after "test".').value;
|
|
@@ -951,7 +974,7 @@ function parse(tokens) {
|
|
|
951
974
|
return { type: 'TestStatement', name, body };
|
|
952
975
|
}
|
|
953
976
|
|
|
954
|
-
// v1.0.
|
|
977
|
+
// v1.0.1 — assertions: `check <a> (equals|is|contains|raises) <b>`
|
|
955
978
|
function parseCheckStatement() {
|
|
956
979
|
advance(); // check
|
|
957
980
|
const a = parseExpression();
|
|
@@ -971,8 +994,49 @@ function parse(tokens) {
|
|
|
971
994
|
// for every <item> in <collection> ... done (alias — "every" maps to EACH token)
|
|
972
995
|
function parseForEach() {
|
|
973
996
|
consume(TOKEN.FOR);
|
|
997
|
+
|
|
998
|
+
// for index <name> from <start> to <end> [by <step>] ... done
|
|
999
|
+
if (peek().type === TOKEN.IDENTIFIER && peek().value === 'index') {
|
|
1000
|
+
advance(); // index
|
|
1001
|
+
const name = consume(
|
|
1002
|
+
TOKEN.IDENTIFIER,
|
|
1003
|
+
'Expected an index name after "for index".\n\nExample:\n for index i from 0 to 9\n show i\n done'
|
|
1004
|
+
).value;
|
|
1005
|
+
if (peek().type === TOKEN.IN || (peek().type === TOKEN.IDENTIFIER && peek().value === 'in')) {
|
|
1006
|
+
// for index <name> in <collection> — zero-based index over a list.
|
|
1007
|
+
advance(); // in
|
|
1008
|
+
const collection = parseExpression();
|
|
1009
|
+
const body = parseBody('"for index" loop');
|
|
1010
|
+
return { type: 'ForIndexStatement', name, start: null, end: collection, step: null, over: collection, body };
|
|
1011
|
+
}
|
|
1012
|
+
if (peek().type !== TOKEN.IDENTIFIER || peek().value !== 'from') {
|
|
1013
|
+
throw new Error(makeError(
|
|
1014
|
+
'Expected "from" or "in" after the "for index" name.\n\nExample:\n for index i from 0 to 9\n for index i in players',
|
|
1015
|
+
peek()
|
|
1016
|
+
));
|
|
1017
|
+
}
|
|
1018
|
+
advance(); // from
|
|
1019
|
+
const start = parseExpression();
|
|
1020
|
+
if (peek().type === TOKEN.IDENTIFIER && peek().value === 'to') {
|
|
1021
|
+
advance(); // to
|
|
1022
|
+
} else {
|
|
1023
|
+
throw new Error(makeError(
|
|
1024
|
+
'Expected "to" between the start and end of a "for index" loop.\n\nExample:\n for index i from 0 to 9',
|
|
1025
|
+
peek()
|
|
1026
|
+
));
|
|
1027
|
+
}
|
|
1028
|
+
const end = parseExpression();
|
|
1029
|
+
let step = null;
|
|
1030
|
+
if (peek().type === TOKEN.IDENTIFIER && peek().value === 'by') {
|
|
1031
|
+
advance(); // by
|
|
1032
|
+
step = parseExpression();
|
|
1033
|
+
}
|
|
1034
|
+
const body = parseBody('"for index" loop');
|
|
1035
|
+
return { type: 'ForIndexStatement', name, start, end, step, over: null, body };
|
|
1036
|
+
}
|
|
1037
|
+
|
|
974
1038
|
consume(TOKEN.EACH,
|
|
975
|
-
'Expected "each" or "
|
|
1039
|
+
'Expected "each", "every" or "index" after "for".\n\nExample:\n for each item in players\n show item\n done');
|
|
976
1040
|
const item = consume(TOKEN.IDENTIFIER, 'Expected an item name after "each" or "every".').value;
|
|
977
1041
|
consume(TOKEN.IN, `Expected "in" after "${item}".\n\nExample:\n for each item in players`);
|
|
978
1042
|
const collection = parseExpression();
|
|
@@ -989,8 +1053,39 @@ function parse(tokens) {
|
|
|
989
1053
|
}
|
|
990
1054
|
|
|
991
1055
|
// import "./file.ps"
|
|
1056
|
+
// import { name1, name2 } from "./file.ps" (named imports — binds only the
|
|
1057
|
+
// listed symbols; the whole file is still bundled as a dependency)
|
|
992
1058
|
function parseImport() {
|
|
993
1059
|
consume(TOKEN.IMPORT);
|
|
1060
|
+
|
|
1061
|
+
// Named-import form: import { a, b } from "./file.ps"
|
|
1062
|
+
if (peek().type === TOKEN.LBRACE) {
|
|
1063
|
+
advance(); // {
|
|
1064
|
+
const names = [];
|
|
1065
|
+
while (true) {
|
|
1066
|
+
names.push(consume(
|
|
1067
|
+
TOKEN.IDENTIFIER,
|
|
1068
|
+
'Expected an exported name inside the import braces.\n\nExample:\n import { helper } from "./util.ps"'
|
|
1069
|
+
).value);
|
|
1070
|
+
if (peek().type === TOKEN.COMMA) { advance(); continue; }
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
consume(TOKEN.RBRACE,
|
|
1074
|
+
'Expected "}" to close the import braces.\n\nExample:\n import { helper } from "./util.ps"');
|
|
1075
|
+
// The "from" is a plain identifier; tolerate its optional presence so
|
|
1076
|
+
// both "import { x } from "./f.ps"" and "import { x } "./f.ps"" read
|
|
1077
|
+
// naturally, but require it for the documented form.
|
|
1078
|
+
if (peek().type === TOKEN.IDENTIFIER && peek().value === 'from') {
|
|
1079
|
+
advance(); // from
|
|
1080
|
+
}
|
|
1081
|
+
const filePath = consume(
|
|
1082
|
+
TOKEN.STRING,
|
|
1083
|
+
'Expected a file path string after the import.\n\nExample:\n import { helper } from "./util.ps"'
|
|
1084
|
+
).value;
|
|
1085
|
+
return { type: 'ImportStatement', path: filePath, names };
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// Whole-module form: import "./file.ps"
|
|
994
1089
|
const filePath = consume(
|
|
995
1090
|
TOKEN.STRING,
|
|
996
1091
|
'Expected a file path string after "import".\n\nExample:\n import "./math.ps"'
|
|
@@ -1807,7 +1902,7 @@ function parse(tokens) {
|
|
|
1807
1902
|
|
|
1808
1903
|
// primary → itemExpr | atom (postfix)*
|
|
1809
1904
|
function parsePrimary() {
|
|
1810
|
-
// v1.0.
|
|
1905
|
+
// v1.0.1 — record constructor: `create a Person with name "Ada" and age 17`.
|
|
1811
1906
|
// `create` then an article ("a"/"an") then a kind name then "with" pairs.
|
|
1812
1907
|
if (peek().type === TOKEN.IDENTIFIER && peek().value === 'create') {
|
|
1813
1908
|
const a1 = peekAt(1);
|
|
@@ -1821,7 +1916,7 @@ function parse(tokens) {
|
|
|
1821
1916
|
}
|
|
1822
1917
|
}
|
|
1823
1918
|
|
|
1824
|
-
// v1.0.
|
|
1919
|
+
// v1.0.1 — concurrency combinators: `all of [a(), b()]`, `any of [...]`,
|
|
1825
1920
|
// `settled of [...]`. Guard on the identifier + "of" lookahead so plain
|
|
1826
1921
|
// property reads like `all of the_list` still work as well as prose.
|
|
1827
1922
|
if (peek().type === TOKEN.IDENTIFIER &&
|
|
@@ -1833,7 +1928,7 @@ function parse(tokens) {
|
|
|
1833
1928
|
return { type: 'ConcurrencyExpression', combo: comboKw, items };
|
|
1834
1929
|
}
|
|
1835
1930
|
|
|
1836
|
-
// v1.0.
|
|
1931
|
+
// v1.0.1 — `spread of <collection>` unfolds an iterable into a new array.
|
|
1837
1932
|
if (peek().type === TOKEN.IDENTIFIER && peek().value === 'spread' &&
|
|
1838
1933
|
peekAt(1).type === TOKEN.IDENTIFIER && peekAt(1).value === 'of') {
|
|
1839
1934
|
advance(); // spread
|
|
@@ -1853,8 +1948,31 @@ function parse(tokens) {
|
|
|
1853
1948
|
node = { type: 'IndexExpression', object: node, index };
|
|
1854
1949
|
} else if (peek().type === TOKEN.DOT) {
|
|
1855
1950
|
advance();
|
|
1856
|
-
|
|
1951
|
+
// After ".", any word is a valid JS property/method name — including
|
|
1952
|
+
// words that are PlainScript keywords in other contexts (e.g. crypto
|
|
1953
|
+
// .update(...), obj .delete()). So accept any word token, not just an
|
|
1954
|
+
// identifier.
|
|
1955
|
+
const propToken = peek();
|
|
1956
|
+
if (propToken.type === TOKEN.EOF || !/^[A-Za-z_$]/.test(propToken.value)) {
|
|
1957
|
+
throw new Error(makeError('Expected a property name after ".".', propToken));
|
|
1958
|
+
}
|
|
1959
|
+
advance();
|
|
1960
|
+
const property = propToken.value;
|
|
1857
1961
|
node = { type: 'MemberExpression', object: node, property };
|
|
1962
|
+
// Method call: object.method(args). Only member access may introduce
|
|
1963
|
+
// a call here; plain `name(args)` is handled in parseAtom.
|
|
1964
|
+
if (peek().type === TOKEN.LPAREN) {
|
|
1965
|
+
advance(); // (
|
|
1966
|
+
const { separator, args } = parseArgList();
|
|
1967
|
+
consume(TOKEN.RPAREN, 'Expected ")" to close the method call.');
|
|
1968
|
+
if (separator) {
|
|
1969
|
+
throw new Error(makeError(
|
|
1970
|
+
'Method calls cannot use "to"/"from" arguments.\n\nExample:\n mrz.parse(line)',
|
|
1971
|
+
peek()
|
|
1972
|
+
));
|
|
1973
|
+
}
|
|
1974
|
+
node = { type: 'CallExpression', callee: node, args };
|
|
1975
|
+
}
|
|
1858
1976
|
} else if (peek().type === TOKEN.IDENTIFIER && peek().value === 'of') {
|
|
1859
1977
|
if (node.type !== 'Identifier') {
|
|
1860
1978
|
throw new Error(makeError(
|
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
|
> ---
|
|
@@ -110,7 +110,7 @@ define a kind called "Person" with
|
|
|
110
110
|
age is 0
|
|
111
111
|
done
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
remember ada as create a Person with name "Ada" and age 17
|
|
114
114
|
show name of ada // "Ada"
|
|
115
115
|
```
|
|
116
116
|
|
|
@@ -126,7 +126,7 @@ show name of ada // "Ada"
|
|
|
126
126
|
|
|
127
127
|
| TypeScript | PlainScript resolution |
|
|
128
128
|
|-------------------------|------------------------|
|
|
129
|
-
| `class`, constructor | **IOPL-native `kind` + `
|
|
129
|
+
| `class`, constructor | **IOPL-native `kind` + `create a X with ...`** (this release). |
|
|
130
130
|
| Fields / properties | `kind` fields; access via `name of x` / `x.name`. |
|
|
131
131
|
| Methods | Top-level `make` functions taking the record. |
|
|
132
132
|
| `this` | **Rationale: unnecessary** — functions receive the record explicitly (no context bugs). |
|
|
@@ -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>
|
|
@@ -109,11 +109,12 @@
|
|
|
109
109
|
<button class="code-copy" aria-label="Copy code"><i class="far fa-copy"></i></button>
|
|
110
110
|
</div>
|
|
111
111
|
<div class="code-window-body">
|
|
112
|
-
<pre><code>
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
<pre><code>web app
|
|
113
|
+
route get "/"
|
|
114
|
+
reply "Hello, World!"
|
|
115
|
+
done
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
show "Server is running"</code></pre>
|
|
117
118
|
</div>
|
|
118
119
|
</div>
|
|
119
120
|
<div class="code-window">
|
|
@@ -235,16 +236,18 @@ console.log("Server is running");</code></pre>
|
|
|
235
236
|
<button class="code-copy" aria-label="Copy code"><i class="far fa-copy"></i></button>
|
|
236
237
|
</div>
|
|
237
238
|
<div class="code-window-body">
|
|
238
|
-
<pre><code>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
239
|
+
<pre><code>web app
|
|
240
|
+
route get "/"
|
|
241
|
+
reply "Hello, World!"
|
|
242
|
+
done
|
|
243
|
+
|
|
244
|
+
route get "/users"
|
|
245
|
+
reply json
|
|
246
|
+
count is 3
|
|
247
|
+
done
|
|
248
|
+
done
|
|
249
|
+
|
|
250
|
+
show "Server running on port 3000"</code></pre>
|
|
248
251
|
</div>
|
|
249
252
|
</div>
|
|
250
253
|
<div class="code-window">
|
|
@@ -296,11 +299,13 @@ app.listen(3000, () => {
|
|
|
296
299
|
<div class="code-window-body">
|
|
297
300
|
<pre><code>database "app.db"
|
|
298
301
|
|
|
299
|
-
|
|
300
|
-
|
|
302
|
+
remember results as query
|
|
303
|
+
SELECT * FROM users WHERE active = 1
|
|
304
|
+
done
|
|
301
305
|
|
|
302
306
|
for each user in results
|
|
303
|
-
|
|
307
|
+
show user.name
|
|
308
|
+
done</code></pre>
|
|
304
309
|
</div>
|
|
305
310
|
</div>
|
|
306
311
|
<div class="code-window">
|
|
@@ -602,7 +607,7 @@ use dotenv</code></pre>
|
|
|
602
607
|
</div>
|
|
603
608
|
<div class="footer-bottom">
|
|
604
609
|
<p>© 2026 PlainScript. Built by Ayokunle.</p>
|
|
605
|
-
<span class="footer-badge">v1.0.
|
|
610
|
+
<span class="footer-badge">v1.0.1</span>
|
|
606
611
|
</div>
|
|
607
612
|
</div>
|
|
608
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"
|
|
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",
|