@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.
Files changed (41) hide show
  1. package/dist/analyser/analyser.d.ts +106 -0
  2. package/dist/analyser/analyser.d.ts.map +1 -0
  3. package/dist/analyser/analyser.js +291 -0
  4. package/dist/analyser/analyser.js.map +1 -0
  5. package/dist/analyser/diagnostics.d.ts +166 -0
  6. package/dist/analyser/diagnostics.d.ts.map +1 -0
  7. package/dist/analyser/diagnostics.js +139 -0
  8. package/dist/analyser/diagnostics.js.map +1 -0
  9. package/dist/analyser/workspace.d.ts +198 -0
  10. package/dist/analyser/workspace.d.ts.map +1 -0
  11. package/dist/analyser/workspace.js +403 -0
  12. package/dist/analyser/workspace.js.map +1 -0
  13. package/dist/index.d.ts +8 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +31 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/lexer/lexer.d.ts +120 -0
  18. package/dist/lexer/lexer.d.ts.map +1 -0
  19. package/dist/lexer/lexer.js +365 -0
  20. package/dist/lexer/lexer.js.map +1 -0
  21. package/dist/lexer/token.d.ts +247 -0
  22. package/dist/lexer/token.d.ts.map +1 -0
  23. package/dist/lexer/token.js +250 -0
  24. package/dist/lexer/token.js.map +1 -0
  25. package/dist/parser/ast.d.ts +685 -0
  26. package/dist/parser/ast.d.ts.map +1 -0
  27. package/dist/parser/ast.js +3 -0
  28. package/dist/parser/ast.js.map +1 -0
  29. package/dist/parser/parser.d.ts +411 -0
  30. package/dist/parser/parser.d.ts.map +1 -0
  31. package/dist/parser/parser.js +1600 -0
  32. package/dist/parser/parser.js.map +1 -0
  33. package/package.json +23 -0
  34. package/src/analyser/analyser.ts +403 -0
  35. package/src/analyser/diagnostics.ts +232 -0
  36. package/src/analyser/workspace.ts +457 -0
  37. package/src/index.ts +7 -0
  38. package/src/lexer/lexer.ts +379 -0
  39. package/src/lexer/token.ts +331 -0
  40. package/src/parser/ast.ts +798 -0
  41. package/src/parser/parser.ts +1815 -0
@@ -0,0 +1,365 @@
1
+ "use strict";
2
+ /**
3
+ * lexer.ts
4
+ *
5
+ * The WORDS lexer. Converts a raw `.wds` source string into a flat array
6
+ * of tokens that the parser consumes.
7
+ *
8
+ * Design principles:
9
+ *
10
+ * - Single-pass, character-by-character. No regular expressions at runtime —
11
+ * all character classification is done with simple comparisons.
12
+ *
13
+ * - Never throws. Unrecognised characters are emitted as `Unknown` tokens so
14
+ * the parser can continue and collect all errors in one pass rather than
15
+ * stopping at the first problem.
16
+ *
17
+ * - `is not` is normalised into a single `IsNot` token during lexing.
18
+ * This simplifies the parser — it never has to handle a two-token sequence
19
+ * in conditional expressions.
20
+ *
21
+ * - Newlines are emitted as `Newline` tokens. The parser uses them to
22
+ * distinguish a bare ownership declaration (`module AuthModule` on its own
23
+ * line) from a construct body opening (`module AuthModule "..." (`).
24
+ *
25
+ * - Comments are included in the token stream (not silently discarded) so the
26
+ * parser can attach them to adjacent nodes for hover documentation.
27
+ *
28
+ * - Method names, callback prop names, and handler method names are all plain
29
+ * camelCase identifiers. Names like `switch`, `onLoad`, `onSubmit` carry no
30
+ * special meaning to the lexer — they are emitted as CamelIdent tokens.
31
+ *
32
+ * - Position tracking (line, column, offset) is maintained for every token
33
+ * so the LSP can report diagnostics and resolve go-to-definition requests
34
+ * at the exact source location.
35
+ */
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.Lexer = void 0;
38
+ const token_1 = require("./token");
39
+ // ── Keyword table ─────────────────────────────────────────────────────────────
40
+ /**
41
+ * Maps every reserved word in WORDS to its token type.
42
+ * Identifiers not found in this table are classified as PascalIdent or
43
+ * CamelIdent based on their first character.
44
+ *
45
+ * Note: `true` and `false` are listed here so they are never accidentally
46
+ * emitted as plain identifiers.
47
+ *
48
+ * Intentionally NOT in this table — these are all plain camelCase names
49
+ * chosen by the designer with no special language meaning:
50
+ * - Method names (e.g. `switch`, `login`, `getProducts`, `clear`)
51
+ * - Callback prop names (e.g. `onSubmit`, `onConfirm`, `onLoad`, `onDismiss`)
52
+ * - Handler method names (e.g. `switch` on a handler interface)
53
+ * - Iteration variables (e.g. `notification`, `category`)
54
+ */
55
+ const KEYWORDS = {
56
+ system: token_1.TokenType.System,
57
+ module: token_1.TokenType.Module,
58
+ process: token_1.TokenType.Process,
59
+ state: token_1.TokenType.State,
60
+ context: token_1.TokenType.Context,
61
+ screen: token_1.TokenType.Screen,
62
+ view: token_1.TokenType.View,
63
+ provider: token_1.TokenType.Provider,
64
+ adapter: token_1.TokenType.Adapter,
65
+ interface: token_1.TokenType.Interface,
66
+ modules: token_1.TokenType.Modules,
67
+ props: token_1.TokenType.Props,
68
+ uses: token_1.TokenType.Uses,
69
+ returns: token_1.TokenType.Returns,
70
+ receives: token_1.TokenType.Receives,
71
+ start: token_1.TokenType.Start,
72
+ implements: token_1.TokenType.Implements,
73
+ when: token_1.TokenType.When,
74
+ enter: token_1.TokenType.Enter,
75
+ if: token_1.TokenType.If,
76
+ for: token_1.TokenType.For,
77
+ as: token_1.TokenType.As,
78
+ is: token_1.TokenType.Is,
79
+ true: token_1.TokenType.BooleanLit,
80
+ false: token_1.TokenType.BooleanLit,
81
+ string: token_1.TokenType.TString,
82
+ integer: token_1.TokenType.TInteger,
83
+ float: token_1.TokenType.TFloat,
84
+ boolean: token_1.TokenType.TBoolean,
85
+ list: token_1.TokenType.TList,
86
+ map: token_1.TokenType.TMap,
87
+ };
88
+ // ── Lexer class ───────────────────────────────────────────────────────────────
89
+ class Lexer {
90
+ constructor(source) {
91
+ /** Current byte offset into `source`. */
92
+ this.pos = 0;
93
+ /** Current 1-based line number. Incremented each time a `\n` is consumed. */
94
+ this.line = 1;
95
+ /**
96
+ * Current 1-based column number.
97
+ * Reset to 1 after each newline; incremented after each other character.
98
+ */
99
+ this.column = 1;
100
+ /** Accumulated token stream. Populated by `tokenize()`. */
101
+ this.tokens = [];
102
+ this.source = source;
103
+ }
104
+ // ── Public API ─────────────────────────────────────────────────────────────
105
+ /**
106
+ * Tokenizes the entire source string and returns the token stream.
107
+ * The last token in the stream is always an `EOF` token.
108
+ *
109
+ * Calling `tokenize()` more than once on the same instance returns a new
110
+ * stream from scratch (internal state is reset on construction, not here —
111
+ * create a new Lexer for each source string).
112
+ */
113
+ tokenize() {
114
+ while (!this.isAtEnd()) {
115
+ // Skip horizontal whitespace between tokens.
116
+ // Newlines are NOT skipped here — they are emitted as Newline tokens.
117
+ this.skipWhitespace();
118
+ if (this.isAtEnd())
119
+ break;
120
+ const start = this.pos;
121
+ const startLine = this.line;
122
+ const startCol = this.column;
123
+ const ch = this.current();
124
+ // ── Line comment ─────────────────────────────────────────────────────
125
+ if (ch === '/' && this.peek(1) === '/') {
126
+ const comment = this.readLineComment();
127
+ this.tokens.push((0, token_1.token)(token_1.TokenType.Comment, comment, startLine, startCol, start));
128
+ continue;
129
+ }
130
+ // ── String literal ───────────────────────────────────────────────────
131
+ if (ch === '"') {
132
+ const str = this.readString();
133
+ this.tokens.push((0, token_1.token)(token_1.TokenType.StringLit, str, startLine, startCol, start));
134
+ continue;
135
+ }
136
+ // ── Number literal ───────────────────────────────────────────────────
137
+ // Integers and floats are distinguished by the presence of a decimal point.
138
+ if (this.isDigit(ch)) {
139
+ const num = this.readNumber();
140
+ const type = num.includes('.') ? token_1.TokenType.FloatLit : token_1.TokenType.IntegerLit;
141
+ this.tokens.push((0, token_1.token)(type, num, startLine, startCol, start));
142
+ continue;
143
+ }
144
+ // ── Identifier or keyword ────────────────────────────────────────────
145
+ if (this.isAlpha(ch) || ch === '_') {
146
+ const ident = this.readIdent();
147
+ // Special case: 'is not' — look ahead past any whitespace to see if
148
+ // the next word is 'not'. If so, consume it and emit a single IsNot
149
+ // token. This keeps the parser free from two-token handling in conditions.
150
+ if (ident === 'is') {
151
+ const savedPos = this.pos;
152
+ const savedLine = this.line;
153
+ const savedCol = this.column;
154
+ this.skipWhitespace();
155
+ if (this.source.startsWith('not', this.pos) &&
156
+ !this.isAlphaNumeric(this.source[this.pos + 3] ?? '')) {
157
+ this.pos += 3;
158
+ this.column += 3;
159
+ this.tokens.push((0, token_1.token)(token_1.TokenType.IsNot, 'is not', startLine, startCol, start));
160
+ continue;
161
+ }
162
+ // Not 'is not' — restore position and emit plain Is.
163
+ this.pos = savedPos;
164
+ this.line = savedLine;
165
+ this.column = savedCol;
166
+ }
167
+ // Look up keyword table; fall through to identifier classification.
168
+ const kwType = KEYWORDS[ident];
169
+ if (kwType !== undefined) {
170
+ this.tokens.push((0, token_1.token)(kwType, ident, startLine, startCol, start));
171
+ }
172
+ else if (/^[A-Z]/.test(ident)) {
173
+ // PascalCase → construct name or type reference
174
+ this.tokens.push((0, token_1.token)(token_1.TokenType.PascalIdent, ident, startLine, startCol, start));
175
+ }
176
+ else {
177
+ // camelCase → prop name, method name, handler method name, or
178
+ // iteration variable. This includes all designer-chosen names
179
+ // such as `switch`, `onLoad`, `onSubmit`, `onConfirm`, etc.
180
+ this.tokens.push((0, token_1.token)(token_1.TokenType.CamelIdent, ident, startLine, startCol, start));
181
+ }
182
+ continue;
183
+ }
184
+ // ── Optional marker ──────────────────────────────────────────────────
185
+ // `?` always immediately precedes a PascalCase type name.
186
+ if (ch === '?') {
187
+ this.advance();
188
+ this.tokens.push((0, token_1.token)(token_1.TokenType.Question, '?', startLine, startCol, start));
189
+ continue;
190
+ }
191
+ // ── Punctuation ──────────────────────────────────────────────────────
192
+ if (ch === '(') {
193
+ this.advance();
194
+ this.tokens.push((0, token_1.token)(token_1.TokenType.LParen, '(', startLine, startCol, start));
195
+ continue;
196
+ }
197
+ if (ch === ')') {
198
+ this.advance();
199
+ this.tokens.push((0, token_1.token)(token_1.TokenType.RParen, ')', startLine, startCol, start));
200
+ continue;
201
+ }
202
+ if (ch === ',') {
203
+ this.advance();
204
+ this.tokens.push((0, token_1.token)(token_1.TokenType.Comma, ',', startLine, startCol, start));
205
+ continue;
206
+ }
207
+ if (ch === '.') {
208
+ this.advance();
209
+ this.tokens.push((0, token_1.token)(token_1.TokenType.Dot, '.', startLine, startCol, start));
210
+ continue;
211
+ }
212
+ // ── Newline ──────────────────────────────────────────────────────────
213
+ // Emitted as a token so the parser can detect line boundaries.
214
+ // The line counter is incremented inside `advance()`.
215
+ if (ch === '\n') {
216
+ this.tokens.push((0, token_1.token)(token_1.TokenType.Newline, '\n', startLine, startCol, start));
217
+ this.advance();
218
+ continue;
219
+ }
220
+ // ── Unknown ──────────────────────────────────────────────────────────
221
+ // Emit and continue rather than throwing, so all errors can be collected.
222
+ this.tokens.push((0, token_1.token)(token_1.TokenType.Unknown, ch, startLine, startCol, start));
223
+ this.advance();
224
+ }
225
+ // EOF sentinel — always the last token.
226
+ this.tokens.push((0, token_1.token)(token_1.TokenType.EOF, '', this.line, this.column, this.pos));
227
+ return this.tokens;
228
+ }
229
+ // ── Private helpers ────────────────────────────────────────────────────────
230
+ /**
231
+ * Returns the character at the current position without consuming it.
232
+ * Returns an empty string if at end of input.
233
+ */
234
+ current() {
235
+ return this.source[this.pos] ?? '';
236
+ }
237
+ /**
238
+ * Returns the character at `pos + offset` without consuming it.
239
+ * Used for one-character lookahead (e.g. distinguishing `//` from `/`).
240
+ * Returns an empty string if the offset is out of bounds.
241
+ */
242
+ peek(offset) {
243
+ return this.source[this.pos + offset] ?? '';
244
+ }
245
+ /**
246
+ * Consumes the current character, advances the position, and updates
247
+ * line/column tracking. Returns the consumed character.
248
+ * Line is incremented and column reset to 1 when a `\n` is consumed.
249
+ */
250
+ advance() {
251
+ const ch = this.source[this.pos];
252
+ if (ch === '\n') {
253
+ this.line++;
254
+ this.column = 1;
255
+ }
256
+ else {
257
+ this.column++;
258
+ }
259
+ this.pos++;
260
+ return ch ?? '';
261
+ }
262
+ /** Returns true when all characters have been consumed. */
263
+ isAtEnd() {
264
+ return this.pos >= this.source.length;
265
+ }
266
+ /** Returns true for ASCII decimal digit characters. */
267
+ isDigit(ch) {
268
+ return ch >= '0' && ch <= '9';
269
+ }
270
+ /** Returns true for ASCII letters and underscore. */
271
+ isAlpha(ch) {
272
+ return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch === '_';
273
+ }
274
+ /** Returns true for characters valid inside an identifier (letters, digits, underscore). */
275
+ isAlphaNumeric(ch) {
276
+ return this.isAlpha(ch) || this.isDigit(ch);
277
+ }
278
+ /**
279
+ * Advances past spaces, tabs, and carriage returns.
280
+ * Newlines are NOT skipped — they are significant and emitted as tokens.
281
+ */
282
+ skipWhitespace() {
283
+ while (!this.isAtEnd()) {
284
+ const ch = this.current();
285
+ if (ch === ' ' || ch === '\t' || ch === '\r') {
286
+ this.advance();
287
+ }
288
+ else {
289
+ break;
290
+ }
291
+ }
292
+ }
293
+ /**
294
+ * Reads a `//` line comment from the current position to the end of the line.
295
+ * The returned value includes the `//` prefix.
296
+ * The terminating `\n` is NOT consumed — it will be emitted as a Newline token
297
+ * on the next iteration.
298
+ */
299
+ readLineComment() {
300
+ let result = '';
301
+ while (!this.isAtEnd() && this.current() !== '\n') {
302
+ result += this.advance();
303
+ }
304
+ return result;
305
+ }
306
+ /**
307
+ * Reads a double-quoted string literal from the current position.
308
+ * Handles backslash escape sequences by consuming both the `\` and the
309
+ * following character as a unit.
310
+ * The returned value includes the surrounding quotes.
311
+ * Unclosed strings (EOF before closing `"`) are returned as-is — the
312
+ * parser will report the error from context.
313
+ */
314
+ readString() {
315
+ let result = '"';
316
+ this.advance(); // consume opening quote
317
+ while (!this.isAtEnd() && this.current() !== '"') {
318
+ if (this.current() === '\\') {
319
+ result += this.advance(); // backslash
320
+ result += this.advance(); // escaped character
321
+ }
322
+ else {
323
+ result += this.advance();
324
+ }
325
+ }
326
+ if (!this.isAtEnd()) {
327
+ result += this.advance(); // consume closing quote
328
+ }
329
+ return result;
330
+ }
331
+ /**
332
+ * Reads an integer or float literal from the current position.
333
+ * A decimal point followed by at least one digit triggers float mode.
334
+ * The returned string is the raw source text — conversion to a number
335
+ * happens in the parser.
336
+ */
337
+ readNumber() {
338
+ let result = '';
339
+ while (!this.isAtEnd() && this.isDigit(this.current())) {
340
+ result += this.advance();
341
+ }
342
+ // Check for decimal point followed by a digit — if so, continue as float.
343
+ if (!this.isAtEnd() && this.current() === '.' && this.isDigit(this.peek(1))) {
344
+ result += this.advance(); // consume '.'
345
+ while (!this.isAtEnd() && this.isDigit(this.current())) {
346
+ result += this.advance();
347
+ }
348
+ }
349
+ return result;
350
+ }
351
+ /**
352
+ * Reads an identifier (keyword or user-defined name) from the current position.
353
+ * Identifiers consist of letters, digits, and underscores.
354
+ * The caller is responsible for classifying the result via the keyword table.
355
+ */
356
+ readIdent() {
357
+ let result = '';
358
+ while (!this.isAtEnd() && this.isAlphaNumeric(this.current())) {
359
+ result += this.advance();
360
+ }
361
+ return result;
362
+ }
363
+ }
364
+ exports.Lexer = Lexer;
365
+ //# sourceMappingURL=lexer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../src/lexer/lexer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;AAEH,mCAAiD;AAEjD,iFAAiF;AAEjF;;;;;;;;;;;;;;GAcG;AACH,MAAM,QAAQ,GAA8B;IACxC,MAAM,EAAE,iBAAS,CAAC,MAAM;IACxB,MAAM,EAAE,iBAAS,CAAC,MAAM;IACxB,OAAO,EAAE,iBAAS,CAAC,OAAO;IAC1B,KAAK,EAAE,iBAAS,CAAC,KAAK;IACtB,OAAO,EAAE,iBAAS,CAAC,OAAO;IAC1B,MAAM,EAAE,iBAAS,CAAC,MAAM;IACxB,IAAI,EAAE,iBAAS,CAAC,IAAI;IACpB,QAAQ,EAAE,iBAAS,CAAC,QAAQ;IAC5B,OAAO,EAAE,iBAAS,CAAC,OAAO;IAC1B,SAAS,EAAE,iBAAS,CAAC,SAAS;IAC9B,OAAO,EAAE,iBAAS,CAAC,OAAO;IAC1B,KAAK,EAAE,iBAAS,CAAC,KAAK;IACtB,IAAI,EAA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SD,sBAgSC"}
@@ -0,0 +1,247 @@
1
+ /**
2
+ * token.ts
3
+ *
4
+ * Defines every token type the WORDS lexer can produce, the Token interface
5
+ * that carries a token's value and source location, and a convenience
6
+ * constructor for creating tokens in tests and the lexer itself.
7
+ */
8
+ /**
9
+ * Every token type the WORDS lexer can produce.
10
+ *
11
+ * Grouped by category:
12
+ * - Top-level construct keywords (system, module, state, ...)
13
+ * - Block keywords (modules, props, uses, returns, ...)
14
+ * - Process / transition keywords (when, enter)
15
+ * - Control flow keywords (if, for, as, is, is not)
16
+ * - Primitive types (tstring, tinteger, ...)
17
+ * - Literals (string_lit, integer_lit, ...)
18
+ * - Identifiers (pascal_ident, camel_ident)
19
+ * - Punctuation ((, ), ,, .)
20
+ * - Special (comment, newline, eof, unknown)
21
+ *
22
+ * Enum values are the string representation of each token — useful for
23
+ * readable error messages and debug output without a separate lookup table.
24
+ *
25
+ * Note on naming conventions: method names, callback prop names, and handler
26
+ * method names (including names like `switch`, `onLoad`, `onSubmit`) are all
27
+ * plain camelCase identifiers chosen by the designer. None of them are
28
+ * reserved keywords in the WORDS language.
29
+ */
30
+ export declare enum TokenType {
31
+ /** `system` — opens the system declaration. Appears exactly once per project. */
32
+ System = "system",
33
+ /**
34
+ * `module` — opens a module definition body, or appears alone on a line
35
+ * as an ownership declaration at the top of component files.
36
+ * e.g. `module AuthModule` (ownership) or `module AuthModule "..." (` (definition)
37
+ */
38
+ Module = "module",
39
+ /** `process` — opens a process definition inside a module body. */
40
+ Process = "process",
41
+ /** `state` — opens a state definition. */
42
+ State = "state",
43
+ /** `context` — opens a context definition. */
44
+ Context = "context",
45
+ /** `screen` — opens a screen definition, or activates a screen inside a `uses` block. */
46
+ Screen = "screen",
47
+ /**
48
+ * `view` — opens a view definition, or activates a view inside a `uses` block.
49
+ * e.g. `view LoginFormSection "..." (` or `view UIModule.LoginForm (`
50
+ */
51
+ View = "view",
52
+ /** `provider` — opens a provider definition, or activates a provider in a `uses` block. */
53
+ Provider = "provider",
54
+ /**
55
+ * `adapter` — opens an adapter definition, or activates an adapter in a `uses` block.
56
+ * e.g. `adapter AuthAdapter.login credentials is state.context`
57
+ */
58
+ Adapter = "adapter",
59
+ /**
60
+ * `interface` — opens an interface component definition, activates one in a
61
+ * `uses` block, or introduces an inline interface block inside a module body.
62
+ */
63
+ Interface = "interface",
64
+ /** `modules` — opens the module list inside a system body. */
65
+ Modules = "modules",
66
+ /** `props` — opens the props block inside a view, provider, adapter, or interface. */
67
+ Props = "props",
68
+ /** `uses` — opens the uses block inside a state, screen, view, provider, or interface. */
69
+ Uses = "uses",
70
+ /**
71
+ * `returns` — appears in two roles:
72
+ * 1. Opens the returns clause inside a state: `returns AccountCredentials`
73
+ * 2. Declares the return type of a method: `getProducts returns(list(Product))`
74
+ */
75
+ Returns = "returns",
76
+ /**
77
+ * `receives` — opens the receives clause on a state definition.
78
+ * e.g. `state Unauthenticated receives ?AuthError`
79
+ */
80
+ Receives = "receives",
81
+ /**
82
+ * `start` — names the initial state of a module.
83
+ * e.g. `start Unauthenticated`
84
+ */
85
+ Start = "start",
86
+ /**
87
+ * `implements` — opens a cross-module handler implementation block
88
+ * inside a module body.
89
+ * e.g. `implements RoutingModule.RouteSwitchHandler (`
90
+ */
91
+ Implements = "implements",
92
+ /**
93
+ * `when` — opens a transition rule inside a process body.
94
+ * e.g. `when Unauthenticated returns AccountCredentials`
95
+ */
96
+ When = "when",
97
+ /**
98
+ * `enter` — names the next state to transition to in a `when` rule
99
+ * or an `implements` branch.
100
+ * e.g. `enter StartAuthenticating "The user tries to authenticate"`
101
+ */
102
+ Enter = "enter",
103
+ /**
104
+ * `if` — opens a conditional block inside a `uses` block or an
105
+ * `implements` handler body.
106
+ * e.g. `if state.context is AccountDeauthenticated (`
107
+ */
108
+ If = "if",
109
+ /**
110
+ * `for` — opens an iteration block inside a `uses` block.
111
+ * e.g. `for state.context.notifications as notification (`
112
+ */
113
+ For = "for",
114
+ /**
115
+ * `as` — binds the iteration variable(s) in a `for` block.
116
+ * For lists: `as notification` — one binding.
117
+ * For maps: `as category, products` — two bindings.
118
+ */
119
+ As = "as",
120
+ /**
121
+ * `is` — the assignment and equality operator.
122
+ * As assignment: `type is "warning"`, `path is "/home"`
123
+ * As comparison: `if state.context is AccountDeauthenticated`
124
+ * Context determines which role it plays.
125
+ */
126
+ Is = "is",
127
+ /**
128
+ * `is not` — the inequality operator, normalised from the two-word
129
+ * sequence `is not` into a single token during lexing.
130
+ * e.g. `if state.context is not AccountRecovered`
131
+ */
132
+ IsNot = "is_not",
133
+ /** `string` — text value type. Default: `""` */
134
+ TString = "tstring",
135
+ /** `integer` — whole number type. Default: `0` */
136
+ TInteger = "tinteger",
137
+ /** `float` — decimal number type. Default: `0.0` */
138
+ TFloat = "tfloat",
139
+ /** `boolean` — true/false type. Default: `false` */
140
+ TBoolean = "tboolean",
141
+ /**
142
+ * `context` — opaque context type used only in the system interface
143
+ * declaration for `getContext` and `setContext`.
144
+ */
145
+ TContext = "tcontext",
146
+ /** `list` — ordered collection type. Parameterised: `list(Product)`. Default: `[]` */
147
+ TList = "tlist",
148
+ /** `map` — key-value collection type. Parameterised: `map(string, OrderSummary)`. Default: `{}` */
149
+ TMap = "tmap",
150
+ /**
151
+ * A double-quoted string literal.
152
+ * The token value includes the surrounding quotes.
153
+ * e.g. `"The user authenticated successfully"`, `"/home"`
154
+ */
155
+ StringLit = "string_lit",
156
+ /**
157
+ * A whole number literal.
158
+ * e.g. `42`, `5000`, `0`
159
+ */
160
+ IntegerLit = "integer_lit",
161
+ /**
162
+ * A decimal number literal.
163
+ * e.g. `0.0`, `3.14`
164
+ */
165
+ FloatLit = "float_lit",
166
+ /**
167
+ * A boolean literal — `true` or `false`.
168
+ * Lexed as keyword-style tokens with value `"true"` or `"false"`.
169
+ */
170
+ BooleanLit = "boolean_lit",
171
+ /**
172
+ * A PascalCase identifier — names a construct (state, context, module, etc.)
173
+ * or a type reference.
174
+ * e.g. `AuthModule`, `AccountCredentials`, `LoginScreen`, `Product`
175
+ */
176
+ PascalIdent = "pascal_ident",
177
+ /**
178
+ * A camelCase identifier — names a prop, method, argument, or iteration variable.
179
+ * This includes all designer-chosen names: callback prop names, method names,
180
+ * and handler method names regardless of what they are called.
181
+ * e.g. `onSubmit`, `credentials`, `fullName`, `notification`, `switch`, `onLoad`
182
+ */
183
+ CamelIdent = "camel_ident",
184
+ /** `(` — opens a body block or argument list. */
185
+ LParen = "(",
186
+ /** `)` — closes a body block or argument list. */
187
+ RParen = ")",
188
+ /** `,` — separates entries in a list — props, arguments, context names. */
189
+ Comma = ",",
190
+ /** `.` — separates parts of a qualified name or access expression. */
191
+ Dot = ".",
192
+ /**
193
+ * `?` — marks an optional type or receives clause.
194
+ * e.g. `?AuthError`, `?Product`
195
+ * Always immediately precedes a PascalIdent.
196
+ */
197
+ Question = "?",
198
+ /**
199
+ * A `//` line comment. The token value includes the `//` prefix and
200
+ * everything up to (but not including) the newline.
201
+ * Comments are included in the token stream so the parser can attach
202
+ * them to adjacent nodes for hover documentation.
203
+ */
204
+ Comment = "comment",
205
+ /**
206
+ * A newline character `\n`.
207
+ * Newlines are significant in WORDS for distinguishing an ownership
208
+ * declaration (`module AuthModule` on its own line) from a construct
209
+ * opening (`module AuthModule "..." (`).
210
+ */
211
+ Newline = "newline",
212
+ /**
213
+ * End of file sentinel. Always the last token in the stream.
214
+ * The parser uses this to detect unexpected end of input.
215
+ */
216
+ EOF = "eof",
217
+ /**
218
+ * An unrecognised character. Emitted rather than throwing so the lexer
219
+ * can continue and collect all errors in a single pass.
220
+ */
221
+ Unknown = "unknown"
222
+ }
223
+ /**
224
+ * A single token produced by the lexer.
225
+ *
226
+ * `type` — the token's category, used by the parser for matching.
227
+ * `value` — the raw source text that produced this token. For string
228
+ * literals this includes the surrounding quotes. For `is not`
229
+ * this is the normalised string `"is not"`.
230
+ * `line` — 1-based line number of the token's first character.
231
+ * `column` — 1-based column number of the token's first character.
232
+ * `offset` — byte offset from the start of the source string. Used by the
233
+ * LSP to convert between source positions and editor positions.
234
+ */
235
+ export interface Token {
236
+ type: TokenType;
237
+ value: string;
238
+ line: number;
239
+ column: number;
240
+ offset: number;
241
+ }
242
+ /**
243
+ * Creates a Token with the given fields.
244
+ * Used internally by the lexer and in tests to avoid repetitive object literals.
245
+ */
246
+ export declare function token(type: TokenType, value: string, line: number, column: number, offset: number): Token;
247
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/lexer/token.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,oBAAY,SAAS;IAMnB,iFAAiF;IACjF,MAAM,WAAW;IAEjB;;;;OAIG;IACH,MAAM,WAAW;IAEjB,mEAAmE;IACnE,OAAO,YAAY;IAEnB,0CAA0C;IAC1C,KAAK,UAAU;IAEf,8CAA8C;IAC9C,OAAO,YAAY;IAEnB,yFAAyF;IACzF,MAAM,WAAW;IAEjB;;;OAGG;IACH,IAAI,SAAS;IAEb,2FAA2F;IAC3F,QAAQ,aAAa;IAErB;;;OAGG;IACH,OAAO,YAAY;IAEnB;;;OAGG;IACH,SAAS,cAAc;IAKvB,8DAA8D;IAC9D,OAAO,YAAY;IAEnB,sFAAsF;IACtF,KAAK,UAAU;IAEf,0FAA0F;IAC1F,IAAI,SAAS;IAEb;;;;OAIG;IACH,OAAO,YAAY;IAEnB;;;OAGG;IACH,QAAQ,aAAa;IAErB;;;OAGG;IACH,KAAK,UAAU;IAEf;;;;OAIG;IACH,UAAU,eAAe;IAIzB;;;OAGG;IACH,IAAI,SAAS;IAEb;;;;OAIG;IACH,KAAK,UAAU;IAIf;;;;OAIG;IACH,EAAE,OAAO;IAET;;;OAGG;IACH,GAAG,QAAQ;IAEX;;;;OAIG;IACH,EAAE,OAAO;IAET;;;;;OAKG;IACH,EAAE,OAAO;IAET;;;;OAIG;IACH,KAAK,WAAW;IAKhB,gDAAgD;IAChD,OAAO,YAAY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