vba-runner 0.1.0-alpha.0 → 0.1.1-alpha.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/bin/vba-analyzer.cjs +19 -7
- package/dist/bin/vba-formatter.cjs +11 -5
- package/dist/bin/vba-parse-check.cjs +19 -7
- package/dist/bin/vba-run.cjs +19 -7
- package/dist/lib.cjs +19 -7
- package/package.json +1 -1
|
@@ -55,6 +55,8 @@ var LexError = class extends Error {
|
|
|
55
55
|
this.name = "LexError";
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
+
var NUMERIC_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@"]);
|
|
59
|
+
var IDENTIFIER_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@", "$"]);
|
|
58
60
|
var Lexer = class _Lexer {
|
|
59
61
|
input = "";
|
|
60
62
|
pos = 0;
|
|
@@ -248,6 +250,7 @@ var Lexer = class _Lexer {
|
|
|
248
250
|
while (/[0-9a-f]/i.test(this.peek())) {
|
|
249
251
|
hexStr += this.advance();
|
|
250
252
|
}
|
|
253
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
251
254
|
return { type: 1 /* Number */, value: "0x" + hexStr, line: startLine, column: startColumn };
|
|
252
255
|
} else if (next === "o" || this.isDigit(next)) {
|
|
253
256
|
if (next === "o") this.advance();
|
|
@@ -255,6 +258,7 @@ var Lexer = class _Lexer {
|
|
|
255
258
|
while (/[0-7]/.test(this.peek())) {
|
|
256
259
|
octStr += this.advance();
|
|
257
260
|
}
|
|
261
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
258
262
|
return { type: 1 /* Number */, value: "0o" + octStr, line: startLine, column: startColumn };
|
|
259
263
|
}
|
|
260
264
|
return { type: 117 /* OperatorAmpersand */, value: "&", line: startLine, column: startColumn };
|
|
@@ -321,8 +325,7 @@ var Lexer = class _Lexer {
|
|
|
321
325
|
numStr += this.advance();
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
|
-
|
|
325
|
-
if (["%", "&", "@", "!", "#", "^"].indexOf(peekChar) !== -1) {
|
|
328
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) {
|
|
326
329
|
numStr += this.advance();
|
|
327
330
|
}
|
|
328
331
|
return { type: 1 /* Number */, value: numStr, line: startLine, column: startColumn };
|
|
@@ -332,9 +335,12 @@ var Lexer = class _Lexer {
|
|
|
332
335
|
while (this.isAlphaNumeric(this.peek())) {
|
|
333
336
|
idStr += this.advance();
|
|
334
337
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
+
{
|
|
339
|
+
const nextCh = this.peek();
|
|
340
|
+
const charAfterNext = this.pos + 1 < this.input.length ? this.input[this.pos + 1] : "\0";
|
|
341
|
+
if (IDENTIFIER_TYPE_SUFFIXES.has(nextCh) && !((nextCh === "!" || nextCh === "^") && (this.isAlphaNumeric(charAfterNext) || charAfterNext === "_"))) {
|
|
342
|
+
idStr += this.advance();
|
|
343
|
+
}
|
|
338
344
|
}
|
|
339
345
|
const lowerId = idStr.toLowerCase();
|
|
340
346
|
const lowerBase = lowerId.replace(/[$%&#@]$/, "");
|
|
@@ -699,7 +705,7 @@ var Parser = class _Parser {
|
|
|
699
705
|
isByVal = this.advance().type === 47 /* KeywordByVal */;
|
|
700
706
|
}
|
|
701
707
|
const token = this.peek();
|
|
702
|
-
if (token.type !== 0 /* Identifier */ && (token.type < 79 /* KeywordBase */ || token.type > 110 /* KeywordAddressOf */)) {
|
|
708
|
+
if (token.type !== 0 /* Identifier */ && !_Parser.CONTEXTUAL_KW.has(token.type) && (token.type < 79 /* KeywordBase */ || token.type > 110 /* KeywordAddressOf */)) {
|
|
703
709
|
this.throwError(`Parse error at line ${token.line}: Expected parameter name (Found ${this.tokenDisplay(token.value)})`);
|
|
704
710
|
}
|
|
705
711
|
const nameToken = this.advance();
|
|
@@ -1112,6 +1118,12 @@ var Parser = class _Parser {
|
|
|
1112
1118
|
}
|
|
1113
1119
|
parseStatementInner() {
|
|
1114
1120
|
const token = this.peek();
|
|
1121
|
+
if (_Parser.CONTEXTUAL_KW.has(token.type) && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1122
|
+
const labelName = token.value;
|
|
1123
|
+
this.advance();
|
|
1124
|
+
this.advance();
|
|
1125
|
+
return { type: "LabelStatement", label: labelName };
|
|
1126
|
+
}
|
|
1115
1127
|
if (token.type === 57 /* KeywordPublic */ || token.type === 58 /* KeywordPrivate */ || token.type === 60 /* KeywordFriend */) {
|
|
1116
1128
|
const scope = this.advance().value.toLowerCase();
|
|
1117
1129
|
const next = this.peek();
|
|
@@ -1293,7 +1305,7 @@ var Parser = class _Parser {
|
|
|
1293
1305
|
}
|
|
1294
1306
|
this.throwError(`Parse error: Expected procedure call after 'Call'`);
|
|
1295
1307
|
} else if (token.type === 0 /* Identifier */ || token.type === 138 /* ForeignName */ || token.type === 129 /* OperatorDot */ || token.type === 1 /* Number */ || _Parser.CONTEXTUAL_KW.has(token.type)) {
|
|
1296
|
-
if (token.type === 0 /* Identifier */ && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1308
|
+
if ((token.type === 0 /* Identifier */ || _Parser.CONTEXTUAL_KW.has(token.type)) && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1297
1309
|
const labelName = token.value;
|
|
1298
1310
|
this.advance();
|
|
1299
1311
|
this.advance();
|
|
@@ -35,6 +35,8 @@ var LexError = class extends Error {
|
|
|
35
35
|
this.name = "LexError";
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var NUMERIC_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@"]);
|
|
39
|
+
var IDENTIFIER_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@", "$"]);
|
|
38
40
|
var Lexer = class _Lexer {
|
|
39
41
|
input = "";
|
|
40
42
|
pos = 0;
|
|
@@ -228,6 +230,7 @@ var Lexer = class _Lexer {
|
|
|
228
230
|
while (/[0-9a-f]/i.test(this.peek())) {
|
|
229
231
|
hexStr += this.advance();
|
|
230
232
|
}
|
|
233
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
231
234
|
return { type: 1 /* Number */, value: "0x" + hexStr, line: startLine, column: startColumn };
|
|
232
235
|
} else if (next === "o" || this.isDigit(next)) {
|
|
233
236
|
if (next === "o") this.advance();
|
|
@@ -235,6 +238,7 @@ var Lexer = class _Lexer {
|
|
|
235
238
|
while (/[0-7]/.test(this.peek())) {
|
|
236
239
|
octStr += this.advance();
|
|
237
240
|
}
|
|
241
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
238
242
|
return { type: 1 /* Number */, value: "0o" + octStr, line: startLine, column: startColumn };
|
|
239
243
|
}
|
|
240
244
|
return { type: 117 /* OperatorAmpersand */, value: "&", line: startLine, column: startColumn };
|
|
@@ -301,8 +305,7 @@ var Lexer = class _Lexer {
|
|
|
301
305
|
numStr += this.advance();
|
|
302
306
|
}
|
|
303
307
|
}
|
|
304
|
-
|
|
305
|
-
if (["%", "&", "@", "!", "#", "^"].indexOf(peekChar) !== -1) {
|
|
308
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) {
|
|
306
309
|
numStr += this.advance();
|
|
307
310
|
}
|
|
308
311
|
return { type: 1 /* Number */, value: numStr, line: startLine, column: startColumn };
|
|
@@ -312,9 +315,12 @@ var Lexer = class _Lexer {
|
|
|
312
315
|
while (this.isAlphaNumeric(this.peek())) {
|
|
313
316
|
idStr += this.advance();
|
|
314
317
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
{
|
|
319
|
+
const nextCh = this.peek();
|
|
320
|
+
const charAfterNext = this.pos + 1 < this.input.length ? this.input[this.pos + 1] : "\0";
|
|
321
|
+
if (IDENTIFIER_TYPE_SUFFIXES.has(nextCh) && !((nextCh === "!" || nextCh === "^") && (this.isAlphaNumeric(charAfterNext) || charAfterNext === "_"))) {
|
|
322
|
+
idStr += this.advance();
|
|
323
|
+
}
|
|
318
324
|
}
|
|
319
325
|
const lowerId = idStr.toLowerCase();
|
|
320
326
|
const lowerBase = lowerId.replace(/[$%&#@]$/, "");
|
|
@@ -31,6 +31,8 @@ var LexError = class extends Error {
|
|
|
31
31
|
this.name = "LexError";
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
+
var NUMERIC_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@"]);
|
|
35
|
+
var IDENTIFIER_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@", "$"]);
|
|
34
36
|
var Lexer = class _Lexer {
|
|
35
37
|
input = "";
|
|
36
38
|
pos = 0;
|
|
@@ -224,6 +226,7 @@ var Lexer = class _Lexer {
|
|
|
224
226
|
while (/[0-9a-f]/i.test(this.peek())) {
|
|
225
227
|
hexStr += this.advance();
|
|
226
228
|
}
|
|
229
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
227
230
|
return { type: 1 /* Number */, value: "0x" + hexStr, line: startLine, column: startColumn };
|
|
228
231
|
} else if (next === "o" || this.isDigit(next)) {
|
|
229
232
|
if (next === "o") this.advance();
|
|
@@ -231,6 +234,7 @@ var Lexer = class _Lexer {
|
|
|
231
234
|
while (/[0-7]/.test(this.peek())) {
|
|
232
235
|
octStr += this.advance();
|
|
233
236
|
}
|
|
237
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
234
238
|
return { type: 1 /* Number */, value: "0o" + octStr, line: startLine, column: startColumn };
|
|
235
239
|
}
|
|
236
240
|
return { type: 117 /* OperatorAmpersand */, value: "&", line: startLine, column: startColumn };
|
|
@@ -297,8 +301,7 @@ var Lexer = class _Lexer {
|
|
|
297
301
|
numStr += this.advance();
|
|
298
302
|
}
|
|
299
303
|
}
|
|
300
|
-
|
|
301
|
-
if (["%", "&", "@", "!", "#", "^"].indexOf(peekChar) !== -1) {
|
|
304
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) {
|
|
302
305
|
numStr += this.advance();
|
|
303
306
|
}
|
|
304
307
|
return { type: 1 /* Number */, value: numStr, line: startLine, column: startColumn };
|
|
@@ -308,9 +311,12 @@ var Lexer = class _Lexer {
|
|
|
308
311
|
while (this.isAlphaNumeric(this.peek())) {
|
|
309
312
|
idStr += this.advance();
|
|
310
313
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
+
{
|
|
315
|
+
const nextCh = this.peek();
|
|
316
|
+
const charAfterNext = this.pos + 1 < this.input.length ? this.input[this.pos + 1] : "\0";
|
|
317
|
+
if (IDENTIFIER_TYPE_SUFFIXES.has(nextCh) && !((nextCh === "!" || nextCh === "^") && (this.isAlphaNumeric(charAfterNext) || charAfterNext === "_"))) {
|
|
318
|
+
idStr += this.advance();
|
|
319
|
+
}
|
|
314
320
|
}
|
|
315
321
|
const lowerId = idStr.toLowerCase();
|
|
316
322
|
const lowerBase = lowerId.replace(/[$%&#@]$/, "");
|
|
@@ -675,7 +681,7 @@ var Parser = class _Parser {
|
|
|
675
681
|
isByVal = this.advance().type === 47 /* KeywordByVal */;
|
|
676
682
|
}
|
|
677
683
|
const token = this.peek();
|
|
678
|
-
if (token.type !== 0 /* Identifier */ && (token.type < 79 /* KeywordBase */ || token.type > 110 /* KeywordAddressOf */)) {
|
|
684
|
+
if (token.type !== 0 /* Identifier */ && !_Parser.CONTEXTUAL_KW.has(token.type) && (token.type < 79 /* KeywordBase */ || token.type > 110 /* KeywordAddressOf */)) {
|
|
679
685
|
this.throwError(`Parse error at line ${token.line}: Expected parameter name (Found ${this.tokenDisplay(token.value)})`);
|
|
680
686
|
}
|
|
681
687
|
const nameToken = this.advance();
|
|
@@ -1088,6 +1094,12 @@ var Parser = class _Parser {
|
|
|
1088
1094
|
}
|
|
1089
1095
|
parseStatementInner() {
|
|
1090
1096
|
const token = this.peek();
|
|
1097
|
+
if (_Parser.CONTEXTUAL_KW.has(token.type) && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1098
|
+
const labelName = token.value;
|
|
1099
|
+
this.advance();
|
|
1100
|
+
this.advance();
|
|
1101
|
+
return { type: "LabelStatement", label: labelName };
|
|
1102
|
+
}
|
|
1091
1103
|
if (token.type === 57 /* KeywordPublic */ || token.type === 58 /* KeywordPrivate */ || token.type === 60 /* KeywordFriend */) {
|
|
1092
1104
|
const scope = this.advance().value.toLowerCase();
|
|
1093
1105
|
const next = this.peek();
|
|
@@ -1269,7 +1281,7 @@ var Parser = class _Parser {
|
|
|
1269
1281
|
}
|
|
1270
1282
|
this.throwError(`Parse error: Expected procedure call after 'Call'`);
|
|
1271
1283
|
} else if (token.type === 0 /* Identifier */ || token.type === 138 /* ForeignName */ || token.type === 129 /* OperatorDot */ || token.type === 1 /* Number */ || _Parser.CONTEXTUAL_KW.has(token.type)) {
|
|
1272
|
-
if (token.type === 0 /* Identifier */ && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1284
|
+
if ((token.type === 0 /* Identifier */ || _Parser.CONTEXTUAL_KW.has(token.type)) && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1273
1285
|
const labelName = token.value;
|
|
1274
1286
|
this.advance();
|
|
1275
1287
|
this.advance();
|
package/dist/bin/vba-run.cjs
CHANGED
|
@@ -35,6 +35,8 @@ var LexError = class extends Error {
|
|
|
35
35
|
this.name = "LexError";
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var NUMERIC_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@"]);
|
|
39
|
+
var IDENTIFIER_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@", "$"]);
|
|
38
40
|
var Lexer = class _Lexer {
|
|
39
41
|
input = "";
|
|
40
42
|
pos = 0;
|
|
@@ -228,6 +230,7 @@ var Lexer = class _Lexer {
|
|
|
228
230
|
while (/[0-9a-f]/i.test(this.peek())) {
|
|
229
231
|
hexStr += this.advance();
|
|
230
232
|
}
|
|
233
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
231
234
|
return { type: 1 /* Number */, value: "0x" + hexStr, line: startLine, column: startColumn };
|
|
232
235
|
} else if (next === "o" || this.isDigit(next)) {
|
|
233
236
|
if (next === "o") this.advance();
|
|
@@ -235,6 +238,7 @@ var Lexer = class _Lexer {
|
|
|
235
238
|
while (/[0-7]/.test(this.peek())) {
|
|
236
239
|
octStr += this.advance();
|
|
237
240
|
}
|
|
241
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
238
242
|
return { type: 1 /* Number */, value: "0o" + octStr, line: startLine, column: startColumn };
|
|
239
243
|
}
|
|
240
244
|
return { type: 117 /* OperatorAmpersand */, value: "&", line: startLine, column: startColumn };
|
|
@@ -301,8 +305,7 @@ var Lexer = class _Lexer {
|
|
|
301
305
|
numStr += this.advance();
|
|
302
306
|
}
|
|
303
307
|
}
|
|
304
|
-
|
|
305
|
-
if (["%", "&", "@", "!", "#", "^"].indexOf(peekChar) !== -1) {
|
|
308
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) {
|
|
306
309
|
numStr += this.advance();
|
|
307
310
|
}
|
|
308
311
|
return { type: 1 /* Number */, value: numStr, line: startLine, column: startColumn };
|
|
@@ -312,9 +315,12 @@ var Lexer = class _Lexer {
|
|
|
312
315
|
while (this.isAlphaNumeric(this.peek())) {
|
|
313
316
|
idStr += this.advance();
|
|
314
317
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
{
|
|
319
|
+
const nextCh = this.peek();
|
|
320
|
+
const charAfterNext = this.pos + 1 < this.input.length ? this.input[this.pos + 1] : "\0";
|
|
321
|
+
if (IDENTIFIER_TYPE_SUFFIXES.has(nextCh) && !((nextCh === "!" || nextCh === "^") && (this.isAlphaNumeric(charAfterNext) || charAfterNext === "_"))) {
|
|
322
|
+
idStr += this.advance();
|
|
323
|
+
}
|
|
318
324
|
}
|
|
319
325
|
const lowerId = idStr.toLowerCase();
|
|
320
326
|
const lowerBase = lowerId.replace(/[$%&#@]$/, "");
|
|
@@ -679,7 +685,7 @@ var Parser = class _Parser {
|
|
|
679
685
|
isByVal = this.advance().type === 47 /* KeywordByVal */;
|
|
680
686
|
}
|
|
681
687
|
const token = this.peek();
|
|
682
|
-
if (token.type !== 0 /* Identifier */ && (token.type < 79 /* KeywordBase */ || token.type > 110 /* KeywordAddressOf */)) {
|
|
688
|
+
if (token.type !== 0 /* Identifier */ && !_Parser.CONTEXTUAL_KW.has(token.type) && (token.type < 79 /* KeywordBase */ || token.type > 110 /* KeywordAddressOf */)) {
|
|
683
689
|
this.throwError(`Parse error at line ${token.line}: Expected parameter name (Found ${this.tokenDisplay(token.value)})`);
|
|
684
690
|
}
|
|
685
691
|
const nameToken = this.advance();
|
|
@@ -1092,6 +1098,12 @@ var Parser = class _Parser {
|
|
|
1092
1098
|
}
|
|
1093
1099
|
parseStatementInner() {
|
|
1094
1100
|
const token = this.peek();
|
|
1101
|
+
if (_Parser.CONTEXTUAL_KW.has(token.type) && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1102
|
+
const labelName = token.value;
|
|
1103
|
+
this.advance();
|
|
1104
|
+
this.advance();
|
|
1105
|
+
return { type: "LabelStatement", label: labelName };
|
|
1106
|
+
}
|
|
1095
1107
|
if (token.type === 57 /* KeywordPublic */ || token.type === 58 /* KeywordPrivate */ || token.type === 60 /* KeywordFriend */) {
|
|
1096
1108
|
const scope = this.advance().value.toLowerCase();
|
|
1097
1109
|
const next = this.peek();
|
|
@@ -1273,7 +1285,7 @@ var Parser = class _Parser {
|
|
|
1273
1285
|
}
|
|
1274
1286
|
this.throwError(`Parse error: Expected procedure call after 'Call'`);
|
|
1275
1287
|
} else if (token.type === 0 /* Identifier */ || token.type === 138 /* ForeignName */ || token.type === 129 /* OperatorDot */ || token.type === 1 /* Number */ || _Parser.CONTEXTUAL_KW.has(token.type)) {
|
|
1276
|
-
if (token.type === 0 /* Identifier */ && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1288
|
+
if ((token.type === 0 /* Identifier */ || _Parser.CONTEXTUAL_KW.has(token.type)) && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1277
1289
|
const labelName = token.value;
|
|
1278
1290
|
this.advance();
|
|
1279
1291
|
this.advance();
|
package/dist/lib.cjs
CHANGED
|
@@ -57,6 +57,8 @@ var LexError = class extends Error {
|
|
|
57
57
|
this.name = "LexError";
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
+
var NUMERIC_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@"]);
|
|
61
|
+
var IDENTIFIER_TYPE_SUFFIXES = /* @__PURE__ */ new Set(["%", "&", "^", "!", "#", "@", "$"]);
|
|
60
62
|
var Lexer = class _Lexer {
|
|
61
63
|
input = "";
|
|
62
64
|
pos = 0;
|
|
@@ -250,6 +252,7 @@ var Lexer = class _Lexer {
|
|
|
250
252
|
while (/[0-9a-f]/i.test(this.peek())) {
|
|
251
253
|
hexStr += this.advance();
|
|
252
254
|
}
|
|
255
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
253
256
|
return { type: 1 /* Number */, value: "0x" + hexStr, line: startLine, column: startColumn };
|
|
254
257
|
} else if (next === "o" || this.isDigit(next)) {
|
|
255
258
|
if (next === "o") this.advance();
|
|
@@ -257,6 +260,7 @@ var Lexer = class _Lexer {
|
|
|
257
260
|
while (/[0-7]/.test(this.peek())) {
|
|
258
261
|
octStr += this.advance();
|
|
259
262
|
}
|
|
263
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) this.advance();
|
|
260
264
|
return { type: 1 /* Number */, value: "0o" + octStr, line: startLine, column: startColumn };
|
|
261
265
|
}
|
|
262
266
|
return { type: 117 /* OperatorAmpersand */, value: "&", line: startLine, column: startColumn };
|
|
@@ -323,8 +327,7 @@ var Lexer = class _Lexer {
|
|
|
323
327
|
numStr += this.advance();
|
|
324
328
|
}
|
|
325
329
|
}
|
|
326
|
-
|
|
327
|
-
if (["%", "&", "@", "!", "#", "^"].indexOf(peekChar) !== -1) {
|
|
330
|
+
if (NUMERIC_TYPE_SUFFIXES.has(this.peek())) {
|
|
328
331
|
numStr += this.advance();
|
|
329
332
|
}
|
|
330
333
|
return { type: 1 /* Number */, value: numStr, line: startLine, column: startColumn };
|
|
@@ -334,9 +337,12 @@ var Lexer = class _Lexer {
|
|
|
334
337
|
while (this.isAlphaNumeric(this.peek())) {
|
|
335
338
|
idStr += this.advance();
|
|
336
339
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
+
{
|
|
341
|
+
const nextCh = this.peek();
|
|
342
|
+
const charAfterNext = this.pos + 1 < this.input.length ? this.input[this.pos + 1] : "\0";
|
|
343
|
+
if (IDENTIFIER_TYPE_SUFFIXES.has(nextCh) && !((nextCh === "!" || nextCh === "^") && (this.isAlphaNumeric(charAfterNext) || charAfterNext === "_"))) {
|
|
344
|
+
idStr += this.advance();
|
|
345
|
+
}
|
|
340
346
|
}
|
|
341
347
|
const lowerId = idStr.toLowerCase();
|
|
342
348
|
const lowerBase = lowerId.replace(/[$%&#@]$/, "");
|
|
@@ -701,7 +707,7 @@ var Parser = class _Parser {
|
|
|
701
707
|
isByVal = this.advance().type === 47 /* KeywordByVal */;
|
|
702
708
|
}
|
|
703
709
|
const token = this.peek();
|
|
704
|
-
if (token.type !== 0 /* Identifier */ && (token.type < 79 /* KeywordBase */ || token.type > 110 /* KeywordAddressOf */)) {
|
|
710
|
+
if (token.type !== 0 /* Identifier */ && !_Parser.CONTEXTUAL_KW.has(token.type) && (token.type < 79 /* KeywordBase */ || token.type > 110 /* KeywordAddressOf */)) {
|
|
705
711
|
this.throwError(`Parse error at line ${token.line}: Expected parameter name (Found ${this.tokenDisplay(token.value)})`);
|
|
706
712
|
}
|
|
707
713
|
const nameToken = this.advance();
|
|
@@ -1114,6 +1120,12 @@ var Parser = class _Parser {
|
|
|
1114
1120
|
}
|
|
1115
1121
|
parseStatementInner() {
|
|
1116
1122
|
const token = this.peek();
|
|
1123
|
+
if (_Parser.CONTEXTUAL_KW.has(token.type) && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1124
|
+
const labelName = token.value;
|
|
1125
|
+
this.advance();
|
|
1126
|
+
this.advance();
|
|
1127
|
+
return { type: "LabelStatement", label: labelName };
|
|
1128
|
+
}
|
|
1117
1129
|
if (token.type === 57 /* KeywordPublic */ || token.type === 58 /* KeywordPrivate */ || token.type === 60 /* KeywordFriend */) {
|
|
1118
1130
|
const scope = this.advance().value.toLowerCase();
|
|
1119
1131
|
const next = this.peek();
|
|
@@ -1295,7 +1307,7 @@ var Parser = class _Parser {
|
|
|
1295
1307
|
}
|
|
1296
1308
|
this.throwError(`Parse error: Expected procedure call after 'Call'`);
|
|
1297
1309
|
} else if (token.type === 0 /* Identifier */ || token.type === 138 /* ForeignName */ || token.type === 129 /* OperatorDot */ || token.type === 1 /* Number */ || _Parser.CONTEXTUAL_KW.has(token.type)) {
|
|
1298
|
-
if (token.type === 0 /* Identifier */ && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1310
|
+
if ((token.type === 0 /* Identifier */ || _Parser.CONTEXTUAL_KW.has(token.type)) && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === 130 /* OperatorColon */) {
|
|
1299
1311
|
const labelName = token.value;
|
|
1300
1312
|
this.advance();
|
|
1301
1313
|
this.advance();
|