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/README.md
CHANGED
|
@@ -16,7 +16,7 @@ PlainScript is an Intent-Oriented Programming Language (IOPL). You describe **wh
|
|
|
16
16
|
## Quick start
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npx plainscript new myapp # scaffolds src/app.
|
|
19
|
+
npx plainscript new myapp # scaffolds src/app.ps and package.json
|
|
20
20
|
cd myapp
|
|
21
21
|
npm install # installs plainscript as a devDependency plus runtime packages
|
|
22
22
|
npm run build # compiles src/ -> dist/ (plainscript build)
|
|
@@ -27,7 +27,7 @@ Adding PlainScript to an existing project:
|
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
npm install --save-dev plainscript
|
|
30
|
-
# start writing src/*.
|
|
30
|
+
# start writing src/*.ps files — plainscript build auto-discovers them
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
No global install is needed anywhere — everything runs through npm scripts
|
|
@@ -38,17 +38,17 @@ and `npx`.
|
|
|
38
38
|
## CLI
|
|
39
39
|
|
|
40
40
|
```
|
|
41
|
-
plainscript run <file.
|
|
41
|
+
plainscript run <file.ps> Install missing dependencies, compile and execute
|
|
42
42
|
(executes from a scratch dir — nothing is written
|
|
43
43
|
into your project)
|
|
44
|
-
plainscript build [file.
|
|
45
|
-
.
|
|
44
|
+
plainscript build [file.ps] Compile to dist/. With no argument, builds every
|
|
45
|
+
.ps file under the source root, preserving names
|
|
46
46
|
and folder structure
|
|
47
|
-
plainscript check <file.
|
|
48
|
-
plainscript fmt <file.
|
|
47
|
+
plainscript check <file.ps> Check syntax only (no output, no execution)
|
|
48
|
+
plainscript fmt <file.ps> Format a PlainScript file in-place
|
|
49
49
|
plainscript new [name] Create a new PlainScript project (npm-ready)
|
|
50
50
|
plainscript install Install dependencies detected in the project's sources
|
|
51
|
-
plainscript start Build src/app.
|
|
51
|
+
plainscript start Build src/app.ps and run its dist/ output
|
|
52
52
|
plainscript doctor Check the PlainScript project environment
|
|
53
53
|
plainscript add <package> Install a package into the project
|
|
54
54
|
plainscript remove <package> Uninstall a package from the project
|
|
@@ -62,13 +62,13 @@ plainscript help Print help text
|
|
|
62
62
|
## Building and configuration
|
|
63
63
|
|
|
64
64
|
`plainscript build` is a deterministic production build, TypeScript-style but for
|
|
65
|
-
`.
|
|
65
|
+
`.ps` sources — **zero configuration required**:
|
|
66
66
|
|
|
67
|
-
- `plainscript build` (no argument) discovers every `.
|
|
67
|
+
- `plainscript build` (no argument) discovers every `.ps` file under `src/` and
|
|
68
68
|
compiles each to `dist/` **preserving source file names and folder structure**:
|
|
69
|
-
`src/messi.
|
|
70
|
-
`src/helpers/math.
|
|
71
|
-
- `plainscript build <file.
|
|
69
|
+
`src/messi.ps` → `dist/messi.js`,
|
|
70
|
+
`src/helpers/math.ps` → `dist/helpers/math.js`.
|
|
71
|
+
- `plainscript build <file.ps>` compiles a single file into `dist/`.
|
|
72
72
|
- Imports are bundled into each output, so every file in `dist/` runs
|
|
73
73
|
standalone under Node.
|
|
74
74
|
- Rebuilds are byte-identical — safe to commit, diff, and cache.
|
|
@@ -112,7 +112,7 @@ For projects that need custom output or source directories, add a
|
|
|
112
112
|
}
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
`src/index.
|
|
115
|
+
`src/index.ps` builds to `dist/index.js`; consumers install and `require()`
|
|
116
116
|
it like any Node package. There is no PlainScript-specific registry or format —
|
|
117
117
|
standard `package.json` semantics apply.
|
|
118
118
|
|
|
@@ -634,8 +634,8 @@ cacheDelete("greeting")
|
|
|
634
634
|
## Multi-file projects
|
|
635
635
|
|
|
636
636
|
```plainscript
|
|
637
|
-
import "./math.
|
|
638
|
-
import "./utils.
|
|
637
|
+
import "./math.ps"
|
|
638
|
+
import "./utils.ps"
|
|
639
639
|
|
|
640
640
|
show PI
|
|
641
641
|
|
|
@@ -731,7 +731,7 @@ plainscript install # Install all detected dependencies
|
|
|
731
731
|
plainscript add express # Add a package
|
|
732
732
|
plainscript remove express # Remove a package
|
|
733
733
|
plainscript update # Update all packages
|
|
734
|
-
plainscript start # Build src/app.
|
|
734
|
+
plainscript start # Build src/app.ps and run its dist/ output
|
|
735
735
|
plainscript doctor # Check project environment
|
|
736
736
|
```
|
|
737
737
|
|
|
@@ -774,27 +774,27 @@ plainscript/
|
|
|
774
774
|
│ └── cli.js — command-line entry point
|
|
775
775
|
│
|
|
776
776
|
├── examples/
|
|
777
|
-
│ ├── hello.
|
|
778
|
-
│ ├── day2.
|
|
779
|
-
│ ├── day3.
|
|
780
|
-
│ ├── arrays.
|
|
781
|
-
│ ├── objects.
|
|
782
|
-
│ ├── loops.
|
|
783
|
-
│ ├── expressions.
|
|
784
|
-
│ ├── stdlib.
|
|
785
|
-
│ ├── server.
|
|
786
|
-
│ ├── web-app.
|
|
787
|
-
│ ├── start.
|
|
788
|
-
│ ├── database.
|
|
789
|
-
│ ├── deployment.
|
|
777
|
+
│ ├── hello.ps
|
|
778
|
+
│ ├── day2.ps
|
|
779
|
+
│ ├── day3.ps
|
|
780
|
+
│ ├── arrays.ps
|
|
781
|
+
│ ├── objects.ps
|
|
782
|
+
│ ├── loops.ps
|
|
783
|
+
│ ├── expressions.ps
|
|
784
|
+
│ ├── stdlib.ps
|
|
785
|
+
│ ├── server.ps
|
|
786
|
+
│ ├── web-app.ps
|
|
787
|
+
│ ├── start.ps
|
|
788
|
+
│ ├── database.ps
|
|
789
|
+
│ ├── deployment.ps
|
|
790
790
|
│ ├── football-backend/ — acceptance example (SQLite + auth + sessions)
|
|
791
|
-
│ │ └── app.
|
|
791
|
+
│ │ └── app.ps
|
|
792
792
|
│ ├── id-verification/ — acceptance example (uploads + OCR matching)
|
|
793
|
-
│ │ ├── app.
|
|
793
|
+
│ │ ├── app.ps
|
|
794
794
|
│ │ └── make-sample-id.js
|
|
795
795
|
│ └── whatsapp-bot/ — WhatsApp bots (QR and pairing linking)
|
|
796
|
-
│ ├── qr.
|
|
797
|
-
│ └── pairing.
|
|
796
|
+
│ ├── qr.ps
|
|
797
|
+
│ └── pairing.ps
|
|
798
798
|
│
|
|
799
799
|
├── tests/
|
|
800
800
|
│ ├── compiler.test.js — language, CLI and formatter coverage
|
package/compiler/bundler.js
CHANGED
|
@@ -46,7 +46,7 @@ function resolveDependencies(entryPath) {
|
|
|
46
46
|
|
|
47
47
|
// Parse the file to discover its own imports.
|
|
48
48
|
// Annotate any tokenise/parse error with the filename so callers see
|
|
49
|
-
// "file.
|
|
49
|
+
// "file.ps — Line N, Column N: …" rather than a bare positional message.
|
|
50
50
|
const source = fs.readFileSync(absPath, 'utf8');
|
|
51
51
|
let tokens, ast;
|
|
52
52
|
try {
|
package/compiler/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// CLI: compile and run PlainScript (.
|
|
2
|
+
// CLI: compile and run PlainScript (.ps) files.
|
|
3
3
|
//
|
|
4
4
|
// Usage:
|
|
5
|
-
// plainscript run <file.
|
|
6
|
-
// plainscript build [file.
|
|
7
|
-
// plainscript check <file.
|
|
8
|
-
// plainscript fmt <file.
|
|
5
|
+
// plainscript run <file.ps> install missing dependencies, compile and execute
|
|
6
|
+
// plainscript build [file.ps] compile src/ (or one file) to dist/, names preserved
|
|
7
|
+
// plainscript check <file.ps> check syntax only (no JS generated, no execution)
|
|
8
|
+
// plainscript fmt <file.ps> format a PlainScript file in-place
|
|
9
9
|
// plainscript new [name] scaffold a new PlainScript project
|
|
10
10
|
// plainscript install install dependencies detected in the project's sources
|
|
11
|
-
// plainscript start build src/app.
|
|
11
|
+
// plainscript start build src/app.ps (or index.ps) and run its dist output
|
|
12
12
|
// plainscript doctor check the PlainScript project environment
|
|
13
13
|
// plainscript add <package> install a package into the project
|
|
14
14
|
// plainscript remove <package> uninstall a package from the project
|
|
@@ -49,18 +49,18 @@ function warn(message) {
|
|
|
49
49
|
const section = (title) => `\n${clrCyan(clrBold(title))}`;
|
|
50
50
|
|
|
51
51
|
const HELP = `
|
|
52
|
-
${clrBold(`PlainScript v${VERSION}`)} ${clrDim('· .
|
|
52
|
+
${clrBold(`PlainScript v${VERSION}`)} ${clrDim('· .ps compiles to readable Node.js')}
|
|
53
53
|
|
|
54
54
|
${section('START')}
|
|
55
|
-
plainscript new [name] Scaffold a new project with a working app.
|
|
56
|
-
plainscript run <file.
|
|
57
|
-
plainscript start Build src/app.
|
|
55
|
+
plainscript new [name] Scaffold a new project with a working app.ps
|
|
56
|
+
plainscript run <file.ps> Install missing deps, compile, execute
|
|
57
|
+
plainscript start Build src/app.ps and run it from dist/
|
|
58
58
|
|
|
59
59
|
${section('BUILD & CHECK')}
|
|
60
|
-
plainscript build Compile every .
|
|
61
|
-
plainscript build <file.
|
|
62
|
-
plainscript check <file.
|
|
63
|
-
plainscript fmt <file.
|
|
60
|
+
plainscript build Compile every .ps under src/ into dist/
|
|
61
|
+
plainscript build <file.ps> Compile one file into dist/ (name preserved)
|
|
62
|
+
plainscript check <file.ps> Syntax-check only — fastest feedback loop
|
|
63
|
+
plainscript fmt <file.ps> Format a file in place
|
|
64
64
|
|
|
65
65
|
${section('PACKAGES')}
|
|
66
66
|
plainscript install Install everything your source needs
|
|
@@ -92,7 +92,7 @@ ${section('ALSO SHIPPED')}
|
|
|
92
92
|
|
|
93
93
|
${section('FIRST RUN')}
|
|
94
94
|
plainscript new hello scaffolds hello/ with a live web app
|
|
95
|
-
plainscript run hello/app.
|
|
95
|
+
plainscript run hello/app.ps serves it at http://localhost:3000
|
|
96
96
|
`.trim();
|
|
97
97
|
|
|
98
98
|
// ── npm invocation ────────────────────────────────────────────────────────────
|
|
@@ -145,8 +145,8 @@ function isValidPackageName(name) {
|
|
|
145
145
|
// "exclude": ["vendor"] } }
|
|
146
146
|
//
|
|
147
147
|
// Filenames and folder structure are always preserved:
|
|
148
|
-
// src/messi.
|
|
149
|
-
// src/helpers/math.
|
|
148
|
+
// src/messi.ps → dist/messi.js
|
|
149
|
+
// src/helpers/math.ps → dist/helpers/math.js
|
|
150
150
|
const SOURCE_DIR = 'src';
|
|
151
151
|
const DEFAULT_OUT_DIR = 'dist';
|
|
152
152
|
|
|
@@ -179,7 +179,7 @@ function resolveOutDir(opts) {
|
|
|
179
179
|
return DEFAULT_OUT_DIR;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
// Every .
|
|
182
|
+
// Every .ps file under srcDir, recursively, as paths relative to srcDir.
|
|
183
183
|
// Deterministic order (sorted); node_modules, hidden directories, the output
|
|
184
184
|
// directory, and any user-specified exclude patterns are skipped.
|
|
185
185
|
function discoverSources(srcDir, outDir, exclude) {
|
|
@@ -202,7 +202,7 @@ function discoverSources(srcDir, outDir, exclude) {
|
|
|
202
202
|
try { stat = fs.statSync(full); } catch (_) { continue; }
|
|
203
203
|
if (stat.isDirectory()) {
|
|
204
204
|
walk(full);
|
|
205
|
-
} else if (name.endsWith('.
|
|
205
|
+
} else if (name.endsWith('.ps')) {
|
|
206
206
|
found.push(path.relative(root, full));
|
|
207
207
|
}
|
|
208
208
|
}
|
|
@@ -399,7 +399,7 @@ function nodeModulesSearchPaths(entryDir) {
|
|
|
399
399
|
|
|
400
400
|
async function cmdRun(filePath, extraArgs = []) {
|
|
401
401
|
if (!filePath) {
|
|
402
|
-
console.error('Usage: plainscript run <file.
|
|
402
|
+
console.error('Usage: plainscript run <file.ps>');
|
|
403
403
|
process.exit(1);
|
|
404
404
|
}
|
|
405
405
|
const js = compile(filePath);
|
|
@@ -436,8 +436,8 @@ function buildOne(filePath, srcDir, outDir) {
|
|
|
436
436
|
}
|
|
437
437
|
const js = compile(absFile);
|
|
438
438
|
const srcRoot = path.resolve(srcDir);
|
|
439
|
-
let rel = path.relative(srcRoot, absFile).replace(/\.
|
|
440
|
-
if (rel.startsWith('..') || path.isAbsolute(rel)) rel = path.basename(absFile).replace(/\.
|
|
439
|
+
let rel = path.relative(srcRoot, absFile).replace(/\.ps$/, '.js');
|
|
440
|
+
if (rel.startsWith('..') || path.isAbsolute(rel)) rel = path.basename(absFile).replace(/\.ps$/, '.js');
|
|
441
441
|
const outPath = path.join(path.resolve(outDir), rel);
|
|
442
442
|
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
443
443
|
fs.writeFileSync(outPath, js, 'utf8');
|
|
@@ -447,16 +447,16 @@ function buildOne(filePath, srcDir, outDir) {
|
|
|
447
447
|
// `plainscript build` — TypeScript-style production build:
|
|
448
448
|
//
|
|
449
449
|
// Zero config (default):
|
|
450
|
-
// messi.
|
|
451
|
-
// src/index.
|
|
452
|
-
// src/a/b.
|
|
450
|
+
// messi.ps → dist/messi.js (project-root sources)
|
|
451
|
+
// src/index.ps → dist/index.js (src/ is the source root)
|
|
452
|
+
// src/a/b.ps → dist/a/b.js (structure preserved)
|
|
453
453
|
//
|
|
454
454
|
// With plainscript.config.json:
|
|
455
455
|
// { "compilerOptions": { "outDir": "./build", "rootDir": "./lib" } }
|
|
456
|
-
// lib/app.
|
|
456
|
+
// lib/app.ps → build/app.js
|
|
457
457
|
//
|
|
458
458
|
// With an explicit file argument only that entry is compiled; without one,
|
|
459
|
-
// every .
|
|
459
|
+
// every .ps under the discovered source root builds to the output directory.
|
|
460
460
|
async function cmdBuild(filePath) {
|
|
461
461
|
const opts = readCompilerOptions();
|
|
462
462
|
const srcDir = resolveSrcDir(opts);
|
|
@@ -469,7 +469,7 @@ async function cmdBuild(filePath) {
|
|
|
469
469
|
}
|
|
470
470
|
const sources = discoverSources(srcDir, outDir, exclude);
|
|
471
471
|
if (sources.length === 0) {
|
|
472
|
-
console.error(`No .
|
|
472
|
+
console.error(`No .ps files found under "${srcDir}".`);
|
|
473
473
|
process.exit(1);
|
|
474
474
|
}
|
|
475
475
|
QUIET_STAGES = true;
|
|
@@ -494,7 +494,7 @@ async function cmdStart(extraArgs = []) {
|
|
|
494
494
|
const outDir = resolveOutDir(opts);
|
|
495
495
|
const entryPath = findEntry(opts);
|
|
496
496
|
if (!entryPath) {
|
|
497
|
-
console.error('No entry file found. Expected "src/app.
|
|
497
|
+
console.error('No entry file found. Expected "src/app.ps" or "src/index.ps".');
|
|
498
498
|
process.exit(1);
|
|
499
499
|
}
|
|
500
500
|
const outFile = buildOne(entryPath, srcDir, outDir);
|
|
@@ -519,8 +519,8 @@ function cmdNew(projectName) {
|
|
|
519
519
|
fs.mkdirSync(path.join(dir, 'public'));
|
|
520
520
|
fs.mkdirSync(path.join(dir, 'src'));
|
|
521
521
|
|
|
522
|
-
// src/app.
|
|
523
|
-
fs.writeFileSync(path.join(dir, 'src', 'app.
|
|
522
|
+
// src/app.ps — starter Express app
|
|
523
|
+
fs.writeFileSync(path.join(dir, 'src', 'app.ps'), `use express
|
|
524
524
|
|
|
525
525
|
remember app as express()
|
|
526
526
|
|
|
@@ -578,7 +578,7 @@ Then open http://localhost:3000 in your browser.
|
|
|
578
578
|
`);
|
|
579
579
|
|
|
580
580
|
console.log(`✓ Created project "${name}"`);
|
|
581
|
-
console.log(`\nNext steps:\n cd ${name}\n npm install\n npx plainscript run src/app.
|
|
581
|
+
console.log(`\nNext steps:\n cd ${name}\n npm install\n npx plainscript run src/app.ps`);
|
|
582
582
|
}
|
|
583
583
|
|
|
584
584
|
// ── plainscript install ────────────────────────────────────────────────────────────
|
|
@@ -588,11 +588,11 @@ Then open http://localhost:3000 in your browser.
|
|
|
588
588
|
function findEntry(opts) {
|
|
589
589
|
const srcDir = resolveSrcDir(opts);
|
|
590
590
|
const candidates = [
|
|
591
|
-
path.join(srcDir, 'app.
|
|
592
|
-
path.join(srcDir, 'index.
|
|
591
|
+
path.join(srcDir, 'app.ps'),
|
|
592
|
+
path.join(srcDir, 'index.ps'),
|
|
593
593
|
];
|
|
594
594
|
if (srcDir !== '.') {
|
|
595
|
-
candidates.push('app.
|
|
595
|
+
candidates.push('app.ps', 'index.ps');
|
|
596
596
|
}
|
|
597
597
|
return candidates.find((c) => fs.existsSync(path.resolve(c))) || null;
|
|
598
598
|
}
|
|
@@ -607,7 +607,7 @@ function collectSourceAsts() {
|
|
|
607
607
|
const exclude = opts && opts.exclude;
|
|
608
608
|
const sources = discoverSources(srcDir, outDir, exclude);
|
|
609
609
|
if (sources.length === 0) {
|
|
610
|
-
console.error(`No .
|
|
610
|
+
console.error(`No .ps source files found under "${srcDir}".`);
|
|
611
611
|
process.exit(1);
|
|
612
612
|
}
|
|
613
613
|
const root = path.resolve(srcDir);
|
|
@@ -663,14 +663,14 @@ function cmdDoctor() {
|
|
|
663
663
|
check('Runtime', fs.existsSync(path.join(__dirname, 'generator.js')));
|
|
664
664
|
console.log('');
|
|
665
665
|
|
|
666
|
-
// Source discovery check: does the project have any .
|
|
666
|
+
// Source discovery check: does the project have any .ps files?
|
|
667
667
|
const opts = readCompilerOptions();
|
|
668
668
|
const srcDir = resolveSrcDir(opts);
|
|
669
669
|
const outDir = resolveOutDir(opts);
|
|
670
670
|
const exclude = opts && opts.exclude;
|
|
671
671
|
const sources = discoverSources(srcDir, outDir, exclude);
|
|
672
672
|
check('Source files', sources.length > 0,
|
|
673
|
-
sources.length > 0 ? `"${srcDir}/" discovered (${sources.length} file(s))` : `no .
|
|
673
|
+
sources.length > 0 ? `"${srcDir}/" discovered (${sources.length} file(s))` : `no .ps files under "${srcDir}"`);
|
|
674
674
|
if (sources.length === 0) return;
|
|
675
675
|
|
|
676
676
|
// Dependency check: scan every source file for npm imports
|
|
@@ -747,7 +747,7 @@ function cmdUpdate() {
|
|
|
747
747
|
// Check syntax of a PlainScript file without generating JavaScript or executing.
|
|
748
748
|
function cmdCheck(filePath) {
|
|
749
749
|
if (!filePath) {
|
|
750
|
-
console.error('Usage: plainscript check <file.
|
|
750
|
+
console.error('Usage: plainscript check <file.ps>');
|
|
751
751
|
process.exit(1);
|
|
752
752
|
}
|
|
753
753
|
const absPath = path.resolve(filePath);
|
|
@@ -769,7 +769,7 @@ function cmdCheck(filePath) {
|
|
|
769
769
|
// Format a PlainScript file in-place.
|
|
770
770
|
function cmdFmt(filePath) {
|
|
771
771
|
if (!filePath) {
|
|
772
|
-
console.error('Usage: plainscript fmt <file.
|
|
772
|
+
console.error('Usage: plainscript fmt <file.ps>');
|
|
773
773
|
process.exit(1);
|
|
774
774
|
}
|
|
775
775
|
const absPath = path.resolve(filePath);
|
|
@@ -828,7 +828,7 @@ async function main() {
|
|
|
828
828
|
case 'help': cmdHelp(); break;
|
|
829
829
|
default:
|
|
830
830
|
// Backwards-compatible: treat the first arg as a file to run directly
|
|
831
|
-
if (command && command.endsWith('.
|
|
831
|
+
if (command && command.endsWith('.ps')) {
|
|
832
832
|
await cmdRun(command);
|
|
833
833
|
} else {
|
|
834
834
|
console.error(`Unknown command: "${command}". Run "plainscript help" for usage.`);
|
package/compiler/parser.js
CHANGED
|
@@ -792,12 +792,12 @@ function parse(tokens) {
|
|
|
792
792
|
return { type: 'WhileStatement', condition, body };
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
-
// import "./file.
|
|
795
|
+
// import "./file.ps"
|
|
796
796
|
function parseImport() {
|
|
797
797
|
consume(TOKEN.IMPORT);
|
|
798
798
|
const filePath = consume(
|
|
799
799
|
TOKEN.STRING,
|
|
800
|
-
'Expected a file path string after "import".\n\nExample:\n import "./math.
|
|
800
|
+
'Expected a file path string after "import".\n\nExample:\n import "./math.ps"'
|
|
801
801
|
).value;
|
|
802
802
|
return { type: 'ImportStatement', path: filePath };
|
|
803
803
|
}
|
package/docs/PLINJS_SPEC.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Version: 2.1.1
|
|
4
4
|
Status: Stable
|
|
5
|
-
File Extension: .
|
|
5
|
+
File Extension: .ps
|
|
6
6
|
|
|
7
7
|
Tagline: "When even a simple sentence can be code."
|
|
8
8
|
|
|
@@ -230,10 +230,10 @@ Notes:
|
|
|
230
230
|
|
|
231
231
|
## PlainScript Imports
|
|
232
232
|
|
|
233
|
-
Split a project across multiple `.
|
|
233
|
+
Split a project across multiple `.ps` files:
|
|
234
234
|
|
|
235
|
-
import "./math.
|
|
236
|
-
import "./utils.
|
|
235
|
+
import "./math.ps"
|
|
236
|
+
import "./utils.ps"
|
|
237
237
|
|
|
238
238
|
Rules:
|
|
239
239
|
|
|
@@ -245,20 +245,20 @@ Rules:
|
|
|
245
245
|
|
|
246
246
|
Example project layout:
|
|
247
247
|
|
|
248
|
-
app.
|
|
249
|
-
math.
|
|
250
|
-
utils.
|
|
248
|
+
app.ps
|
|
249
|
+
math.ps
|
|
250
|
+
utils.ps
|
|
251
251
|
|
|
252
|
-
`math.
|
|
252
|
+
`math.ps`:
|
|
253
253
|
|
|
254
254
|
remember PI as 3.14
|
|
255
255
|
|
|
256
|
-
`app.
|
|
256
|
+
`app.ps`:
|
|
257
257
|
|
|
258
|
-
import "./math.
|
|
258
|
+
import "./math.ps"
|
|
259
259
|
show PI
|
|
260
260
|
|
|
261
|
-
Output: one combined JavaScript file with `math.
|
|
261
|
+
Output: one combined JavaScript file with `math.ps` code before `app.ps` code.
|
|
262
262
|
|
|
263
263
|
---
|
|
264
264
|
|
|
@@ -341,11 +341,11 @@ filesystem.
|
|
|
341
341
|
```bash
|
|
342
342
|
npm install --save-dev plainscript
|
|
343
343
|
plainscript install
|
|
344
|
-
plainscript build app.
|
|
345
|
-
plainscript run app.
|
|
344
|
+
plainscript build app.ps
|
|
345
|
+
plainscript run app.ps
|
|
346
346
|
```
|
|
347
347
|
|
|
348
|
-
`plainscript start` builds `src/app.
|
|
348
|
+
`plainscript start` builds `src/app.ps` (or `src/index.ps`) into the output
|
|
349
349
|
directory and runs it. `plainscript doctor` reports missing tools, source files,
|
|
350
350
|
or dependencies. Generated JavaScript remains standard
|
|
351
351
|
Node.js-compatible JavaScript and runtime `require()` declarations are emitted
|
|
@@ -916,7 +916,7 @@ __whatsappOnMessage(async (__waCtx) => {
|
|
|
916
916
|
|
|
917
917
|
Format a PlainScript file in-place:
|
|
918
918
|
|
|
919
|
-
plainscript fmt app.
|
|
919
|
+
plainscript fmt app.ps
|
|
920
920
|
|
|
921
921
|
Formatting rules:
|
|
922
922
|
|
|
@@ -930,7 +930,7 @@ Formatting rules:
|
|
|
930
930
|
|
|
931
931
|
Check syntax without generating JavaScript or running anything:
|
|
932
932
|
|
|
933
|
-
plainscript check app.
|
|
933
|
+
plainscript check app.ps
|
|
934
934
|
|
|
935
935
|
Exits with code 0 if no errors are found. Exits with code 1 and prints a
|
|
936
936
|
friendly error (with line, column, and suggestion where possible) if the
|
|
@@ -941,7 +941,7 @@ file contains a syntax error.
|
|
|
941
941
|
Install `plainscript-vscode` for:
|
|
942
942
|
|
|
943
943
|
- Syntax highlighting
|
|
944
|
-
- File icon for `.
|
|
944
|
+
- File icon for `.ps` files
|
|
945
945
|
- Auto-closing pairs: `()` `[]` `{}` `""`
|
|
946
946
|
- Comment toggling (`//`)
|
|
947
947
|
- Bracket matching
|
|
@@ -952,7 +952,7 @@ See `plainscript-vscode/README.md` for installation instructions.
|
|
|
952
952
|
|
|
953
953
|
### Acode Editor
|
|
954
954
|
|
|
955
|
-
Acode support (`plainscript-acode/`) provides syntax highlighting and `.
|
|
955
|
+
Acode support (`plainscript-acode/`) provides syntax highlighting and `.ps` file
|
|
956
956
|
recognition in the [Acode](https://acode.app) Android editor, using Acode's
|
|
957
957
|
modern CodeMirror 6 `editorLanguages` API.
|
|
958
958
|
|
|
@@ -993,13 +993,13 @@ For projects that need custom output or source directories, add an optional
|
|
|
993
993
|
|
|
994
994
|
| Command | Behaviour |
|
|
995
995
|
|-------------------------|------------------------------------------------------|
|
|
996
|
-
| `plainscript run <file.
|
|
996
|
+
| `plainscript run <file.ps>` | Install dependencies, compile and execute |
|
|
997
997
|
| `plainscript build [file]` | Compile to dist/ preserving names; no arg builds all|
|
|
998
|
-
| `plainscript check <file.
|
|
999
|
-
| `plainscript fmt <file.
|
|
998
|
+
| `plainscript check <file.ps>` | Check syntax only (no output, no execution) |
|
|
999
|
+
| `plainscript fmt <file.ps>` | Format a PlainScript file in-place |
|
|
1000
1000
|
| `plainscript new [name]` | Create a new PlainScript project |
|
|
1001
1001
|
| `plainscript install` | Detect and install dependencies from source files |
|
|
1002
|
-
| `plainscript start` | Build src/app.
|
|
1002
|
+
| `plainscript start` | Build src/app.ps and run its dist/ output |
|
|
1003
1003
|
| `plainscript doctor` | Check the PlainScript project environment |
|
|
1004
1004
|
| `plainscript add <pkg>` | Install a package into the project |
|
|
1005
1005
|
| `plainscript remove <pkg>` | Uninstall a package from the project |
|