lumina-lang 0.3.0
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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +243 -0
- package/RELEASE.md +8 -0
- package/dist/bin/cli.cjs +20043 -0
- package/dist/bin/cli.cjs.map +1 -0
- package/dist/bin/cli.js +20045 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/bin/lumina-lsp.cjs +19056 -0
- package/dist/bin/lumina-lsp.cjs.map +1 -0
- package/dist/bin/lumina-lsp.js +19055 -0
- package/dist/bin/lumina-lsp.js.map +1 -0
- package/dist/bin/lumina.cjs +23044 -0
- package/dist/bin/lumina.cjs.map +1 -0
- package/dist/bin/lumina.js +23044 -0
- package/dist/bin/lumina.js.map +1 -0
- package/dist/index.cjs +22173 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1411 -0
- package/dist/index.js +22096 -0
- package/dist/index.js.map +1 -0
- package/dist/lumina-runtime.cjs +623 -0
- package/dist/lumina-runtime.cjs.map +1 -0
- package/dist/lumina-runtime.js +579 -0
- package/dist/lumina-runtime.js.map +1 -0
- package/lumina.config.schema.json +54 -0
- package/package.json +132 -0
- package/std/io.lm +1 -0
- package/std/math.lm +3 -0
- package/std/prelude.lm +10 -0
- package/std/string.lm +2 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
## 0.3.0 - 2026-02-14
|
|
8
|
+
|
|
9
|
+
- **Breaking:** Removed the `parsergen` binary. Use `lumina grammar` for parser generator tooling.
|
|
10
|
+
- **Rename:** Package published as `lumina-lang` (formerly `parsergen-starter`).
|
|
11
|
+
- Lumina language pipeline (lexer, parser, semantic checks, IR, codegen).
|
|
12
|
+
- Multi-file project context with panic recovery and dependency graph.
|
|
13
|
+
- Lumina LSP server (diagnostics, completion, symbols, rename, references, semantic tokens).
|
|
14
|
+
- CLI enhancements (`lumina`, `lumina-lsp`, `parsergen` updates).
|
|
15
|
+
- Optimizations (constant folding, dead code elimination, constant propagation).
|
|
16
|
+
- **Fix:** SSA IR codegen now hoists SSA temporaries and avoids loop-unsafe constant folding.
|
|
17
|
+
- Source maps support and improved watcher tooling.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 nyigoro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# Lumina (v0.3.0)
|
|
2
|
+
|
|
3
|
+
A modern functional language with async/await, type inference, and package management.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## โจ Highlights
|
|
12
|
+
|
|
13
|
+
- PEG grammar compiler with AST output
|
|
14
|
+
- Streaming parsing with custom delimiters
|
|
15
|
+
- REPL with multiline input, history, AST views, profiling, and clipboard helpers
|
|
16
|
+
- Lumina language pipeline (lexer, parser, semantic checks, IR, codegen)
|
|
17
|
+
- Project context for multi-file parsing + panic mode recovery
|
|
18
|
+
- Lumina LSP server with diagnostics, completion, symbols, rename, references, semantic tokens
|
|
19
|
+
- CLI tools for parsing and Lumina workflows
|
|
20
|
+
- Structs/enums with match + member access
|
|
21
|
+
- Hex/binary/underscored numeric literals
|
|
22
|
+
- IR visualization via `--debug-ir`
|
|
23
|
+
|
|
24
|
+
## ๐ฆ Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g lumina-lang
|
|
28
|
+
# or
|
|
29
|
+
pnpm add -D lumina-lang
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## ๐ Getting Started (Lumina)
|
|
33
|
+
|
|
34
|
+
Lumina is a full toolchain: multi-file parsing, semantic checks, IR optimization, and codegen.
|
|
35
|
+
|
|
36
|
+
## ๐งช Tests
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm test
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## ๐งฐ CLI
|
|
43
|
+
|
|
44
|
+
The package installs two binaries:
|
|
45
|
+
- `lumina` for the Lumina toolchain (including grammar tooling)
|
|
46
|
+
- `lumina-lsp` for editor integration
|
|
47
|
+
|
|
48
|
+
### `lumina`
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
lumina repl
|
|
52
|
+
lumina compile examples/hello.lm --out dist/hello.js --target esm
|
|
53
|
+
lumina compile examples/hello.lm --sourcemap
|
|
54
|
+
lumina compile examples/hello.lm --debug-ir
|
|
55
|
+
lumina compile examples/hello.lm --profile-cache
|
|
56
|
+
lumina check examples/hello.lm
|
|
57
|
+
lumina watch examples
|
|
58
|
+
lumina compile examples/hello.lm --dry-run
|
|
59
|
+
lumina compile examples/hello.lm --recovery
|
|
60
|
+
lumina compile --list-config
|
|
61
|
+
lumina watch "examples/**/*.lm"
|
|
62
|
+
lumina init
|
|
63
|
+
lumina grammar mylang.peg --test "hello world"
|
|
64
|
+
|
|
65
|
+
Parser generator tooling now lives under `lumina grammar`.
|
|
66
|
+
|
|
67
|
+
`--profile-cache` also prints dependency graph stats.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### `lumina.config.json`
|
|
71
|
+
|
|
72
|
+
You can configure defaults for the Lumina CLI:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"grammarPath": "src/grammar/lumina.peg",
|
|
77
|
+
"outDir": "dist",
|
|
78
|
+
"target": "esm",
|
|
79
|
+
"entries": ["examples/hello.lm"],
|
|
80
|
+
"watch": ["examples/hello.lm"],
|
|
81
|
+
"fileExtensions": [".lm", ".lumina"],
|
|
82
|
+
"cacheDir": ".lumina-cache",
|
|
83
|
+
"recovery": true
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Schema: `lumina.config.schema.json`
|
|
88
|
+
|
|
89
|
+
### REPL
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm run repl
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Key commands:
|
|
96
|
+
- `.grammar [inline|@file]`
|
|
97
|
+
- `.test [inline]`
|
|
98
|
+
- `.paste [--no-parse]`
|
|
99
|
+
- `.ast on|off|json|tree`
|
|
100
|
+
- `.stats`
|
|
101
|
+
- `.profile [n]`
|
|
102
|
+
- `.watch <file>`
|
|
103
|
+
- `.session save|load <file>`
|
|
104
|
+
|
|
105
|
+
## ๐งญ Lumina LSP
|
|
106
|
+
|
|
107
|
+
Run the server:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npx lumina-lsp
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
If built locally:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
node dist/bin/lumina-lsp.js
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### LSP Settings
|
|
120
|
+
|
|
121
|
+
- `lumina.grammarPath`: path to the grammar (default `src/grammar/lumina.peg`)
|
|
122
|
+
- `lumina.maxDiagnostics`: max diagnostics per file (default `200`)
|
|
123
|
+
- `lumina.fileExtensions`: file extensions to watch (default `[".lum", ".lumina"]`)
|
|
124
|
+
- `lumina.maxIndexFiles`: max files indexed per workspace (default `2000`)
|
|
125
|
+
- `lumina.renameConflictMode`: conflict checks (`"all"` or `"exports"`, default `"all"`)
|
|
126
|
+
- `lumina.renamePreviewMode`: rename preview output (`"popup"`, `"log"`, `"off"`, default `"popup"`)
|
|
127
|
+
- `lumina.recovery`: enable resilient parsing for CLI `compile/check/watch` (default `false`)
|
|
128
|
+
- Go-to-Definition, Find References, Rename, and Semantic Tokens
|
|
129
|
+
|
|
130
|
+
Example (VS Code settings):
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"lumina.renamePreviewMode": "log",
|
|
135
|
+
"lumina.renameConflictMode": "all"
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## ๐งญ Lumina By Example
|
|
140
|
+
|
|
141
|
+
Create two files:
|
|
142
|
+
|
|
143
|
+
`examples/types.lm`:
|
|
144
|
+
|
|
145
|
+
```lumina
|
|
146
|
+
import { io } from "@std";
|
|
147
|
+
|
|
148
|
+
struct User { id: int, name: string }
|
|
149
|
+
enum Result { Ok(int), Err(string) }
|
|
150
|
+
|
|
151
|
+
fn main() {
|
|
152
|
+
let user: User = match Ok(1) {
|
|
153
|
+
Ok(value) => User,
|
|
154
|
+
Err(msg) => User,
|
|
155
|
+
};
|
|
156
|
+
return user.id;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`examples/main.lm`:
|
|
161
|
+
|
|
162
|
+
```lumina
|
|
163
|
+
import { main } from "./types.lm";
|
|
164
|
+
|
|
165
|
+
fn entry() {
|
|
166
|
+
return main();
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Local Type Inference
|
|
171
|
+
|
|
172
|
+
```lumina
|
|
173
|
+
fn main() {
|
|
174
|
+
let x = 42;
|
|
175
|
+
let y: int = 10;
|
|
176
|
+
return x + y;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Compile the project:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
lumina compile examples/main.lm --out dist/main.js --target esm
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Dependency Graph + Resilient Parsing
|
|
187
|
+
|
|
188
|
+
Lumina maintains a dependency graph for multi-file projects and uses panic-mode recovery so a single syntax error does not stop the entire analysis pass.
|
|
189
|
+
|
|
190
|
+
## ๐งช REPL With Custom Grammar
|
|
191
|
+
|
|
192
|
+
You can start the REPL and load a grammar file directly:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npm run repl
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Inside the REPL:
|
|
199
|
+
|
|
200
|
+
```text
|
|
201
|
+
.grammar @examples/lumina.peg
|
|
202
|
+
.test
|
|
203
|
+
fn main() { return 1; }
|
|
204
|
+
.end
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## ๐ค Contributing / Development
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
npm install
|
|
211
|
+
npm run build
|
|
212
|
+
npm run lint:check
|
|
213
|
+
npm test
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## ๐ Project Layout
|
|
217
|
+
|
|
218
|
+
- `src/grammar`: grammar compiler and bundled grammars
|
|
219
|
+
- `src/parser`: parser utilities, streaming parse, diagnostics
|
|
220
|
+
- `src/repl.ts`: REPL implementation
|
|
221
|
+
- `src/lumina`: Lumina lexer, AST, semantic analysis, IR, codegen
|
|
222
|
+
- `src/project`: multi-file project context + panic recovery
|
|
223
|
+
- `src/lsp`: Lumina language server
|
|
224
|
+
- `examples`: sample grammars and Lumina templates
|
|
225
|
+
- `tests`: Jest test suite
|
|
226
|
+
|
|
227
|
+
## ๐ ๏ธ Build
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
npm run build
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## ๐ฆ Packaging Check
|
|
234
|
+
|
|
235
|
+
Before publishing, run:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
npm run pack:check
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## ๐ License
|
|
242
|
+
|
|
243
|
+
MIT
|
package/RELEASE.md
ADDED