affinirum 1.0.3 → 1.0.4
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/dst/Affinirum.d.ts +10 -10
- package/dst/Affinirum.js +41 -41
- package/dst/Constant.d.ts +2 -2
- package/dst/Constant.js +1 -1
- package/dst/Constants.d.ts +1 -1
- package/dst/Constants.js +20 -20
- package/dst/Functions.d.ts +1 -1
- package/dst/Functions.js +75 -75
- package/dst/Keywords.js +15 -15
- package/dst/Node.d.ts +3 -3
- package/dst/Node.js +2 -2
- package/dst/ParserFrame.js +31 -31
- package/dst/ParserState.d.ts +4 -4
- package/dst/ParserState.js +115 -111
- package/dst/StaticScope.d.ts +1 -1
- package/dst/Type.d.ts +5 -5
- package/dst/Type.js +23 -23
- package/dst/Variable.d.ts +2 -2
- package/dst/Variable.js +1 -1
- package/dst/atom/ArrayAtom.d.ts +2 -2
- package/dst/atom/ArrayAtom.js +1 -1
- package/dst/atom/FunctionAtom.d.ts +2 -2
- package/dst/atom/FunctionAtom.js +4 -4
- package/dst/atom/ObjectAtom.d.ts +2 -2
- package/dst/atom/ObjectAtom.js +1 -1
- package/dst/atom/PrimitiveAtom.d.ts +2 -2
- package/dst/atom/PrimitiveAtom.js +8 -8
- package/dst/cjs/Affinirum.js +20 -20
- package/dst/cjs/Constants.js +10 -10
- package/dst/cjs/Functions.js +66 -66
- package/dst/cjs/Keywords.js +15 -15
- package/dst/cjs/Node.js +1 -1
- package/dst/cjs/ParserFrame.js +31 -31
- package/dst/cjs/ParserState.js +106 -102
- package/dst/cjs/Type.js +19 -19
- package/dst/cjs/atom/ArrayAtom.js +1 -1
- package/dst/cjs/atom/FunctionAtom.js +3 -3
- package/dst/cjs/atom/ObjectAtom.js +1 -1
- package/dst/cjs/atom/PrimitiveAtom.js +8 -8
- package/dst/cjs/constant/Boolean.js +1 -1
- package/dst/cjs/constant/Buffer.js +3 -3
- package/dst/cjs/constant/Enumerable.js +3 -3
- package/dst/cjs/constant/Float.js +14 -14
- package/dst/cjs/constant/Integer.js +33 -33
- package/dst/cjs/constant/Iterable.js +2 -2
- package/dst/cjs/constant/Number.js +9 -9
- package/dst/cjs/constant/String.js +20 -22
- package/dst/cjs/constant/Timestamp.js +4 -4
- package/dst/cjs/constant/Unknown.js +22 -22
- package/dst/cjs/constant/notation/AN.js +13 -13
- package/dst/cjs/constant/notation/JSON.js +1 -1
- package/dst/cjs/node/ArrayNode.js +1 -1
- package/dst/cjs/node/BlockNode.js +1 -1
- package/dst/cjs/node/CallNode.js +2 -2
- package/dst/cjs/node/ObjectNode.js +1 -1
- package/dst/cjs/node/SwitchNode.js +1 -1
- package/dst/constant/Array.d.ts +1 -1
- package/dst/constant/Array.js +3 -3
- package/dst/constant/Boolean.d.ts +1 -1
- package/dst/constant/Boolean.js +3 -3
- package/dst/constant/Buffer.d.ts +1 -1
- package/dst/constant/Buffer.js +5 -5
- package/dst/constant/Enumerable.d.ts +1 -1
- package/dst/constant/Enumerable.js +6 -6
- package/dst/constant/Float.d.ts +1 -1
- package/dst/constant/Float.js +16 -16
- package/dst/constant/Integer.d.ts +1 -1
- package/dst/constant/Integer.js +35 -35
- package/dst/constant/Iterable.d.ts +1 -1
- package/dst/constant/Iterable.js +6 -6
- package/dst/constant/Number.d.ts +1 -1
- package/dst/constant/Number.js +11 -11
- package/dst/constant/Object.d.ts +1 -1
- package/dst/constant/Object.js +2 -2
- package/dst/constant/String.d.ts +1 -2
- package/dst/constant/String.js +21 -22
- package/dst/constant/Timestamp.d.ts +1 -1
- package/dst/constant/Timestamp.js +6 -6
- package/dst/constant/Unknown.d.ts +2 -2
- package/dst/constant/Unknown.js +29 -29
- package/dst/constant/notation/AN.d.ts +2 -2
- package/dst/constant/notation/AN.js +17 -17
- package/dst/constant/notation/JSON.d.ts +2 -2
- package/dst/constant/notation/JSON.js +3 -3
- package/dst/index.d.ts +3 -3
- package/dst/index.js +3 -3
- package/dst/node/ArrayNode.d.ts +4 -4
- package/dst/node/ArrayNode.js +5 -5
- package/dst/node/BlockNode.d.ts +4 -4
- package/dst/node/BlockNode.js +5 -5
- package/dst/node/CallNode.d.ts +4 -4
- package/dst/node/CallNode.js +7 -7
- package/dst/node/ConstantNode.d.ts +5 -5
- package/dst/node/ConstantNode.js +1 -1
- package/dst/node/LoopNode.d.ts +4 -4
- package/dst/node/LoopNode.js +2 -2
- package/dst/node/ObjectNode.d.ts +4 -4
- package/dst/node/ObjectNode.js +5 -5
- package/dst/node/SwitchNode.d.ts +4 -4
- package/dst/node/SwitchNode.js +5 -5
- package/dst/node/VariableNode.d.ts +5 -5
- package/dst/node/VariableNode.js +1 -1
- package/package.json +1 -1
package/dst/Affinirum.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Constant } from
|
|
2
|
-
import { Variable } from
|
|
3
|
-
import { Value } from
|
|
4
|
-
import { Type } from
|
|
5
|
-
import { Node } from
|
|
6
|
-
import { LoopNode } from
|
|
7
|
-
import { SwitchNode } from
|
|
8
|
-
import { ParserFrame } from
|
|
9
|
-
import { ParserState } from
|
|
10
|
-
import { StaticScope } from
|
|
1
|
+
import { Constant } from "./Constant.js";
|
|
2
|
+
import { Variable } from "./Variable.js";
|
|
3
|
+
import { Value } from "./Value.js";
|
|
4
|
+
import { Type } from "./Type.js";
|
|
5
|
+
import { Node } from "./Node.js";
|
|
6
|
+
import { LoopNode } from "./node/LoopNode.js";
|
|
7
|
+
import { SwitchNode } from "./node/SwitchNode.js";
|
|
8
|
+
import { ParserFrame } from "./ParserFrame.js";
|
|
9
|
+
import { ParserState } from "./ParserState.js";
|
|
10
|
+
import { StaticScope } from "./StaticScope.js";
|
|
11
11
|
export declare class Affinirum {
|
|
12
12
|
static readonly keywords: string[];
|
|
13
13
|
protected readonly _script: string;
|
package/dst/Affinirum.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { funcOr, funcAnd, funcNot } from
|
|
2
|
-
import { funcAdd } from
|
|
3
|
-
import { funcAt, funcHas } from
|
|
4
|
-
import { funcGreaterThan, funcLessThan, funcGreaterOrEqual, funcLessOrEqual, funcSubtract, funcMultiply, funcDivide, funcRemainder, funcPower, funcNegate } from
|
|
5
|
-
import { funcCoalesce, funcEqual, funcNotEqual } from
|
|
6
|
-
import { Constant } from
|
|
7
|
-
import { Variable } from
|
|
8
|
-
import { Type } from
|
|
9
|
-
import { Keywords } from
|
|
10
|
-
import { Constants } from
|
|
11
|
-
import { Functions } from
|
|
12
|
-
import { ArrayNode } from
|
|
13
|
-
import { BlockNode } from
|
|
14
|
-
import { ConstantNode } from
|
|
15
|
-
import { CallNode } from
|
|
16
|
-
import { LoopNode } from
|
|
17
|
-
import { ObjectNode } from
|
|
18
|
-
import { SwitchNode } from
|
|
19
|
-
import { VariableNode } from
|
|
20
|
-
import { ParserState } from
|
|
21
|
-
import { StaticScope } from
|
|
1
|
+
import { funcOr, funcAnd, funcNot } from "./constant/Boolean.js";
|
|
2
|
+
import { funcAdd } from "./constant/Enumerable.js";
|
|
3
|
+
import { funcAt, funcHas } from "./constant/Iterable.js";
|
|
4
|
+
import { funcGreaterThan, funcLessThan, funcGreaterOrEqual, funcLessOrEqual, funcSubtract, funcMultiply, funcDivide, funcRemainder, funcPower, funcNegate } from "./constant/Number.js";
|
|
5
|
+
import { funcCoalesce, funcEqual, funcNotEqual } from "./constant/Unknown.js";
|
|
6
|
+
import { Constant } from "./Constant.js";
|
|
7
|
+
import { Variable } from "./Variable.js";
|
|
8
|
+
import { Type } from "./Type.js";
|
|
9
|
+
import { Keywords } from "./Keywords.js";
|
|
10
|
+
import { Constants } from "./Constants.js";
|
|
11
|
+
import { Functions } from "./Functions.js";
|
|
12
|
+
import { ArrayNode } from "./node/ArrayNode.js";
|
|
13
|
+
import { BlockNode } from "./node/BlockNode.js";
|
|
14
|
+
import { ConstantNode } from "./node/ConstantNode.js";
|
|
15
|
+
import { CallNode } from "./node/CallNode.js";
|
|
16
|
+
import { LoopNode } from "./node/LoopNode.js";
|
|
17
|
+
import { ObjectNode } from "./node/ObjectNode.js";
|
|
18
|
+
import { SwitchNode } from "./node/SwitchNode.js";
|
|
19
|
+
import { VariableNode } from "./node/VariableNode.js";
|
|
20
|
+
import { ParserState } from "./ParserState.js";
|
|
21
|
+
import { StaticScope } from "./StaticScope.js";
|
|
22
22
|
export class Affinirum {
|
|
23
23
|
static keywords = [...Keywords, ...Constants.map((c) => c[0])];
|
|
24
24
|
_script;
|
|
@@ -47,7 +47,7 @@ export class Affinirum {
|
|
|
47
47
|
const state = new ParserState(this._script);
|
|
48
48
|
this._root = this._block(state.next(), this._scope);
|
|
49
49
|
if (!state.isVoid) {
|
|
50
|
-
state.throwError(
|
|
50
|
+
state.throwError("unexpected expression token or expression end");
|
|
51
51
|
}
|
|
52
52
|
this._root = this._root.compile(config?.type ?? Type.Unknown);
|
|
53
53
|
}
|
|
@@ -190,7 +190,7 @@ export class Affinirum {
|
|
|
190
190
|
const frame = state.starts();
|
|
191
191
|
if (state.isDotMark || state.isQuestionMark) {
|
|
192
192
|
const operator = state.isDotMark ? funcAt : funcHas;
|
|
193
|
-
if (state.next().isLiteral && (typeof state.literal.value ===
|
|
193
|
+
if (state.next().isLiteral && (typeof state.literal.value === "string" || typeof state.literal.value === "bigint")) {
|
|
194
194
|
node = this._call(frame.ends(state), operator, [node, new ConstantNode(state, new Constant(state.literal.value))]);
|
|
195
195
|
state.next();
|
|
196
196
|
}
|
|
@@ -219,7 +219,7 @@ export class Affinirum {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
else {
|
|
222
|
-
state.throwError(
|
|
222
|
+
state.throwError("missing array index or object key");
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
else if (state.isParenthesesOpen) {
|
|
@@ -252,10 +252,10 @@ export class Affinirum {
|
|
|
252
252
|
const constants = this._constants.get(state.token);
|
|
253
253
|
if (constants != null) {
|
|
254
254
|
if (!state.next().isDotMark) {
|
|
255
|
-
state.throwError(
|
|
255
|
+
state.throwError("missing constant accessor operator");
|
|
256
256
|
}
|
|
257
257
|
if (!state.next().isToken) {
|
|
258
|
-
state.throwError(
|
|
258
|
+
state.throwError("missing constant name");
|
|
259
259
|
}
|
|
260
260
|
const constant = constants[state.token];
|
|
261
261
|
if (!constant) {
|
|
@@ -282,7 +282,7 @@ export class Affinirum {
|
|
|
282
282
|
}
|
|
283
283
|
if (state.next().isAssignment) {
|
|
284
284
|
if (variable.constant) {
|
|
285
|
-
state.throwError(
|
|
285
|
+
state.throwError("illegal constant assignment");
|
|
286
286
|
}
|
|
287
287
|
if (state.assignment.operator) {
|
|
288
288
|
const operator = state.assignment.operator;
|
|
@@ -301,7 +301,7 @@ export class Affinirum {
|
|
|
301
301
|
return node;
|
|
302
302
|
}
|
|
303
303
|
else if (state.isBracesClose) {
|
|
304
|
-
state.throwError(
|
|
304
|
+
state.throwError("unexpected closing braces");
|
|
305
305
|
}
|
|
306
306
|
else if (state.isParenthesesOpen) {
|
|
307
307
|
const node = this._unit(state.next(), scope);
|
|
@@ -309,7 +309,7 @@ export class Affinirum {
|
|
|
309
309
|
return node;
|
|
310
310
|
}
|
|
311
311
|
else if (state.isParenthesesClose) {
|
|
312
|
-
state.throwError(
|
|
312
|
+
state.throwError("unexpected closing parentheses");
|
|
313
313
|
}
|
|
314
314
|
else if (state.isBracketsOpen) {
|
|
315
315
|
const frame = state.starts();
|
|
@@ -336,21 +336,21 @@ export class Affinirum {
|
|
|
336
336
|
frame.ends(state);
|
|
337
337
|
state.closeBrackets().next();
|
|
338
338
|
if (colon) {
|
|
339
|
-
return new ObjectNode(frame, subnodes.map(([k, v]) => [typeof k ===
|
|
339
|
+
return new ObjectNode(frame, subnodes.map(([k, v]) => [typeof k === "number" ? new ConstantNode(v, new Constant(String(k))) : k, v]));
|
|
340
340
|
}
|
|
341
341
|
return new ArrayNode(frame, subnodes.map(([, v]) => v));
|
|
342
342
|
}
|
|
343
343
|
else if (state.isBracketsClose) {
|
|
344
|
-
state.throwError(
|
|
344
|
+
state.throwError("unexpected closing brackets");
|
|
345
345
|
}
|
|
346
346
|
else if (state.isVariableDefinition || state.isConstantDefinition) {
|
|
347
347
|
const constant = state.isConstantDefinition;
|
|
348
348
|
if (!state.next().isToken) {
|
|
349
|
-
state.throwError(`missing ${constant ?
|
|
349
|
+
state.throwError(`missing ${constant ? "constant" : "variable"} name`);
|
|
350
350
|
}
|
|
351
351
|
const token = state.token;
|
|
352
352
|
if (scope.has(token)) {
|
|
353
|
-
state.throwError(`illegal redefinition of ${constant ?
|
|
353
|
+
state.throwError(`illegal redefinition of ${constant ? "constant" : "variable"} ${token}`);
|
|
354
354
|
}
|
|
355
355
|
const frame = state.starts();
|
|
356
356
|
let type;
|
|
@@ -361,7 +361,7 @@ export class Affinirum {
|
|
|
361
361
|
scope.local(token, variable);
|
|
362
362
|
if (state.isAssignment) {
|
|
363
363
|
if (state.assignment.operator) {
|
|
364
|
-
state.throwError(`illegal assignment operator to ${constant ?
|
|
364
|
+
state.throwError(`illegal assignment operator to ${constant ? "constant" : "variable"} ${token}`);
|
|
365
365
|
}
|
|
366
366
|
return new VariableNode(frame, variable, this._unit(state.next(), scope));
|
|
367
367
|
}
|
|
@@ -377,9 +377,9 @@ export class Affinirum {
|
|
|
377
377
|
return this._switch(state, scope);
|
|
378
378
|
}
|
|
379
379
|
else if (state.isVoid) {
|
|
380
|
-
state.throwError(
|
|
380
|
+
state.throwError("unexpected end of expression");
|
|
381
381
|
}
|
|
382
|
-
state.throwError(
|
|
382
|
+
state.throwError("unexpected expression token");
|
|
383
383
|
}
|
|
384
384
|
_function(state, scope) {
|
|
385
385
|
const frame = state.starts();
|
|
@@ -392,11 +392,11 @@ export class Affinirum {
|
|
|
392
392
|
const variables = new Map();
|
|
393
393
|
while (!state.next().isParenthesesClose) {
|
|
394
394
|
if (!state.isToken) {
|
|
395
|
-
state.throwError(
|
|
395
|
+
state.throwError("missing function argument name");
|
|
396
396
|
}
|
|
397
397
|
const token = state.token;
|
|
398
398
|
if (scope.get(token)) {
|
|
399
|
-
state.throwError(
|
|
399
|
+
state.throwError("variable redefinition");
|
|
400
400
|
}
|
|
401
401
|
let argType = Type.Unknown;
|
|
402
402
|
if (state.next().isColonSeparator) {
|
|
@@ -488,7 +488,7 @@ export class Affinirum {
|
|
|
488
488
|
itemPropTypes.push([token, this._type(state, scope)]);
|
|
489
489
|
}
|
|
490
490
|
else {
|
|
491
|
-
state.throwError(
|
|
491
|
+
state.throwError("missing type or property name");
|
|
492
492
|
}
|
|
493
493
|
if (!state.isCommaSeparator) {
|
|
494
494
|
break;
|
|
@@ -517,7 +517,7 @@ export class Affinirum {
|
|
|
517
517
|
break;
|
|
518
518
|
}
|
|
519
519
|
else {
|
|
520
|
-
state.throwError(
|
|
520
|
+
state.throwError("variadic function argument must be an array type");
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
if (!state.isCommaSeparator) {
|
|
@@ -531,7 +531,7 @@ export class Affinirum {
|
|
|
531
531
|
return Type.functionType(retType, argTypes, variadic);
|
|
532
532
|
}
|
|
533
533
|
else {
|
|
534
|
-
state.throwError(
|
|
534
|
+
state.throwError("missing type name");
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
537
|
}
|
package/dst/Constant.d.ts
CHANGED
package/dst/Constant.js
CHANGED
package/dst/Constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Constant } from
|
|
1
|
+
import { Constant } from "./Constant.js";
|
|
2
2
|
export declare const Constants: [string, Record<string, Constant>][];
|
package/dst/Constants.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { constArray } from
|
|
2
|
-
import { constBoolean } from
|
|
3
|
-
import { constBuffer } from
|
|
4
|
-
import { constInteger } from
|
|
5
|
-
import { constFloat } from
|
|
6
|
-
import { constObject } from
|
|
7
|
-
import { constString } from
|
|
8
|
-
import { constTimestamp } from
|
|
9
|
-
import { constAN } from
|
|
10
|
-
import { constJSON } from
|
|
1
|
+
import { constArray } from "./constant/Array.js";
|
|
2
|
+
import { constBoolean } from "./constant/Boolean.js";
|
|
3
|
+
import { constBuffer } from "./constant/Buffer.js";
|
|
4
|
+
import { constInteger } from "./constant/Integer.js";
|
|
5
|
+
import { constFloat } from "./constant/Float.js";
|
|
6
|
+
import { constObject } from "./constant/Object.js";
|
|
7
|
+
import { constString } from "./constant/String.js";
|
|
8
|
+
import { constTimestamp } from "./constant/Timestamp.js";
|
|
9
|
+
import { constAN } from "./constant/notation/AN.js";
|
|
10
|
+
import { constJSON } from "./constant/notation/JSON.js";
|
|
11
11
|
export const Constants = [
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
12
|
+
["Array", constArray],
|
|
13
|
+
["Boolean", constBoolean],
|
|
14
|
+
["Buffer", constBuffer],
|
|
15
|
+
["Float", constFloat],
|
|
16
|
+
["Integer", constInteger],
|
|
17
|
+
["Object", constObject],
|
|
18
|
+
["String", constString],
|
|
19
|
+
["Timestamp", constTimestamp],
|
|
20
|
+
["AN", constAN],
|
|
21
|
+
["JSON", constJSON],
|
|
22
22
|
];
|
package/dst/Functions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Constant } from
|
|
1
|
+
import { Constant } from "./Constant.js";
|
|
2
2
|
export declare const Functions: [string, Constant][];
|
package/dst/Functions.js
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { funcFirst, funcLast, funcFirstIndex, funcLastIndex, funcEvery, funcAny, funcFlatten, funcReverse, funcMutate, funcFilter, funcReduce, funcCompose, funcPrepend, funcAppend } from
|
|
2
|
-
import { funcByte } from
|
|
3
|
-
import { funcAdd, funcSlice, funcSplice, funcInject } from
|
|
4
|
-
import { funcLength, funcContains, funcAt, funcHas } from
|
|
5
|
-
import { funcGreaterThan, funcLessThan, funcGreaterOrEqual, funcLessOrEqual, funcSubtract, funcMultiply, funcDivide, funcRemainder, funcModulo, funcPower, funcRoot, funcNegate, funcCast } from
|
|
6
|
-
import { funcEntries, funcKeys, funcValues } from
|
|
7
|
-
import { funcLike, funcUnlike, funcStartsWith, funcEndsWith, funcChar, funcCharCode, funcTrim, funcTrimStart, funcTrimEnd, funcLowerCase, funcUpperCase, funcSplit } from
|
|
8
|
-
import { funcYear, funcMonth, funcMonthIndex, funcWeekdayIndex, funcDay, funcHour, funcMinute, funcSecond, funcMillisecond, funcEpochTime } from
|
|
9
|
-
import { funcCoalesce, funcEqual, funcNotEqual, funcEncode, funcFormat } from
|
|
1
|
+
import { funcFirst, funcLast, funcFirstIndex, funcLastIndex, funcEvery, funcAny, funcFlatten, funcReverse, funcMutate, funcFilter, funcReduce, funcCompose, funcPrepend, funcAppend } from "./constant/Array.js";
|
|
2
|
+
import { funcByte } from "./constant/Buffer.js";
|
|
3
|
+
import { funcAdd, funcSlice, funcSplice, funcInject } from "./constant/Enumerable.js";
|
|
4
|
+
import { funcLength, funcContains, funcAt, funcHas } from "./constant/Iterable.js";
|
|
5
|
+
import { funcGreaterThan, funcLessThan, funcGreaterOrEqual, funcLessOrEqual, funcSubtract, funcMultiply, funcDivide, funcRemainder, funcModulo, funcPower, funcRoot, funcNegate, funcCast } from "./constant/Number.js";
|
|
6
|
+
import { funcEntries, funcKeys, funcValues } from "./constant/Object.js";
|
|
7
|
+
import { funcLike, funcUnlike, funcStartsWith, funcEndsWith, funcChar, funcCharCode, funcTrim, funcTrimStart, funcTrimEnd, funcLowerCase, funcUpperCase, funcSplit } from "./constant/String.js";
|
|
8
|
+
import { funcYear, funcMonth, funcMonthIndex, funcWeekdayIndex, funcDay, funcHour, funcMinute, funcSecond, funcMillisecond, funcEpochTime } from "./constant/Timestamp.js";
|
|
9
|
+
import { funcCoalesce, funcEqual, funcNotEqual, funcEncode, funcFormat } from "./constant/Unknown.js";
|
|
10
10
|
export const Functions = [
|
|
11
11
|
// Array
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
12
|
+
["First", funcFirst],
|
|
13
|
+
["Last", funcLast],
|
|
14
|
+
["FirstIndex", funcFirstIndex],
|
|
15
|
+
["LastIndex", funcLastIndex],
|
|
16
|
+
["Any", funcAny],
|
|
17
|
+
["Every", funcEvery],
|
|
18
|
+
["Flatten", funcFlatten],
|
|
19
|
+
["Reverse", funcReverse],
|
|
20
|
+
["Mutate", funcMutate],
|
|
21
|
+
["Filter", funcFilter],
|
|
22
|
+
["Reduce", funcReduce],
|
|
23
|
+
["Compose", funcCompose],
|
|
24
|
+
["Prepend", funcPrepend],
|
|
25
|
+
["Append", funcAppend],
|
|
26
26
|
// Buffer
|
|
27
|
-
[
|
|
27
|
+
["Byte", funcByte],
|
|
28
28
|
// Enumerable
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
29
|
+
["Add", funcAdd],
|
|
30
|
+
["Slice", funcSlice],
|
|
31
|
+
["Splice", funcSplice],
|
|
32
|
+
["Inject", funcInject],
|
|
33
33
|
// Iterable
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
34
|
+
["Length", funcLength],
|
|
35
|
+
["Contains", funcContains],
|
|
36
|
+
["At", funcAt],
|
|
37
|
+
["Has", funcHas],
|
|
38
38
|
// Number
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
39
|
+
["GreaterThan", funcGreaterThan],
|
|
40
|
+
["LessThan", funcLessThan],
|
|
41
|
+
["GreaterOrEqual", funcGreaterOrEqual],
|
|
42
|
+
["LessOrEqual", funcLessOrEqual],
|
|
43
|
+
["Subtract", funcSubtract],
|
|
44
|
+
["Multiply", funcMultiply],
|
|
45
|
+
["Divide", funcDivide],
|
|
46
|
+
["Remainder", funcRemainder],
|
|
47
|
+
["Modulo", funcModulo],
|
|
48
|
+
["Power", funcPower],
|
|
49
|
+
["Root", funcRoot],
|
|
50
|
+
["Negate", funcNegate],
|
|
51
|
+
["Cast", funcCast],
|
|
52
52
|
// Object
|
|
53
|
-
[
|
|
54
|
-
[
|
|
55
|
-
[
|
|
53
|
+
["Entries", funcEntries],
|
|
54
|
+
["Keys", funcKeys],
|
|
55
|
+
["Values", funcValues],
|
|
56
56
|
// String
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
57
|
+
["Like", funcLike],
|
|
58
|
+
["Unlike", funcUnlike],
|
|
59
|
+
["StartsWith", funcStartsWith],
|
|
60
|
+
["EndsWith", funcEndsWith],
|
|
61
|
+
["Char", funcChar],
|
|
62
|
+
["CharCode", funcCharCode],
|
|
63
|
+
["Trim", funcTrim],
|
|
64
|
+
["TrimStart", funcTrimStart],
|
|
65
|
+
["TrimEnd", funcTrimEnd],
|
|
66
|
+
["LowerCase", funcLowerCase],
|
|
67
|
+
["UpperCase", funcUpperCase],
|
|
68
|
+
["Split", funcSplit],
|
|
69
69
|
// Timestamp
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
-
[
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[
|
|
70
|
+
["Year", funcYear],
|
|
71
|
+
["Month", funcMonth],
|
|
72
|
+
["MonthIndex", funcMonthIndex],
|
|
73
|
+
["WeekdayIndex", funcWeekdayIndex],
|
|
74
|
+
["Day", funcDay],
|
|
75
|
+
["Hour", funcHour],
|
|
76
|
+
["Minute", funcMinute],
|
|
77
|
+
["Second", funcSecond],
|
|
78
|
+
["Millisecond", funcMillisecond],
|
|
79
|
+
["EpochTime", funcEpochTime],
|
|
80
80
|
// Unknown
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
81
|
+
["Coalesce", funcCoalesce],
|
|
82
|
+
["Equal", funcEqual],
|
|
83
|
+
["Unequal", funcNotEqual],
|
|
84
|
+
["Encode", funcEncode],
|
|
85
|
+
["Format", funcFormat],
|
|
86
86
|
];
|
package/dst/Keywords.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export const Keywords = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"true", "false",
|
|
3
|
+
"null", "void",
|
|
4
|
+
"boolean", "bool",
|
|
5
|
+
"timestamp", "time",
|
|
6
|
+
"float", "flo",
|
|
7
|
+
"integer", "int",
|
|
8
|
+
"buffer", "buf",
|
|
9
|
+
"string", "str",
|
|
10
|
+
"array", "arr",
|
|
11
|
+
"object", "obj",
|
|
12
|
+
"function", "func",
|
|
13
|
+
"variable", "var",
|
|
14
|
+
"constant", "const",
|
|
15
|
+
"while",
|
|
16
|
+
"if", "else",
|
|
17
17
|
];
|
package/dst/Node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ParserFrame } from
|
|
2
|
-
import { Value } from
|
|
3
|
-
import { Type } from
|
|
1
|
+
import { ParserFrame } from "./ParserFrame.js";
|
|
2
|
+
import { Value } from "./Value.js";
|
|
3
|
+
import { Type } from "./Type.js";
|
|
4
4
|
export declare abstract class Node extends ParserFrame {
|
|
5
5
|
constructor(frame: ParserFrame);
|
|
6
6
|
abstract type: Type;
|
package/dst/Node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParserFrame } from
|
|
1
|
+
import { ParserFrame } from "./ParserFrame.js";
|
|
2
2
|
export class Node extends ParserFrame {
|
|
3
3
|
constructor(frame) {
|
|
4
4
|
super(frame.expr, frame.start, frame.end);
|
|
@@ -17,6 +17,6 @@ export class Node extends ParserFrame {
|
|
|
17
17
|
return this.throwError(`type ${this.type} mismatch with expected type ${type}`);
|
|
18
18
|
}
|
|
19
19
|
toString(ident = 0) {
|
|
20
|
-
return
|
|
20
|
+
return " ".repeat(ident) + `[${this._start}:${this.end}] <${this.type}>`;
|
|
21
21
|
}
|
|
22
22
|
}
|
package/dst/ParserFrame.js
CHANGED
|
@@ -33,13 +33,13 @@ export class ParserFrame {
|
|
|
33
33
|
throwError(message) {
|
|
34
34
|
const offset = this._start < 32 ? 0 : this._start - 32;
|
|
35
35
|
const length = this._end < this._start ? 0 : this._end - this._start - 1;
|
|
36
|
-
let expr =
|
|
36
|
+
let expr = "";
|
|
37
37
|
for (let i = 0; i < this._expr.length; ++i) {
|
|
38
38
|
const c = this._expr[i];
|
|
39
|
-
expr += SPACE_SYMBOLS.includes(c) ?
|
|
39
|
+
expr += SPACE_SYMBOLS.includes(c) ? " " : c;
|
|
40
40
|
}
|
|
41
41
|
throw new Error(`error: ${message} at position ${this._start}:\n${expr.substring(offset, offset + 60)}\n` +
|
|
42
|
-
`${
|
|
42
|
+
`${" ".repeat(expr.substring(offset, this._start).length)}^${"'".repeat(length)}`);
|
|
43
43
|
}
|
|
44
44
|
toString() {
|
|
45
45
|
return `[${this._start}:${this._end}]`;
|
|
@@ -47,34 +47,34 @@ export class ParserFrame {
|
|
|
47
47
|
}
|
|
48
48
|
const SPACE_SYMBOLS = [
|
|
49
49
|
// Whitespace and line-breaking characters
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
"\t", // tab
|
|
51
|
+
"\n", // newline
|
|
52
|
+
"\r", // carriage return
|
|
53
|
+
"\f", // form feed
|
|
54
|
+
"\v", // vertical tab
|
|
55
55
|
// Unicode spaces and separators
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
"\u00A0", // no-break space
|
|
57
|
+
"\u1680", // ogham space mark
|
|
58
|
+
"\u180E", // mongolian vowel separator
|
|
59
|
+
"\u2000", // en quad
|
|
60
|
+
"\u2001", // em quad
|
|
61
|
+
"\u2002", // en space
|
|
62
|
+
"\u2003", // em space
|
|
63
|
+
"\u2004", // three-per-em space
|
|
64
|
+
"\u2005", // four-per-em space
|
|
65
|
+
"\u2006", // six-per-em space
|
|
66
|
+
"\u2007", // figure space
|
|
67
|
+
"\u2008", // punctuation space
|
|
68
|
+
"\u2009", // thin space
|
|
69
|
+
"\u200A", // hair space
|
|
70
|
+
"\u2028", // line separator
|
|
71
|
+
"\u2029", // paragraph separator
|
|
72
|
+
"\u205F", // medium mathematical space
|
|
73
|
+
"\u3000", // ideographic space
|
|
74
74
|
// Zero-width & directional formatting characters
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
"\u200B", // zero-width space
|
|
76
|
+
"\u200C", // zero-width non-joiner
|
|
77
|
+
"\u200D", // zero-width joiner
|
|
78
|
+
"\u2060", // word joiner
|
|
79
|
+
"\uFEFF", // byte order mark
|
|
80
80
|
];
|
package/dst/ParserState.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Constant } from
|
|
2
|
-
import { Value } from
|
|
3
|
-
import { Type } from
|
|
4
|
-
import { ParserFrame } from
|
|
1
|
+
import { Constant } from "./Constant.js";
|
|
2
|
+
import { Value } from "./Value.js";
|
|
3
|
+
import { Type } from "./Type.js";
|
|
4
|
+
import { ParserFrame } from "./ParserFrame.js";
|
|
5
5
|
declare class Literal {
|
|
6
6
|
readonly value: Value;
|
|
7
7
|
constructor(value: Value);
|