@words-lang/parser 0.1.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/dist/analyser/analyser.d.ts +106 -0
- package/dist/analyser/analyser.d.ts.map +1 -0
- package/dist/analyser/analyser.js +291 -0
- package/dist/analyser/analyser.js.map +1 -0
- package/dist/analyser/diagnostics.d.ts +166 -0
- package/dist/analyser/diagnostics.d.ts.map +1 -0
- package/dist/analyser/diagnostics.js +139 -0
- package/dist/analyser/diagnostics.js.map +1 -0
- package/dist/analyser/workspace.d.ts +198 -0
- package/dist/analyser/workspace.d.ts.map +1 -0
- package/dist/analyser/workspace.js +403 -0
- package/dist/analyser/workspace.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/lexer/lexer.d.ts +120 -0
- package/dist/lexer/lexer.d.ts.map +1 -0
- package/dist/lexer/lexer.js +365 -0
- package/dist/lexer/lexer.js.map +1 -0
- package/dist/lexer/token.d.ts +247 -0
- package/dist/lexer/token.d.ts.map +1 -0
- package/dist/lexer/token.js +250 -0
- package/dist/lexer/token.js.map +1 -0
- package/dist/parser/ast.d.ts +685 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/ast.js +3 -0
- package/dist/parser/ast.js.map +1 -0
- package/dist/parser/parser.d.ts +411 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +1600 -0
- package/dist/parser/parser.js.map +1 -0
- package/package.json +23 -0
- package/src/analyser/analyser.ts +403 -0
- package/src/analyser/diagnostics.ts +232 -0
- package/src/analyser/workspace.ts +457 -0
- package/src/index.ts +7 -0
- package/src/lexer/lexer.ts +379 -0
- package/src/lexer/token.ts +331 -0
- package/src/parser/ast.ts +798 -0
- package/src/parser/parser.ts +1815 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* workspace.ts
|
|
4
|
+
*
|
|
5
|
+
* The Workspace scans a WORDS project directory, parses every `.wds` file it
|
|
6
|
+
* finds, and builds a cross-file index of all constructs organised by module.
|
|
7
|
+
*
|
|
8
|
+
* The index is the shared data structure consumed by the Analyser and later
|
|
9
|
+
* by the LSP server for go-to-definition and find-references. Neither the
|
|
10
|
+
* Analyser nor the LSP reads files directly — they always go through the
|
|
11
|
+
* Workspace.
|
|
12
|
+
*
|
|
13
|
+
* Design principles:
|
|
14
|
+
*
|
|
15
|
+
* - One parse per file. The Workspace caches parse results so the Analyser
|
|
16
|
+
* can query the index repeatedly without re-parsing.
|
|
17
|
+
*
|
|
18
|
+
* - Flat index structure. Constructs are indexed by module name and construct
|
|
19
|
+
* name so lookups are O(1) rather than requiring a tree walk.
|
|
20
|
+
*
|
|
21
|
+
* - Parse errors are preserved. Files that fail to parse partially are still
|
|
22
|
+
* indexed — whatever nodes were recovered are included. Parse diagnostics
|
|
23
|
+
* are stored alongside the index and returned with analyser diagnostics.
|
|
24
|
+
*
|
|
25
|
+
* - The Workspace is synchronous. File I/O uses Node's `fs` module directly.
|
|
26
|
+
* The LSP layer wraps this in async when needed.
|
|
27
|
+
*/
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
+
var ownKeys = function(o) {
|
|
46
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
return ownKeys(o);
|
|
52
|
+
};
|
|
53
|
+
return function (mod) {
|
|
54
|
+
if (mod && mod.__esModule) return mod;
|
|
55
|
+
var result = {};
|
|
56
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
+
__setModuleDefault(result, mod);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
})();
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.Workspace = void 0;
|
|
63
|
+
const fs = __importStar(require("fs"));
|
|
64
|
+
const path = __importStar(require("path"));
|
|
65
|
+
const lexer_1 = require("../lexer/lexer");
|
|
66
|
+
const parser_1 = require("../parser/parser");
|
|
67
|
+
// ── Workspace ─────────────────────────────────────────────────────────────────
|
|
68
|
+
/**
|
|
69
|
+
* The cross-file index of a WORDS project.
|
|
70
|
+
*
|
|
71
|
+
* Built by calling `Workspace.load(projectRoot)`. Consumers query the index
|
|
72
|
+
* directly via the public maps — there are no query methods, just data.
|
|
73
|
+
*/
|
|
74
|
+
class Workspace {
|
|
75
|
+
constructor(projectRoot) {
|
|
76
|
+
/**
|
|
77
|
+
* All parsed files, keyed by absolute file path.
|
|
78
|
+
* Includes both successfully parsed files and files with parse errors.
|
|
79
|
+
*/
|
|
80
|
+
this.files = new Map();
|
|
81
|
+
/**
|
|
82
|
+
* All parse-layer diagnostics collected across all files.
|
|
83
|
+
* Indexed by absolute file path.
|
|
84
|
+
*/
|
|
85
|
+
this.parseDiagnostics = new Map();
|
|
86
|
+
/**
|
|
87
|
+
* The single system declaration found in the project.
|
|
88
|
+
* Null if no system file was found or if it failed to parse.
|
|
89
|
+
*/
|
|
90
|
+
this.system = null;
|
|
91
|
+
/**
|
|
92
|
+
* The file path of the system declaration, for diagnostic reporting.
|
|
93
|
+
*/
|
|
94
|
+
this.systemFilePath = null;
|
|
95
|
+
/**
|
|
96
|
+
* All module definitions, keyed by module name.
|
|
97
|
+
* e.g. modules.get('AuthModule') → ModuleNode
|
|
98
|
+
*/
|
|
99
|
+
this.modules = new Map();
|
|
100
|
+
/**
|
|
101
|
+
* File path of each module definition, for diagnostic reporting.
|
|
102
|
+
* e.g. modulePaths.get('AuthModule') → '/project/AuthModule/AuthModule.wds'
|
|
103
|
+
*/
|
|
104
|
+
this.modulePaths = new Map();
|
|
105
|
+
/**
|
|
106
|
+
* All state definitions, keyed by module name then state name.
|
|
107
|
+
* e.g. states.get('AuthModule')?.get('Unauthenticated') → StateNode
|
|
108
|
+
*/
|
|
109
|
+
this.states = new Map();
|
|
110
|
+
/**
|
|
111
|
+
* All context definitions, keyed by module name then context name.
|
|
112
|
+
*/
|
|
113
|
+
this.contexts = new Map();
|
|
114
|
+
/**
|
|
115
|
+
* All screen definitions, keyed by module name then screen name.
|
|
116
|
+
*/
|
|
117
|
+
this.screens = new Map();
|
|
118
|
+
/**
|
|
119
|
+
* All view definitions, keyed by module name then view name.
|
|
120
|
+
*/
|
|
121
|
+
this.views = new Map();
|
|
122
|
+
/**
|
|
123
|
+
* All provider definitions, keyed by module name then provider name.
|
|
124
|
+
*/
|
|
125
|
+
this.providers = new Map();
|
|
126
|
+
/**
|
|
127
|
+
* All adapter definitions, keyed by module name then adapter name.
|
|
128
|
+
*/
|
|
129
|
+
this.adapters = new Map();
|
|
130
|
+
/**
|
|
131
|
+
* All interface component definitions, keyed by module name then interface name.
|
|
132
|
+
*/
|
|
133
|
+
this.interfaces = new Map();
|
|
134
|
+
/**
|
|
135
|
+
* File path of each construct, for go-to-definition.
|
|
136
|
+
* Key format: 'ModuleName/ConstructName' (e.g. 'AuthModule/Unauthenticated')
|
|
137
|
+
*/
|
|
138
|
+
this.constructPaths = new Map();
|
|
139
|
+
this.projectRoot = projectRoot;
|
|
140
|
+
}
|
|
141
|
+
// ── Factory ────────────────────────────────────────────────────────────────
|
|
142
|
+
/**
|
|
143
|
+
* Scans `projectRoot` recursively for `.wds` files, parses each one,
|
|
144
|
+
* and returns a fully populated Workspace.
|
|
145
|
+
*
|
|
146
|
+
* Never throws — files that cannot be read or parsed are recorded with
|
|
147
|
+
* their errors and skipped during indexing.
|
|
148
|
+
*/
|
|
149
|
+
static load(projectRoot) {
|
|
150
|
+
const ws = new Workspace(path.resolve(projectRoot));
|
|
151
|
+
const wdsPaths = ws.findWdsFiles(ws.projectRoot);
|
|
152
|
+
for (const filePath of wdsPaths) {
|
|
153
|
+
ws.loadFile(filePath);
|
|
154
|
+
}
|
|
155
|
+
ws.buildIndex();
|
|
156
|
+
return ws;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Reloads a single file and rebuilds the index.
|
|
160
|
+
* Used by the LSP server when a file changes on disk.
|
|
161
|
+
*/
|
|
162
|
+
reload(filePath) {
|
|
163
|
+
this.loadFile(path.resolve(filePath));
|
|
164
|
+
this.clearIndex();
|
|
165
|
+
this.buildIndex();
|
|
166
|
+
}
|
|
167
|
+
// ── Query helpers ──────────────────────────────────────────────────────────
|
|
168
|
+
/**
|
|
169
|
+
* Returns the StateNode for the given module and state name, or null.
|
|
170
|
+
*/
|
|
171
|
+
getState(moduleName, stateName) {
|
|
172
|
+
return this.states.get(moduleName)?.get(stateName) ?? null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Returns the ContextNode for the given module and context name, or null.
|
|
176
|
+
*/
|
|
177
|
+
getContext(moduleName, contextName) {
|
|
178
|
+
return this.contexts.get(moduleName)?.get(contextName) ?? null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Returns the ScreenNode for the given module and screen name, or null.
|
|
182
|
+
*/
|
|
183
|
+
getScreen(moduleName, screenName) {
|
|
184
|
+
return this.screens.get(moduleName)?.get(screenName) ?? null;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Returns the ViewNode for the given module and view name, or null.
|
|
188
|
+
* Also searches other modules if moduleName is null.
|
|
189
|
+
*/
|
|
190
|
+
getView(moduleName, viewName) {
|
|
191
|
+
return this.views.get(moduleName)?.get(viewName) ?? null;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Returns all parse diagnostics across all files as a flat array,
|
|
195
|
+
* each annotated with the file path that produced it.
|
|
196
|
+
*/
|
|
197
|
+
allParseDiagnostics() {
|
|
198
|
+
const result = [];
|
|
199
|
+
for (const [filePath, diags] of this.parseDiagnostics) {
|
|
200
|
+
for (const d of diags) {
|
|
201
|
+
result.push({ filePath, diagnostic: d });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
// ── Private — file loading ─────────────────────────────────────────────────
|
|
207
|
+
/**
|
|
208
|
+
* Reads and parses a single `.wds` file, storing the result in `this.files`.
|
|
209
|
+
* Silently records any read error as a parse diagnostic.
|
|
210
|
+
*/
|
|
211
|
+
loadFile(filePath) {
|
|
212
|
+
let source;
|
|
213
|
+
try {
|
|
214
|
+
source = fs.readFileSync(filePath, 'utf-8');
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
// File could not be read — record and skip
|
|
218
|
+
this.files.set(filePath, {
|
|
219
|
+
filePath,
|
|
220
|
+
source: '',
|
|
221
|
+
parseResult: {
|
|
222
|
+
document: { kind: 'Document', ownerModule: null, nodes: [] },
|
|
223
|
+
diagnostics: [],
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const tokens = new lexer_1.Lexer(source).tokenize();
|
|
229
|
+
const parseResult = new parser_1.Parser(tokens).parse();
|
|
230
|
+
this.files.set(filePath, { filePath, source, parseResult });
|
|
231
|
+
if (parseResult.diagnostics.length > 0) {
|
|
232
|
+
this.parseDiagnostics.set(filePath, parseResult.diagnostics);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Recursively finds all `.wds` files under `dir`.
|
|
237
|
+
* Skips `node_modules` and hidden directories.
|
|
238
|
+
*/
|
|
239
|
+
findWdsFiles(dir) {
|
|
240
|
+
const results = [];
|
|
241
|
+
let entries;
|
|
242
|
+
try {
|
|
243
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
return results;
|
|
247
|
+
}
|
|
248
|
+
for (const entry of entries) {
|
|
249
|
+
if (entry.name.startsWith('.'))
|
|
250
|
+
continue;
|
|
251
|
+
if (entry.name === 'node_modules')
|
|
252
|
+
continue;
|
|
253
|
+
const fullPath = path.join(dir, entry.name);
|
|
254
|
+
if (entry.isDirectory()) {
|
|
255
|
+
results.push(...this.findWdsFiles(fullPath));
|
|
256
|
+
}
|
|
257
|
+
else if (entry.isFile() && entry.name.endsWith('.wds')) {
|
|
258
|
+
results.push(fullPath);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return results;
|
|
262
|
+
}
|
|
263
|
+
// ── Private — index building ───────────────────────────────────────────────
|
|
264
|
+
/**
|
|
265
|
+
* Clears all index maps. Called before a rebuild.
|
|
266
|
+
*/
|
|
267
|
+
clearIndex() {
|
|
268
|
+
this.system = null;
|
|
269
|
+
this.systemFilePath = null;
|
|
270
|
+
this.modules.clear();
|
|
271
|
+
this.modulePaths.clear();
|
|
272
|
+
this.states.clear();
|
|
273
|
+
this.contexts.clear();
|
|
274
|
+
this.screens.clear();
|
|
275
|
+
this.views.clear();
|
|
276
|
+
this.providers.clear();
|
|
277
|
+
this.adapters.clear();
|
|
278
|
+
this.interfaces.clear();
|
|
279
|
+
this.constructPaths.clear();
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Walks all parsed documents and populates the index maps.
|
|
283
|
+
* Called once after all files are loaded, and again after each reload.
|
|
284
|
+
*/
|
|
285
|
+
buildIndex() {
|
|
286
|
+
for (const [filePath, record] of this.files) {
|
|
287
|
+
this.indexDocument(filePath, record.parseResult.document);
|
|
288
|
+
}
|
|
289
|
+
// Second pass: fill in the module name on component nodes that were
|
|
290
|
+
// parsed from files with an ownerModule declaration. The parser leaves
|
|
291
|
+
// module: '' on component nodes — we fill it in here from ownerModule.
|
|
292
|
+
for (const [, record] of this.files) {
|
|
293
|
+
const doc = record.parseResult.document;
|
|
294
|
+
if (doc.ownerModule) {
|
|
295
|
+
for (const node of doc.nodes) {
|
|
296
|
+
if ('module' in node && node.module === '') {
|
|
297
|
+
;
|
|
298
|
+
node.module = doc.ownerModule;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Indexes all top-level nodes in a single document into the appropriate maps.
|
|
306
|
+
*/
|
|
307
|
+
indexDocument(filePath, document) {
|
|
308
|
+
const ownerModule = document.ownerModule;
|
|
309
|
+
for (const node of document.nodes) {
|
|
310
|
+
this.indexNode(filePath, node, ownerModule);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Indexes a single top-level node into the appropriate map.
|
|
315
|
+
* Uses `ownerModule` from the ownership declaration if the node's own
|
|
316
|
+
* `module` field is empty (component files).
|
|
317
|
+
*/
|
|
318
|
+
indexNode(filePath, node, ownerModule) {
|
|
319
|
+
switch (node.kind) {
|
|
320
|
+
case 'System':
|
|
321
|
+
this.system = node;
|
|
322
|
+
this.systemFilePath = filePath;
|
|
323
|
+
break;
|
|
324
|
+
case 'Module':
|
|
325
|
+
this.modules.set(node.name, node);
|
|
326
|
+
this.modulePaths.set(node.name, filePath);
|
|
327
|
+
break;
|
|
328
|
+
case 'State': {
|
|
329
|
+
const mod = node.module || ownerModule || '';
|
|
330
|
+
if (!mod)
|
|
331
|
+
break;
|
|
332
|
+
this.ensureModuleMap(this.states, mod);
|
|
333
|
+
this.states.get(mod).set(node.name, node);
|
|
334
|
+
this.constructPaths.set(`${mod}/${node.name}`, filePath);
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
case 'Context': {
|
|
338
|
+
const mod = node.module || ownerModule || '';
|
|
339
|
+
if (!mod)
|
|
340
|
+
break;
|
|
341
|
+
this.ensureModuleMap(this.contexts, mod);
|
|
342
|
+
this.contexts.get(mod).set(node.name, node);
|
|
343
|
+
this.constructPaths.set(`${mod}/${node.name}`, filePath);
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
case 'Screen': {
|
|
347
|
+
const mod = node.module || ownerModule || '';
|
|
348
|
+
if (!mod)
|
|
349
|
+
break;
|
|
350
|
+
this.ensureModuleMap(this.screens, mod);
|
|
351
|
+
this.screens.get(mod).set(node.name, node);
|
|
352
|
+
this.constructPaths.set(`${mod}/${node.name}`, filePath);
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
case 'View': {
|
|
356
|
+
const mod = node.module || ownerModule || '';
|
|
357
|
+
if (!mod)
|
|
358
|
+
break;
|
|
359
|
+
this.ensureModuleMap(this.views, mod);
|
|
360
|
+
this.views.get(mod).set(node.name, node);
|
|
361
|
+
this.constructPaths.set(`${mod}/${node.name}`, filePath);
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case 'Provider': {
|
|
365
|
+
const mod = node.module || ownerModule || '';
|
|
366
|
+
if (!mod)
|
|
367
|
+
break;
|
|
368
|
+
this.ensureModuleMap(this.providers, mod);
|
|
369
|
+
this.providers.get(mod).set(node.name, node);
|
|
370
|
+
this.constructPaths.set(`${mod}/${node.name}`, filePath);
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
case 'Adapter': {
|
|
374
|
+
const mod = node.module || ownerModule || '';
|
|
375
|
+
if (!mod)
|
|
376
|
+
break;
|
|
377
|
+
this.ensureModuleMap(this.adapters, mod);
|
|
378
|
+
this.adapters.get(mod).set(node.name, node);
|
|
379
|
+
this.constructPaths.set(`${mod}/${node.name}`, filePath);
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
case 'Interface': {
|
|
383
|
+
const mod = node.module || ownerModule || '';
|
|
384
|
+
if (!mod)
|
|
385
|
+
break;
|
|
386
|
+
this.ensureModuleMap(this.interfaces, mod);
|
|
387
|
+
this.interfaces.get(mod).set(node.name, node);
|
|
388
|
+
this.constructPaths.set(`${mod}/${node.name}`, filePath);
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Ensures a per-module map exists for the given module name.
|
|
395
|
+
*/
|
|
396
|
+
ensureModuleMap(index, moduleName) {
|
|
397
|
+
if (!index.has(moduleName)) {
|
|
398
|
+
index.set(moduleName, new Map());
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
exports.Workspace = Workspace;
|
|
403
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/analyser/workspace.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAwB;AACxB,2CAA4B;AAC5B,0CAAsC;AACtC,6CAAsD;AA6CtD,iFAAiF;AAEjF;;;;;GAKG;AACH,MAAa,SAAS;IAiFlB,YAAoB,WAAmB;QA7EvC;;;WAGG;QACM,UAAK,GAA4B,IAAI,GAAG,EAAE,CAAA;QAEnD;;;WAGG;QACM,qBAAgB,GAA8B,IAAI,GAAG,EAAE,CAAA;QAEhE;;;WAGG;QACH,WAAM,GAAsB,IAAI,CAAA;QAEhC;;WAEG;Q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2
|
+
export { Token, TokenType, token } from './lexer/token';
|
|
3
|
+
export * from './parser/ast';
|
|
4
|
+
export { Parser, ParseResult } from './parser/parser';
|
|
5
|
+
export * from './analyser/diagnostics';
|
|
6
|
+
export { Workspace, FileRecord } from './analyser/workspace';
|
|
7
|
+
export { Analyser, AnalysisResult } from './analyser/analyser';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACvD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACrD,cAAc,wBAAwB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Analyser = exports.Workspace = exports.Parser = exports.token = exports.TokenType = exports.Lexer = void 0;
|
|
18
|
+
var lexer_1 = require("./lexer/lexer");
|
|
19
|
+
Object.defineProperty(exports, "Lexer", { enumerable: true, get: function () { return lexer_1.Lexer; } });
|
|
20
|
+
var token_1 = require("./lexer/token");
|
|
21
|
+
Object.defineProperty(exports, "TokenType", { enumerable: true, get: function () { return token_1.TokenType; } });
|
|
22
|
+
Object.defineProperty(exports, "token", { enumerable: true, get: function () { return token_1.token; } });
|
|
23
|
+
__exportStar(require("./parser/ast"), exports);
|
|
24
|
+
var parser_1 = require("./parser/parser");
|
|
25
|
+
Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return parser_1.Parser; } });
|
|
26
|
+
__exportStar(require("./analyser/diagnostics"), exports);
|
|
27
|
+
var workspace_1 = require("./analyser/workspace");
|
|
28
|
+
Object.defineProperty(exports, "Workspace", { enumerable: true, get: function () { return workspace_1.Workspace; } });
|
|
29
|
+
var analyser_1 = require("./analyser/analyser");
|
|
30
|
+
Object.defineProperty(exports, "Analyser", { enumerable: true, get: function () { return analyser_1.Analyser; } });
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAqC;AAA5B,8FAAA,KAAK,OAAA;AACd,uCAAuD;AAAvC,kGAAA,SAAS,OAAA;AAAE,8FAAA,KAAK,OAAA;AAChC,+CAA4B;AAC5B,0CAAqD;AAA5C,gGAAA,MAAM,OAAA;AACf,yDAAsC;AACtC,kDAA4D;AAAnD,sGAAA,SAAS,OAAA;AAClB,gDAA8D;AAArD,oGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lexer.ts
|
|
3
|
+
*
|
|
4
|
+
* The WORDS lexer. Converts a raw `.wds` source string into a flat array
|
|
5
|
+
* of tokens that the parser consumes.
|
|
6
|
+
*
|
|
7
|
+
* Design principles:
|
|
8
|
+
*
|
|
9
|
+
* - Single-pass, character-by-character. No regular expressions at runtime —
|
|
10
|
+
* all character classification is done with simple comparisons.
|
|
11
|
+
*
|
|
12
|
+
* - Never throws. Unrecognised characters are emitted as `Unknown` tokens so
|
|
13
|
+
* the parser can continue and collect all errors in one pass rather than
|
|
14
|
+
* stopping at the first problem.
|
|
15
|
+
*
|
|
16
|
+
* - `is not` is normalised into a single `IsNot` token during lexing.
|
|
17
|
+
* This simplifies the parser — it never has to handle a two-token sequence
|
|
18
|
+
* in conditional expressions.
|
|
19
|
+
*
|
|
20
|
+
* - Newlines are emitted as `Newline` tokens. The parser uses them to
|
|
21
|
+
* distinguish a bare ownership declaration (`module AuthModule` on its own
|
|
22
|
+
* line) from a construct body opening (`module AuthModule "..." (`).
|
|
23
|
+
*
|
|
24
|
+
* - Comments are included in the token stream (not silently discarded) so the
|
|
25
|
+
* parser can attach them to adjacent nodes for hover documentation.
|
|
26
|
+
*
|
|
27
|
+
* - Method names, callback prop names, and handler method names are all plain
|
|
28
|
+
* camelCase identifiers. Names like `switch`, `onLoad`, `onSubmit` carry no
|
|
29
|
+
* special meaning to the lexer — they are emitted as CamelIdent tokens.
|
|
30
|
+
*
|
|
31
|
+
* - Position tracking (line, column, offset) is maintained for every token
|
|
32
|
+
* so the LSP can report diagnostics and resolve go-to-definition requests
|
|
33
|
+
* at the exact source location.
|
|
34
|
+
*/
|
|
35
|
+
import { Token } from './token';
|
|
36
|
+
export declare class Lexer {
|
|
37
|
+
/** The full source text being tokenized. */
|
|
38
|
+
private source;
|
|
39
|
+
/** Current byte offset into `source`. */
|
|
40
|
+
private pos;
|
|
41
|
+
/** Current 1-based line number. Incremented each time a `\n` is consumed. */
|
|
42
|
+
private line;
|
|
43
|
+
/**
|
|
44
|
+
* Current 1-based column number.
|
|
45
|
+
* Reset to 1 after each newline; incremented after each other character.
|
|
46
|
+
*/
|
|
47
|
+
private column;
|
|
48
|
+
/** Accumulated token stream. Populated by `tokenize()`. */
|
|
49
|
+
private tokens;
|
|
50
|
+
constructor(source: string);
|
|
51
|
+
/**
|
|
52
|
+
* Tokenizes the entire source string and returns the token stream.
|
|
53
|
+
* The last token in the stream is always an `EOF` token.
|
|
54
|
+
*
|
|
55
|
+
* Calling `tokenize()` more than once on the same instance returns a new
|
|
56
|
+
* stream from scratch (internal state is reset on construction, not here —
|
|
57
|
+
* create a new Lexer for each source string).
|
|
58
|
+
*/
|
|
59
|
+
tokenize(): Token[];
|
|
60
|
+
/**
|
|
61
|
+
* Returns the character at the current position without consuming it.
|
|
62
|
+
* Returns an empty string if at end of input.
|
|
63
|
+
*/
|
|
64
|
+
private current;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the character at `pos + offset` without consuming it.
|
|
67
|
+
* Used for one-character lookahead (e.g. distinguishing `//` from `/`).
|
|
68
|
+
* Returns an empty string if the offset is out of bounds.
|
|
69
|
+
*/
|
|
70
|
+
private peek;
|
|
71
|
+
/**
|
|
72
|
+
* Consumes the current character, advances the position, and updates
|
|
73
|
+
* line/column tracking. Returns the consumed character.
|
|
74
|
+
* Line is incremented and column reset to 1 when a `\n` is consumed.
|
|
75
|
+
*/
|
|
76
|
+
private advance;
|
|
77
|
+
/** Returns true when all characters have been consumed. */
|
|
78
|
+
private isAtEnd;
|
|
79
|
+
/** Returns true for ASCII decimal digit characters. */
|
|
80
|
+
private isDigit;
|
|
81
|
+
/** Returns true for ASCII letters and underscore. */
|
|
82
|
+
private isAlpha;
|
|
83
|
+
/** Returns true for characters valid inside an identifier (letters, digits, underscore). */
|
|
84
|
+
private isAlphaNumeric;
|
|
85
|
+
/**
|
|
86
|
+
* Advances past spaces, tabs, and carriage returns.
|
|
87
|
+
* Newlines are NOT skipped — they are significant and emitted as tokens.
|
|
88
|
+
*/
|
|
89
|
+
private skipWhitespace;
|
|
90
|
+
/**
|
|
91
|
+
* Reads a `//` line comment from the current position to the end of the line.
|
|
92
|
+
* The returned value includes the `//` prefix.
|
|
93
|
+
* The terminating `\n` is NOT consumed — it will be emitted as a Newline token
|
|
94
|
+
* on the next iteration.
|
|
95
|
+
*/
|
|
96
|
+
private readLineComment;
|
|
97
|
+
/**
|
|
98
|
+
* Reads a double-quoted string literal from the current position.
|
|
99
|
+
* Handles backslash escape sequences by consuming both the `\` and the
|
|
100
|
+
* following character as a unit.
|
|
101
|
+
* The returned value includes the surrounding quotes.
|
|
102
|
+
* Unclosed strings (EOF before closing `"`) are returned as-is — the
|
|
103
|
+
* parser will report the error from context.
|
|
104
|
+
*/
|
|
105
|
+
private readString;
|
|
106
|
+
/**
|
|
107
|
+
* Reads an integer or float literal from the current position.
|
|
108
|
+
* A decimal point followed by at least one digit triggers float mode.
|
|
109
|
+
* The returned string is the raw source text — conversion to a number
|
|
110
|
+
* happens in the parser.
|
|
111
|
+
*/
|
|
112
|
+
private readNumber;
|
|
113
|
+
/**
|
|
114
|
+
* Reads an identifier (keyword or user-defined name) from the current position.
|
|
115
|
+
* Identifiers consist of letters, digits, and underscores.
|
|
116
|
+
* The caller is responsible for classifying the result via the keyword table.
|
|
117
|
+
*/
|
|
118
|
+
private readIdent;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=lexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../../src/lexer/lexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAA;AAuDjD,qBAAa,KAAK;IACd,4CAA4C;IAC5C,OAAO,CAAC,MAAM,CAAQ;IAEtB,yCAAyC;IACzC,OAAO,CAAC,GAAG,CAAY;IAEvB,6EAA6E;IAC7E,OAAO,CAAC,IAAI,CAAY;IAExB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAY;IAE1B,2DAA2D;IAC3D,OAAO,CAAC,MAAM,CAAc;gBAEhB,MAAM,EAAE,MAAM;IAM1B;;;;;;;OAOG;IACH,QAAQ,IAAI,KAAK,EAAE;IAkHnB;;;OAGG;IACH,OAAO,CAAC,OAAO;IAIf;;;;OAIG;IACH,OAAO,CAAC,IAAI;IAIZ;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAYf,2DAA2D;IAC3D,OAAO,CAAC,OAAO;IAIf,uDAAuD;IACvD,OAAO,CAAC,OAAO;IAIf,qDAAqD;IACrD,OAAO,CAAC,OAAO;IAIf,4FAA4F;IAC5F,OAAO,CAAC,cAAc;IAItB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAWtB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAQvB;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;IAiBlB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAelB;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAOpB"}
|