@katnip-org/compiler 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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +42 -0
- package/build/cli.d.ts +2 -0
- package/build/cli.js +141 -0
- package/build/cli.js.map +1 -0
- package/build/codegen/SB3Generator.d.ts +1 -0
- package/build/codegen/SB3Generator.js +2 -0
- package/build/codegen/SB3Generator.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +26 -0
- package/build/index.js.map +1 -0
- package/build/ir/IRGenerator.d.ts +1 -0
- package/build/ir/IRGenerator.js +2 -0
- package/build/ir/IRGenerator.js.map +1 -0
- package/build/ir/IRNode.d.ts +1 -0
- package/build/ir/IRNode.js +2 -0
- package/build/ir/IRNode.js.map +1 -0
- package/build/lexer/Lexer.d.ts +69 -0
- package/build/lexer/Lexer.js +441 -0
- package/build/lexer/Lexer.js.map +1 -0
- package/build/lexer/LexerState.d.ts +14 -0
- package/build/lexer/LexerState.js +16 -0
- package/build/lexer/LexerState.js.map +1 -0
- package/build/lexer/Token.d.ts +105 -0
- package/build/lexer/Token.js +114 -0
- package/build/lexer/Token.js.map +1 -0
- package/build/parser/AST-nodes.d.ts +230 -0
- package/build/parser/AST-nodes.js +10 -0
- package/build/parser/AST-nodes.js.map +1 -0
- package/build/parser/BindingPowerTable.d.ts +8 -0
- package/build/parser/BindingPowerTable.js +37 -0
- package/build/parser/BindingPowerTable.js.map +1 -0
- package/build/parser/Parser.d.ts +208 -0
- package/build/parser/Parser.js +1215 -0
- package/build/parser/Parser.js.map +1 -0
- package/build/semantic/InternalTypes.d.ts +43 -0
- package/build/semantic/InternalTypes.js +95 -0
- package/build/semantic/InternalTypes.js.map +1 -0
- package/build/semantic/SemanticAnalyzer.d.ts +109 -0
- package/build/semantic/SemanticAnalyzer.js +998 -0
- package/build/semantic/SemanticAnalyzer.js.map +1 -0
- package/build/semantic/StdlibLoader.d.ts +18 -0
- package/build/semantic/StdlibLoader.js +42 -0
- package/build/semantic/StdlibLoader.js.map +1 -0
- package/build/semantic/SymbolTable.d.ts +64 -0
- package/build/semantic/SymbolTable.js +28 -0
- package/build/semantic/SymbolTable.js.map +1 -0
- package/build/utils/ErrorReporter.d.ts +29 -0
- package/build/utils/ErrorReporter.js +84 -0
- package/build/utils/ErrorReporter.js.map +1 -0
- package/build/utils/Logger.d.ts +32 -0
- package/build/utils/Logger.js +62 -0
- package/build/utils/Logger.js.map +1 -0
- package/build/utils/colors.d.ts +8 -0
- package/build/utils/colors.js +14 -0
- package/build/utils/colors.js.map +1 -0
- package/package.json +58 -0
- package/stdlib/clone.knip +5 -0
- package/stdlib/console.knip +6 -0
- package/stdlib/control.knip +3 -0
- package/stdlib/dict.knip +7 -0
- package/stdlib/events.knip +3 -0
- package/stdlib/list.knip +10 -0
- package/stdlib/looks.knip +4 -0
- package/stdlib/math.knip +7 -0
- package/stdlib/motion.knip +25 -0
- package/stdlib/pen.knip +14 -0
- package/stdlib/prelude.knip +25 -0
- package/stdlib/str.knip +3 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Contains the main lexer class for the Katnip compiler.
|
|
3
|
+
*/
|
|
4
|
+
import { isUnitTokenType, isValuedTokenType, unitTokenByLexeme, operatorTrie, singleCharUnitTokens } from "./Token.js";
|
|
5
|
+
import { LexerState } from "./LexerState.js";
|
|
6
|
+
import { ErrorReporter, KatnipError } from "../utils/ErrorReporter.js";
|
|
7
|
+
import { Logger, KatnipLog, KatnipLogType } from "../utils/Logger.js";
|
|
8
|
+
export class Lexer {
|
|
9
|
+
reporter;
|
|
10
|
+
logger;
|
|
11
|
+
// Lexer traversal position
|
|
12
|
+
src = "";
|
|
13
|
+
position = 0;
|
|
14
|
+
line = 1;
|
|
15
|
+
lineStart = 0;
|
|
16
|
+
col = 1;
|
|
17
|
+
colStart = 1;
|
|
18
|
+
// Lexer states
|
|
19
|
+
currentState = LexerState.Start;
|
|
20
|
+
buffer = "";
|
|
21
|
+
stringQuote = null;
|
|
22
|
+
isInterpolatedString = false;
|
|
23
|
+
inInterpolatedExpression = false;
|
|
24
|
+
interpolatedBraceDepth = 0;
|
|
25
|
+
commentType = "";
|
|
26
|
+
operatorNode = null;
|
|
27
|
+
lastValidOperatorNode = null;
|
|
28
|
+
// Emitted tokens
|
|
29
|
+
tokens = [];
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new Lexer instance.
|
|
32
|
+
*/
|
|
33
|
+
constructor(reporter, logger = new Logger()) {
|
|
34
|
+
this.reporter = reporter;
|
|
35
|
+
this.logger = logger;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Tokenizes the provided source code into an array of tokens.
|
|
39
|
+
*
|
|
40
|
+
* @param src Source code to tokenize.
|
|
41
|
+
* @returns The tokens extracted from the source code.
|
|
42
|
+
*/
|
|
43
|
+
tokenize(src) {
|
|
44
|
+
this.logger.print(new KatnipLog(KatnipLogType.Info, `--- Lexing started with ${src.length} characters ---`));
|
|
45
|
+
this.src = src.replaceAll(/\x04/g, "").replaceAll("\r", ""); // Remove any existing EOF characters
|
|
46
|
+
this.src += "\x04"; // EOF Sentinel
|
|
47
|
+
this.position = 0;
|
|
48
|
+
this.line = 1;
|
|
49
|
+
this.lineStart = 0;
|
|
50
|
+
this.col = 1;
|
|
51
|
+
this.colStart = 1;
|
|
52
|
+
this.currentState = LexerState.Start;
|
|
53
|
+
this.buffer = "";
|
|
54
|
+
this.stringQuote = null;
|
|
55
|
+
this.isInterpolatedString = false;
|
|
56
|
+
this.inInterpolatedExpression = false;
|
|
57
|
+
this.interpolatedBraceDepth = 0;
|
|
58
|
+
this.commentType = "";
|
|
59
|
+
this.operatorNode = null;
|
|
60
|
+
this.operatorNode = null;
|
|
61
|
+
this.tokens = [];
|
|
62
|
+
while (this.position < this.src.length) {
|
|
63
|
+
const char = this.peek();
|
|
64
|
+
if (char === null) {
|
|
65
|
+
break; // End of input
|
|
66
|
+
}
|
|
67
|
+
this.processChar(char);
|
|
68
|
+
}
|
|
69
|
+
return this.tokens;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Emits a token based on the current buffer and resets the buffer.
|
|
73
|
+
*
|
|
74
|
+
* @param type The type of token to emit.
|
|
75
|
+
*/
|
|
76
|
+
emit(type) {
|
|
77
|
+
if (isValuedTokenType(type)) {
|
|
78
|
+
if (type !== "String" && type !== "InterpolatedString" && type !== "InterpolatedStringEnd") {
|
|
79
|
+
this.buffer = this.buffer.trim();
|
|
80
|
+
}
|
|
81
|
+
this.tokens.push({
|
|
82
|
+
token: { type, value: this.buffer },
|
|
83
|
+
start: { line: this.lineStart, column: this.colStart },
|
|
84
|
+
end: { line: this.line, column: this.col }
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else if (isUnitTokenType(type)) {
|
|
88
|
+
this.tokens.push({
|
|
89
|
+
token: { type },
|
|
90
|
+
start: { line: this.lineStart, column: this.colStart },
|
|
91
|
+
end: { line: this.line, column: this.col }
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
this.buffer = ""; // Reset buffer after emitting
|
|
95
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Peeks at the next character in the source code without consuming it.
|
|
99
|
+
*
|
|
100
|
+
* @param distance The number of characters to look ahead (default is 0).
|
|
101
|
+
* @returns The character at the specified distance or null if out of bounds.
|
|
102
|
+
*/
|
|
103
|
+
peek(distance = 0) {
|
|
104
|
+
if (this.position < this.src.length) {
|
|
105
|
+
return this.src[this.position + distance];
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Advances the lexer position by one character and updates line/column tracking.
|
|
111
|
+
*
|
|
112
|
+
* @returns The character that was advanced or null if at the end of input.
|
|
113
|
+
*/
|
|
114
|
+
advance(amount = 1) {
|
|
115
|
+
let char = this.peek();
|
|
116
|
+
for (let i = 0; i < amount; i++) {
|
|
117
|
+
char = this.peek();
|
|
118
|
+
if (char !== null) {
|
|
119
|
+
this.position++;
|
|
120
|
+
if (char === '\n') {
|
|
121
|
+
this.line++;
|
|
122
|
+
this.col = 1;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.col++;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return char;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Processes a single character from the source code and updates the lexer state.
|
|
133
|
+
*
|
|
134
|
+
* @param char The character to process.
|
|
135
|
+
*/
|
|
136
|
+
processChar(char) {
|
|
137
|
+
this.logger.log(new KatnipLog(KatnipLogType.Debug, `Lexer state: ${LexerState[this.currentState]}, char: '${char}'`, { line: this.line, column: this.col }));
|
|
138
|
+
if (this.currentState === LexerState.Start) {
|
|
139
|
+
this.processStartLike(char);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.processState(char);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
processStartLike(char) {
|
|
146
|
+
this.colStart = this.col; // Reset column start for new token
|
|
147
|
+
this.lineStart = this.line; // Reset line start for new token
|
|
148
|
+
if (/\s/.test(char)) {
|
|
149
|
+
// Whitespace
|
|
150
|
+
this.advance();
|
|
151
|
+
}
|
|
152
|
+
else if (/[a-zA-Z_]/.test(char)) {
|
|
153
|
+
// Identifier start
|
|
154
|
+
this.currentState = LexerState.Identifier;
|
|
155
|
+
this.buffer += this.advance();
|
|
156
|
+
}
|
|
157
|
+
else if (/[-0-9]/.test(char) || (/[.]/.test(char) && /[0-9]/.test(this.peek(1)))) {
|
|
158
|
+
if (/[.0-9]/.test(this.peek(1)) || /[0-9]/.test(char)) {
|
|
159
|
+
// Number literal start
|
|
160
|
+
this.currentState = LexerState.Number;
|
|
161
|
+
this.buffer += this.advance();
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
// Just a minus sign
|
|
165
|
+
this.currentState = LexerState.Operator;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else if (char === '"' || char === "'") {
|
|
169
|
+
// String literal start
|
|
170
|
+
this.stringQuote = char;
|
|
171
|
+
this.isInterpolatedString = false;
|
|
172
|
+
this.currentState = LexerState.String;
|
|
173
|
+
this.advance();
|
|
174
|
+
}
|
|
175
|
+
else if (char === '#') {
|
|
176
|
+
// Comment start
|
|
177
|
+
this.currentState = LexerState.Comment;
|
|
178
|
+
this.advance();
|
|
179
|
+
}
|
|
180
|
+
else if (singleCharUnitTokens.has(char)) {
|
|
181
|
+
this.currentState = LexerState.Operator;
|
|
182
|
+
this.operatorNode = operatorTrie.start();
|
|
183
|
+
}
|
|
184
|
+
else if (char === '\x04') {
|
|
185
|
+
this.advance(); // Consume EOF character
|
|
186
|
+
this.emit("<EOF>");
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this.reporter.add(new KatnipError("Lexer", `Unexpected character '${char}'`, { line: this.line, column: this.col }));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Processes the current state of the lexer based on the character and source code.
|
|
194
|
+
*
|
|
195
|
+
* @param char The current character being processed.
|
|
196
|
+
*/
|
|
197
|
+
processState(char) {
|
|
198
|
+
this.logger.log(new KatnipLog(KatnipLogType.Debug, `Lexer state: ${LexerState[this.currentState]}, char: '${char}', buffer: '${this.buffer}'`, { line: this.line, column: this.col }));
|
|
199
|
+
// State: Identifier
|
|
200
|
+
switch (this.currentState) {
|
|
201
|
+
case LexerState.Identifier:
|
|
202
|
+
if (this.buffer === "f" && (char === '"' || char === "'")) {
|
|
203
|
+
this.stringQuote = char;
|
|
204
|
+
this.isInterpolatedString = true;
|
|
205
|
+
this.buffer = "";
|
|
206
|
+
this.currentState = LexerState.String;
|
|
207
|
+
this.advance();
|
|
208
|
+
}
|
|
209
|
+
else if (/[a-zA-Z0-9_]/.test(char)) {
|
|
210
|
+
this.buffer += this.advance();
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this.emit("Identifier");
|
|
214
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
case LexerState.String:
|
|
218
|
+
if (this.isInterpolatedString && char === "{") {
|
|
219
|
+
this.emit("InterpolatedString");
|
|
220
|
+
this.buffer = "";
|
|
221
|
+
this.isInterpolatedString = true;
|
|
222
|
+
this.advance();
|
|
223
|
+
this.inInterpolatedExpression = true;
|
|
224
|
+
this.interpolatedBraceDepth = 0;
|
|
225
|
+
this.currentState = LexerState.InterpolatedExpression;
|
|
226
|
+
}
|
|
227
|
+
else if (char === this.stringQuote) {
|
|
228
|
+
this.advance();
|
|
229
|
+
this.emit(this.isInterpolatedString ? "InterpolatedString" : "String");
|
|
230
|
+
this.isInterpolatedString = false;
|
|
231
|
+
}
|
|
232
|
+
else if (char === '\\') {
|
|
233
|
+
// Handle escape sequences
|
|
234
|
+
this.buffer += this.advance();
|
|
235
|
+
this.currentState = LexerState.EscapedString;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
this.buffer += this.advance();
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
case LexerState.InterpolatedExpression:
|
|
242
|
+
if (char === "}") {
|
|
243
|
+
if (this.interpolatedBraceDepth === 0) {
|
|
244
|
+
this.lineStart = this.line;
|
|
245
|
+
this.colStart = this.col;
|
|
246
|
+
this.advance();
|
|
247
|
+
this.inInterpolatedExpression = false;
|
|
248
|
+
this.emit("InterpolatedStringEnd");
|
|
249
|
+
this.currentState = LexerState.String;
|
|
250
|
+
this.colStart = this.col;
|
|
251
|
+
this.lineStart = this.line;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
this.interpolatedBraceDepth--;
|
|
255
|
+
}
|
|
256
|
+
else if (char === "{") {
|
|
257
|
+
this.interpolatedBraceDepth++;
|
|
258
|
+
}
|
|
259
|
+
this.processStartLike(char);
|
|
260
|
+
break;
|
|
261
|
+
case LexerState.EscapedString:
|
|
262
|
+
const escaped = this.advance();
|
|
263
|
+
if (escaped === null) {
|
|
264
|
+
this.reporter.add(new KatnipError("Lexer", `Unterminated string literal`, { line: this.line, column: this.col }));
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
if (escaped === "u") {
|
|
268
|
+
// Handle Unicode escape sequences
|
|
269
|
+
let unicodeBuffer = "";
|
|
270
|
+
for (let i = 0; i < 4; i++) {
|
|
271
|
+
const nextChar = this.advance();
|
|
272
|
+
if (nextChar === null || !/[0-9a-fA-F]/.test(nextChar)) {
|
|
273
|
+
this.reporter.add(new KatnipError("Lexer", `Invalid Unicode escape sequence`, { line: this.line, column: this.col }));
|
|
274
|
+
}
|
|
275
|
+
unicodeBuffer += nextChar;
|
|
276
|
+
}
|
|
277
|
+
this.buffer += String.fromCharCode(parseInt(unicodeBuffer, 16));
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
const escapeSequenceMap = {
|
|
281
|
+
"n": "\n",
|
|
282
|
+
"t": "\t",
|
|
283
|
+
"r": "\r",
|
|
284
|
+
};
|
|
285
|
+
this.buffer += escapeSequenceMap[escaped] ?? escaped;
|
|
286
|
+
}
|
|
287
|
+
// Reset to String state after handling escape
|
|
288
|
+
this.currentState = LexerState.String;
|
|
289
|
+
break;
|
|
290
|
+
case LexerState.Number:
|
|
291
|
+
if (/[0-9]/.test(char)) {
|
|
292
|
+
this.buffer += this.advance();
|
|
293
|
+
}
|
|
294
|
+
else if (char === '.') {
|
|
295
|
+
// Handle decimal point
|
|
296
|
+
if (this.buffer.includes('.')) {
|
|
297
|
+
this.reporter.add(new KatnipError("Lexer", `Invalid number format: Multiple decimal points`, { line: this.line, column: this.col }));
|
|
298
|
+
this.emit("Number");
|
|
299
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
this.buffer += this.advance();
|
|
303
|
+
this.currentState = LexerState.Number; // Still in number state
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else if (/[eE]/.test(char)) {
|
|
307
|
+
// Handle exponential notation
|
|
308
|
+
if (this.buffer.includes('e') || this.buffer.includes("E")) {
|
|
309
|
+
this.reporter.add(new KatnipError("Lexer", `Invalid number format: Multiple exponentional notation characters`, { line: this.line, column: this.col }));
|
|
310
|
+
this.emit("Number");
|
|
311
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
this.buffer += this.advance();
|
|
315
|
+
this.currentState = LexerState.Number; // Still in number state
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
else if (/[+\-]/.test(char)) {
|
|
319
|
+
// Handle sign in scientific notation
|
|
320
|
+
if (this.buffer.slice(-1) === 'e' || this.buffer.slice(-1) === 'E') {
|
|
321
|
+
this.buffer += this.advance();
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
this.emit("Number");
|
|
325
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else if (/[xbo]/.test(char)) {
|
|
329
|
+
// Handle hexadecimal or binary prefixes
|
|
330
|
+
if (this.buffer === "0") {
|
|
331
|
+
this.buffer += this.advance(); // consume 'x', 'b', or 'o'
|
|
332
|
+
this.currentState = LexerState.Number; // stay in number state
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.emit("Number");
|
|
336
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
this.emit("Number");
|
|
341
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
case LexerState.Operator:
|
|
345
|
+
// Initialize trie if starting over
|
|
346
|
+
if (this.operatorNode === null) {
|
|
347
|
+
this.operatorNode = operatorTrie.start();
|
|
348
|
+
this.lastValidOperatorNode = null;
|
|
349
|
+
this.lineStart = this.lineStart ?? this.line;
|
|
350
|
+
this.colStart = this.colStart ?? this.col;
|
|
351
|
+
}
|
|
352
|
+
const stepNode = operatorTrie.step(this.operatorNode, char);
|
|
353
|
+
if (stepNode) {
|
|
354
|
+
this.buffer += this.advance();
|
|
355
|
+
this.operatorNode = stepNode;
|
|
356
|
+
if (stepNode.tokenType) {
|
|
357
|
+
this.lastValidOperatorNode = { node: stepNode, len: this.buffer.length };
|
|
358
|
+
}
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
if (this.lastValidOperatorNode) {
|
|
362
|
+
const opNode = this.lastValidOperatorNode.node;
|
|
363
|
+
// Rewind BEFORE emitting: if the trie over-consumed past the
|
|
364
|
+
// last valid operator, back the cursor up first so emit()
|
|
365
|
+
// records the correct end position, then re-lex the extra
|
|
366
|
+
// chars. (emit() clears the buffer, so the rewind count must
|
|
367
|
+
// be computed here, before the emit.)
|
|
368
|
+
//
|
|
369
|
+
// Today every operator's prefixes are themselves operators
|
|
370
|
+
// (`*`->`**`->`**=`, `-`->`->`, etc.), so rewind is always 0.
|
|
371
|
+
// This guards the day an operator like `..`/`...` is added
|
|
372
|
+
// whose prefix is not itself an operator.
|
|
373
|
+
const rewind = this.buffer.length - this.lastValidOperatorNode.len;
|
|
374
|
+
for (let i = 0; i < rewind; i++) {
|
|
375
|
+
this.position--;
|
|
376
|
+
this.col--;
|
|
377
|
+
}
|
|
378
|
+
if (opNode.tokenType) {
|
|
379
|
+
this.emit(opNode.tokenType);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
this.reporter.add(new KatnipError("Lexer", `Invalid operator '${this.buffer + char}'`, { line: this.line, column: this.col }));
|
|
384
|
+
this.advance();
|
|
385
|
+
}
|
|
386
|
+
// Reset
|
|
387
|
+
this.operatorNode = null;
|
|
388
|
+
this.lastValidOperatorNode = null;
|
|
389
|
+
this.buffer = "";
|
|
390
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
391
|
+
break;
|
|
392
|
+
case LexerState.Comment:
|
|
393
|
+
this.logger.log(new KatnipLog(KatnipLogType.Debug, `In Comment state of type: '${this.commentType}', char: '${char}', buffer: '${this.buffer}'`, { line: this.line, column: this.col }));
|
|
394
|
+
const commentMap = {
|
|
395
|
+
"none": ["Comment_SingleExpanded", "\n"],
|
|
396
|
+
"*": ["Comment_SingleCollapsed", "\n"],
|
|
397
|
+
"!": ["Comment_SingleIgnored", "\n"],
|
|
398
|
+
"<": ["Comment_MultilineExpanded", ">#"],
|
|
399
|
+
">": ["Comment_MultilineCollapsed", "<#"],
|
|
400
|
+
"[": ["Comment_MultilineIgnored", "]#"]
|
|
401
|
+
};
|
|
402
|
+
if (this.commentType === "") {
|
|
403
|
+
const nextChar = this.advance();
|
|
404
|
+
if (nextChar && commentMap[nextChar]) {
|
|
405
|
+
this.commentType = nextChar;
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
this.commentType = "none"; // Default to single-line comment
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
const [tokenType, commentEnd] = commentMap[this.commentType];
|
|
413
|
+
// Multichar end delimiter
|
|
414
|
+
if (commentEnd.length === 2 && char + this.peek(1) === commentEnd) {
|
|
415
|
+
this.advance(); // 1st char of delimiter
|
|
416
|
+
this.advance(); // 2nd char of delimiter
|
|
417
|
+
if (tokenType !== "Comment_MultilineIgnored")
|
|
418
|
+
this.emit(tokenType);
|
|
419
|
+
this.buffer = ""; // ignored comments skip emit(), so clear here
|
|
420
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
421
|
+
this.commentType = "";
|
|
422
|
+
}
|
|
423
|
+
// Single-char end delimiter
|
|
424
|
+
else if (commentEnd.length === 1 && char === commentEnd) {
|
|
425
|
+
this.advance(); // Move past delimiter
|
|
426
|
+
if (tokenType !== "Comment_SingleIgnored")
|
|
427
|
+
this.emit(tokenType);
|
|
428
|
+
this.buffer = ""; // ignored comments skip emit(), so clear here
|
|
429
|
+
this.currentState = this.inInterpolatedExpression ? LexerState.InterpolatedExpression : LexerState.Start;
|
|
430
|
+
this.commentType = "";
|
|
431
|
+
}
|
|
432
|
+
// No end yet -> keep buffering
|
|
433
|
+
else {
|
|
434
|
+
this.buffer += this.advance() ?? "";
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
//# sourceMappingURL=Lexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lexer.js","sourceRoot":"","sources":["../../src/lexer/Lexer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAWpB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,OAAO,KAAK;IA6BF;IACA;IA7BZ,2BAA2B;IACnB,GAAG,GAAW,EAAE,CAAC;IACjB,QAAQ,GAAG,CAAC,CAAC;IACb,IAAI,GAAG,CAAC,CAAC;IACT,SAAS,GAAG,CAAC,CAAC;IACd,GAAG,GAAG,CAAC,CAAC;IACR,QAAQ,GAAG,CAAC,CAAC;IAErB,eAAe;IACP,YAAY,GAAe,UAAU,CAAC,KAAK,CAAC;IAE5C,MAAM,GAAW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AI,KAAK,UAAU,EAAE,CAAC;wBACtD,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,sBAAsB;wBACtC,IAAI,SAAS,KAAK,uBAAuB;4BAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;wBAChE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,8CAA8C;wBAChE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;wBACzG,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;oBAC1B,CAAC;oBACD,+BAA+B;yBAC1B,CAAC;wBACF,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;oBACxC,CAAC;gBACL,CAAC;gBACD,MAAM;QACd,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Contains the lexer state enum for the Katnip lexer.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum LexerState {
|
|
5
|
+
Start = 0,
|
|
6
|
+
Identifier = 1,
|
|
7
|
+
String = 2,
|
|
8
|
+
EscapedString = 3,
|
|
9
|
+
InterpolatedExpression = 4,
|
|
10
|
+
Number = 5,
|
|
11
|
+
Operator = 6,
|
|
12
|
+
Punctuation = 7,
|
|
13
|
+
Comment = 8
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Contains the lexer state enum for the Katnip lexer.
|
|
3
|
+
*/
|
|
4
|
+
export var LexerState;
|
|
5
|
+
(function (LexerState) {
|
|
6
|
+
LexerState[LexerState["Start"] = 0] = "Start";
|
|
7
|
+
LexerState[LexerState["Identifier"] = 1] = "Identifier";
|
|
8
|
+
LexerState[LexerState["String"] = 2] = "String";
|
|
9
|
+
LexerState[LexerState["EscapedString"] = 3] = "EscapedString";
|
|
10
|
+
LexerState[LexerState["InterpolatedExpression"] = 4] = "InterpolatedExpression";
|
|
11
|
+
LexerState[LexerState["Number"] = 5] = "Number";
|
|
12
|
+
LexerState[LexerState["Operator"] = 6] = "Operator";
|
|
13
|
+
LexerState[LexerState["Punctuation"] = 7] = "Punctuation";
|
|
14
|
+
LexerState[LexerState["Comment"] = 8] = "Comment";
|
|
15
|
+
})(LexerState || (LexerState = {}));
|
|
16
|
+
//# sourceMappingURL=LexerState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LexerState.js","sourceRoot":"","sources":["../../src/lexer/LexerState.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAN,IAAY,UAcX;AAdD,WAAY,UAAU;IAClB,6CAAK,CAAA;IAEL,uDAAU,CAAA;IAEV,+CAAM,CAAA;IACN,6DAAa,CAAA;IACb,+EAAsB,CAAA;IACtB,+CAAM,CAAA;IAEN,mDAAQ,CAAA;IACR,yDAAW,CAAA;IAEX,iDAAO,CAAA;AACX,CAAC,EAdW,UAAU,KAAV,UAAU,QAcrB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Token definitions for the Katnip lexer.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ValuedTokenType: {
|
|
5
|
+
readonly String: "String";
|
|
6
|
+
readonly InterpolatedString: "InterpolatedString";
|
|
7
|
+
readonly InterpolatedStringEnd: "InterpolatedStringEnd";
|
|
8
|
+
readonly Number: "Number";
|
|
9
|
+
readonly Comment_SingleExpanded: "Comment_SingleExpanded";
|
|
10
|
+
readonly Comment_SingleCollapsed: "Comment_SingleCollapsed";
|
|
11
|
+
readonly Comment_SingleIgnored: "Comment_SingleIgnored";
|
|
12
|
+
readonly Comment_MultilineExpanded: "Comment_MultilineExpanded";
|
|
13
|
+
readonly Comment_MultilineCollapsed: "Comment_MultilineCollapsed";
|
|
14
|
+
readonly Comment_MultilineIgnored: "Comment_MultilineIgnored";
|
|
15
|
+
readonly Identifier: "Identifier";
|
|
16
|
+
readonly ErrorToken: "ErrorToken";
|
|
17
|
+
};
|
|
18
|
+
export type ValuedTokenType = typeof ValuedTokenType[keyof typeof ValuedTokenType];
|
|
19
|
+
export declare const UnitTokenType: {
|
|
20
|
+
readonly BracketOpen: "[";
|
|
21
|
+
readonly BracketClose: "]";
|
|
22
|
+
readonly BraceOpen: "{";
|
|
23
|
+
readonly BraceClose: "}";
|
|
24
|
+
readonly ParenOpen: "(";
|
|
25
|
+
readonly ParenClose: ")";
|
|
26
|
+
readonly Dot: ".";
|
|
27
|
+
readonly Comma: ",";
|
|
28
|
+
readonly Colon: ":";
|
|
29
|
+
readonly Semicolon: ";";
|
|
30
|
+
readonly AtSymbol: "@";
|
|
31
|
+
readonly Pound: "#";
|
|
32
|
+
readonly QuestionMark: "?";
|
|
33
|
+
readonly Plus: "+";
|
|
34
|
+
readonly Minus: "-";
|
|
35
|
+
readonly Asterisk: "*";
|
|
36
|
+
readonly FwdSlash: "/";
|
|
37
|
+
readonly Percent: "%";
|
|
38
|
+
readonly Caret: "^";
|
|
39
|
+
readonly Exclamation: "!";
|
|
40
|
+
readonly Ampersand: "&";
|
|
41
|
+
readonly Pipe: "|";
|
|
42
|
+
readonly LeftChevron: "<";
|
|
43
|
+
readonly RightChevron: ">";
|
|
44
|
+
readonly Equals: "=";
|
|
45
|
+
readonly Power: "**";
|
|
46
|
+
readonly EqualsTo: "==";
|
|
47
|
+
readonly LessThanOrEqualsTo: "<=";
|
|
48
|
+
readonly GreaterThanOrEqualsTo: ">=";
|
|
49
|
+
readonly AND: "&&";
|
|
50
|
+
readonly OR: "||";
|
|
51
|
+
readonly NAND: "!&";
|
|
52
|
+
readonly NOR: "!|";
|
|
53
|
+
readonly XNOR: "!^";
|
|
54
|
+
readonly PlusEquals: "+=";
|
|
55
|
+
readonly MinusEquals: "-=";
|
|
56
|
+
readonly AsteriskEquals: "*=";
|
|
57
|
+
readonly PowerEquals: "**=";
|
|
58
|
+
readonly FwdSlashEquals: "/=";
|
|
59
|
+
readonly PercentEquals: "%=";
|
|
60
|
+
readonly FunctionReturn: "->";
|
|
61
|
+
readonly Newline: "\n";
|
|
62
|
+
readonly EOF: "<EOF>";
|
|
63
|
+
};
|
|
64
|
+
export type UnitTokenType = typeof UnitTokenType[keyof typeof UnitTokenType];
|
|
65
|
+
export declare const unitTokenByLexeme: Map<UnitTokenType, UnitTokenType>;
|
|
66
|
+
export declare const singleCharUnitTokens: Set<UnitTokenType>;
|
|
67
|
+
export declare class OperatorTrieNode {
|
|
68
|
+
children: Map<string, OperatorTrieNode>;
|
|
69
|
+
tokenType: UnitTokenType | null;
|
|
70
|
+
}
|
|
71
|
+
export declare class OperatorTrie {
|
|
72
|
+
private root;
|
|
73
|
+
constructor(operators: readonly UnitTokenType[]);
|
|
74
|
+
private insert;
|
|
75
|
+
start(): OperatorTrieNode;
|
|
76
|
+
step(node: OperatorTrieNode, char: string): OperatorTrieNode | null;
|
|
77
|
+
}
|
|
78
|
+
export declare const operatorTrie: OperatorTrie;
|
|
79
|
+
export type TokenType = ValuedTokenType | UnitTokenType;
|
|
80
|
+
export type TokenInfoFor<T extends TokenType> = T extends ValuedTokenType ? {
|
|
81
|
+
type: T;
|
|
82
|
+
value: string;
|
|
83
|
+
} : T extends UnitTokenType ? {
|
|
84
|
+
type: T;
|
|
85
|
+
} : never;
|
|
86
|
+
type TokenInfo = ValuedToken | UnitToken;
|
|
87
|
+
export type ValuedToken = {
|
|
88
|
+
type: ValuedTokenType;
|
|
89
|
+
value: string;
|
|
90
|
+
};
|
|
91
|
+
export type UnitToken = {
|
|
92
|
+
type: UnitTokenType;
|
|
93
|
+
};
|
|
94
|
+
export interface TokenPos {
|
|
95
|
+
line: number;
|
|
96
|
+
column: number;
|
|
97
|
+
}
|
|
98
|
+
export interface Token {
|
|
99
|
+
token: TokenInfo;
|
|
100
|
+
start: TokenPos;
|
|
101
|
+
end: TokenPos;
|
|
102
|
+
}
|
|
103
|
+
export declare function isValuedTokenType(type: string): type is ValuedTokenType;
|
|
104
|
+
export declare function isUnitTokenType(type: string): type is UnitTokenType;
|
|
105
|
+
export {};
|