@tsplc/build 0.2.17 → 0.2.19

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 (51) hide show
  1. package/dist/cli.js +628 -352
  2. package/dist/cli.js.map +30 -28
  3. package/dist/index.js +548 -387
  4. package/dist/index.js.map +27 -25
  5. package/dist/libraries.js +68 -27
  6. package/dist/libraries.js.map +3 -3
  7. package/docker/Dockerfile +2 -0
  8. package/docker/Dockerfile.dockerignore +4 -1
  9. package/docker/Dockerfile.source +3 -0
  10. package/docker/config.ts +10 -5
  11. package/docker/runner.ts +140 -127
  12. package/package.json +54 -53
  13. package/python/build.py +183 -124
  14. package/python/codesys_online.py +44 -45
  15. package/python/hardware.py +9 -9
  16. package/python/test_build.py +3 -3
  17. package/python/test_codesys_online.py +18 -12
  18. package/python/test_installer_packages.py +1 -0
  19. package/python/worker.py +11 -7
  20. package/src/artifacts.ts +82 -60
  21. package/src/build.ts +71 -62
  22. package/src/cli.ts +109 -100
  23. package/src/controller-online.ts +400 -425
  24. package/src/controller-protocol.ts +140 -0
  25. package/src/controller-session.ts +466 -397
  26. package/src/device-tree.ts +19 -15
  27. package/src/diagnostics.ts +59 -49
  28. package/src/docker-build.ts +217 -156
  29. package/src/docker-context.ts +49 -27
  30. package/src/docker-run.ts +137 -111
  31. package/src/engineering-settings.ts +42 -0
  32. package/src/host/codesys-command.ts +35 -34
  33. package/src/host/codesys-host.ts +157 -129
  34. package/src/host/codesys-worker.ts +318 -301
  35. package/src/host/windows-path.ts +63 -59
  36. package/src/import-request.ts +24 -0
  37. package/src/index.ts +37 -31
  38. package/src/io.ts +152 -116
  39. package/src/libraries.ts +214 -146
  40. package/src/package-path.ts +3 -1
  41. package/src/run.ts +132 -108
  42. package/src/runtime-status.ts +25 -19
  43. package/src/sources.ts +264 -225
  44. package/src/st/declarations.ts +181 -193
  45. package/src/st/lexer.ts +102 -118
  46. package/src/st/parse.ts +193 -171
  47. package/src/st/reader.ts +47 -42
  48. package/src/__tests__/fixtures/xml/fb-simple.xml +0 -40
  49. package/src/__tests__/fixtures/xml/fb-state-machine.xml +0 -86
  50. package/src/__tests__/fixtures/xml/prg-cyclic.xml +0 -44
  51. package/src/config.ts +0 -12
@@ -1,229 +1,217 @@
1
+ import {
2
+ conditionalDirective,
3
+ modifiers,
4
+ type ObjectKeyword,
5
+ variableSections,
6
+ } from "@tsplc/iec/st";
1
7
  import type { Token } from "./lexer";
2
8
  import type { TokenReader } from "./reader";
3
9
 
4
10
  export const objectKinds = {
5
- PROGRAM: "program",
6
- FUNCTION_BLOCK: "function_block",
7
- FUNCTIONBLOCK: "function_block",
8
- FUNCTION: "function",
9
- METHOD: "method",
10
- INTERFACE: "interface",
11
- PROPERTY: "property",
12
- } as const;
13
-
14
- const modifiers = new Set([
15
- "PUBLIC",
16
- "PRIVATE",
17
- "PROTECTED",
18
- "INTERNAL",
19
- "FINAL",
20
- "ABSTRACT",
21
- "OVERRIDE",
22
- ]);
23
- export const globalSections = new Set(["VAR_GLOBAL", "VAR_CONFIG"]);
24
- export const variableSections = new Set([
25
- ...globalSections,
26
- "VAR",
27
- "VAR_INPUT",
28
- "VAR_OUTPUT",
29
- "VAR_IN_OUT",
30
- "VAR_TEMP",
31
- "VAR_STAT",
32
- "VAR_INST",
33
- "VAR_EXTERNAL",
34
- "VAR_ACCESS",
35
- "VAR_GENERIC",
36
- ]);
37
- const closingObjects = new Set(Object.keys(objectKinds).map((kind) => `END_${kind}`));
11
+ PROGRAM: "program",
12
+ FUNCTION_BLOCK: "function_block",
13
+ FUNCTIONBLOCK: "function_block",
14
+ FUNCTION: "function",
15
+ METHOD: "method",
16
+ INTERFACE: "interface",
17
+ PROPERTY: "property",
18
+ } as const satisfies Record<ObjectKeyword | "FUNCTIONBLOCK", string>;
19
+ const closingObjects = new Set(
20
+ Object.keys(objectKinds).map((kind) => `END_${kind}`),
21
+ );
38
22
  export const declarationKeywords = new Set([
39
- ...Object.keys(objectKinds),
40
- ...closingObjects,
41
- ...variableSections,
42
- "END_VAR",
43
- "TYPE",
44
- "END_TYPE",
45
- "STRUCT",
46
- "END_STRUCT",
47
- "UNION",
48
- "END_UNION",
49
- "ACTION",
50
- "END_ACTION",
51
- "CONFIGURATION",
52
- "END_CONFIGURATION",
23
+ ...Object.keys(objectKinds),
24
+ ...closingObjects,
25
+ ...variableSections,
26
+ "END_VAR",
27
+ "TYPE",
28
+ "END_TYPE",
29
+ "STRUCT",
30
+ "END_STRUCT",
31
+ "UNION",
32
+ "END_UNION",
33
+ "ACTION",
34
+ "END_ACTION",
35
+ "CONFIGURATION",
36
+ "END_CONFIGURATION",
53
37
  ]);
54
38
 
55
- const conditionalDirective = (token?: Token) => {
56
- if (token?.kind === "pragma") {
57
- return /^\{\s*(IF|ELSIF|ELSE|END_IF)\b/i.exec(token.value)?.[1]?.toUpperCase();
58
- }
59
- };
60
39
  const isDeclarationPragma = (token?: Token) =>
61
- token?.kind === "pragma" && !conditionalDirective(token);
40
+ token?.kind === "pragma" && !conditionalDirective(token.value);
62
41
 
63
42
  export const readDeclarationPragmas = (reader: TokenReader) => {
64
- while (isDeclarationPragma(reader.peek())) {
65
- reader.take();
66
- }
43
+ while (isDeclarationPragma(reader.peek())) {
44
+ reader.take();
45
+ }
67
46
  };
68
47
 
69
48
  export const readDeclarationSemicolon = (reader: TokenReader) => {
70
- const token = reader.peek();
71
- // A semicolon on the next line may be the body's first empty statement.
72
- // Only attach it to a declaration when it terminates that same line.
73
- if (token?.value === ";" && !/[\r\n]/.test(reader.source.slice(reader.end, token.start))) {
74
- reader.take();
75
- }
49
+ const token = reader.peek();
50
+ // A semicolon on the next line may be the body's first empty statement.
51
+ // Only attach it to a declaration when it terminates that same line.
52
+ if (
53
+ token?.value === ";" &&
54
+ !/[\r\n]/.test(reader.source.slice(reader.end, token.start))
55
+ ) {
56
+ reader.take();
57
+ }
76
58
  };
77
59
 
78
60
  export const readIdentifier = (reader: TokenReader) => {
79
- const token = reader.take();
80
- if (token.kind !== "word" || declarationKeywords.has(token.value)) {
81
- reader.fail("Expected an IEC identifier", token);
82
- }
83
- return reader.source.slice(token.start, token.end);
61
+ const token = reader.take();
62
+ if (token.kind !== "word" || declarationKeywords.has(token.value)) {
63
+ reader.fail("Expected an IEC identifier", token);
64
+ }
65
+ return reader.source.slice(token.start, token.end);
84
66
  };
85
67
 
86
68
  const isOverrideModifier = (reader: TokenReader) => {
87
- // OVERRIDE is also an established IEC name (e.g. OSCAT's function).
88
- // A modifier needs a following name on the same line, not a body statement.
89
- const name = reader.peek(1);
90
- return (
91
- name?.kind === "word" &&
92
- !declarationKeywords.has(name.value) &&
93
- !["(", "[", ":=", ".", "^"].includes(reader.peek(2)?.value ?? "") &&
94
- !/[\r\n]/.test(reader.source.slice(reader.peek()?.end, name.start))
95
- );
69
+ // OVERRIDE is also an established IEC name (e.g. OSCAT's function).
70
+ // A modifier needs a following name on the same line, not a body statement.
71
+ const name = reader.peek(1);
72
+ return (
73
+ name?.kind === "word" &&
74
+ !declarationKeywords.has(name.value) &&
75
+ !["(", "[", ":=", ".", "^"].includes(reader.peek(2)?.value ?? "") &&
76
+ !/[\r\n]/.test(reader.source.slice(reader.peek()?.end, name.start))
77
+ );
96
78
  };
97
79
 
98
80
  export const readModifiers = (reader: TokenReader) => {
99
- while (modifiers.has(reader.peek()?.value ?? "")) {
100
- if (reader.peek()?.value === "OVERRIDE" && !isOverrideModifier(reader)) {
101
- return;
102
- }
103
- reader.take();
104
- }
81
+ while (modifiers.has(reader.peek()?.value ?? "")) {
82
+ if (reader.peek()?.value === "OVERRIDE" && !isOverrideModifier(reader)) {
83
+ return;
84
+ }
85
+ reader.take();
86
+ }
105
87
  };
106
88
 
107
89
  const typeDelimiters = { "(": ")", "[": "]", "<": ">" } as const;
108
90
 
109
- const readDelimitedType = (reader: TokenReader, open: keyof typeof typeDelimiters) => {
110
- reader.expect(open);
111
- const closings = [typeDelimiters[open]];
112
- while (closings.length) {
113
- const token = reader.take();
114
- if (token.kind === "string" || token.kind === "pragma") {
115
- continue;
116
- }
117
- if (token.value === "(" || token.value === "[") {
118
- closings.push(typeDelimiters[token.value]);
119
- } else if (token.value === ")" || token.value === "]") {
120
- if (closings.pop() !== token.value) {
121
- reader.fail(`Mismatched delimiter ${token.value}`, token);
122
- }
123
- } else if (open === "<" && closings.at(-1) === ">") {
124
- // Inside parentheses, < and > are comparisons, not generic delimiters:
125
- // FB_Base<(Size := BOOL_TO_INT(1 < 2))>.
126
- if (token.value === "<") {
127
- closings.push(">");
128
- }
129
- if (token.value === ">") {
130
- closings.pop();
131
- }
132
- }
133
- if (declarationKeywords.has(token.value) || token.value === ";") {
134
- reader.fail(`Unclosed ${open}`, token);
135
- }
136
- }
91
+ const readDelimitedType = (
92
+ reader: TokenReader,
93
+ open: keyof typeof typeDelimiters,
94
+ ) => {
95
+ reader.expect(open);
96
+ const closings = [typeDelimiters[open]];
97
+ while (closings.length) {
98
+ const token = reader.take();
99
+ if (token.kind === "string" || token.kind === "pragma") {
100
+ continue;
101
+ }
102
+ if (token.value === "(" || token.value === "[") {
103
+ closings.push(typeDelimiters[token.value]);
104
+ } else if (token.value === ")" || token.value === "]") {
105
+ if (closings.pop() !== token.value) {
106
+ reader.fail(`Mismatched delimiter ${token.value}`, token);
107
+ }
108
+ } else if (open === "<" && closings.at(-1) === ">") {
109
+ // Inside parentheses, < and > are comparisons, not generic delimiters:
110
+ // FB_Base<(Size := BOOL_TO_INT(1 < 2))>.
111
+ if (token.value === "<") {
112
+ closings.push(">");
113
+ }
114
+ if (token.value === ">") {
115
+ closings.pop();
116
+ }
117
+ }
118
+ if (declarationKeywords.has(token.value) || token.value === ";") {
119
+ reader.fail(`Unclosed ${open}`, token);
120
+ }
121
+ }
137
122
  };
138
123
 
139
124
  export const readType = (reader: TokenReader): string => {
140
- const start = reader.peek()?.start ?? reader.source.length;
141
- // Prefix types can nest arbitrarily; iteration avoids a JavaScript stack limit.
142
- while (true) {
143
- if (["POINTER", "REFERENCE", "REF_TO"].includes(reader.peek()?.value ?? "")) {
144
- if (reader.take().value !== "REF_TO") {
145
- reader.expect("TO");
146
- }
147
- continue;
148
- }
149
- if (reader.consume("ARRAY")) {
150
- readDelimitedType(reader, "[");
151
- reader.expect("OF");
152
- continue;
153
- }
154
- break;
155
- }
156
- readIdentifier(reader);
157
- while (reader.consume(".")) {
158
- readIdentifier(reader);
159
- }
160
- for (const open of ["(", "[", "<"] as const) {
161
- if (reader.peek()?.value === open) {
162
- readDelimitedType(reader, open);
163
- }
164
- }
165
- return reader.source.slice(start, reader.end);
125
+ const start = reader.peek()?.start ?? reader.source.length;
126
+ // Prefix types can nest arbitrarily; iteration avoids a JavaScript stack limit.
127
+ while (true) {
128
+ if (
129
+ ["POINTER", "REFERENCE", "REF_TO"].includes(reader.peek()?.value ?? "")
130
+ ) {
131
+ if (reader.take().value !== "REF_TO") {
132
+ reader.expect("TO");
133
+ }
134
+ continue;
135
+ }
136
+ if (reader.consume("ARRAY")) {
137
+ readDelimitedType(reader, "[");
138
+ reader.expect("OF");
139
+ continue;
140
+ }
141
+ break;
142
+ }
143
+ readIdentifier(reader);
144
+ while (reader.consume(".")) {
145
+ readIdentifier(reader);
146
+ }
147
+ for (const open of ["(", "[", "<"] as const) {
148
+ if (reader.peek()?.value === open) {
149
+ readDelimitedType(reader, open);
150
+ }
151
+ }
152
+ return reader.source.slice(start, reader.end);
166
153
  };
167
154
 
168
155
  export const readVariableSection = (reader: TokenReader) => {
169
- reader.take();
170
- const conditionals: { hasElse: boolean }[] = [];
171
- while (reader.peek()?.value !== "END_VAR") {
172
- const token = reader.take();
173
- if (variableSections.has(token.value) || closingObjects.has(token.value)) {
174
- reader.fail("Missing END_VAR", token);
175
- }
176
- const directive = conditionalDirective(token);
177
- if (!directive) {
178
- continue;
179
- }
180
- if (directive === "IF") {
181
- conditionals.push({ hasElse: false });
182
- continue;
183
- }
184
- const current = conditionals.at(-1);
185
- if (!current) {
186
- return reader.fail("Unmatched conditional pragma", token);
187
- }
188
- if (directive === "END_IF") {
189
- conditionals.pop();
190
- continue;
191
- }
192
- if (current.hasElse) {
193
- reader.fail("Conditional branch after ELSE", token);
194
- }
195
- current.hasElse = directive === "ELSE";
196
- }
197
- if (conditionals.length) {
198
- reader.fail("Conditional pragmas must remain inside one variable section");
199
- }
200
- reader.take();
201
- readDeclarationSemicolon(reader);
156
+ reader.take();
157
+ const conditionals: { hasElse: boolean }[] = [];
158
+ while (reader.peek()?.value !== "END_VAR") {
159
+ const token = reader.take();
160
+ if (variableSections.has(token.value) || closingObjects.has(token.value)) {
161
+ reader.fail("Missing END_VAR", token);
162
+ }
163
+ const directive =
164
+ token.kind === "pragma" && conditionalDirective(token.value);
165
+ if (!directive) {
166
+ continue;
167
+ }
168
+ if (directive === "IF") {
169
+ conditionals.push({ hasElse: false });
170
+ continue;
171
+ }
172
+ const current = conditionals.at(-1);
173
+ if (!current) {
174
+ return reader.fail("Unmatched conditional pragma", token);
175
+ }
176
+ if (directive === "END_IF") {
177
+ conditionals.pop();
178
+ continue;
179
+ }
180
+ if (current.hasElse) {
181
+ reader.fail("Conditional branch after ELSE", token);
182
+ }
183
+ current.hasElse = directive === "ELSE";
184
+ }
185
+ if (conditionals.length) {
186
+ reader.fail("Conditional pragmas must remain inside one variable section");
187
+ }
188
+ reader.take();
189
+ readDeclarationSemicolon(reader);
202
190
  };
203
191
 
204
192
  export const readDeclarationSections = (reader: TokenReader) => {
205
- while (reader.peek()) {
206
- // Pragmas belong to the declaration only when another declaration follows.
207
- // Look ahead without consuming them so a pragma-only body stays intact.
208
- let ahead = 0;
209
- while (isDeclarationPragma(reader.peek(ahead))) {
210
- ahead++;
211
- }
212
- const next = reader.peek(ahead)?.value ?? "";
213
- if (variableSections.has(next)) {
214
- readDeclarationPragmas(reader);
215
- readVariableSection(reader);
216
- continue;
217
- }
218
- if (next !== "EXTENDS" && next !== "IMPLEMENTS") {
219
- return;
220
- }
221
- // CODESYS generic FBs can place these clauses after VAR_GENERIC.
222
- readDeclarationPragmas(reader);
223
- reader.take();
224
- readType(reader);
225
- while (reader.consume(",")) {
226
- readType(reader);
227
- }
228
- }
193
+ while (reader.peek()) {
194
+ // Pragmas belong to the declaration only when another declaration follows.
195
+ // Look ahead without consuming them so a pragma-only body stays intact.
196
+ let ahead = 0;
197
+ while (isDeclarationPragma(reader.peek(ahead))) {
198
+ ahead++;
199
+ }
200
+ const next = reader.peek(ahead)?.value ?? "";
201
+ if (variableSections.has(next)) {
202
+ readDeclarationPragmas(reader);
203
+ readVariableSection(reader);
204
+ continue;
205
+ }
206
+ if (next !== "EXTENDS" && next !== "IMPLEMENTS") {
207
+ return;
208
+ }
209
+ // CODESYS generic FBs can place these clauses after VAR_GENERIC.
210
+ readDeclarationPragmas(reader);
211
+ reader.take();
212
+ readType(reader);
213
+ while (reader.consume(",")) {
214
+ readType(reader);
215
+ }
216
+ }
229
217
  };
package/src/st/lexer.ts CHANGED
@@ -1,125 +1,109 @@
1
- export type Token = {
2
- kind: "word" | "string" | "pragma" | "symbol";
3
- value: string;
4
- start: number;
5
- end: number;
6
- };
1
+ import { blockCommentEnd, lineCommentEnd, stringEnd } from "@tsplc/iec/st";
2
+
3
+ export interface Token {
4
+ kind: "word" | "string" | "pragma" | "symbol";
5
+ value: string;
6
+ start: number;
7
+ end: number;
8
+ }
7
9
 
8
10
  export class StSyntaxError extends Error {
9
- constructor(source: string, offset: number, filename: string, message: string) {
10
- const lines = source.slice(0, offset).split(/\r\n|\r|\n/);
11
- super(`${filename}:${lines.length}:${(lines.at(-1)?.length ?? 0) + 1}: ${message}`);
12
- this.name = "StSyntaxError";
13
- }
11
+ constructor(
12
+ source: string,
13
+ offset: number,
14
+ filename: string,
15
+ message: string,
16
+ ) {
17
+ const lines = source.slice(0, offset).split(/\r\n|\r|\n/);
18
+ super(
19
+ `${filename}:${lines.length}:${(lines.at(-1)?.length ?? 0) + 1}: ${message}`,
20
+ );
21
+ this.name = "StSyntaxError";
22
+ }
14
23
  }
15
24
 
16
25
  /** Keep original offsets: splitting must preserve comments, pragmas and source spelling. */
17
26
  export const tokenize = (source: string, filename = "<source>"): Token[] => {
18
- const tokens: Token[] = [];
19
- let offset = 0;
20
- const fail = (start: number, message: string): never => {
21
- throw new StSyntaxError(source, start, filename, message);
22
- };
23
- const quoted = () => {
24
- const start = offset;
25
- const quote = source[offset++];
26
- while (offset < source.length) {
27
- // IEC strings escape characters (including quotes and $ itself) with $.
28
- if (source[offset] === "$") {
29
- offset += 2;
30
- } else if (source[offset++] === quote) {
31
- return;
32
- }
33
- }
34
- fail(start, "Unterminated string");
35
- };
36
- while (offset < source.length) {
37
- const start = offset;
38
- const character = source[offset] ?? "";
39
- if (/\s|\uFEFF/.test(character)) {
40
- offset++;
41
- continue;
42
- }
43
- if (source.startsWith("//", offset)) {
44
- while (offset < source.length && !/[\r\n]/.test(source[offset] ?? "")) {
45
- offset++;
46
- }
47
- continue;
48
- }
49
- if (source.startsWith("(*", offset)) {
50
- offset += 2;
51
- let depth = 1;
52
- while (offset < source.length && depth > 0) {
53
- if (source.startsWith("(*", offset)) {
54
- depth++;
55
- offset += 2;
56
- } else if (source.startsWith("*)", offset)) {
57
- depth--;
58
- offset += 2;
59
- } else {
60
- offset++;
61
- }
62
- }
63
- if (depth) {
64
- fail(start, "Unterminated block comment");
65
- }
66
- continue;
67
- }
68
- if (character === "'" || character === '"') {
69
- quoted();
70
- tokens.push({
71
- kind: "string",
72
- value: source.slice(start, offset),
73
- start,
74
- end: offset,
75
- });
76
- continue;
77
- }
78
- if (character === "{") {
79
- offset++;
80
- while (offset < source.length && source[offset] !== "}") {
81
- if (source[offset] === "'" || source[offset] === '"') {
82
- quoted();
83
- } else {
84
- offset++;
85
- }
86
- }
87
- if (offset === source.length) {
88
- fail(start, "Unterminated pragma");
89
- }
90
- offset++;
91
- tokens.push({
92
- kind: "pragma",
93
- value: source.slice(start, offset),
94
- start,
95
- end: offset,
96
- });
97
- continue;
98
- }
99
- if (/[A-Za-z_]/.test(character)) {
100
- offset++;
101
- while (/[A-Za-z_0-9]/.test(source[offset] ?? "")) {
102
- offset++;
103
- }
104
- tokens.push({
105
- kind: "word",
106
- value: source.slice(start, offset).toUpperCase(),
107
- start,
108
- end: offset,
109
- });
110
- continue;
111
- }
112
- offset++;
113
- const pair = source.slice(start, offset + 1);
114
- if ([":=", "=>", "..", "<=", ">=", "<>", "**"].includes(pair)) {
115
- offset++;
116
- }
117
- tokens.push({
118
- kind: "symbol",
119
- value: source.slice(start, offset),
120
- start,
121
- end: offset,
122
- });
123
- }
124
- return tokens;
27
+ const tokens: Token[] = [];
28
+ let offset = 0;
29
+ const fail = (start: number, message: string): never => {
30
+ throw new StSyntaxError(source, start, filename, message);
31
+ };
32
+ const quoted = () => {
33
+ offset = stringEnd(source, offset) ?? fail(offset, "Unterminated string");
34
+ };
35
+ while (offset < source.length) {
36
+ const start = offset;
37
+ const character = source[offset] ?? "";
38
+ if (/\s|\uFEFF/.test(character)) {
39
+ offset++;
40
+ continue;
41
+ }
42
+ if (source.startsWith("//", offset)) {
43
+ offset = lineCommentEnd(source, start);
44
+ continue;
45
+ }
46
+ if (source.startsWith("(*", offset)) {
47
+ offset =
48
+ blockCommentEnd(source, start) ??
49
+ fail(start, "Unterminated block comment");
50
+ continue;
51
+ }
52
+ if (character === "'" || character === '"') {
53
+ quoted();
54
+ tokens.push({
55
+ kind: "string",
56
+ value: source.slice(start, offset),
57
+ start,
58
+ end: offset,
59
+ });
60
+ continue;
61
+ }
62
+ if (character === "{") {
63
+ offset++;
64
+ while (offset < source.length && source[offset] !== "}") {
65
+ if (source[offset] === "'" || source[offset] === '"') {
66
+ quoted();
67
+ } else {
68
+ offset++;
69
+ }
70
+ }
71
+ if (offset === source.length) {
72
+ fail(start, "Unterminated pragma");
73
+ }
74
+ offset++;
75
+ tokens.push({
76
+ kind: "pragma",
77
+ value: source.slice(start, offset),
78
+ start,
79
+ end: offset,
80
+ });
81
+ continue;
82
+ }
83
+ if (/[A-Za-z_]/.test(character)) {
84
+ offset++;
85
+ while (/[A-Za-z_0-9]/.test(source[offset] ?? "")) {
86
+ offset++;
87
+ }
88
+ tokens.push({
89
+ kind: "word",
90
+ value: source.slice(start, offset).toUpperCase(),
91
+ start,
92
+ end: offset,
93
+ });
94
+ continue;
95
+ }
96
+ offset++;
97
+ const pair = source.slice(start, offset + 1);
98
+ if ([":=", "=>", "..", "<=", ">=", "<>", "**"].includes(pair)) {
99
+ offset++;
100
+ }
101
+ tokens.push({
102
+ kind: "symbol",
103
+ value: source.slice(start, offset),
104
+ start,
105
+ end: offset,
106
+ });
107
+ }
108
+ return tokens;
125
109
  };