plainscript-lang 1.0.3-beta → 1.0.3
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 +97 -120
- package/compiler/bundler.js +83 -12
- package/compiler/cli.js +62 -11
- package/compiler/dependency-detector.js +11 -0
- package/compiler/generator.js +280 -15
- package/compiler/lexer.js +2 -0
- package/compiler/parser.js +410 -28
- package/compiler/sourcemap.js +142 -0
- package/compiler/version.js +1 -1
- package/docs/CAPABILITY_GAP_AUDIT.md +17 -15
- package/docs/PLAINSCRIPT-SPEC.md +41 -39
- package/docs/index.html +60 -33
- package/docs/website/script.js +168 -19
- package/docs/website/style.css +187 -41
- package/examples/ai-providers.pln +1 -1
- package/examples/arrays.pln +1 -1
- package/examples/async-errors.pln +1 -1
- package/examples/auth-api.pln +1 -1
- package/examples/auth-sessions.pln +1 -1
- package/examples/basics.pln +1 -1
- package/examples/bots.pln +1 -1
- package/examples/cache-and-jobs.pln +1 -1
- package/examples/cache-schedule.pln +1 -1
- package/examples/collections.pln +1 -1
- package/examples/concurrency.pln +1 -1
- package/examples/conditions.pln +1 -1
- package/examples/database.pln +1 -1
- package/examples/day2.pln +1 -1
- package/examples/day3.pln +1 -1
- package/examples/deployment.pln +1 -1
- package/examples/email-send.pln +1 -1
- package/examples/error-handling.pln +1 -1
- package/examples/expressions.pln +1 -1
- package/examples/file-uploads.pln +1 -1
- package/examples/files-and-config.pln +1 -1
- package/examples/files.pln +1 -1
- package/examples/football-backend/app.pln +1 -1
- package/examples/functions.pln +1 -1
- package/examples/hello.pln +1 -1
- package/examples/http-client.pln +1 -1
- package/examples/http.pln +1 -1
- package/examples/id-verification/app.pln +1 -1
- package/examples/json.pln +1 -1
- package/examples/loops.pln +1 -1
- package/examples/modules/app.pln +1 -1
- package/examples/modules/main.pln +1 -1
- package/examples/modules/math.pln +1 -1
- package/examples/mongo.pln +33 -0
- package/examples/objects.pln +1 -1
- package/examples/ocr.pln +1 -1
- package/examples/packages.pln +1 -1
- package/examples/record-kinds.pln +1 -1
- package/examples/records.pln +1 -1
- package/examples/rest-api-fetch.pln +1 -1
- package/examples/rest-api.pln +1 -1
- package/examples/scheduled-tasks.pln +1 -1
- package/examples/search-and-filter.pln +1 -1
- package/examples/server.pln +1 -1
- package/examples/sessions-and-cookies.pln +1 -1
- package/examples/sqlite.pln +1 -1
- package/examples/start.pln +1 -1
- package/examples/stdlib.pln +1 -1
- package/examples/string-verbs.pln +16 -0
- package/examples/telegram-ai-bot.pln +1 -1
- package/examples/telegram-bot.pln +1 -1
- package/examples/testing.pln +1 -1
- package/examples/web-api.pln +1 -1
- package/examples/web-app.pln +1 -1
- package/examples/websocket-server.pln +1 -1
- package/examples/websocket.pln +1 -1
- package/examples/whatsapp-bot/pairing.pln +1 -1
- package/examples/whatsapp-bot/qr.pln +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// SourceMap: V3 Source Map generator for PlainScript compiler.
|
|
2
|
+
// Zero external dependencies — implements VLQ Base64 encoding.
|
|
3
|
+
|
|
4
|
+
const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
5
|
+
|
|
6
|
+
function encodeVlq(value) {
|
|
7
|
+
let vlq = value < 0 ? ((-value) << 1) | 1 : (value << 1);
|
|
8
|
+
let encoded = '';
|
|
9
|
+
do {
|
|
10
|
+
let digit = vlq & 31;
|
|
11
|
+
vlq >>>= 5;
|
|
12
|
+
if (vlq > 0) {
|
|
13
|
+
digit |= 32;
|
|
14
|
+
}
|
|
15
|
+
encoded += BASE64_CHARS[digit];
|
|
16
|
+
} while (vlq > 0);
|
|
17
|
+
return encoded;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function decodeVlq(str, state = { index: 0 }) {
|
|
21
|
+
let result = 0;
|
|
22
|
+
let shift = 0;
|
|
23
|
+
let continuation = true;
|
|
24
|
+
while (continuation && state.index < str.length) {
|
|
25
|
+
const char = str[state.index++];
|
|
26
|
+
const digit = BASE64_CHARS.indexOf(char);
|
|
27
|
+
if (digit === -1) throw new Error(`Invalid Base64 character: ${char}`);
|
|
28
|
+
continuation = (digit & 32) !== 0;
|
|
29
|
+
result += (digit & 31) << shift;
|
|
30
|
+
shift += 5;
|
|
31
|
+
}
|
|
32
|
+
const isNegative = (result & 1) === 1;
|
|
33
|
+
const value = result >> 1;
|
|
34
|
+
return isNegative ? -value : value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
class SourceMapGenerator {
|
|
38
|
+
constructor(options = {}) {
|
|
39
|
+
this.file = options.file || '';
|
|
40
|
+
this.sourceRoot = options.sourceRoot || '';
|
|
41
|
+
this.sources = [];
|
|
42
|
+
this.sourcesContent = [];
|
|
43
|
+
this.mappings = [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
addSource(sourcePath, content = null) {
|
|
47
|
+
let idx = this.sources.indexOf(sourcePath);
|
|
48
|
+
if (idx === -1) {
|
|
49
|
+
idx = this.sources.length;
|
|
50
|
+
this.sources.push(sourcePath);
|
|
51
|
+
this.sourcesContent.push(content);
|
|
52
|
+
} else if (content !== null && this.sourcesContent[idx] === null) {
|
|
53
|
+
this.sourcesContent[idx] = content;
|
|
54
|
+
}
|
|
55
|
+
return idx;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
addMapping({ generated, original, source }) {
|
|
59
|
+
if (!generated || generated.line == null || generated.column == null) return;
|
|
60
|
+
if (!original || original.line == null || original.column == null) return;
|
|
61
|
+
|
|
62
|
+
const sourceIdx = source ? this.addSource(source) : 0;
|
|
63
|
+
this.mappings.push({
|
|
64
|
+
generatedLine: generated.line,
|
|
65
|
+
generatedColumn: generated.column,
|
|
66
|
+
originalLine: original.line,
|
|
67
|
+
originalColumn: original.column,
|
|
68
|
+
sourceIdx,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
toJSON() {
|
|
73
|
+
// Sort mappings by generated line, then generated column
|
|
74
|
+
const sorted = [...this.mappings].sort((a, b) => {
|
|
75
|
+
if (a.generatedLine !== b.generatedLine) return a.generatedLine - b.generatedLine;
|
|
76
|
+
return a.generatedColumn - b.generatedColumn;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
let mappingsStr = '';
|
|
80
|
+
let prevGenLine = 1;
|
|
81
|
+
let prevGenCol = 0;
|
|
82
|
+
let prevOrigLine = 0;
|
|
83
|
+
let prevOrigCol = 0;
|
|
84
|
+
let prevSourceIdx = 0;
|
|
85
|
+
|
|
86
|
+
for (const m of sorted) {
|
|
87
|
+
while (prevGenLine < m.generatedLine) {
|
|
88
|
+
mappingsStr += ';';
|
|
89
|
+
prevGenLine++;
|
|
90
|
+
prevGenCol = 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (mappingsStr.length > 0 && !mappingsStr.endsWith(';')) {
|
|
94
|
+
mappingsStr += ',';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const genColDiff = m.generatedColumn - prevGenCol;
|
|
98
|
+
const sourceIdxDiff = m.sourceIdx - prevSourceIdx;
|
|
99
|
+
const origLineDiff = (m.originalLine - 1) - prevOrigLine;
|
|
100
|
+
const origColDiff = (m.originalColumn - 1) - prevOrigCol;
|
|
101
|
+
|
|
102
|
+
mappingsStr += encodeVlq(genColDiff);
|
|
103
|
+
mappingsStr += encodeVlq(sourceIdxDiff);
|
|
104
|
+
mappingsStr += encodeVlq(origLineDiff);
|
|
105
|
+
mappingsStr += encodeVlq(origColDiff);
|
|
106
|
+
|
|
107
|
+
prevGenCol = m.generatedColumn;
|
|
108
|
+
prevSourceIdx = m.sourceIdx;
|
|
109
|
+
prevOrigLine = m.originalLine - 1;
|
|
110
|
+
prevOrigCol = m.originalColumn - 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const mapObj = {
|
|
114
|
+
version: 3,
|
|
115
|
+
file: this.file,
|
|
116
|
+
sources: this.sources,
|
|
117
|
+
mappings: mappingsStr,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
if (this.sourcesContent.some(c => c !== null)) {
|
|
121
|
+
mapObj.sourcesContent = this.sourcesContent;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return mapObj;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
toString() {
|
|
128
|
+
return JSON.stringify(this.toJSON());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
toInlineDataUrl() {
|
|
132
|
+
const json = this.toString();
|
|
133
|
+
const base64 = Buffer.from(json, 'utf8').toString('base64');
|
|
134
|
+
return `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = {
|
|
139
|
+
SourceMapGenerator,
|
|
140
|
+
encodeVlq,
|
|
141
|
+
decodeVlq,
|
|
142
|
+
};
|
package/compiler/version.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
# PlainScript 1.0.3
|
|
1
|
+
# PlainScript 1.0.3 Capability Audit
|
|
2
2
|
|
|
3
|
-
This audit is
|
|
4
|
-
|
|
5
|
-
here only when a source program can be validated by `plainscript check`.
|
|
3
|
+
This audit is based on what the compiler actually supports right now.
|
|
4
|
+
If `plainscript check` validates it, it's listed here.
|
|
6
5
|
|
|
7
|
-
## Core
|
|
6
|
+
## Core Language
|
|
8
7
|
|
|
9
8
|
| Capability | Status | Current source form |
|
|
10
9
|
| --- | --- | --- |
|
|
@@ -21,7 +20,7 @@ here only when a source program can be validated by `plainscript check`.
|
|
|
21
20
|
| Loop control | Implemented | `break`, `continue` |
|
|
22
21
|
| Classes and `new` | Implemented | JavaScript-compatible class forms |
|
|
23
22
|
|
|
24
|
-
## Modules and
|
|
23
|
+
## Modules and Runtime
|
|
25
24
|
|
|
26
25
|
| Capability | Status | Notes |
|
|
27
26
|
| --- | --- | --- |
|
|
@@ -36,7 +35,7 @@ here only when a source program can be validated by `plainscript check`.
|
|
|
36
35
|
| Errors and retries | Implemented | `try`, `recover`, `finally`, `retry` |
|
|
37
36
|
| Native tests | Implemented | `test` and `check` assertions |
|
|
38
37
|
|
|
39
|
-
## Web and
|
|
38
|
+
## Web and Services
|
|
40
39
|
|
|
41
40
|
| Capability | Status | Current source form |
|
|
42
41
|
| --- | --- | --- |
|
|
@@ -61,9 +60,9 @@ here only when a source program can be validated by `plainscript check`.
|
|
|
61
60
|
| WhatsApp bots | Implemented | `whatsapp bot` |
|
|
62
61
|
| OCR | Implemented | `ocr path of file as text` |
|
|
63
62
|
|
|
64
|
-
## Canonical
|
|
63
|
+
## Canonical Examples
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
Here are the example files that exercise each capability:
|
|
67
66
|
|
|
68
67
|
```text
|
|
69
68
|
examples/basics.pln
|
|
@@ -92,11 +91,14 @@ examples/id-verification/
|
|
|
92
91
|
examples/whatsapp-bot/
|
|
93
92
|
```
|
|
94
93
|
|
|
95
|
-
Run
|
|
96
|
-
before changing the language reference.
|
|
94
|
+
Run this to make sure everything still compiles:
|
|
97
95
|
|
|
98
|
-
|
|
96
|
+
```bash
|
|
97
|
+
find examples -name '*.pln' -exec node compiler/cli.js check {} \;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Version Info
|
|
99
101
|
|
|
100
|
-
The
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
The release label for this repo is `1.0.3`. It covers the compiler,
|
|
103
|
+
package metadata, website, and editor tooling. Third-party dependency
|
|
104
|
+
versions are not tied to this label.
|
package/docs/PLAINSCRIPT-SPEC.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# PlainScript 1.0.3
|
|
1
|
+
# PlainScript 1.0.3 language specification
|
|
2
2
|
|
|
3
|
-
This reference
|
|
4
|
-
`compiler/parser.js`. The
|
|
5
|
-
`compiler/generator.js`.
|
|
3
|
+
This reference covers the syntax implemented by `compiler/lexer.js` and
|
|
4
|
+
`compiler/parser.js`. The runtime it generates lives in
|
|
5
|
+
`compiler/generator.js`. Every example here is checked against the
|
|
6
6
|
repository's maintained example set.
|
|
7
7
|
|
|
8
8
|
## Design
|
|
9
9
|
|
|
10
|
-
PlainScript is a line-oriented, intent-oriented language for Node.js.
|
|
11
|
-
files use `.pln`. Blocks
|
|
12
|
-
`together`. Whitespace
|
|
10
|
+
PlainScript is a line-oriented, intent-oriented language made for Node.js.
|
|
11
|
+
Source files use `.pln`. Blocks end with `done` unless the syntax says
|
|
12
|
+
`together`. Whitespace does not matter.
|
|
13
13
|
|
|
14
|
-
The
|
|
14
|
+
The basic declaration forms are:
|
|
15
15
|
|
|
16
16
|
```plainscript
|
|
17
17
|
remember name as "Ada"
|
|
@@ -21,13 +21,13 @@ show name
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Comments begin with `//`. Double-quoted strings support escapes. Backtick
|
|
24
|
-
strings
|
|
24
|
+
strings keep their content as-is and support `${expression}` interpolation.
|
|
25
25
|
|
|
26
26
|
## Values and expressions
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
`undefined`, BigInt, arrays, objects, identifiers, calls, member
|
|
30
|
-
optional member access, and indexed access.
|
|
28
|
+
PlainScript has strings, template strings, numbers, booleans, `null`,
|
|
29
|
+
`undefined`, BigInt, arrays, objects, identifiers, function calls, member
|
|
30
|
+
access, optional member access, and indexed access.
|
|
31
31
|
|
|
32
32
|
```plainscript
|
|
33
33
|
remember names as ["Ada", "Grace"]
|
|
@@ -36,7 +36,7 @@ show names[0]
|
|
|
36
36
|
show user?.name
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
English collection expressions:
|
|
39
|
+
English-style collection expressions:
|
|
40
40
|
|
|
41
41
|
```plainscript
|
|
42
42
|
remember items as list with "one", "two", "three"
|
|
@@ -47,10 +47,10 @@ show item one from items
|
|
|
47
47
|
show items at position 1
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Arithmetic
|
|
51
|
-
precedence. Word forms `plus`, `minus`, `times`, and `divided by`
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
Arithmetic uses `+`, `-`, `*`, `/`, `%`, and `**`, with normal
|
|
51
|
+
precedence. Word forms `plus`, `minus`, `times`, and `divided by` also work.
|
|
52
|
+
`??` plus unary `-`, `wait for`, `typeof`, `void`, and `delete` are
|
|
53
|
+
supported.
|
|
54
54
|
|
|
55
55
|
## Conditions
|
|
56
56
|
|
|
@@ -82,6 +82,8 @@ Use `and`, `or`, and `not` to combine conditions. Inline conditionals use
|
|
|
82
82
|
|
|
83
83
|
## Functions
|
|
84
84
|
|
|
85
|
+
Write a function with `make` and return a value with `give`:
|
|
86
|
+
|
|
85
87
|
```plainscript
|
|
86
88
|
make add(a, b)
|
|
87
89
|
give a + b
|
|
@@ -98,8 +100,8 @@ make greet(name as "friend")
|
|
|
98
100
|
done
|
|
99
101
|
```
|
|
100
102
|
|
|
101
|
-
Aliases `define`, `function`, `return`, and `give back`
|
|
102
|
-
readable
|
|
103
|
+
Aliases like `define`, `function`, `return`, and `give back` also work. Use
|
|
104
|
+
`make` and `give` for the readable form:
|
|
103
105
|
|
|
104
106
|
```plainscript
|
|
105
107
|
make add(a, b)
|
|
@@ -107,8 +109,8 @@ make add(a, b)
|
|
|
107
109
|
done
|
|
108
110
|
```
|
|
109
111
|
|
|
110
|
-
`yield`
|
|
111
|
-
async operations.
|
|
112
|
+
`yield` turns a function into a generator. Functions can use `wait for` and
|
|
113
|
+
other async operations.
|
|
112
114
|
|
|
113
115
|
## Control flow
|
|
114
116
|
|
|
@@ -127,8 +129,8 @@ done
|
|
|
127
129
|
```
|
|
128
130
|
|
|
129
131
|
Use `break` and `continue` inside loops. `match value against` uses `->`
|
|
130
|
-
case arrows and `otherwise`. `switch value against`
|
|
131
|
-
|
|
132
|
+
case arrows and `otherwise`. `switch value against` works the same way and
|
|
133
|
+
is just another way to write it.
|
|
132
134
|
|
|
133
135
|
## Record kinds
|
|
134
136
|
|
|
@@ -141,8 +143,9 @@ done
|
|
|
141
143
|
remember player as create a Player with name "Ada" and goals 4
|
|
142
144
|
```
|
|
143
145
|
|
|
144
|
-
`define a kind called`
|
|
145
|
-
`create a Kind with field value and field value`
|
|
146
|
+
`define a kind called` makes a new record kind. Fields use default
|
|
147
|
+
expressions. `create a Kind with field value and field value` builds an
|
|
148
|
+
instance.
|
|
146
149
|
|
|
147
150
|
## Modules and packages
|
|
148
151
|
|
|
@@ -153,7 +156,7 @@ export circleArea
|
|
|
153
156
|
use express
|
|
154
157
|
```
|
|
155
158
|
|
|
156
|
-
Imports
|
|
159
|
+
Imports get bundled in dependency order. `use` declares an npm package.
|
|
157
160
|
|
|
158
161
|
## Web server syntax
|
|
159
162
|
|
|
@@ -179,7 +182,7 @@ Methods are `get`, `post`, `put`, `patch`, and `delete`. Request values use
|
|
|
179
182
|
`body of request`, `param("id")`, `query("name")`, `header("x-token")`,
|
|
180
183
|
`upload("file")`, and `uploads("file")`.
|
|
181
184
|
|
|
182
|
-
|
|
185
|
+
The server also supports:
|
|
183
186
|
|
|
184
187
|
```plainscript
|
|
185
188
|
enable sessions "secret"
|
|
@@ -208,8 +211,8 @@ done
|
|
|
208
211
|
```
|
|
209
212
|
|
|
210
213
|
SQL blocks are closed by `done`. `{variable}` placeholders are bound safely.
|
|
211
|
-
`transaction ... done` groups writes. `postgres connection`
|
|
212
|
-
PostgreSQL
|
|
214
|
+
`transaction ... done` groups writes. `postgres connection` generates
|
|
215
|
+
PostgreSQL code instead.
|
|
213
216
|
|
|
214
217
|
HTTP client expressions:
|
|
215
218
|
|
|
@@ -234,14 +237,14 @@ done
|
|
|
234
237
|
```
|
|
235
238
|
|
|
236
239
|
Concurrency helpers are `allOf`, `anyOf`, `settledOf`, and `withTimeout`.
|
|
237
|
-
Recurring blocks
|
|
240
|
+
Recurring blocks use `every 5 minutes ... done` and
|
|
238
241
|
`schedule "0 * * * *" ... done`.
|
|
239
242
|
|
|
240
243
|
## AI providers
|
|
241
244
|
|
|
242
|
-
`chat(model, messages, options)` and `embedText(model, text, options)`
|
|
243
|
-
OpenAI-compatible API. Provider presets
|
|
244
|
-
and environment variable:
|
|
245
|
+
`chat(model, messages, options)` and `embedText(model, text, options)` talk
|
|
246
|
+
to an OpenAI-compatible API. Provider presets pick safe defaults for the
|
|
247
|
+
endpoint and the environment variable:
|
|
245
248
|
|
|
246
249
|
| Provider | API key | Default base |
|
|
247
250
|
| --- | --- | --- |
|
|
@@ -264,10 +267,9 @@ show answer
|
|
|
264
267
|
```
|
|
265
268
|
|
|
266
269
|
`base`, `key`, `headers`, `temperature`, `maxTokens`, and `responseFormat`
|
|
267
|
-
are optional
|
|
268
|
-
`
|
|
269
|
-
|
|
270
|
-
routes, jobs, and messaging handlers.
|
|
270
|
+
are optional. Custom providers can supply a provider name plus `base` and
|
|
271
|
+
`key`; the runtime falls back to `PROVIDER_API_KEY` and `PROVIDER_BASE_URL`.
|
|
272
|
+
These calls work in ordinary programs, routes, jobs, and messaging handlers.
|
|
271
273
|
|
|
272
274
|
## WebSockets, cache, bots, and OCR
|
|
273
275
|
|
|
@@ -297,9 +299,9 @@ start telegram bot
|
|
|
297
299
|
```
|
|
298
300
|
|
|
299
301
|
Inside a Telegram handler, `message`, `text`, `args`, `matches`, `chat`,
|
|
300
|
-
`chatId`, and callback `data`
|
|
302
|
+
`chatId`, and callback `data` hold the update context. Fixed replies use
|
|
301
303
|
`reply "text"`; provider-backed replies can use `chatWith` before `reply`.
|
|
302
|
-
`telegramCall(method, params)`
|
|
304
|
+
`telegramCall(method, params)` calls any Telegram Bot API method.
|
|
303
305
|
|
|
304
306
|
WhatsApp uses `whatsapp bot ... done`, with `auth`, `login qr`, `login
|
|
305
307
|
pairing`, and `on message` clauses. OCR uses:
|
package/docs/index.html
CHANGED
|
@@ -3,17 +3,38 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<meta name="description" content="PlainScript 1.0.3
|
|
7
|
-
<
|
|
6
|
+
<meta name="description" content="PlainScript 1.0.3 language reference and examples">
|
|
7
|
+
<meta name="theme-color" content="#070c16">
|
|
8
|
+
<title>PlainScript 1.0.3</title>
|
|
9
|
+
<script>
|
|
10
|
+
// Force desktop rendering on small screens: lay out at a desktop width and
|
|
11
|
+
// let the browser scale it down, so mobile users see the full site right
|
|
12
|
+
// away instead of having to pinch-zoom out.
|
|
13
|
+
(function () {
|
|
14
|
+
var isMobile = /Android|iPhone|iPod|iPad|Mobile|Windows Phone/i.test(navigator.userAgent);
|
|
15
|
+
if (isMobile) {
|
|
16
|
+
var vp = document.querySelector('meta[name="viewport"]');
|
|
17
|
+
if (vp) {
|
|
18
|
+
var layoutWidth = 1400;
|
|
19
|
+
var deviceWidth = window.screen.width || document.documentElement.clientWidth;
|
|
20
|
+
var scale = Math.min(deviceWidth / layoutWidth, 1).toFixed(5);
|
|
21
|
+
vp.setAttribute('content', 'width=' + layoutWidth + ', initial-scale=' + scale + ', maximum-scale=5');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
</script>
|
|
8
26
|
<link rel="stylesheet" href="website/style.css">
|
|
9
27
|
</head>
|
|
10
28
|
<body>
|
|
11
|
-
<
|
|
29
|
+
<div class="bg-scrim" aria-hidden="true"></div>
|
|
30
|
+
<canvas id="bg-canvas" aria-hidden="true"></canvas>
|
|
31
|
+
|
|
32
|
+
<header class="site-nav" id="site-nav">
|
|
12
33
|
<div class="container nav-inner">
|
|
13
34
|
<a class="nav-logo" href="#">
|
|
14
|
-
<
|
|
35
|
+
<span class="nav-logo-mark" aria-hidden="true">>_</span>
|
|
15
36
|
<span>PlainScript</span>
|
|
16
|
-
<span class="logo-ver">1.0.3
|
|
37
|
+
<span class="logo-ver">1.0.3</span>
|
|
17
38
|
</a>
|
|
18
39
|
<nav class="nav-links" aria-label="Primary navigation">
|
|
19
40
|
<a href="#quickstart">Quick start</a>
|
|
@@ -27,9 +48,9 @@
|
|
|
27
48
|
<main>
|
|
28
49
|
<section class="hero">
|
|
29
50
|
<div class="container hero-content">
|
|
30
|
-
<p class="hero-badge">1.0.3
|
|
51
|
+
<p class="hero-badge" data-reveal>1.0.3: Node.js programming for everyone</p>
|
|
31
52
|
<h1 class="hero-title">Code that reads like plain English.</h1>
|
|
32
|
-
<p class="hero-lead">
|
|
53
|
+
<p class="hero-lead">Write what you want in plain words. PlainScript turns it into JavaScript — simple, readable, and easy to check.</p>
|
|
33
54
|
<div class="hero-actions">
|
|
34
55
|
<a class="button button-primary" href="#quickstart">Start building</a>
|
|
35
56
|
<a class="button button-secondary" href="#library">Browse examples</a>
|
|
@@ -43,14 +64,14 @@ done</code></pre>
|
|
|
43
64
|
|
|
44
65
|
<section id="quickstart" class="section">
|
|
45
66
|
<div class="container">
|
|
46
|
-
<p class="section-tag">Quick start</p>
|
|
47
|
-
<h2 class="section-title">
|
|
67
|
+
<p class="section-tag" data-reveal>Quick start</p>
|
|
68
|
+
<h2 class="section-title" data-reveal>A simple three-step workflow.</h2>
|
|
48
69
|
<div class="three-column">
|
|
49
|
-
<article class="info-card"><span class="card-number">01</span><h3>Write</h3><p>Create a <code>.pln</code> file with readable
|
|
50
|
-
<article class="info-card"><span class="card-number">02</span><h3>Check</h3><p>Run <code>plainscript check file.pln</code> to
|
|
51
|
-
<article class="info-card"><span class="card-number">03</span><h3>Build</h3><p>Run <code>plainscript build</code> to
|
|
70
|
+
<article class="info-card" data-reveal><span class="card-number">01</span><h3>Write</h3><p>Create a <code>.pln</code> file with readable code blocks.</p></article>
|
|
71
|
+
<article class="info-card" data-reveal><span class="card-number">02</span><h3>Check</h3><p>Run <code>plainscript check file.pln</code> to catch mistakes.</p></article>
|
|
72
|
+
<article class="info-card" data-reveal><span class="card-number">03</span><h3>Build</h3><p>Run <code>plainscript build</code> to get your files in <code>dist/</code>.</p></article>
|
|
52
73
|
</div>
|
|
53
|
-
<pre class="code-window"><code>npx plainscript new hello
|
|
74
|
+
<pre class="code-window" data-reveal><code>npx plainscript new hello
|
|
54
75
|
cd hello
|
|
55
76
|
npx plainscript check
|
|
56
77
|
npx plainscript build
|
|
@@ -60,36 +81,38 @@ npm start</code></pre>
|
|
|
60
81
|
|
|
61
82
|
<section id="language" class="section section--alt">
|
|
62
83
|
<div class="container">
|
|
63
|
-
<p class="section-tag">Language</p>
|
|
64
|
-
<h2 class="section-title">A
|
|
84
|
+
<p class="section-tag" data-reveal>Language</p>
|
|
85
|
+
<h2 class="section-title" data-reveal>A small set of words you already know.</h2>
|
|
65
86
|
<div class="feature-grid">
|
|
66
|
-
<article class="feature-card"><h3>Variables</h3><p
|
|
67
|
-
<article class="feature-card"><h3>Conditions</h3><p>
|
|
68
|
-
<article class="feature-card"><h3>Functions</h3><p>
|
|
69
|
-
<article class="feature-card"><h3>Records</h3><p>Model data with record kinds and
|
|
70
|
-
<article class="feature-card"><h3>
|
|
71
|
-
<article class="feature-card"><h3>
|
|
72
|
-
<article class="feature-card"><h3>
|
|
87
|
+
<article class="feature-card" data-reveal><h3>Variables</h3><p>Store values with <code>remember name as "Ada"</code> and change them with <code>becomes</code>.</p></article>
|
|
88
|
+
<article class="feature-card" data-reveal><h3>Conditions</h3><p>Compare things with <code>is at least</code>, <code>contains</code>, <code>between</code>, and more.</p></article>
|
|
89
|
+
<article class="feature-card" data-reveal><h3>Functions</h3><p>Create functions with <code>make</code>, return with <code>give</code>, and close with <code>done</code>.</p></article>
|
|
90
|
+
<article class="feature-card" data-reveal><h3>Records</h3><p>Model your data with record kinds and easy constructors.</p></article>
|
|
91
|
+
<article class="feature-card" data-reveal><h3>Modules</h3><p>Import code with <code>bring ... from</code>, <code>@/</code> aliases, and re-exports.</p></article>
|
|
92
|
+
<article class="feature-card" data-reveal><h3>Compound Types</h3><p>Use dictionaries, sets, and tuples with unpacking.</p></article>
|
|
93
|
+
<article class="feature-card" data-reveal><h3>Web apps</h3><p>Set up routes, JSON responses, sessions, cookies, uploads, and auth.</p></article>
|
|
94
|
+
<article class="feature-card" data-reveal><h3>Data and async</h3><p>Work with SQLite, HTTP, files, schedules, concurrency, and WebSockets.</p></article>
|
|
95
|
+
<article class="feature-card" data-reveal><h3>AI providers</h3><p>Call Groq and other OpenAI-compatible providers using your own keys.</p></article>
|
|
73
96
|
</div>
|
|
74
97
|
</div>
|
|
75
98
|
</section>
|
|
76
99
|
|
|
77
100
|
<section id="capabilities" class="section">
|
|
78
101
|
<div class="container">
|
|
79
|
-
<p class="section-tag">Capabilities</p>
|
|
80
|
-
<h2 class="section-title">
|
|
81
|
-
<div class="capability-list">
|
|
82
|
-
<span>JSON</span><span>SQLite and SQL</span><span>HTTP client</span><span>Auth and sessions</span><span>Files</span><span>Packages</span><span>Async</span><span>Errors</span><span>Concurrency</span><span>WebSockets</span><span>Cache</span><span>Bots</span><span>OCR</span><span>Tests</span><span>Modules</span>
|
|
102
|
+
<p class="section-tag" data-reveal>Capabilities</p>
|
|
103
|
+
<h2 class="section-title" data-reveal>Everything you need is built in.</h2>
|
|
104
|
+
<div class="capability-list" data-reveal>
|
|
105
|
+
<span>JSON</span><span>SQLite and SQL</span><span>HTTP client</span><span>Auth and sessions</span><span>Files</span><span>Packages</span><span>Async</span><span>Errors</span><span>Concurrency</span><span>WebSockets</span><span>Cache</span><span>Bots</span><span>OCR</span><span>Tests</span><span>Modules</span><span>Source Maps</span><span>Compound Types</span>
|
|
83
106
|
</div>
|
|
84
107
|
</div>
|
|
85
108
|
</section>
|
|
86
109
|
|
|
87
110
|
<section id="library" class="section section--alt">
|
|
88
111
|
<div class="container">
|
|
89
|
-
<p class="section-tag">Feature library</p>
|
|
90
|
-
<h2 class="section-title">
|
|
91
|
-
<p class="section-lead">These snippets use the
|
|
92
|
-
<div class="library-toolbar">
|
|
112
|
+
<p class="section-tag" data-reveal>Feature library</p>
|
|
113
|
+
<h2 class="section-title" data-reveal>Examples you can try today.</h2>
|
|
114
|
+
<p class="section-lead">These snippets use the PlainScript 1.0.3 grammar.</p>
|
|
115
|
+
<div class="library-toolbar" data-reveal>
|
|
93
116
|
<label class="sr-only" for="lib-search">Search examples</label>
|
|
94
117
|
<input id="lib-search" class="lib-search-input" type="search" placeholder="Search examples">
|
|
95
118
|
<div id="lib-filters" class="lib-filters" aria-label="Filter examples"></div>
|
|
@@ -101,15 +124,19 @@ npm start</code></pre>
|
|
|
101
124
|
|
|
102
125
|
<section class="section">
|
|
103
126
|
<div class="container split">
|
|
104
|
-
<div><p class="section-tag">Reference</p><h2 class="section-title">
|
|
105
|
-
<div><p>Read the <a href="PLAINSCRIPT-SPEC.md">language specification</a> and the <a href="../knowledge.md">AI coding specification</a>. The repository's <code>examples/</code> directory
|
|
127
|
+
<div data-reveal><p class="section-tag">Reference</p><h2 class="section-title">The compiler is the source of truth.</h2></div>
|
|
128
|
+
<div data-reveal><p>Read the <a href="PLAINSCRIPT-SPEC.md">language specification</a> and the <a href="../knowledge.md">AI coding specification</a>. The repository's <code>examples/</code> directory has runnable examples.</p><p>Validate a file with <code>node compiler/cli.js check path/to/file.pln</code>.</p></div>
|
|
106
129
|
</div>
|
|
107
130
|
</section>
|
|
108
131
|
</main>
|
|
109
132
|
|
|
110
133
|
<footer class="site-footer">
|
|
111
|
-
<div class="container footer-bottom"><span>PlainScript</span><span>1.0.3
|
|
134
|
+
<div class="container footer-bottom"><span>PlainScript</span><span>1.0.3</span></div>
|
|
112
135
|
</footer>
|
|
136
|
+
|
|
137
|
+
<script src="https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js"></script>
|
|
138
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js"></script>
|
|
139
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/ScrollTrigger.min.js"></script>
|
|
113
140
|
<script src="website/script.js"></script>
|
|
114
141
|
</body>
|
|
115
142
|
</html>
|