plainscript-lang 0.1.7-latest → 0.1.7-rc
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 +34 -34
- package/compiler/bundler.js +1 -1
- package/compiler/cli.js +41 -41
- package/compiler/parser.js +2 -2
- package/docs/PLINJS_SPEC.md +22 -22
- package/docs/index.html +523 -2205
- package/docs/website/script.js +814 -133
- package/docs/website/style.css +652 -1113
- package/examples/{cache-and-jobs.pln → cache-and-jobs.ps} +1 -1
- package/examples/{database.pln → database.ps} +1 -1
- package/examples/{deployment.pln → deployment.ps} +1 -1
- package/examples/{email-send.pln → email-send.ps} +1 -1
- package/examples/{rest-api.pln → rest-api.ps} +1 -1
- package/examples/{scheduled-tasks.pln → scheduled-tasks.ps} +1 -1
- package/examples/{websocket-server.pln → websocket-server.ps} +1 -1
- package/package.json +1 -1
- package/docs/website/index.html +0 -1500
- /package/examples/{arrays.pln → arrays.ps} +0 -0
- /package/examples/{day2.pln → day2.ps} +0 -0
- /package/examples/{day3.pln → day3.ps} +0 -0
- /package/examples/{expressions.pln → expressions.ps} +0 -0
- /package/examples/football-backend/{app.pln → app.ps} +0 -0
- /package/examples/{hello.pln → hello.ps} +0 -0
- /package/examples/id-verification/{app.pln → app.ps} +0 -0
- /package/examples/{loops.pln → loops.ps} +0 -0
- /package/examples/{objects.pln → objects.ps} +0 -0
- /package/examples/{rest-api-fetch.pln → rest-api-fetch.ps} +0 -0
- /package/examples/{server.pln → server.ps} +0 -0
- /package/examples/{start.pln → start.ps} +0 -0
- /package/examples/{stdlib.pln → stdlib.ps} +0 -0
- /package/examples/{telegram-bot.pln → telegram-bot.ps} +0 -0
- /package/examples/{web-app.pln → web-app.ps} +0 -0
- /package/examples/whatsapp-bot/{pairing.pln → pairing.ps} +0 -0
- /package/examples/whatsapp-bot/{qr.pln → qr.ps} +0 -0
package/docs/website/index.html
DELETED
|
@@ -1,1500 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
|
|
7
|
-
<!-- SEO -->
|
|
8
|
-
<title>PlainScript — The programming language that reads like English</title>
|
|
9
|
-
<meta name="description" content="PlainScript is an Intent-Oriented Programming Language (IOPL). Write programs in near-English sentences and compile them to JavaScript..">
|
|
10
|
-
<meta name="keywords" content="PlainScript, IOPL, intent-oriented programming, programming language, JavaScript, PlainScript language, plainscript, beginner programming language">
|
|
11
|
-
<link rel="canonical" href="https://plain-code.name.ng/">
|
|
12
|
-
|
|
13
|
-
<!-- OpenGraph -->
|
|
14
|
-
<meta property="og:type" content="website">
|
|
15
|
-
<meta property="og:url" content="https://plain-lang.dev/">
|
|
16
|
-
<meta property="og:title" content="PlainScript — The programming language that reads like English">
|
|
17
|
-
<meta property="og:description" content="Write programs in near-English sentences. PlainScript compiles to JavaScript..">
|
|
18
|
-
<meta property="og:image" content="https://plain-code.name.ng/logo.jpg">
|
|
19
|
-
|
|
20
|
-
<!-- Twitter Card -->
|
|
21
|
-
<meta name="twitter:card" content="summary_large_image">
|
|
22
|
-
<meta name="twitter:title" content="PlainScript — The programming language that reads like English">
|
|
23
|
-
<meta name="twitter:description" content="Write programs in near-English sentences. PlainScript compiles to JavaScript..">
|
|
24
|
-
<meta name="twitter:image" content="https://plain-code.name.ng/logo.jpg">
|
|
25
|
-
|
|
26
|
-
<!-- Font Awesome -->
|
|
27
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer">
|
|
28
|
-
|
|
29
|
-
<!-- Styles -->
|
|
30
|
-
<link rel="stylesheet" href="/website/style.css">
|
|
31
|
-
</head>
|
|
32
|
-
<body>
|
|
33
|
-
|
|
34
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
35
|
-
<!-- NAV -->
|
|
36
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
37
|
-
<nav class="site-nav" role="navigation" aria-label="Main navigation">
|
|
38
|
-
<div class="nav-inner">
|
|
39
|
-
<a class="nav-logo" href="#top">
|
|
40
|
-
<span class="logo-word">PlainScript</span>
|
|
41
|
-
<span class="logo-ver">v0.1.7</span>
|
|
42
|
-
</a>
|
|
43
|
-
|
|
44
|
-
<ul class="nav-links" role="list">
|
|
45
|
-
<li><a href="#quickstart">Docs</a></li>
|
|
46
|
-
<li><a href="#examples">Examples</a></li>
|
|
47
|
-
<li><a href="#language">Language</a></li>
|
|
48
|
-
<li><a href="#ocr">OCR</a></li>
|
|
49
|
-
<li><a href="#cli">CLI</a></li>
|
|
50
|
-
<li><a href="#packages">Packages</a></li>
|
|
51
|
-
<li><a href="#faq">FAQ</a></li>
|
|
52
|
-
</ul>
|
|
53
|
-
|
|
54
|
-
<div class="nav-actions">
|
|
55
|
-
<a class="nav-cta" href="https://github.com/ayoistooslick/plain-code" target="_blank" rel="noopener">
|
|
56
|
-
<i class="fa-brands fa-github"></i>
|
|
57
|
-
<span>GitHub</span>
|
|
58
|
-
</a>
|
|
59
|
-
<a class="nav-cta" href="https://www.npmjs.com/package/plainscript" target="_blank" rel="noopener">
|
|
60
|
-
<i class="fa-brands fa-npm"></i>
|
|
61
|
-
<span>npm</span>
|
|
62
|
-
</a>
|
|
63
|
-
<button class="nav-hamburger" id="nav-hamburger" aria-label="Toggle menu" aria-expanded="false">
|
|
64
|
-
<i class="fa-solid fa-bars"></i>
|
|
65
|
-
</button>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
</nav>
|
|
69
|
-
|
|
70
|
-
<!-- Mobile menu -->
|
|
71
|
-
<div class="mobile-menu" id="mobile-menu" role="dialog" aria-label="Mobile navigation">
|
|
72
|
-
<a href="#quickstart">Docs</a>
|
|
73
|
-
<a href="#examples">Examples</a>
|
|
74
|
-
<a href="#language">Language</a>
|
|
75
|
-
<a href="#stdlib">Standard Library</a>
|
|
76
|
-
<a href="#web">Web Development</a>
|
|
77
|
-
<a href="#database">SQLite</a>
|
|
78
|
-
<a href="#ocr">OCR</a>
|
|
79
|
-
<a href="#cli">CLI</a>
|
|
80
|
-
<a href="#packages">Packages</a>
|
|
81
|
-
<a href="#formatter">Formatter</a>
|
|
82
|
-
<a href="#vscode">VS Code</a>
|
|
83
|
-
<a href="#roadmap">Roadmap</a>
|
|
84
|
-
<a href="#faq">FAQ</a>
|
|
85
|
-
<a href="https://github.com/ayoistooslick/plain-code" target="_blank" rel="noopener"><i class="fa-brands fa-github"></i> GitHub</a>
|
|
86
|
-
<a href="https://www.npmjs.com/package/plainscript" target="_blank" rel="noopener"><i class="fa-brands fa-npm"></i> npm</a>
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
90
|
-
<!-- HERO -->
|
|
91
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
92
|
-
<header class="hero" id="top">
|
|
93
|
-
<div class="container">
|
|
94
|
-
<div class="hero-grid">
|
|
95
|
-
|
|
96
|
-
<!-- Left: copy -->
|
|
97
|
-
<div class="hero-copy">
|
|
98
|
-
<div class="hero-badge">
|
|
99
|
-
<i class="fa-solid fa-bolt"></i>
|
|
100
|
-
v0.1.7 — production builds · dist output · local devDependency
|
|
101
|
-
</div>
|
|
102
|
-
<h1 class="hero-title">
|
|
103
|
-
The language<br>
|
|
104
|
-
that reads<br>
|
|
105
|
-
like <span class="accent">English.</span>
|
|
106
|
-
</h1>
|
|
107
|
-
<p class="hero-sub">
|
|
108
|
-
PlainScript is an Intent-Oriented Programming Language. Describe <em>what</em> you want in near-English sentences and PlainScript compiles it to JavaScript. No boilerplate, no ceremony.
|
|
109
|
-
</p>
|
|
110
|
-
<div class="hero-actions">
|
|
111
|
-
<a class="btn btn-primary" href="#quickstart">
|
|
112
|
-
<i class="fa-solid fa-rocket"></i>
|
|
113
|
-
Get Started
|
|
114
|
-
</a>
|
|
115
|
-
<a class="btn btn-outline" href="#language">
|
|
116
|
-
<i class="fa-solid fa-book"></i>
|
|
117
|
-
Language Reference
|
|
118
|
-
</a>
|
|
119
|
-
<a class="btn btn-outline" href="https://github.com/ayoistooslick/plain-code" target="_blank" rel="noopener">
|
|
120
|
-
<i class="fa-brands fa-github"></i>
|
|
121
|
-
GitHub
|
|
122
|
-
</a>
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
|
|
126
|
-
<!-- Right: code -->
|
|
127
|
-
<div class="hero-code">
|
|
128
|
-
<div class="code-block">
|
|
129
|
-
<div class="code-block-header">
|
|
130
|
-
<div class="code-block-dots">
|
|
131
|
-
<span></span><span></span><span></span>
|
|
132
|
-
</div>
|
|
133
|
-
<span class="code-block-title">app.pln</span>
|
|
134
|
-
<button class="code-copy" aria-label="Copy code">
|
|
135
|
-
<i class="fa-regular fa-copy"></i> Copy
|
|
136
|
-
</button>
|
|
137
|
-
</div>
|
|
138
|
-
<pre><code><span class="kw">web app</span>
|
|
139
|
-
|
|
140
|
-
<span class="kw">route</span> <span class="str">"/"</span>
|
|
141
|
-
<span class="kw">reply json</span>
|
|
142
|
-
message <span class="kw">is</span> <span class="str">"Hello, World!"</span>
|
|
143
|
-
version <span class="kw">is</span> <span class="str">"1.0"</span>
|
|
144
|
-
<span class="kw">done</span>
|
|
145
|
-
<span class="kw">done</span>
|
|
146
|
-
|
|
147
|
-
<span class="kw">route</span> <span class="str">"/users/:id"</span>
|
|
148
|
-
<span class="kw">remember</span> id <span class="kw">as</span> request.params.id
|
|
149
|
-
<span class="kw">reply json</span>
|
|
150
|
-
user <span class="kw">is</span> id
|
|
151
|
-
status <span class="kw">is</span> <span class="str">"found"</span>
|
|
152
|
-
<span class="kw">done</span>
|
|
153
|
-
<span class="kw">done</span>
|
|
154
|
-
|
|
155
|
-
<span class="kw">start</span> <span class="num">3000</span></code></pre>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
</header>
|
|
162
|
-
|
|
163
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
164
|
-
<!-- STATS -->
|
|
165
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
166
|
-
<div class="container">
|
|
167
|
-
<div class="stats-row">
|
|
168
|
-
<div class="stat-item">
|
|
169
|
-
<div class="stat-value">40<span class="unit">+</span></div>
|
|
170
|
-
<div class="stat-label">Keywords</div>
|
|
171
|
-
</div>
|
|
172
|
-
<div class="stat-item">
|
|
173
|
-
<div class="stat-value">625<span class="unit">+</span></div>
|
|
174
|
-
<div class="stat-label">Tests Passing</div>
|
|
175
|
-
</div>
|
|
176
|
-
<div class="stat-item">
|
|
177
|
-
<div class="stat-value">0</div>
|
|
178
|
-
<div class="stat-label">Config Files Needed</div>
|
|
179
|
-
</div>
|
|
180
|
-
<div class="stat-item">
|
|
181
|
-
<div class="stat-value">MIT</div>
|
|
182
|
-
<div class="stat-label">License</div>
|
|
183
|
-
</div>
|
|
184
|
-
</div>
|
|
185
|
-
</div>
|
|
186
|
-
|
|
187
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
188
|
-
<!-- WHY PlainScript -->
|
|
189
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
190
|
-
<section class="section" id="why">
|
|
191
|
-
<div class="container">
|
|
192
|
-
<div class="section-tag"><i class="fa-solid fa-lightbulb"></i> Philosophy</div>
|
|
193
|
-
<h2 class="section-title">Why PlainScript?</h2>
|
|
194
|
-
<p class="section-lead">
|
|
195
|
-
Most programming languages were designed by and for computer scientists. PlainScript was designed to be understood by anyone who can write a sentence.
|
|
196
|
-
</p>
|
|
197
|
-
|
|
198
|
-
<div class="why-grid">
|
|
199
|
-
<div class="why-item">
|
|
200
|
-
<div class="why-num"><i class="fa-solid fa-pen-nib"></i></div>
|
|
201
|
-
<h3>Intent, not implementation</h3>
|
|
202
|
-
<p>Write <em>what</em> you want to happen, not <em>how</em> JavaScript should do it. The compiler bridges the gap, generating clean, readable JS output.</p>
|
|
203
|
-
</div>
|
|
204
|
-
<div class="why-item">
|
|
205
|
-
<div class="why-num"><i class="fa-solid fa-gauge-high"></i></div>
|
|
206
|
-
<h3>Zero configuration</h3>
|
|
207
|
-
<p>No webpack. No tsconfig. No babel. Drop a <code>.pln</code> file anywhere and run it. Zero configuration required.</p>
|
|
208
|
-
</div>
|
|
209
|
-
<div class="why-item">
|
|
210
|
-
<div class="why-num"><i class="fa-solid fa-ruler"></i></div>
|
|
211
|
-
<h3>One way to do everything</h3>
|
|
212
|
-
<p>No decision fatigue. PlainScript has exactly one way to declare a variable, one way to loop, one way to define a function. Less syntax to memorise, more time to build.</p>
|
|
213
|
-
</div>
|
|
214
|
-
<div class="why-item">
|
|
215
|
-
<div class="why-num"><i class="fa-solid fa-comment-dots"></i></div>
|
|
216
|
-
<h3>Errors that teach</h3>
|
|
217
|
-
<p>Every error message tells you what went wrong, which line, and — when possible — exactly what to type instead. The compiler is a tutor, not a gatekeeper.</p>
|
|
218
|
-
</div>
|
|
219
|
-
<div class="why-item">
|
|
220
|
-
<div class="why-num"><i class="fa-solid fa-puzzle-piece"></i></div>
|
|
221
|
-
<h3>npm-compatible</h3>
|
|
222
|
-
<p>Any npm package can be declared with <code>use</code> and installed with <code>plainscript add</code>. The entire Node.js ecosystem is one keyword away.</p>
|
|
223
|
-
</div>
|
|
224
|
-
<div class="why-item">
|
|
225
|
-
<div class="why-num"><i class="fa-solid fa-eye"></i></div>
|
|
226
|
-
<h3>Code that reads like docs</h3>
|
|
227
|
-
<p>PlainScript code doubles as documentation. Hand it to a non-programmer and they will understand it. That constraint makes your code better for everyone.</p>
|
|
228
|
-
</div>
|
|
229
|
-
</div>
|
|
230
|
-
</div>
|
|
231
|
-
</section>
|
|
232
|
-
|
|
233
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
234
|
-
<!-- FEATURES -->
|
|
235
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
236
|
-
<section class="section section--alt" id="features">
|
|
237
|
-
<div class="container">
|
|
238
|
-
<div class="section-tag"><i class="fa-solid fa-cubes"></i> Features</div>
|
|
239
|
-
<h2 class="section-title">Everything you need. Nothing you don’t.</h2>
|
|
240
|
-
<p class="section-lead">
|
|
241
|
-
PlainScript ships with batteries included — a full standard library, built-in web and database support, a formatter, and a VS Code extension.
|
|
242
|
-
</p>
|
|
243
|
-
|
|
244
|
-
<div class="feature-grid">
|
|
245
|
-
<div class="feature-card">
|
|
246
|
-
<div class="feature-card-icon"><i class="fa-solid fa-font"></i></div>
|
|
247
|
-
<h4>English Keywords</h4>
|
|
248
|
-
<p>Every keyword — <code>remember</code>, <code>becomes</code>, <code>show</code>, <code>make</code>, <code>give</code> — was chosen to mirror plain English. No symbol soup.</p>
|
|
249
|
-
</div>
|
|
250
|
-
<div class="feature-card">
|
|
251
|
-
<div class="feature-card-icon"><i class="fa-solid fa-server"></i></div>
|
|
252
|
-
<h4>Built-in Web DX</h4>
|
|
253
|
-
<p>First-class Express integration with <code>web app</code>, <code>route</code>, <code>reply json</code>, and <code>start</code>. Build REST APIs in a dozen lines.</p>
|
|
254
|
-
</div>
|
|
255
|
-
<div class="feature-card">
|
|
256
|
-
<div class="feature-card-icon"><i class="fa-solid fa-database"></i></div>
|
|
257
|
-
<h4>Built-in SQLite DX</h4>
|
|
258
|
-
<p>Write SQL inline with <code>query</code>, <code>insert</code>, <code>update</code>, <code>delete</code>, and <code>execute</code> blocks. Powered by <code>better-sqlite3</code>.</p>
|
|
259
|
-
</div>
|
|
260
|
-
<div class="feature-card">
|
|
261
|
-
<div class="feature-card-icon"><i class="fa-solid fa-box"></i></div>
|
|
262
|
-
<h4>Standard Library</h4>
|
|
263
|
-
<p>20+ built-in functions for I/O, strings, numbers, files, time, JSON, and UUID — all available with no import statement.</p>
|
|
264
|
-
</div>
|
|
265
|
-
<div class="feature-card">
|
|
266
|
-
<div class="feature-card-icon"><i class="fa-solid fa-wand-magic-sparkles"></i></div>
|
|
267
|
-
<h4>Auto Formatter</h4>
|
|
268
|
-
<p>One command formats your entire <code>.pln</code> file with consistent 4-space indentation, proper spacing, and normalised blank lines.</p>
|
|
269
|
-
</div>
|
|
270
|
-
<div class="feature-card">
|
|
271
|
-
<div class="feature-card-icon"><i class="fa-solid fa-code"></i></div>
|
|
272
|
-
<h4>VS Code Extension</h4>
|
|
273
|
-
<p>Syntax highlighting, snippets, bracket matching, comment toggling, and code folding — all for <code>.pln</code> files out of the box.</p>
|
|
274
|
-
</div>
|
|
275
|
-
</div>
|
|
276
|
-
</div>
|
|
277
|
-
</section>
|
|
278
|
-
|
|
279
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
280
|
-
<!-- INSTALLATION / QUICK START -->
|
|
281
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
282
|
-
<section class="section" id="quickstart">
|
|
283
|
-
<div class="container">
|
|
284
|
-
<div class="section-tag"><i class="fa-solid fa-download"></i> Setup</div>
|
|
285
|
-
<h2 class="section-title">Quick Start</h2>
|
|
286
|
-
<p class="section-lead">
|
|
287
|
-
PlainScript compiles <code>.pln</code> files to JavaScript and runs them with Node.js. No bundlers, no transpilers, no configuration required.
|
|
288
|
-
</p>
|
|
289
|
-
|
|
290
|
-
<div class="install-strip">
|
|
291
|
-
<div class="install-strip-label">
|
|
292
|
-
<i class="fa-brands fa-npm"></i>
|
|
293
|
-
Install locally via npm
|
|
294
|
-
</div>
|
|
295
|
-
<div class="install-cmd">
|
|
296
|
-
<code>npm install --save-dev plainscript</code>
|
|
297
|
-
<button aria-label="Copy install command">
|
|
298
|
-
<i class="fa-regular fa-copy"></i> Copy
|
|
299
|
-
</button>
|
|
300
|
-
</div>
|
|
301
|
-
</div>
|
|
302
|
-
|
|
303
|
-
<h3 class="sub-heading"><i class="fa-solid fa-folder-plus"></i> Create a new project</h3>
|
|
304
|
-
|
|
305
|
-
<div class="code-block" style="margin-bottom:1.5rem">
|
|
306
|
-
<div class="code-block-header">
|
|
307
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
308
|
-
<span class="code-block-title">Terminal</span>
|
|
309
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
310
|
-
</div>
|
|
311
|
-
<pre><code><span class="prm">$</span> plainscript new myapp
|
|
312
|
-
<span class="prm">$</span> cd myapp
|
|
313
|
-
<span class="prm">$</span> plainscript install
|
|
314
|
-
<span class="prm">$</span> plainscript run app.pln</code></pre>
|
|
315
|
-
</div>
|
|
316
|
-
|
|
317
|
-
<h3 class="sub-heading"><i class="fa-solid fa-file-code"></i> Your first PlainScript program</h3>
|
|
318
|
-
|
|
319
|
-
<div class="compare" style="margin-bottom:1.5rem">
|
|
320
|
-
<div class="code-block">
|
|
321
|
-
<div class="code-block-header">
|
|
322
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
323
|
-
<span class="code-block-title">hello.pln</span>
|
|
324
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
325
|
-
</div>
|
|
326
|
-
<pre><code><span class="kw">remember</span> name <span class="kw">as</span> <span class="str">"World"</span>
|
|
327
|
-
<span class="kw">show</span> <span class="str">"Hello, "</span> + name
|
|
328
|
-
|
|
329
|
-
<span class="kw">make</span> <span class="fn">greet</span>(person)
|
|
330
|
-
<span class="kw">show</span> <span class="str">"Nice to meet you, "</span> + person
|
|
331
|
-
<span class="kw">done</span>
|
|
332
|
-
|
|
333
|
-
<span class="fn">greet</span>(name)</code></pre>
|
|
334
|
-
</div>
|
|
335
|
-
<div class="code-block">
|
|
336
|
-
<div class="code-block-header">
|
|
337
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
338
|
-
<span class="code-block-title">Generated JavaScript</span>
|
|
339
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
340
|
-
</div>
|
|
341
|
-
<pre><code><span class="kw">let</span> name = <span class="str">"World"</span>;
|
|
342
|
-
console.<span class="fn">log</span>(<span class="str">"Hello, "</span> + name);
|
|
343
|
-
|
|
344
|
-
<span class="kw">function</span> <span class="fn">greet</span>(person) {
|
|
345
|
-
console.<span class="fn">log</span>(<span class="str">"Nice to meet you, "</span> + person);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
<span class="fn">greet</span>(name);</code></pre>
|
|
349
|
-
</div>
|
|
350
|
-
</div>
|
|
351
|
-
|
|
352
|
-
<h3 class="sub-heading"><i class="fa-solid fa-terminal"></i> Essential commands</h3>
|
|
353
|
-
<div class="feature-grid" style="margin-top:1rem">
|
|
354
|
-
<div class="feature-card">
|
|
355
|
-
<div class="feature-card-icon"><i class="fa-solid fa-circle-check"></i></div>
|
|
356
|
-
<h4>plainscript check</h4>
|
|
357
|
-
<p>Validate syntax without compiling or running. Exits 0 on success, 1 on error. Ideal for CI pipelines.</p>
|
|
358
|
-
</div>
|
|
359
|
-
<div class="feature-card">
|
|
360
|
-
<div class="feature-card-icon"><i class="fa-solid fa-paintbrush"></i></div>
|
|
361
|
-
<h4>plainscript fmt</h4>
|
|
362
|
-
<p>Auto-format your <code>.pln</code> file in-place with consistent 4-space indentation and normalised spacing.</p>
|
|
363
|
-
</div>
|
|
364
|
-
<div class="feature-card">
|
|
365
|
-
<div class="feature-card-icon"><i class="fa-solid fa-cubes"></i></div>
|
|
366
|
-
<h4>plainscript add</h4>
|
|
367
|
-
<p>Install an npm package into the project automatically. Try <code>plainscript add express</code>.</p>
|
|
368
|
-
</div>
|
|
369
|
-
<div class="feature-card">
|
|
370
|
-
<div class="feature-card-icon"><i class="fa-solid fa-hammer"></i></div>
|
|
371
|
-
<h4>plainscript build</h4>
|
|
372
|
-
<p>Compile to <code>.js</code> without executing. Inspect the generated JavaScript to understand what PlainScript does.</p>
|
|
373
|
-
</div>
|
|
374
|
-
<div class="feature-card">
|
|
375
|
-
<div class="feature-card-icon"><i class="fa-solid fa-play"></i></div>
|
|
376
|
-
<h4>plainscript run</h4>
|
|
377
|
-
<p>Compile and immediately execute a <code>.pln</code> file. The output is printed to the terminal as it runs.</p>
|
|
378
|
-
</div>
|
|
379
|
-
<div class="feature-card">
|
|
380
|
-
<div class="feature-card-icon"><i class="fa-solid fa-folder-plus"></i></div>
|
|
381
|
-
<h4>plainscript new</h4>
|
|
382
|
-
<p>Scaffold a new PlainScript project with <code>src/app.pln</code>, <code>package.json</code>, and a <code>README</code> already set up.</p>
|
|
383
|
-
</div>
|
|
384
|
-
</div>
|
|
385
|
-
</div>
|
|
386
|
-
</section>
|
|
387
|
-
|
|
388
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
389
|
-
<!-- LANGUAGE TOUR -->
|
|
390
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
391
|
-
<section class="section section--alt" id="language">
|
|
392
|
-
<div class="container">
|
|
393
|
-
<div class="section-tag"><i class="fa-solid fa-book"></i> Language Reference</div>
|
|
394
|
-
<h2 class="section-title">Language Tour</h2>
|
|
395
|
-
<p class="section-lead">
|
|
396
|
-
A complete reference for every PlainScript construct. Every keyword compiles to a direct JavaScript equivalent — no magic, no hidden behaviour.
|
|
397
|
-
</p>
|
|
398
|
-
|
|
399
|
-
<!-- Variables -->
|
|
400
|
-
<h3 class="sub-heading"><i class="fa-solid fa-square-root-variable"></i> Variables</h3>
|
|
401
|
-
<p style="color:var(--muted);margin-bottom:.75rem">Declare with <code>remember … as</code>. Reassign with <code>becomes</code>.</p>
|
|
402
|
-
<div class="compare" style="margin-bottom:2rem">
|
|
403
|
-
<div class="code-block">
|
|
404
|
-
<div class="code-block-header">
|
|
405
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
406
|
-
<span class="code-block-title">PlainScript</span>
|
|
407
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
408
|
-
</div>
|
|
409
|
-
<pre><code><span class="kw">remember</span> name <span class="kw">as</span> <span class="str">"Ayokunle"</span>
|
|
410
|
-
<span class="kw">remember</span> score <span class="kw">as</span> <span class="num">100</span>
|
|
411
|
-
<span class="kw">remember</span> active <span class="kw">as</span> true
|
|
412
|
-
|
|
413
|
-
score <span class="kw">becomes</span> score + <span class="num">10</span></code></pre>
|
|
414
|
-
</div>
|
|
415
|
-
<div class="code-block">
|
|
416
|
-
<div class="code-block-header">
|
|
417
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
418
|
-
<span class="code-block-title">JavaScript</span>
|
|
419
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
420
|
-
</div>
|
|
421
|
-
<pre><code><span class="kw">let</span> name = <span class="str">"Ayokunle"</span>;
|
|
422
|
-
<span class="kw">let</span> score = <span class="num">100</span>;
|
|
423
|
-
<span class="kw">let</span> active = <span class="kw">true</span>;
|
|
424
|
-
|
|
425
|
-
score = score + <span class="num">10</span>;</code></pre>
|
|
426
|
-
</div>
|
|
427
|
-
</div>
|
|
428
|
-
|
|
429
|
-
<!-- Comparisons -->
|
|
430
|
-
<h3 class="sub-heading"><i class="fa-solid fa-scale-balanced"></i> Comparisons</h3>
|
|
431
|
-
<p style="color:var(--muted);margin-bottom:.75rem">PlainScript supports a full set of English comparison operators.</p>
|
|
432
|
-
<div class="table-wrap">
|
|
433
|
-
<table>
|
|
434
|
-
<thead>
|
|
435
|
-
<tr><th>PlainScript</th><th>JavaScript</th><th>Notes</th></tr>
|
|
436
|
-
</thead>
|
|
437
|
-
<tbody>
|
|
438
|
-
<tr><td><code>is</code> / <code>is equal to</code></td><td><code>===</code></td><td>Strict equality</td></tr>
|
|
439
|
-
<tr><td><code>is not</code></td><td><code>!==</code></td><td>Strict inequality</td></tr>
|
|
440
|
-
<tr><td><code>is greater than</code> / <code>is above</code></td><td><code>></code></td><td></td></tr>
|
|
441
|
-
<tr><td><code>is less than</code> / <code>is below</code></td><td><code><</code></td><td></td></tr>
|
|
442
|
-
<tr><td><code>is at least</code></td><td><code>>=</code></td><td></td></tr>
|
|
443
|
-
<tr><td><code>is at most</code></td><td><code><=</code></td><td></td></tr>
|
|
444
|
-
<tr><td><code>is empty</code></td><td><code>.length === 0</code></td><td>Arrays and strings</td></tr>
|
|
445
|
-
<tr><td><code>is not empty</code></td><td><code>.length > 0</code></td><td>Arrays and strings</td></tr>
|
|
446
|
-
<tr><td><code>contains "x"</code></td><td><code>.includes("x")</code></td><td></td></tr>
|
|
447
|
-
<tr><td><code>starts with "x"</code></td><td><code>.startsWith("x")</code></td><td></td></tr>
|
|
448
|
-
<tr><td><code>ends with "x"</code></td><td><code>.endsWith("x")</code></td><td></td></tr>
|
|
449
|
-
<tr><td><code>between A and B</code></td><td><code>>= A && <= B</code></td><td>Inclusive range</td></tr>
|
|
450
|
-
</tbody>
|
|
451
|
-
</table>
|
|
452
|
-
</div>
|
|
453
|
-
|
|
454
|
-
<!-- Control Flow -->
|
|
455
|
-
<h3 class="sub-heading"><i class="fa-solid fa-code-branch"></i> Control Flow</h3>
|
|
456
|
-
<div class="code-block" style="margin-bottom:2rem">
|
|
457
|
-
<div class="code-block-header">
|
|
458
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
459
|
-
<span class="code-block-title">control-flow.pln</span>
|
|
460
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
461
|
-
</div>
|
|
462
|
-
<pre><code><span class="cmt">// if / otherwise</span>
|
|
463
|
-
<span class="kw">if</span> age <span class="kw">between</span> <span class="num">13</span> <span class="kw">and</span> <span class="num">19</span>
|
|
464
|
-
<span class="kw">show</span> <span class="str">"Teenager"</span>
|
|
465
|
-
<span class="kw">otherwise</span>
|
|
466
|
-
<span class="kw">show</span> <span class="str">"Not a teenager"</span>
|
|
467
|
-
<span class="kw">done</span>
|
|
468
|
-
|
|
469
|
-
<span class="cmt">// while loop</span>
|
|
470
|
-
<span class="kw">while</span> x <span class="kw">is above</span> <span class="num">0</span>
|
|
471
|
-
x <span class="kw">becomes</span> x <span class="op">-</span> <span class="num">1</span>
|
|
472
|
-
<span class="kw">done</span>
|
|
473
|
-
|
|
474
|
-
<span class="cmt">// for each loop</span>
|
|
475
|
-
<span class="kw">for each</span> player <span class="kw">in</span> players
|
|
476
|
-
<span class="kw">show</span> player
|
|
477
|
-
<span class="kw">done</span>
|
|
478
|
-
|
|
479
|
-
<span class="cmt">// "for every" is an alias for "for each"</span>
|
|
480
|
-
<span class="kw">for every</span> item <span class="kw">in</span> basket
|
|
481
|
-
<span class="kw">show</span> item
|
|
482
|
-
<span class="kw">done</span></code></pre>
|
|
483
|
-
</div>
|
|
484
|
-
|
|
485
|
-
<!-- Functions -->
|
|
486
|
-
<h3 class="sub-heading"><i class="fa-solid fa-f"></i> Functions</h3>
|
|
487
|
-
<div class="compare" style="margin-bottom:2rem">
|
|
488
|
-
<div class="code-block">
|
|
489
|
-
<div class="code-block-header">
|
|
490
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
491
|
-
<span class="code-block-title">PlainScript</span>
|
|
492
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
493
|
-
</div>
|
|
494
|
-
<pre><code><span class="kw">make</span> <span class="fn">add</span>(a, b)
|
|
495
|
-
<span class="kw">give</span> a <span class="op">+</span> b
|
|
496
|
-
<span class="kw">done</span>
|
|
497
|
-
|
|
498
|
-
<span class="kw">make</span> <span class="fn">greet</span>(name)
|
|
499
|
-
<span class="kw">show</span> <span class="str">"Hello, "</span> + name
|
|
500
|
-
<span class="kw">done</span>
|
|
501
|
-
|
|
502
|
-
<span class="kw">show</span> <span class="fn">add</span>(<span class="num">5</span>, <span class="num">7</span>) <span class="cmt">// 12</span>
|
|
503
|
-
<span class="fn">greet</span>(<span class="str">"World"</span>)</code></pre>
|
|
504
|
-
</div>
|
|
505
|
-
<div class="code-block">
|
|
506
|
-
<div class="code-block-header">
|
|
507
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
508
|
-
<span class="code-block-title">JavaScript</span>
|
|
509
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
510
|
-
</div>
|
|
511
|
-
<pre><code><span class="kw">function</span> <span class="fn">add</span>(a, b) {
|
|
512
|
-
<span class="kw">return</span> a + b;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
<span class="kw">function</span> <span class="fn">greet</span>(name) {
|
|
516
|
-
console.<span class="fn">log</span>(<span class="str">"Hello, "</span> + name);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
console.<span class="fn">log</span>(<span class="fn">add</span>(<span class="num">5</span>, <span class="num">7</span>)); <span class="cmt">// 12</span>
|
|
520
|
-
<span class="fn">greet</span>(<span class="str">"World"</span>);</code></pre>
|
|
521
|
-
</div>
|
|
522
|
-
</div>
|
|
523
|
-
|
|
524
|
-
<!-- Objects & Arrays -->
|
|
525
|
-
<h3 class="sub-heading"><i class="fa-solid fa-layer-group"></i> Objects & Arrays</h3>
|
|
526
|
-
<div class="compare" style="margin-bottom:2rem">
|
|
527
|
-
<div class="code-block">
|
|
528
|
-
<div class="code-block-header">
|
|
529
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
530
|
-
<span class="code-block-title">PlainScript</span>
|
|
531
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
532
|
-
</div>
|
|
533
|
-
<pre><code><span class="kw">remember</span> user <span class="kw">as</span>
|
|
534
|
-
name <span class="kw">is</span> <span class="str">"Ayokunle"</span>
|
|
535
|
-
age <span class="kw">is</span> <span class="num">17</span>
|
|
536
|
-
country <span class="kw">is</span> <span class="str">"Nigeria"</span>
|
|
537
|
-
<span class="kw">done</span>
|
|
538
|
-
|
|
539
|
-
<span class="kw">show</span> user.name
|
|
540
|
-
user.age <span class="kw">becomes</span> <span class="num">18</span>
|
|
541
|
-
|
|
542
|
-
<span class="kw">remember</span> scores <span class="kw">as</span> [<span class="num">90</span>, <span class="num">85</span>, <span class="num">92</span>]
|
|
543
|
-
<span class="kw">show</span> scores[<span class="num">0</span>]
|
|
544
|
-
scores[<span class="num">1</span>] <span class="kw">becomes</span> <span class="num">95</span></code></pre>
|
|
545
|
-
</div>
|
|
546
|
-
<div class="code-block">
|
|
547
|
-
<div class="code-block-header">
|
|
548
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
549
|
-
<span class="code-block-title">JavaScript</span>
|
|
550
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
551
|
-
</div>
|
|
552
|
-
<pre><code><span class="kw">let</span> user = {
|
|
553
|
-
<span class="str">"name"</span>: <span class="str">"Ayokunle"</span>,
|
|
554
|
-
<span class="str">"age"</span>: <span class="num">17</span>,
|
|
555
|
-
<span class="str">"country"</span>: <span class="str">"Nigeria"</span>
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
console.<span class="fn">log</span>(user.name);
|
|
559
|
-
user.age = <span class="num">18</span>;
|
|
560
|
-
|
|
561
|
-
<span class="kw">let</span> scores = [<span class="num">90</span>, <span class="num">85</span>, <span class="num">92</span>];
|
|
562
|
-
console.<span class="fn">log</span>(scores[<span class="num">0</span>]);
|
|
563
|
-
scores[<span class="num">1</span>] = <span class="num">95</span>;</code></pre>
|
|
564
|
-
</div>
|
|
565
|
-
</div>
|
|
566
|
-
|
|
567
|
-
<!-- Imports -->
|
|
568
|
-
<h3 class="sub-heading"><i class="fa-solid fa-arrows-split-up-and-left"></i> Imports</h3>
|
|
569
|
-
<p style="color:var(--muted);margin-bottom:.75rem">Split a project across multiple <code>.pln</code> files using relative paths.</p>
|
|
570
|
-
<div class="code-block" style="margin-bottom:1rem">
|
|
571
|
-
<div class="code-block-header">
|
|
572
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
573
|
-
<span class="code-block-title">app.pln</span>
|
|
574
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
575
|
-
</div>
|
|
576
|
-
<pre><code><span class="kw">import</span> <span class="str">"./math.pln"</span>
|
|
577
|
-
<span class="kw">import</span> <span class="str">"./utils.pln"</span>
|
|
578
|
-
|
|
579
|
-
<span class="kw">show</span> <span class="fn">add</span>(<span class="num">3</span>, <span class="num">4</span>)</code></pre>
|
|
580
|
-
</div>
|
|
581
|
-
<div class="callout callout-info">
|
|
582
|
-
<i class="fa-solid fa-circle-info"></i>
|
|
583
|
-
<div class="callout-body">
|
|
584
|
-
<strong>Import rules</strong>
|
|
585
|
-
<p>Paths must be relative (<code>./</code> or <code>../</code>). Files compile in dependency order — deepest first. Circular imports produce a friendly compiler error.</p>
|
|
586
|
-
</div>
|
|
587
|
-
</div>
|
|
588
|
-
|
|
589
|
-
<!-- Comments -->
|
|
590
|
-
<h3 class="sub-heading"><i class="fa-solid fa-comment"></i> Comments</h3>
|
|
591
|
-
<div class="code-block">
|
|
592
|
-
<div class="code-block-header">
|
|
593
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
594
|
-
<span class="code-block-title">PlainScript</span>
|
|
595
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
596
|
-
</div>
|
|
597
|
-
<pre><code><span class="cmt">// This is a single-line comment</span>
|
|
598
|
-
<span class="kw">remember</span> x <span class="kw">as</span> <span class="num">42</span> <span class="cmt">// inline comment</span>
|
|
599
|
-
|
|
600
|
-
<span class="cmt">// note keyword is also available for block-level notes</span>
|
|
601
|
-
<span class="kw">note</span> <span class="str">"This section handles user authentication"</span></code></pre>
|
|
602
|
-
</div>
|
|
603
|
-
</div>
|
|
604
|
-
</section>
|
|
605
|
-
|
|
606
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
607
|
-
<!-- EXAMPLES -->
|
|
608
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
609
|
-
<section class="section" id="examples">
|
|
610
|
-
<div class="container">
|
|
611
|
-
<div class="section-tag"><i class="fa-solid fa-terminal"></i> Examples</div>
|
|
612
|
-
<h2 class="section-title">PlainScript in action</h2>
|
|
613
|
-
<p class="section-lead">
|
|
614
|
-
Real programs written in PlainScript. Every example compiles to clean, readable JavaScript.
|
|
615
|
-
</p>
|
|
616
|
-
|
|
617
|
-
<h3 class="sub-heading"><i class="fa-solid fa-list-check"></i> Conditions & loops</h3>
|
|
618
|
-
<div class="compare" style="margin-bottom:2rem">
|
|
619
|
-
<div class="code-block">
|
|
620
|
-
<div class="code-block-header">
|
|
621
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
622
|
-
<span class="code-block-title">conditions.pln</span>
|
|
623
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
624
|
-
</div>
|
|
625
|
-
<pre><code><span class="kw">remember</span> name <span class="kw">as</span> <span class="str">"Ayokunle"</span>
|
|
626
|
-
<span class="kw">remember</span> age <span class="kw">as</span> <span class="num">17</span>
|
|
627
|
-
<span class="kw">remember</span> score <span class="kw">as</span> <span class="num">85</span>
|
|
628
|
-
|
|
629
|
-
<span class="kw">if</span> age <span class="kw">is at least</span> <span class="num">18</span>
|
|
630
|
-
<span class="kw">show</span> <span class="str">"Adult"</span>
|
|
631
|
-
<span class="kw">otherwise</span>
|
|
632
|
-
<span class="kw">show</span> <span class="str">"Teenager"</span>
|
|
633
|
-
<span class="kw">done</span>
|
|
634
|
-
|
|
635
|
-
<span class="kw">if</span> score <span class="kw">between</span> <span class="num">80</span> <span class="kw">and</span> <span class="num">100</span>
|
|
636
|
-
<span class="kw">show</span> <span class="str">"Distinction"</span>
|
|
637
|
-
<span class="kw">done</span></code></pre>
|
|
638
|
-
</div>
|
|
639
|
-
<div class="code-block">
|
|
640
|
-
<div class="code-block-header">
|
|
641
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
642
|
-
<span class="code-block-title">loops.pln</span>
|
|
643
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
644
|
-
</div>
|
|
645
|
-
<pre><code><span class="kw">remember</span> players <span class="kw">as</span> [
|
|
646
|
-
<span class="str">"Haaland"</span>,
|
|
647
|
-
<span class="str">"Foden"</span>,
|
|
648
|
-
<span class="str">"Rodri"</span>
|
|
649
|
-
]
|
|
650
|
-
|
|
651
|
-
<span class="kw">for each</span> player <span class="kw">in</span> players
|
|
652
|
-
<span class="kw">show</span> <span class="str">"Player: "</span> + player
|
|
653
|
-
<span class="kw">done</span>
|
|
654
|
-
|
|
655
|
-
<span class="kw">remember</span> count <span class="kw">as</span> <span class="num">0</span>
|
|
656
|
-
<span class="kw">while</span> count <span class="kw">is below</span> <span class="num">5</span>
|
|
657
|
-
count <span class="kw">becomes</span> count + <span class="num">1</span>
|
|
658
|
-
<span class="kw">done</span></code></pre>
|
|
659
|
-
</div>
|
|
660
|
-
</div>
|
|
661
|
-
|
|
662
|
-
<h3 class="sub-heading"><i class="fa-solid fa-globe"></i> Fetch & stdlib</h3>
|
|
663
|
-
<div class="code-block" style="margin-bottom:2rem">
|
|
664
|
-
<div class="code-block-header">
|
|
665
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
666
|
-
<span class="code-block-title">stdlib.pln</span>
|
|
667
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
668
|
-
</div>
|
|
669
|
-
<pre><code><span class="cmt">// Built-in functions — no imports needed</span>
|
|
670
|
-
<span class="kw">remember</span> id <span class="kw">as</span> <span class="fn">uuid</span>()
|
|
671
|
-
<span class="kw">remember</span> now <span class="kw">as</span> <span class="fn">date</span>()
|
|
672
|
-
<span class="kw">remember</span> name <span class="kw">as</span> <span class="fn">uppercase</span>(<span class="str">"plainscript"</span>)
|
|
673
|
-
|
|
674
|
-
<span class="kw">show</span> id
|
|
675
|
-
<span class="kw">show</span> now
|
|
676
|
-
<span class="kw">show</span> name <span class="cmt">// "PlainScript"</span>
|
|
677
|
-
|
|
678
|
-
<span class="kw">remember</span> config <span class="kw">as</span> <span class="fn">jsonDecode</span>(<span class="fn">readFile</span>(<span class="str">"./config.json"</span>))
|
|
679
|
-
<span class="kw">show</span> config.version</code></pre>
|
|
680
|
-
</div>
|
|
681
|
-
</div>
|
|
682
|
-
</section>
|
|
683
|
-
|
|
684
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
685
|
-
<!-- STANDARD LIBRARY -->
|
|
686
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
687
|
-
<section class="section section--alt" id="stdlib">
|
|
688
|
-
<div class="container">
|
|
689
|
-
<div class="section-tag"><i class="fa-solid fa-box"></i> Standard Library</div>
|
|
690
|
-
<h2 class="section-title">Built-in Functions</h2>
|
|
691
|
-
<p class="section-lead">
|
|
692
|
-
All standard library functions are available without any <code>use</code> or import statement. No configuration needed.
|
|
693
|
-
</p>
|
|
694
|
-
|
|
695
|
-
<div class="callout callout-tip">
|
|
696
|
-
<i class="fa-solid fa-circle-check"></i>
|
|
697
|
-
<div class="callout-body">
|
|
698
|
-
<strong>Always available</strong>
|
|
699
|
-
<p>Unlike npm packages, stdlib functions never need to be installed. Just call them directly in any <code>.pln</code> file.</p>
|
|
700
|
-
</div>
|
|
701
|
-
</div>
|
|
702
|
-
|
|
703
|
-
<h3 class="sub-heading"><i class="fa-solid fa-terminal"></i> I/O & System</h3>
|
|
704
|
-
<div class="table-wrap">
|
|
705
|
-
<table>
|
|
706
|
-
<thead><tr><th>PlainScript</th><th>Compiles to</th><th>Description</th></tr></thead>
|
|
707
|
-
<tbody>
|
|
708
|
-
<tr><td><code>print(x)</code></td><td><code>console.log(x)</code></td><td>Print a value to stdout</td></tr>
|
|
709
|
-
<tr><td><code>show x</code></td><td><code>console.log(x)</code></td><td>Print a value (statement form)</td></tr>
|
|
710
|
-
<tr><td><code>env("KEY")</code></td><td><code>process.env["KEY"]</code></td><td>Read an environment variable</td></tr>
|
|
711
|
-
<tr><td><code>exit(code)</code></td><td><code>process.exit(code)</code></td><td>Exit the process with a code</td></tr>
|
|
712
|
-
</tbody>
|
|
713
|
-
</table>
|
|
714
|
-
</div>
|
|
715
|
-
|
|
716
|
-
<h3 class="sub-heading"><i class="fa-solid fa-file"></i> Files</h3>
|
|
717
|
-
<div class="table-wrap">
|
|
718
|
-
<table>
|
|
719
|
-
<thead><tr><th>PlainScript</th><th>Description</th></tr></thead>
|
|
720
|
-
<tbody>
|
|
721
|
-
<tr><td><code>readFile("path")</code></td><td>Read a file as UTF-8 text (synchronous)</td></tr>
|
|
722
|
-
<tr><td><code>writeFile("path", content)</code></td><td>Write text to a file (synchronous)</td></tr>
|
|
723
|
-
<tr><td><code>fileExists("path")</code></td><td>Check if a file exists — returns <code>true</code> or <code>false</code></td></tr>
|
|
724
|
-
</tbody>
|
|
725
|
-
</table>
|
|
726
|
-
</div>
|
|
727
|
-
|
|
728
|
-
<h3 class="sub-heading"><i class="fa-solid fa-clock"></i> Time & Utilities</h3>
|
|
729
|
-
<div class="table-wrap">
|
|
730
|
-
<table>
|
|
731
|
-
<thead><tr><th>PlainScript</th><th>Compiles to</th></tr></thead>
|
|
732
|
-
<tbody>
|
|
733
|
-
<tr><td><code>time()</code></td><td><code>Date.now()</code> — milliseconds since epoch</td></tr>
|
|
734
|
-
<tr><td><code>date()</code></td><td><code>new Date().toISOString()</code></td></tr>
|
|
735
|
-
<tr><td><code>sleep(ms)</code></td><td>Synchronous sleep via <code>Atomics.wait</code></td></tr>
|
|
736
|
-
<tr><td><code>uuid()</code></td><td><code>require('crypto').randomUUID()</code></td></tr>
|
|
737
|
-
</tbody>
|
|
738
|
-
</table>
|
|
739
|
-
</div>
|
|
740
|
-
|
|
741
|
-
<h3 class="sub-heading"><i class="fa-solid fa-code"></i> JSON</h3>
|
|
742
|
-
<div class="table-wrap">
|
|
743
|
-
<table>
|
|
744
|
-
<thead><tr><th>PlainScript</th><th>Compiles to</th></tr></thead>
|
|
745
|
-
<tbody>
|
|
746
|
-
<tr><td><code>jsonEncode(value)</code></td><td><code>JSON.stringify(value)</code></td></tr>
|
|
747
|
-
<tr><td><code>jsonDecode(string)</code></td><td><code>JSON.parse(string)</code></td></tr>
|
|
748
|
-
</tbody>
|
|
749
|
-
</table>
|
|
750
|
-
</div>
|
|
751
|
-
|
|
752
|
-
<h3 class="sub-heading"><i class="fa-solid fa-font"></i> Strings & Numbers</h3>
|
|
753
|
-
<div class="table-wrap">
|
|
754
|
-
<table>
|
|
755
|
-
<thead><tr><th>PlainScript</th><th>Description</th></tr></thead>
|
|
756
|
-
<tbody>
|
|
757
|
-
<tr><td><code>length(x)</code></td><td>Length of a string or array</td></tr>
|
|
758
|
-
<tr><td><code>uppercase(x)</code></td><td>Convert string to uppercase</td></tr>
|
|
759
|
-
<tr><td><code>lowercase(x)</code></td><td>Convert string to lowercase</td></tr>
|
|
760
|
-
<tr><td><code>round(x)</code></td><td>Round number to nearest integer</td></tr>
|
|
761
|
-
<tr><td><code>random()</code></td><td>Random float between 0 and 1 — equivalent to <code>Math.random()</code></td></tr>
|
|
762
|
-
</tbody>
|
|
763
|
-
</table>
|
|
764
|
-
</div>
|
|
765
|
-
</div>
|
|
766
|
-
</section>
|
|
767
|
-
|
|
768
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
769
|
-
<!-- PACKAGES -->
|
|
770
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
771
|
-
<section class="section" id="packages">
|
|
772
|
-
<div class="container">
|
|
773
|
-
<div class="section-tag"><i class="fa-solid fa-cubes"></i> Package System</div>
|
|
774
|
-
<h2 class="section-title">npm, without the boilerplate</h2>
|
|
775
|
-
<p class="section-lead">
|
|
776
|
-
PlainScript wraps npm's package manager to keep dependency management natural and minimal. Any npm package can be used in a PlainScript project.
|
|
777
|
-
</p>
|
|
778
|
-
|
|
779
|
-
<div class="two-col" style="margin-bottom:2rem">
|
|
780
|
-
<div>
|
|
781
|
-
<h3 class="sub-heading"><i class="fa-solid fa-terminal"></i> Package commands</h3>
|
|
782
|
-
<div class="cmd-strip"><span class="prm">$</span> <span class="cmd">plainscript add</span> <span class="arg">express</span></div>
|
|
783
|
-
<div class="cmd-strip"><span class="prm">$</span> <span class="cmd">plainscript remove</span> <span class="arg">express</span></div>
|
|
784
|
-
<div class="cmd-strip"><span class="prm">$</span> <span class="cmd">plainscript install</span></div>
|
|
785
|
-
<div class="cmd-strip"><span class="prm">$</span> <span class="cmd">plainscript update</span></div>
|
|
786
|
-
|
|
787
|
-
<h3 class="sub-heading" style="margin-top:1.5rem"><i class="fa-solid fa-folder-tree"></i> Project layout</h3>
|
|
788
|
-
<div class="code-block">
|
|
789
|
-
<div class="code-block-header">
|
|
790
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
791
|
-
<span class="code-block-title">zero-config build</span>
|
|
792
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
793
|
-
</div>
|
|
794
|
-
<pre><code>src/
|
|
795
|
-
app.pln <span class="str">← entry point</span>
|
|
796
|
-
lib/
|
|
797
|
-
helpers.pln <span class="str">← any .pln file you add</span>
|
|
798
|
-
dist/ <span class="str">← compiled output (auto-created)</span></code></pre>
|
|
799
|
-
</div>
|
|
800
|
-
</div>
|
|
801
|
-
<div>
|
|
802
|
-
<h3 class="sub-heading"><i class="fa-solid fa-plug"></i> Supported packages</h3>
|
|
803
|
-
<div class="table-wrap">
|
|
804
|
-
<table>
|
|
805
|
-
<thead><tr><th>PlainScript</th><th>Compiles to</th></tr></thead>
|
|
806
|
-
<tbody>
|
|
807
|
-
<tr><td><code>use express</code></td><td><code>const express = require('express')</code></td></tr>
|
|
808
|
-
<tr><td><code>use sqlite</code></td><td><code>const Database = require('better-sqlite3')</code></td></tr>
|
|
809
|
-
<tr><td><code>use fs</code></td><td><code>const fs = require('fs')</code></td></tr>
|
|
810
|
-
<tr><td><code>use path</code></td><td><code>const path = require('path')</code></td></tr>
|
|
811
|
-
<tr><td><code>use axios</code></td><td><code>const axios = require('axios')</code></td></tr>
|
|
812
|
-
<tr><td><code>use node-fetch as fetch</code> </td><td><code>const fetch = require('node-fetch')</code></td></tr>
|
|
813
|
-
<tr><td><code>use left-pad@^1.3.0</code> </td><td><code>require('left-pad')</code> · installs <code>@^1.3.0</code></td></tr>
|
|
814
|
-
<tr><td><code>use @scope/pkg as scoped</code> </td><td><code>const scoped = require('@scope/pkg')</code></td></tr>
|
|
815
|
-
<tr><td><code>use <any npm></code></td><td><code>require('<package>')</code></td></tr>
|
|
816
|
-
</tbody>
|
|
817
|
-
</table>
|
|
818
|
-
</div>
|
|
819
|
-
|
|
820
|
-
<div class="callout callout-info" style="margin-top:1rem">
|
|
821
|
-
<i class="fa-solid fa-tag"></i>
|
|
822
|
-
<div class="callout-body">
|
|
823
|
-
<strong>Aliases & version ranges</strong>
|
|
824
|
-
<p>Bind hyphenated or scoped packages to a variable with <code>as <name></code>, and pin ranges inline (<code>@^1.3.0</code>, <code>@~2</code>, <code>@*</code>). Ranges flow through to installation; <code>require()</code> always uses the bare name.</p>
|
|
825
|
-
</div>
|
|
826
|
-
</div>
|
|
827
|
-
|
|
828
|
-
<div class="callout callout-warning" style="margin-top:1rem">
|
|
829
|
-
<i class="fa-solid fa-triangle-exclamation"></i>
|
|
830
|
-
<div class="callout-body">
|
|
831
|
-
<strong>Dependency validation</strong>
|
|
832
|
-
<p>Before compiling, PlainScript checks that every package referenced by <code>use</code> is installed — by bare name, so versioned specifiers resolve against whatever is in <code>node_modules</code>. Missing packages are installed with their full <code>name@range</code> specifier and produce a friendly error with the exact command if that fails.</p>
|
|
833
|
-
</div>
|
|
834
|
-
</div>
|
|
835
|
-
</div>
|
|
836
|
-
</div>
|
|
837
|
-
</div>
|
|
838
|
-
</section>
|
|
839
|
-
|
|
840
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
841
|
-
<!-- WEB DEVELOPMENT -->
|
|
842
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
843
|
-
<section class="section section--alt" id="web">
|
|
844
|
-
<div class="container">
|
|
845
|
-
<div class="section-tag"><i class="fa-solid fa-globe"></i> Web Development</div>
|
|
846
|
-
<h2 class="section-title">Express Developer Experience</h2>
|
|
847
|
-
<p class="section-lead">
|
|
848
|
-
Two styles of web server — choose the one that fits your mental model. Both compile to identical Express.js code.
|
|
849
|
-
</p>
|
|
850
|
-
|
|
851
|
-
<div class="compare" style="margin-bottom:2rem">
|
|
852
|
-
<div class="code-block">
|
|
853
|
-
<div class="code-block-header">
|
|
854
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
855
|
-
<span class="code-block-title">Shorthand style</span>
|
|
856
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
857
|
-
</div>
|
|
858
|
-
<pre><code><span class="kw">web app</span>
|
|
859
|
-
|
|
860
|
-
<span class="kw">serve folder</span> <span class="str">"public"</span>
|
|
861
|
-
|
|
862
|
-
<span class="kw">route</span> <span class="str">"/"</span>
|
|
863
|
-
<span class="kw">reply</span> <span class="str">"Hello from PlainScript!"</span>
|
|
864
|
-
<span class="kw">done</span>
|
|
865
|
-
|
|
866
|
-
<span class="kw">route</span> <span class="str">"/api/status"</span>
|
|
867
|
-
<span class="kw">reply json</span>
|
|
868
|
-
status <span class="kw">is</span> <span class="str">"ok"</span>
|
|
869
|
-
version <span class="kw">is</span> <span class="str">"1.0"</span>
|
|
870
|
-
<span class="kw">done</span>
|
|
871
|
-
<span class="kw">done</span>
|
|
872
|
-
|
|
873
|
-
<span class="kw">start</span> <span class="num">3000</span></code></pre>
|
|
874
|
-
</div>
|
|
875
|
-
<div class="code-block">
|
|
876
|
-
<div class="code-block-header">
|
|
877
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
878
|
-
<span class="code-block-title">Classic style — still supported</span>
|
|
879
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
880
|
-
</div>
|
|
881
|
-
<pre><code><span class="kw">use</span> express
|
|
882
|
-
|
|
883
|
-
<span class="kw">remember</span> app <span class="kw">as</span> <span class="fn">express</span>()
|
|
884
|
-
|
|
885
|
-
<span class="kw">serve folder</span> <span class="str">"public"</span>
|
|
886
|
-
|
|
887
|
-
<span class="kw">when someone visits</span> <span class="str">"/"</span>
|
|
888
|
-
<span class="kw">reply</span> <span class="str">"Hello from PlainScript!"</span>
|
|
889
|
-
<span class="kw">done</span>
|
|
890
|
-
|
|
891
|
-
<span class="kw">when someone visits</span> <span class="str">"/api/status"</span>
|
|
892
|
-
<span class="kw">reply json</span>
|
|
893
|
-
status <span class="kw">is</span> <span class="str">"ok"</span>
|
|
894
|
-
<span class="kw">done</span>
|
|
895
|
-
<span class="kw">done</span>
|
|
896
|
-
|
|
897
|
-
<span class="kw">listen on</span> <span class="num">3000</span>
|
|
898
|
-
<span class="kw">show</span> <span class="str">"Server running"</span>
|
|
899
|
-
<span class="kw">done</span></code></pre>
|
|
900
|
-
</div>
|
|
901
|
-
</div>
|
|
902
|
-
|
|
903
|
-
<h3 class="sub-heading"><i class="fa-solid fa-table-list"></i> Route reference</h3>
|
|
904
|
-
<div class="table-wrap">
|
|
905
|
-
<table>
|
|
906
|
-
<thead><tr><th>Construct</th><th>Compiles to</th><th>Notes</th></tr></thead>
|
|
907
|
-
<tbody>
|
|
908
|
-
<tr><td><code>web app</code></td><td><code>const app = require('express')()</code></td><td>Shorthand bootstrapper</td></tr>
|
|
909
|
-
<tr><td><code>route "/"</code></td><td><code>app.get("/", (req, res) => { ... })</code></td><td>GET route</td></tr>
|
|
910
|
-
<tr><td><code>when someone visits "/"</code></td><td><code>app.get("/", (req, res) => { ... })</code></td><td>Classic alias</td></tr>
|
|
911
|
-
<tr><td><code>reply "Hello"</code></td><td><code>res.send("Hello")</code></td><td></td></tr>
|
|
912
|
-
<tr><td><code>reply json … done</code></td><td><code>res.json({ ... })</code></td><td></td></tr>
|
|
913
|
-
<tr><td><code>serve folder "public"</code></td><td><code>app.use(express.static("public"))</code></td><td></td></tr>
|
|
914
|
-
<tr><td><code>start 3000</code></td><td><code>app.listen(3000)</code></td><td>Shorthand</td></tr>
|
|
915
|
-
<tr><td><code>listen on 3000 … done</code></td><td><code>app.listen(3000, () => { ... })</code></td><td>Classic with callback</td></tr>
|
|
916
|
-
<tr><td><code>request</code></td><td><code>req</code></td><td>Inside route bodies</td></tr>
|
|
917
|
-
<tr><td><code>response</code></td><td><code>res</code></td><td>Inside route bodies</td></tr>
|
|
918
|
-
</tbody>
|
|
919
|
-
</table>
|
|
920
|
-
</div>
|
|
921
|
-
</div>
|
|
922
|
-
</section>
|
|
923
|
-
|
|
924
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
925
|
-
<!-- SQLITE -->
|
|
926
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
927
|
-
<section class="section" id="database">
|
|
928
|
-
<div class="container">
|
|
929
|
-
<div class="section-tag"><i class="fa-solid fa-database"></i> Database</div>
|
|
930
|
-
<h2 class="section-title">SQLite Developer Experience</h2>
|
|
931
|
-
<p class="section-lead">
|
|
932
|
-
Inline SQL blocks compile directly to <code>better-sqlite3</code> calls. No ORM. No query builder. Just SQL written naturally inside your PlainScript program.
|
|
933
|
-
</p>
|
|
934
|
-
|
|
935
|
-
<div class="two-col-wide" style="margin-bottom:2rem">
|
|
936
|
-
<div class="code-block">
|
|
937
|
-
<div class="code-block-header">
|
|
938
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
939
|
-
<span class="code-block-title">database.pln</span>
|
|
940
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
941
|
-
</div>
|
|
942
|
-
<pre><code><span class="kw">database</span> <span class="str">"app.db"</span>
|
|
943
|
-
|
|
944
|
-
<span class="kw">execute</span>
|
|
945
|
-
CREATE TABLE IF NOT EXISTS users (
|
|
946
|
-
id INTEGER PRIMARY KEY,
|
|
947
|
-
name TEXT NOT NULL,
|
|
948
|
-
age INTEGER
|
|
949
|
-
)
|
|
950
|
-
<span class="kw">done</span>
|
|
951
|
-
|
|
952
|
-
<span class="kw">insert</span>
|
|
953
|
-
INSERT INTO users (name, age)
|
|
954
|
-
VALUES ('Alice', 28)
|
|
955
|
-
<span class="kw">done</span>
|
|
956
|
-
|
|
957
|
-
<span class="kw">query</span>
|
|
958
|
-
SELECT * FROM users ORDER BY name
|
|
959
|
-
<span class="kw">done</span>
|
|
960
|
-
|
|
961
|
-
<span class="kw">update</span>
|
|
962
|
-
UPDATE users SET age = 29
|
|
963
|
-
WHERE name = 'Alice'
|
|
964
|
-
<span class="kw">done</span>
|
|
965
|
-
|
|
966
|
-
<span class="kw">delete</span>
|
|
967
|
-
DELETE FROM users WHERE id = 1
|
|
968
|
-
<span class="kw">done</span></code></pre>
|
|
969
|
-
</div>
|
|
970
|
-
<div>
|
|
971
|
-
<h3 class="sub-heading" style="margin-top:0"><i class="fa-solid fa-table-list"></i> SQL block reference</h3>
|
|
972
|
-
<div class="table-wrap">
|
|
973
|
-
<table>
|
|
974
|
-
<thead><tr><th>PlainScript</th><th>Compiles to</th></tr></thead>
|
|
975
|
-
<tbody>
|
|
976
|
-
<tr><td><code>database "file.db"</code></td><td><code>const db = new Database("file.db")</code></td></tr>
|
|
977
|
-
<tr><td><code>query … done</code></td><td><code>db.prepare(`…`).all()</code></td></tr>
|
|
978
|
-
<tr><td><code>insert … done</code></td><td><code>db.prepare(`…`).run()</code></td></tr>
|
|
979
|
-
<tr><td><code>update … done</code></td><td><code>db.prepare(`…`).run()</code></td></tr>
|
|
980
|
-
<tr><td><code>delete … done</code></td><td><code>db.prepare(`…`).run()</code></td></tr>
|
|
981
|
-
<tr><td><code>execute … done</code></td><td><code>db.exec(`…`)</code></td></tr>
|
|
982
|
-
</tbody>
|
|
983
|
-
</table>
|
|
984
|
-
</div>
|
|
985
|
-
|
|
986
|
-
<div class="callout callout-info" style="margin-top:1.25rem">
|
|
987
|
-
<i class="fa-solid fa-circle-info"></i>
|
|
988
|
-
<div class="callout-body">
|
|
989
|
-
<strong>Classic style also works</strong>
|
|
990
|
-
<p>You can also <code>use sqlite</code> and call <code>sqlite("database.db")</code> directly if you prefer the classic approach.</p>
|
|
991
|
-
</div>
|
|
992
|
-
</div>
|
|
993
|
-
|
|
994
|
-
<div class="callout callout-tip" style="margin-top:.75rem">
|
|
995
|
-
<i class="fa-solid fa-circle-check"></i>
|
|
996
|
-
<div class="callout-body">
|
|
997
|
-
<strong>Zero configuration</strong>
|
|
998
|
-
<p>SQLite files are created automatically if they don’t exist. No server to start, no credentials to manage.</p>
|
|
999
|
-
</div>
|
|
1000
|
-
</div>
|
|
1001
|
-
</div>
|
|
1002
|
-
</div>
|
|
1003
|
-
</div>
|
|
1004
|
-
</section>
|
|
1005
|
-
|
|
1006
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1007
|
-
<!-- OCR -->
|
|
1008
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1009
|
-
<section class="section" id="ocr">
|
|
1010
|
-
<div class="container">
|
|
1011
|
-
<div class="section-tag"><i class="fa-solid fa-eye"></i> Vision </div>
|
|
1012
|
-
<h2 class="section-title">OCR — read text out of images</h2>
|
|
1013
|
-
<p class="section-lead">
|
|
1014
|
-
One sentence extracts text from scans, screenshots, and photos. Tesseract.js does the work; PlainScript keeps it out of your source.
|
|
1015
|
-
</p>
|
|
1016
|
-
|
|
1017
|
-
<div class="compare" style="margin-bottom:2rem">
|
|
1018
|
-
<div class="code-block">
|
|
1019
|
-
<div class="code-block-header">
|
|
1020
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
1021
|
-
<span class="code-block-title">ocr.pln</span>
|
|
1022
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
1023
|
-
</div>
|
|
1024
|
-
<pre><code><span class="cmt">// Extract text — mirrors ask "... as name"</span>
|
|
1025
|
-
<span class="kw">ocr</span> <span class="str">"scan.png"</span> <span class="kw">as</span> text
|
|
1026
|
-
<span class="kw">show</span> text
|
|
1027
|
-
|
|
1028
|
-
<span class="cmt">// Pick a language pack (default: "eng")</span>
|
|
1029
|
-
<span class="kw">ocr</span> <span class="str">"brief.png"</span> <span class="kw">as</span> inhalt <span class="kw">using</span> <span class="str">"deu"</span>
|
|
1030
|
-
|
|
1031
|
-
<span class="cmt">// Any expression works as the image source</span>
|
|
1032
|
-
<span class="kw">remember</span> shot <span class="kw">as</span> <span class="str">"receipts/receipt-01.png"</span>
|
|
1033
|
-
<span class="kw">ocr</span> shot <span class="kw">as</span> total <span class="kw">using</span> <span class="str">"deu+eng"</span>
|
|
1034
|
-
|
|
1035
|
-
<span class="kw">if</span> total <span class="kw">contains</span> <span class="str">"INVOICE"</span>
|
|
1036
|
-
<span class="kw">show</span> <span class="str">"invoice detected"</span>
|
|
1037
|
-
<span class="kw">done</span></code></pre>
|
|
1038
|
-
</div>
|
|
1039
|
-
<div class="code-block">
|
|
1040
|
-
<div class="code-block-header">
|
|
1041
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
1042
|
-
<span class="code-block-title">Generated JavaScript</span>
|
|
1043
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
1044
|
-
</div>
|
|
1045
|
-
<pre><code><span class="kw">const</span> { <span class="fn">createWorker</span> } = <span class="fn">require</span>(<span class="str">'tesseract.js'</span>);
|
|
1046
|
-
|
|
1047
|
-
<span class="kw">async function</span> <span class="fn">__ocr</span>(imagePath, lang) {
|
|
1048
|
-
<span class="kw">const</span> worker = <span class="kw">await</span> <span class="fn">createWorker</span>(lang || <span class="str">'eng'</span>);
|
|
1049
|
-
<span class="kw">try</span> {
|
|
1050
|
-
<span class="kw">const</span> { data } = <span class="kw">await</span> worker.<span class="fn">recognize</span>(imagePath);
|
|
1051
|
-
<span class="kw">return</span> data.text;
|
|
1052
|
-
} <span class="kw">finally</span> {
|
|
1053
|
-
<span class="kw">await</span> worker.<span class="fn">terminate</span>();
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
<span class="kw">let</span> text = <span class="kw">await</span> <span class="fn">__ocr</span>(<span class="str">"scan.png"</span>, <span class="str">"eng"</span>);</code></pre>
|
|
1058
|
-
</div>
|
|
1059
|
-
</div>
|
|
1060
|
-
|
|
1061
|
-
<div class="callout callout-info">
|
|
1062
|
-
<i class="fa-solid fa-circle-info"></i>
|
|
1063
|
-
<div class="callout-body">
|
|
1064
|
-
<strong>tesseract.js stays out of your source</strong>
|
|
1065
|
-
<p><code>plainscript install</code>, <code>plainscript run</code>, and <code>plainscript build</code> detect <code>ocr</code> statements and fetch the package automatically. The statement is async like <code>ask</code> — top-level use wraps the program in the async runtime, and using it inside a function makes that function async.</p>
|
|
1066
|
-
</div>
|
|
1067
|
-
</div>
|
|
1068
|
-
</div>
|
|
1069
|
-
</section>
|
|
1070
|
-
|
|
1071
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1072
|
-
<!-- CLI -->
|
|
1073
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1074
|
-
<section class="section section--alt" id="cli">
|
|
1075
|
-
<div class="container">
|
|
1076
|
-
<div class="section-tag"><i class="fa-solid fa-terminal"></i> CLI Reference</div>
|
|
1077
|
-
<h2 class="section-title">All Commands</h2>
|
|
1078
|
-
<p class="section-lead">
|
|
1079
|
-
Everything the PlainScript compiler can do, from a single unified CLI.
|
|
1080
|
-
</p>
|
|
1081
|
-
|
|
1082
|
-
<div class="two-col-wide" style="margin-bottom:2rem">
|
|
1083
|
-
<div>
|
|
1084
|
-
<div class="table-wrap">
|
|
1085
|
-
<table>
|
|
1086
|
-
<thead><tr><th>Command</th><th>Description</th></tr></thead>
|
|
1087
|
-
<tbody>
|
|
1088
|
-
<tr><td><code>plainscript run <file.pln></code></td><td>Compile and execute immediately</td></tr>
|
|
1089
|
-
<tr><td><code>plainscript build <file.pln></code></td><td>Compile to <code>.js</code> without running</td></tr>
|
|
1090
|
-
<tr><td><code>plainscript check <file.pln></code></td><td>Syntax check — exits 0 or 1</td></tr>
|
|
1091
|
-
<tr><td><code>plainscript fmt <file.pln></code></td><td>Format source in-place</td></tr>
|
|
1092
|
-
<tr><td><code>plainscript new [name]</code></td><td>Scaffold a new project</td></tr>
|
|
1093
|
-
<tr><td><code>plainscript install</code></td><td>Install all dependencies detected in the project's sources</td></tr>
|
|
1094
|
-
<tr><td><code>plainscript add <pkg></code></td><td>Install a package and record it</td></tr>
|
|
1095
|
-
<tr><td><code>plainscript remove <pkg></code></td><td>Uninstall a package</td></tr>
|
|
1096
|
-
<tr><td><code>plainscript update</code></td><td>Update all installed packages</td></tr>
|
|
1097
|
-
<tr><td><code>plainscript version</code></td><td>Print the compiler version</td></tr>
|
|
1098
|
-
<tr><td><code>plainscript help</code></td><td>Show help text</td></tr>
|
|
1099
|
-
</tbody>
|
|
1100
|
-
</table>
|
|
1101
|
-
</div>
|
|
1102
|
-
</div>
|
|
1103
|
-
|
|
1104
|
-
<div>
|
|
1105
|
-
<h3 class="sub-heading" style="margin-top:0"><i class="fa-solid fa-rectangle-terminal"></i> CLI output</h3>
|
|
1106
|
-
<div class="code-block">
|
|
1107
|
-
<div class="code-block-header">
|
|
1108
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
1109
|
-
<span class="code-block-title">Terminal</span>
|
|
1110
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
1111
|
-
</div>
|
|
1112
|
-
<pre><code><span class="prm">$</span> plainscript run app.pln
|
|
1113
|
-
<span class="ok">✓</span> tokenize
|
|
1114
|
-
<span class="ok">✓</span> parse
|
|
1115
|
-
<span class="ok">✓</span> generate
|
|
1116
|
-
<span class="ok">✓</span> run
|
|
1117
|
-
Done.
|
|
1118
|
-
|
|
1119
|
-
<span class="prm">$</span> plainscript check app.pln
|
|
1120
|
-
<span class="ok">✓</span> app.pln — no errors found. (3ms)
|
|
1121
|
-
|
|
1122
|
-
<span class="prm">$</span> plainscript fmt app.pln
|
|
1123
|
-
<span class="ok">✓</span> Formatted app.pln
|
|
1124
|
-
|
|
1125
|
-
<span class="prm">$</span> plainscript version
|
|
1126
|
-
PlainScript v0.1.7</code></pre>
|
|
1127
|
-
</div>
|
|
1128
|
-
</div>
|
|
1129
|
-
</div>
|
|
1130
|
-
</div>
|
|
1131
|
-
</section>
|
|
1132
|
-
|
|
1133
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1134
|
-
<!-- FORMATTER -->
|
|
1135
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1136
|
-
<section class="section" id="formatter">
|
|
1137
|
-
<div class="container">
|
|
1138
|
-
<div class="section-tag"><i class="fa-solid fa-paintbrush"></i> Formatter</div>
|
|
1139
|
-
<h2 class="section-title">Automatic Code Formatting</h2>
|
|
1140
|
-
<p class="section-lead">
|
|
1141
|
-
<code>plainscript fmt</code> formats your <code>.pln</code> file in-place. One command, no options — consistent code across every project.
|
|
1142
|
-
</p>
|
|
1143
|
-
|
|
1144
|
-
<div class="compare" style="margin-bottom:2rem">
|
|
1145
|
-
<div class="code-block">
|
|
1146
|
-
<div class="code-block-header">
|
|
1147
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
1148
|
-
<span class="code-block-title">Before formatting</span>
|
|
1149
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
1150
|
-
</div>
|
|
1151
|
-
<pre><code><span class="kw">remember</span> x <span class="kw">as</span> <span class="num">10</span>
|
|
1152
|
-
<span class="kw">if</span> x <span class="kw">is above</span> <span class="num">5</span>
|
|
1153
|
-
<span class="kw">show</span> <span class="str">"big"</span>
|
|
1154
|
-
|
|
1155
|
-
<span class="kw">otherwise</span>
|
|
1156
|
-
<span class="kw">show</span> <span class="str">"small"</span>
|
|
1157
|
-
<span class="kw">done</span></code></pre>
|
|
1158
|
-
</div>
|
|
1159
|
-
<div class="code-block">
|
|
1160
|
-
<div class="code-block-header">
|
|
1161
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
1162
|
-
<span class="code-block-title">After plainscript fmt</span>
|
|
1163
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
1164
|
-
</div>
|
|
1165
|
-
<pre><code><span class="kw">remember</span> x <span class="kw">as</span> <span class="num">10</span>
|
|
1166
|
-
|
|
1167
|
-
<span class="kw">if</span> x <span class="kw">is above</span> <span class="num">5</span>
|
|
1168
|
-
<span class="kw">show</span> <span class="str">"big"</span>
|
|
1169
|
-
<span class="kw">otherwise</span>
|
|
1170
|
-
<span class="kw">show</span> <span class="str">"small"</span>
|
|
1171
|
-
<span class="kw">done</span></code></pre>
|
|
1172
|
-
</div>
|
|
1173
|
-
</div>
|
|
1174
|
-
|
|
1175
|
-
<h3 class="sub-heading"><i class="fa-solid fa-list"></i> Formatting rules</h3>
|
|
1176
|
-
<div class="feature-grid" style="margin-top:1rem">
|
|
1177
|
-
<div class="feature-card">
|
|
1178
|
-
<div class="feature-card-icon"><i class="fa-solid fa-indent"></i></div>
|
|
1179
|
-
<h4>4-space indentation</h4>
|
|
1180
|
-
<p>All block bodies — <code>if</code>, <code>while</code>, <code>for each</code>, <code>make</code>, <code>route</code> — are indented with exactly 4 spaces.</p>
|
|
1181
|
-
</div>
|
|
1182
|
-
<div class="feature-card">
|
|
1183
|
-
<div class="feature-card-icon"><i class="fa-solid fa-text-slash"></i></div>
|
|
1184
|
-
<h4>Trailing whitespace removed</h4>
|
|
1185
|
-
<p>Every line has trailing spaces stripped. The file ends with exactly one newline.</p>
|
|
1186
|
-
</div>
|
|
1187
|
-
<div class="feature-card">
|
|
1188
|
-
<div class="feature-card-icon"><i class="fa-solid fa-arrows-up-down"></i></div>
|
|
1189
|
-
<h4>Blank lines normalised</h4>
|
|
1190
|
-
<p>One blank line between top-level blocks. Multiple consecutive blank lines are collapsed into one.</p>
|
|
1191
|
-
</div>
|
|
1192
|
-
</div>
|
|
1193
|
-
</div>
|
|
1194
|
-
</section>
|
|
1195
|
-
|
|
1196
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1197
|
-
<!-- VS CODE -->
|
|
1198
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1199
|
-
<section class="section section--alt" id="vscode">
|
|
1200
|
-
<div class="container">
|
|
1201
|
-
<div class="section-tag"><i class="fa-solid fa-code"></i> Editor</div>
|
|
1202
|
-
<h2 class="section-title">VS Code Extension</h2>
|
|
1203
|
-
<p class="section-lead">
|
|
1204
|
-
The <strong>PlainScript Language</strong> extension brings first-class <code>.pln</code> support to VS Code — syntax highlighting, smart snippets, bracket matching, and code folding.
|
|
1205
|
-
</p>
|
|
1206
|
-
|
|
1207
|
-
<div class="feature-grid" style="margin-bottom:2rem">
|
|
1208
|
-
<div class="feature-card">
|
|
1209
|
-
<div class="feature-card-icon"><i class="fa-solid fa-palette"></i></div>
|
|
1210
|
-
<h4>Syntax Highlighting</h4>
|
|
1211
|
-
<p>All keywords, strings, numbers, operators, comments, and stdlib functions are coloured correctly.</p>
|
|
1212
|
-
</div>
|
|
1213
|
-
<div class="feature-card">
|
|
1214
|
-
<div class="feature-card-icon"><i class="fa-solid fa-bolt"></i></div>
|
|
1215
|
-
<h4>Snippets</h4>
|
|
1216
|
-
<p>Type <kbd>if</kbd>, <kbd>make</kbd>, <kbd>webapp</kbd>, <kbd>route</kbd>, <kbd>foreach</kbd>, and more — press <kbd>Tab</kbd> to expand.</p>
|
|
1217
|
-
</div>
|
|
1218
|
-
<div class="feature-card">
|
|
1219
|
-
<div class="feature-card-icon"><i class="fa-solid fa-file"></i></div>
|
|
1220
|
-
<h4>File Icon</h4>
|
|
1221
|
-
<p>Custom file icon for <code>.pln</code> files in the VS Code explorer sidebar.</p>
|
|
1222
|
-
</div>
|
|
1223
|
-
<div class="feature-card">
|
|
1224
|
-
<div class="feature-card-icon"><i class="fa-solid fa-screwdriver-wrench"></i></div>
|
|
1225
|
-
<h4>Language Config</h4>
|
|
1226
|
-
<p>Auto-closing brackets, comment toggling (<kbd>Ctrl</kbd>+<kbd>/</kbd>), and <code>done</code>-based block folding.</p>
|
|
1227
|
-
</div>
|
|
1228
|
-
</div>
|
|
1229
|
-
|
|
1230
|
-
<div class="callout callout-info">
|
|
1231
|
-
<i class="fa-solid fa-circle-info"></i>
|
|
1232
|
-
<div class="callout-body">
|
|
1233
|
-
<strong>Installation</strong>
|
|
1234
|
-
<p>Install via the VS Code Extensions panel (search <em>PlainScript Language</em>) or by downloading the <code>.vsix</code> file from the GitHub releases page and running <code>code --install-extension plain-language-1.0.0.vsix</code>.</p>
|
|
1235
|
-
</div>
|
|
1236
|
-
</div>
|
|
1237
|
-
</div>
|
|
1238
|
-
</section>
|
|
1239
|
-
|
|
1240
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1241
|
-
<!-- ROADMAP -->
|
|
1242
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1243
|
-
<section class="section" id="roadmap">
|
|
1244
|
-
<div class="container">
|
|
1245
|
-
<div class="section-tag"><i class="fa-solid fa-map"></i> Roadmap</div>
|
|
1246
|
-
<h2 class="section-title">What’s next</h2>
|
|
1247
|
-
<p class="section-lead">
|
|
1248
|
-
PlainScript 0.1.7 is the first release: one deterministic compiler, the complete language, production builds, backend services, and WhatsApp and Telegram bots.
|
|
1249
|
-
</p>
|
|
1250
|
-
|
|
1251
|
-
<div class="roadmap">
|
|
1252
|
-
|
|
1253
|
-
<div class="roadmap-item">
|
|
1254
|
-
<div class="roadmap-version">0.1.7</div>
|
|
1255
|
-
<div class="roadmap-line-wrap">
|
|
1256
|
-
<div class="roadmap-dot done"></div>
|
|
1257
|
-
<div class="roadmap-connector"></div>
|
|
1258
|
-
</div>
|
|
1259
|
-
<div class="roadmap-content">
|
|
1260
|
-
<h4>0.1.7 — First release <span class="badge badge-green" style="margin-left:.5rem"><i class="fa-solid fa-check"></i> Released</span></h4>
|
|
1261
|
-
<ul>
|
|
1262
|
-
<li>Deterministic compiler — lexer, parser, generator and bundler with production builds to <code>dist/</code></li>
|
|
1263
|
-
<li>The complete language — conditions, functions, collections, string templates, PlainScript Expressions, multi-file projects and the JavaScript Gateway</li>
|
|
1264
|
-
<li>Backend services — routing, SQLite and PostgreSQL, sessions, password hashing and tokens, uploads, OCR, email, cron jobs, WebSocket servers and cache</li>
|
|
1265
|
-
<li>WhatsApp bots — QR and pairing-code linking; Telegram bots with inline keyboards</li>
|
|
1266
|
-
<li>Npm aliases and version ranges, interactive terminal input, formatter and doctor</li>
|
|
1267
|
-
</ul>
|
|
1268
|
-
</div>
|
|
1269
|
-
</div>
|
|
1270
|
-
|
|
1271
|
-
<div class="roadmap-item">
|
|
1272
|
-
<div class="roadmap-version">Future</div>
|
|
1273
|
-
<div class="roadmap-line-wrap">
|
|
1274
|
-
<div class="roadmap-dot"></div>
|
|
1275
|
-
</div>
|
|
1276
|
-
<div class="roadmap-content">
|
|
1277
|
-
<h4>Future — Extended Language <span class="badge badge-amber" style="margin-left:.5rem">Planned</span></h4>
|
|
1278
|
-
<ul>
|
|
1279
|
-
<li>Optional type hints (non-breaking)</li>
|
|
1280
|
-
<li><code>plainscript watch</code> — recompile on file change</li>
|
|
1281
|
-
<li>Language Server Protocol (LSP) support</li>
|
|
1282
|
-
<li>Standard library expansion & module refinements</li>
|
|
1283
|
-
</ul>
|
|
1284
|
-
</div>
|
|
1285
|
-
</div>
|
|
1286
|
-
|
|
1287
|
-
</div>
|
|
1288
|
-
</div>
|
|
1289
|
-
</section>
|
|
1290
|
-
|
|
1291
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1292
|
-
<!-- FAQ -->
|
|
1293
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1294
|
-
<section class="section section--alt" id="faq">
|
|
1295
|
-
<div class="container">
|
|
1296
|
-
<div class="section-tag"><i class="fa-solid fa-circle-question"></i> FAQ</div>
|
|
1297
|
-
<h2 class="section-title">Frequently Asked Questions</h2>
|
|
1298
|
-
|
|
1299
|
-
<div class="faq">
|
|
1300
|
-
|
|
1301
|
-
<div class="faq-item">
|
|
1302
|
-
<button class="faq-question">What is PlainScript? <i class="fa-solid fa-chevron-down"></i></button>
|
|
1303
|
-
<div class="faq-answer">
|
|
1304
|
-
PlainScript is an Intent-Oriented Programming Language (IOPL). It compiles <code>.pln</code> source files to JavaScript and runs them with Node.js. PlainScript's design goal is to let developers describe <em>what</em> they want to happen in near-English sentences, while the compiler handles the JavaScript implementation details.
|
|
1305
|
-
</div>
|
|
1306
|
-
</div>
|
|
1307
|
-
|
|
1308
|
-
<div class="faq-item">
|
|
1309
|
-
<button class="faq-question">Is PlainScript production-ready? <i class="fa-solid fa-chevron-down"></i></button>
|
|
1310
|
-
<div class="faq-answer">
|
|
1311
|
-
PlainScript 0.1.7 includes runtime dependency detection, automatic installation, OCR, portable databases, an HTTP client, sessions, uploads, rate limiting, deployment-oriented CLI commands, WhatsApp bots, and interactive terminal input — backed by a test suite of 625 checks. It compiles to standard Node.js-compatible JavaScript and is well-suited for personal projects, tooling, and learning. For large production systems, evaluate whether the JavaScript ecosystem's tooling (TypeScript, linters, bundlers) is needed alongside it.
|
|
1312
|
-
</div>
|
|
1313
|
-
</div>
|
|
1314
|
-
|
|
1315
|
-
<div class="faq-item">
|
|
1316
|
-
<button class="faq-question">Does PlainScript support TypeScript? <i class="fa-solid fa-chevron-down"></i></button>
|
|
1317
|
-
<div class="faq-answer">
|
|
1318
|
-
Not currently. PlainScript compiles to plain JavaScript. Optional type hints are planned, but they will be designed to stay readable in PlainScript's English-sentence style — not to mirror TypeScript syntax.
|
|
1319
|
-
</div>
|
|
1320
|
-
</div>
|
|
1321
|
-
|
|
1322
|
-
<div class="faq-item">
|
|
1323
|
-
<button class="faq-question">Can I use npm packages? <i class="fa-solid fa-chevron-down"></i></button>
|
|
1324
|
-
<div class="faq-answer">
|
|
1325
|
-
Yes. Any npm package can be declared with <code>use <package></code> and installed with <code>plainscript add <package></code>. Since v2.0.1 you can bind hyphenated or scoped packages to a variable with <code>use node-fetch as fetch</code>, and pin ranges inline with <code>use left-pad@^1.3.0</code>. PlainScript scans your source files for <code>use</code> declarations and manages the underlying <code>node_modules</code> automatically, validating that all declared packages are installed before compiling.
|
|
1326
|
-
</div>
|
|
1327
|
-
</div>
|
|
1328
|
-
|
|
1329
|
-
<div class="faq-item">
|
|
1330
|
-
<button class="faq-question">How does OCR work? <i class="fa-solid fa-chevron-down"></i></button>
|
|
1331
|
-
<div class="faq-answer">
|
|
1332
|
-
Write <code>ocr "scan.png" as text</code>. The statement is backed by Tesseract.js — an implementation detail that never appears in your source. <code>plainscript install</code>, <code>plainscript run</code>, and <code>plainscript build</code> detect <code>ocr</code> statements and fetch the package automatically. An optional <code>using "<lang>"</code> clause selects a language pack; extraction defaults to English.
|
|
1333
|
-
</div>
|
|
1334
|
-
</div>
|
|
1335
|
-
|
|
1336
|
-
<div class="faq-item">
|
|
1337
|
-
<button class="faq-question">What’s the difference between <code>for each</code> and <code>for every</code>? <i class="fa-solid fa-chevron-down"></i></button>
|
|
1338
|
-
<div class="faq-answer">
|
|
1339
|
-
They are identical. Both compile to a <code>for...of</code> JavaScript loop. <code>for every</code> is provided as an alias because it reads naturally in certain sentences — e.g. <em>for every item in basket</em>. In PlainScript, there is never a functional difference between the two.
|
|
1340
|
-
</div>
|
|
1341
|
-
</div>
|
|
1342
|
-
|
|
1343
|
-
<div class="faq-item">
|
|
1344
|
-
<button class="faq-question">How do I debug PlainScript code? <i class="fa-solid fa-chevron-down"></i></button>
|
|
1345
|
-
<div class="faq-answer">
|
|
1346
|
-
Use <code>plainscript build app.pln</code> to compile to <code>app.js</code> and inspect the generated JavaScript. Since the output is clean, readable JS you can open it in any Node.js debugger, add <code>console.log</code> statements, or run it directly with <code>node app.js</code>. You can also use <code>plainscript check app.pln</code> to catch syntax errors before running.
|
|
1347
|
-
</div>
|
|
1348
|
-
</div>
|
|
1349
|
-
|
|
1350
|
-
<div class="faq-item">
|
|
1351
|
-
<button class="faq-question">Does PlainScript work on Windows? <i class="fa-solid fa-chevron-down"></i></button>
|
|
1352
|
-
<div class="faq-answer">
|
|
1353
|
-
Yes. PlainScript is a Node.js package and works wherever Node.js is installed — Windows, macOS, and Linux. Install it with <code>npm install --save-dev plainscript</code> on any platform.
|
|
1354
|
-
</div>
|
|
1355
|
-
</div>
|
|
1356
|
-
|
|
1357
|
-
</div>
|
|
1358
|
-
</div>
|
|
1359
|
-
</section>
|
|
1360
|
-
|
|
1361
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1362
|
-
<!-- CONTRIBUTING -->
|
|
1363
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1364
|
-
<section class="section" id="contributing">
|
|
1365
|
-
<div class="container">
|
|
1366
|
-
<div class="section-tag"><i class="fa-solid fa-hands-helping"></i> Open Source</div>
|
|
1367
|
-
<h2 class="section-title">Contributing</h2>
|
|
1368
|
-
<p class="section-lead">
|
|
1369
|
-
PlainScript is open-source and welcomes contributions. Whether it’s a bug report, a test case, a documentation fix, or a new feature — every contribution matters.
|
|
1370
|
-
</p>
|
|
1371
|
-
|
|
1372
|
-
<div class="feature-grid" style="margin-bottom:2rem">
|
|
1373
|
-
<div class="feature-card">
|
|
1374
|
-
<div class="feature-card-icon"><i class="fa-solid fa-bug"></i></div>
|
|
1375
|
-
<h4>Report a bug</h4>
|
|
1376
|
-
<p>Found something that compiles incorrectly or crashes? Open an issue on GitHub with a minimal <code>.pln</code> reproduction.</p>
|
|
1377
|
-
</div>
|
|
1378
|
-
<div class="feature-card">
|
|
1379
|
-
<div class="feature-card-icon"><i class="fa-solid fa-flask"></i></div>
|
|
1380
|
-
<h4>Write a test</h4>
|
|
1381
|
-
<p>Tests live in <code>tests/compiler.test.js</code>. Adding a test for an edge case is one of the most valuable contributions.</p>
|
|
1382
|
-
</div>
|
|
1383
|
-
<div class="feature-card">
|
|
1384
|
-
<div class="feature-card-icon"><i class="fa-solid fa-code-pull-request"></i></div>
|
|
1385
|
-
<h4>Submit a pull request</h4>
|
|
1386
|
-
<p>Fork the repo, make your change, and run <code>node tests/compiler.test.js</code>. All 625 tests must pass before merging.</p>
|
|
1387
|
-
</div>
|
|
1388
|
-
</div>
|
|
1389
|
-
|
|
1390
|
-
<div class="callout callout-info">
|
|
1391
|
-
<i class="fa-brands fa-github"></i>
|
|
1392
|
-
<div class="callout-body">
|
|
1393
|
-
<strong>GitHub repository</strong>
|
|
1394
|
-
<p>Source code, issues, and pull requests at <a href="https://github.com/ayoistooslick/plain-code" target="_blank" rel="noopener">github.com/ayoxx/plain</a>. Read <code>CONTRIBUTING.md</code> before opening a PR.</p>
|
|
1395
|
-
</div>
|
|
1396
|
-
</div>
|
|
1397
|
-
</div>
|
|
1398
|
-
</section>
|
|
1399
|
-
|
|
1400
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1401
|
-
<!-- LICENSE -->
|
|
1402
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1403
|
-
<section class="section section--alt" id="license">
|
|
1404
|
-
<div class="container">
|
|
1405
|
-
<div class="section-tag"><i class="fa-solid fa-scale-balanced"></i> License</div>
|
|
1406
|
-
<h2 class="section-title">MIT License</h2>
|
|
1407
|
-
<p style="color:var(--muted);max-width:640px;line-height:1.8">
|
|
1408
|
-
PlainScript is released under the <strong>MIT License</strong>. You are free to use, modify, and distribute PlainScript — commercially or non-commercially — with or without modification, as long as the original copyright notice is preserved.
|
|
1409
|
-
</p>
|
|
1410
|
-
|
|
1411
|
-
<div class="code-block" style="margin-top:1.5rem;max-width:640px">
|
|
1412
|
-
<div class="code-block-header">
|
|
1413
|
-
<div class="code-block-dots"><span></span><span></span><span></span></div>
|
|
1414
|
-
<span class="code-block-title">LICENSE</span>
|
|
1415
|
-
<button class="code-copy"><i class="fa-regular fa-copy"></i> Copy</button>
|
|
1416
|
-
</div>
|
|
1417
|
-
<pre><code>MIT License
|
|
1418
|
-
|
|
1419
|
-
Copyright (c) 2024 Ayokunle
|
|
1420
|
-
|
|
1421
|
-
Permission is hereby granted, free of charge, to any person
|
|
1422
|
-
obtaining a copy of this software and associated documentation
|
|
1423
|
-
files (the "Software"), to deal in the Software without
|
|
1424
|
-
restriction, including without limitation the rights to use,
|
|
1425
|
-
copy, modify, merge, publish, distribute, sublicense, and/or
|
|
1426
|
-
sell copies of the Software, and to permit persons to whom the
|
|
1427
|
-
Software is furnished to do so, subject to the following
|
|
1428
|
-
conditions:
|
|
1429
|
-
|
|
1430
|
-
The above copyright notice and this permission notice shall be
|
|
1431
|
-
included in all copies or substantial portions of the Software.
|
|
1432
|
-
|
|
1433
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.</code></pre>
|
|
1434
|
-
</div>
|
|
1435
|
-
</div>
|
|
1436
|
-
</section>
|
|
1437
|
-
|
|
1438
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1439
|
-
<!-- FOOTER -->
|
|
1440
|
-
<!-- ════════════════════════════════════════════════════════════════════════ -->
|
|
1441
|
-
<footer class="site-footer">
|
|
1442
|
-
<div class="footer-inner">
|
|
1443
|
-
<div class="footer-brand">
|
|
1444
|
-
<span class="footer-logo"><span>PlainScript</span></span>
|
|
1445
|
-
<p>An Intent-Oriented Programming Language. Write programs in near-English. Compile to JavaScript.</p>
|
|
1446
|
-
<div class="footer-socials">
|
|
1447
|
-
<a href="https://github.com/ayoistooslick/plain-code" target="_blank" rel="noopener" aria-label="GitHub">
|
|
1448
|
-
<i class="fa-brands fa-github"></i>
|
|
1449
|
-
</a>
|
|
1450
|
-
<a href="https://www.npmjs.com/package/plainscript" target="_blank" rel="noopener" aria-label="npm">
|
|
1451
|
-
<i class="fa-brands fa-npm"></i>
|
|
1452
|
-
</a>
|
|
1453
|
-
</div>
|
|
1454
|
-
</div>
|
|
1455
|
-
|
|
1456
|
-
<div class="footer-col">
|
|
1457
|
-
<h5>Documentation</h5>
|
|
1458
|
-
<ul>
|
|
1459
|
-
<li><a href="#quickstart">Quick Start</a></li>
|
|
1460
|
-
<li><a href="#language">Language Tour</a></li>
|
|
1461
|
-
<li><a href="#stdlib">Standard Library</a></li>
|
|
1462
|
-
<li><a href="#examples">Examples</a></li>
|
|
1463
|
-
<li><a href="#packages">Package System</a></li>
|
|
1464
|
-
</ul>
|
|
1465
|
-
</div>
|
|
1466
|
-
|
|
1467
|
-
<div class="footer-col">
|
|
1468
|
-
<h5>Features</h5>
|
|
1469
|
-
<ul>
|
|
1470
|
-
<li><a href="#web">Web Development</a></li>
|
|
1471
|
-
<li><a href="#database">SQLite</a></li>
|
|
1472
|
-
<li><a href="#cli">CLI Reference</a></li>
|
|
1473
|
-
<li><a href="#formatter">Formatter</a></li>
|
|
1474
|
-
<li><a href="#vscode">VS Code Extension</a></li>
|
|
1475
|
-
</ul>
|
|
1476
|
-
</div>
|
|
1477
|
-
|
|
1478
|
-
<div class="footer-col">
|
|
1479
|
-
<h5>Project</h5>
|
|
1480
|
-
<ul>
|
|
1481
|
-
<li><a href="#roadmap">Roadmap</a></li>
|
|
1482
|
-
<li><a href="#faq">FAQ</a></li>
|
|
1483
|
-
<li><a href="#contributing">Contributing</a></li>
|
|
1484
|
-
<li><a href="#license">License</a></li>
|
|
1485
|
-
<li><a href="https://github.com/ayoistooslick/plain-code/releases" target="_blank" rel="noopener">Releases</a></li>
|
|
1486
|
-
</ul>
|
|
1487
|
-
</div>
|
|
1488
|
-
</div>
|
|
1489
|
-
|
|
1490
|
-
<div class="footer-bottom">
|
|
1491
|
-
<p>Copyright © 2024 Ayokunle. Released under the MIT License.</p>
|
|
1492
|
-
<span class="badge badge-blue version-badge">
|
|
1493
|
-
<i class="fa-solid fa-bolt"></i> PlainScript v0.1.7
|
|
1494
|
-
</span>
|
|
1495
|
-
</div>
|
|
1496
|
-
</footer>
|
|
1497
|
-
|
|
1498
|
-
<script src="/website/script.js"></script>
|
|
1499
|
-
</body>
|
|
1500
|
-
</html>
|