affinirum 1.5.4 → 2.0.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/.cache/arrow-preview-vWvB5K/affinirum-arrow-functions.patch +155 -0
- package/.cache/function-syntax-tests.log +20 -0
- package/README.md +925 -355
- package/dst/Affinirum.d.ts +29 -19
- package/dst/Affinirum.js +399 -334
- package/dst/CallFrame.d.ts +12 -3
- package/dst/CallFrame.js +49 -10
- package/dst/Constant.d.ts +1 -3
- package/dst/Constant.js +3 -8
- package/dst/LexicalScope.d.ts +11 -9
- package/dst/LexicalScope.js +10 -6
- package/dst/ParserSpan.d.ts +11 -0
- package/dst/{ScriptSpan.js → ParserSpan.js} +8 -5
- package/dst/ParserState.d.ts +28 -49
- package/dst/ParserState.js +256 -489
- package/dst/Type.d.ts +34 -17
- package/dst/Type.js +211 -115
- package/dst/TypeParser.d.ts +9 -0
- package/dst/TypeParser.js +127 -0
- package/dst/Value.d.ts +1 -1
- package/dst/Value.js +21 -10
- package/dst/Variable.d.ts +16 -5
- package/dst/Variable.js +32 -7
- package/dst/atom/ArrayAtom.d.ts +10 -10
- package/dst/atom/ArrayAtom.js +62 -55
- package/dst/atom/Atom.d.ts +7 -0
- package/dst/atom/FunctionAtom.d.ts +13 -15
- package/dst/atom/FunctionAtom.js +53 -104
- package/dst/atom/FunctionSignature.d.ts +23 -0
- package/dst/atom/FunctionSignature.js +124 -0
- package/dst/atom/ObjectAtom.d.ts +11 -9
- package/dst/atom/ObjectAtom.js +73 -33
- package/dst/atom/PrimitiveAtom.d.ts +6 -7
- package/dst/atom/PrimitiveAtom.js +7 -10
- package/dst/cjs/Affinirum.d.ts +29 -19
- package/dst/cjs/Affinirum.js +398 -333
- package/dst/cjs/CallFrame.d.ts +12 -3
- package/dst/cjs/CallFrame.js +49 -10
- package/dst/cjs/Constant.d.ts +1 -3
- package/dst/cjs/Constant.js +3 -8
- package/dst/cjs/LexicalScope.d.ts +11 -9
- package/dst/cjs/LexicalScope.js +10 -6
- package/dst/cjs/ParserSpan.d.ts +11 -0
- package/dst/cjs/{ScriptSpan.js → ParserSpan.js} +10 -7
- package/dst/cjs/ParserState.d.ts +28 -49
- package/dst/cjs/ParserState.js +255 -488
- package/dst/cjs/Type.d.ts +34 -17
- package/dst/cjs/Type.js +211 -115
- package/dst/cjs/TypeParser.d.ts +9 -0
- package/dst/cjs/TypeParser.js +131 -0
- package/dst/cjs/Value.d.ts +1 -1
- package/dst/cjs/Value.js +21 -10
- package/dst/cjs/Variable.d.ts +16 -5
- package/dst/cjs/Variable.js +36 -9
- package/dst/cjs/atom/ArrayAtom.d.ts +10 -10
- package/dst/cjs/atom/ArrayAtom.js +62 -55
- package/dst/cjs/atom/Atom.d.ts +7 -0
- package/dst/cjs/atom/FunctionAtom.d.ts +13 -15
- package/dst/cjs/atom/FunctionAtom.js +54 -105
- package/dst/cjs/atom/FunctionSignature.d.ts +23 -0
- package/dst/cjs/atom/FunctionSignature.js +128 -0
- package/dst/cjs/atom/ObjectAtom.d.ts +11 -9
- package/dst/cjs/atom/ObjectAtom.js +73 -33
- package/dst/cjs/atom/PrimitiveAtom.d.ts +6 -7
- package/dst/cjs/atom/PrimitiveAtom.js +7 -10
- package/dst/cjs/dictionary/Constants.d.ts +2 -0
- package/dst/cjs/dictionary/Constants.js +27 -0
- package/dst/cjs/dictionary/Functions.d.ts +2 -0
- package/dst/cjs/{Functions.js → dictionary/Functions.js} +27 -25
- package/dst/cjs/native/Aggregable.js +10 -2
- package/dst/cjs/native/Array.d.ts +2 -3
- package/dst/cjs/native/Array.js +38 -39
- package/dst/cjs/native/Boolean.d.ts +1 -1
- package/dst/cjs/native/Boolean.js +13 -10
- package/dst/cjs/native/Buffer.d.ts +5 -5
- package/dst/cjs/native/Buffer.js +70 -46
- package/dst/cjs/native/Composite.d.ts +5 -0
- package/dst/cjs/native/Composite.js +35 -0
- package/dst/cjs/native/Enumerable.js +20 -8
- package/dst/cjs/native/Float.d.ts +3 -1
- package/dst/cjs/native/Float.js +51 -12
- package/dst/cjs/native/Integer.d.ts +4 -2
- package/dst/cjs/native/Integer.js +60 -25
- package/dst/cjs/native/Iterable.d.ts +0 -2
- package/dst/cjs/native/Iterable.js +9 -28
- package/dst/cjs/native/Number.d.ts +0 -2
- package/dst/cjs/native/Number.js +34 -48
- package/dst/cjs/native/Object.d.ts +1 -1
- package/dst/cjs/native/Object.js +5 -6
- package/dst/cjs/native/String.d.ts +7 -6
- package/dst/cjs/native/String.js +28 -27
- package/dst/cjs/native/Timestamp.d.ts +3 -3
- package/dst/cjs/native/Timestamp.js +34 -36
- package/dst/cjs/native/Unknown.d.ts +3 -3
- package/dst/cjs/native/Unknown.js +48 -17
- package/dst/cjs/native/notation/AN.d.ts +1 -1
- package/dst/cjs/native/notation/AN.js +37 -35
- package/dst/cjs/native/notation/IP.d.ts +1 -1
- package/dst/cjs/native/notation/IP.js +11 -12
- package/dst/cjs/native/notation/JSON.d.ts +1 -1
- package/dst/cjs/native/notation/JSON.js +7 -6
- package/dst/cjs/node/AccessNode.d.ts +24 -0
- package/dst/cjs/node/AccessNode.js +193 -0
- package/dst/cjs/node/ArrayNode.d.ts +7 -4
- package/dst/cjs/node/ArrayNode.js +26 -15
- package/dst/cjs/node/AssignableNode.d.ts +16 -0
- package/dst/cjs/node/AssignableNode.js +18 -0
- package/dst/cjs/node/AssignmentNode.d.ts +20 -0
- package/dst/cjs/node/AssignmentNode.js +66 -0
- package/dst/cjs/node/BlockNode.d.ts +5 -4
- package/dst/cjs/node/BlockNode.js +18 -11
- package/dst/cjs/node/CallNode.d.ts +7 -5
- package/dst/cjs/node/CallNode.js +40 -41
- package/dst/cjs/node/CastNode.d.ts +5 -6
- package/dst/cjs/node/CastNode.js +16 -17
- package/dst/cjs/node/ConstantNode.d.ts +4 -6
- package/dst/cjs/node/ConstantNode.js +9 -17
- package/dst/cjs/node/FinalNode.d.ts +19 -0
- package/dst/cjs/node/FinalNode.js +41 -0
- package/dst/cjs/node/FunctionNode.d.ts +17 -0
- package/dst/cjs/node/FunctionNode.js +51 -0
- package/dst/cjs/node/InvocationNode.d.ts +5 -0
- package/dst/cjs/node/InvocationNode.js +34 -0
- package/dst/cjs/node/JumpNode.d.ts +7 -9
- package/dst/cjs/node/JumpNode.js +12 -19
- package/dst/cjs/node/LoopNode.d.ts +7 -5
- package/dst/cjs/node/LoopNode.js +33 -22
- package/dst/cjs/node/MatchNode.d.ts +17 -0
- package/dst/cjs/node/MatchNode.js +65 -0
- package/dst/cjs/node/Node.d.ts +14 -0
- package/dst/cjs/{Node.js → node/Node.js} +17 -11
- package/dst/cjs/node/ObjectNode.d.ts +7 -4
- package/dst/cjs/node/ObjectNode.js +42 -11
- package/dst/cjs/node/{SwitchNode.d.ts → TernaryNode.d.ts} +6 -6
- package/dst/cjs/node/TernaryNode.js +45 -0
- package/dst/cjs/node/VariableNode.d.ts +10 -6
- package/dst/cjs/node/VariableNode.js +50 -16
- package/dst/dictionary/Constants.d.ts +2 -0
- package/dst/dictionary/Constants.js +24 -0
- package/dst/dictionary/Functions.d.ts +2 -0
- package/dst/{Functions.js → dictionary/Functions.js} +26 -24
- package/dst/native/Aggregable.js +11 -3
- package/dst/native/Array.d.ts +2 -3
- package/dst/native/Array.js +37 -38
- package/dst/native/Boolean.d.ts +1 -1
- package/dst/native/Boolean.js +12 -9
- package/dst/native/Buffer.d.ts +5 -5
- package/dst/native/Buffer.js +66 -42
- package/dst/native/Composite.d.ts +5 -0
- package/dst/native/Composite.js +32 -0
- package/dst/native/Enumerable.js +20 -8
- package/dst/native/Float.d.ts +3 -1
- package/dst/native/Float.js +48 -11
- package/dst/native/Integer.d.ts +4 -2
- package/dst/native/Integer.js +56 -23
- package/dst/native/Iterable.d.ts +0 -2
- package/dst/native/Iterable.js +8 -27
- package/dst/native/Number.d.ts +0 -2
- package/dst/native/Number.js +34 -46
- package/dst/native/Object.d.ts +1 -1
- package/dst/native/Object.js +4 -5
- package/dst/native/String.d.ts +7 -6
- package/dst/native/String.js +24 -24
- package/dst/native/Timestamp.d.ts +3 -3
- package/dst/native/Timestamp.js +31 -33
- package/dst/native/Unknown.d.ts +3 -3
- package/dst/native/Unknown.js +49 -18
- package/dst/native/notation/AN.d.ts +1 -1
- package/dst/native/notation/AN.js +37 -35
- package/dst/native/notation/IP.d.ts +1 -1
- package/dst/native/notation/IP.js +10 -11
- package/dst/native/notation/JSON.d.ts +1 -1
- package/dst/native/notation/JSON.js +6 -5
- package/dst/node/AccessNode.d.ts +24 -0
- package/dst/node/AccessNode.js +189 -0
- package/dst/node/ArrayNode.d.ts +7 -4
- package/dst/node/ArrayNode.js +26 -15
- package/dst/node/AssignableNode.d.ts +16 -0
- package/dst/node/AssignableNode.js +14 -0
- package/dst/node/AssignmentNode.d.ts +20 -0
- package/dst/node/AssignmentNode.js +62 -0
- package/dst/node/BlockNode.d.ts +5 -4
- package/dst/node/BlockNode.js +18 -11
- package/dst/node/CallNode.d.ts +7 -5
- package/dst/node/CallNode.js +40 -41
- package/dst/node/CastNode.d.ts +5 -6
- package/dst/node/CastNode.js +16 -17
- package/dst/node/ConstantNode.d.ts +4 -6
- package/dst/node/ConstantNode.js +9 -17
- package/dst/node/FinalNode.d.ts +19 -0
- package/dst/node/FinalNode.js +37 -0
- package/dst/node/FunctionNode.d.ts +17 -0
- package/dst/node/FunctionNode.js +47 -0
- package/dst/node/InvocationNode.d.ts +5 -0
- package/dst/node/InvocationNode.js +30 -0
- package/dst/node/JumpNode.d.ts +7 -9
- package/dst/node/JumpNode.js +12 -19
- package/dst/node/LoopNode.d.ts +7 -5
- package/dst/node/LoopNode.js +33 -22
- package/dst/node/MatchNode.d.ts +17 -0
- package/dst/node/MatchNode.js +61 -0
- package/dst/node/Node.d.ts +14 -0
- package/dst/node/Node.js +28 -0
- package/dst/node/ObjectNode.d.ts +7 -4
- package/dst/node/ObjectNode.js +42 -11
- package/dst/node/{SwitchNode.d.ts → TernaryNode.d.ts} +6 -6
- package/dst/node/TernaryNode.js +41 -0
- package/dst/node/VariableNode.d.ts +10 -6
- package/dst/node/VariableNode.js +50 -16
- package/package.json +4 -4
- package/dst/Atom.d.ts +0 -7
- package/dst/Constants.d.ts +0 -2
- package/dst/Constants.js +0 -24
- package/dst/Functions.d.ts +0 -2
- package/dst/Jump.d.ts +0 -1
- package/dst/Jump.js +0 -1
- package/dst/JumpException.d.ts +0 -9
- package/dst/JumpException.js +0 -14
- package/dst/Keywords.d.ts +0 -1
- package/dst/Keywords.js +0 -17
- package/dst/Node.d.ts +0 -14
- package/dst/Node.js +0 -22
- package/dst/ScriptSpan.d.ts +0 -10
- package/dst/cjs/Atom.d.ts +0 -7
- package/dst/cjs/Constants.d.ts +0 -2
- package/dst/cjs/Constants.js +0 -27
- package/dst/cjs/Functions.d.ts +0 -2
- package/dst/cjs/Jump.d.ts +0 -1
- package/dst/cjs/Jump.js +0 -2
- package/dst/cjs/JumpException.d.ts +0 -9
- package/dst/cjs/JumpException.js +0 -18
- package/dst/cjs/Keywords.d.ts +0 -1
- package/dst/cjs/Keywords.js +0 -20
- package/dst/cjs/Node.d.ts +0 -14
- package/dst/cjs/ScriptSpan.d.ts +0 -10
- package/dst/cjs/node/SwitchNode.js +0 -49
- package/dst/cjs/node/VariadicNode.d.ts +0 -4
- package/dst/cjs/node/VariadicNode.js +0 -10
- package/dst/node/SwitchNode.js +0 -45
- package/dst/node/VariadicNode.d.ts +0 -4
- package/dst/node/VariadicNode.js +0 -6
- /package/dst/{Atom.js → atom/Atom.js} +0 -0
- /package/dst/cjs/{Atom.js → atom/Atom.js} +0 -0
package/dst/ParserState.js
CHANGED
|
@@ -1,564 +1,331 @@
|
|
|
1
|
+
import { Type } from "./Type.js";
|
|
2
|
+
import { Constant } from "./Constant.js";
|
|
3
|
+
import { ParserSpan } from "./ParserSpan.js";
|
|
4
|
+
import { funcRange } from "./native/Array.js";
|
|
1
5
|
import { funcOr, funcAnd, funcNot } from "./native/Boolean.js";
|
|
2
6
|
import { parseLiteralBuffer } from "./native/Buffer.js";
|
|
7
|
+
import { funcAt, funcOptionalAt, funcHas, funcOptionalHas } from "./native/Composite.js";
|
|
3
8
|
import { funcAdd } from "./native/Aggregable.js";
|
|
4
9
|
import { funcGreaterThan, funcLessThan, funcGreaterOrEqual, funcLessOrEqual, funcSubtract, funcMultiply, funcDivide, funcRemainder, funcPower, isNumericSymbol, parseLiteralNumber } from "./native/Number.js";
|
|
5
|
-
import { funcCoalesce,
|
|
6
|
-
import {
|
|
10
|
+
import { funcCoalesce, funcEquals, funcNotEquals } from "./native/Unknown.js";
|
|
11
|
+
import { isIdentifierStartSymbol, isIdentifierSymbol, isWhiteSpaceSymbol, parseLiteralString } from "./native/String.js";
|
|
7
12
|
import { parseLiteralTimestamp } from "./native/Timestamp.js";
|
|
8
|
-
import { Constant } from "./Constant.js";
|
|
9
|
-
import { Type } from "./Type.js";
|
|
10
|
-
import { ScriptSpan } from "./ScriptSpan.js";
|
|
11
13
|
class Literal {
|
|
12
14
|
value;
|
|
13
15
|
constructor(value) {
|
|
14
16
|
this.value = value;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.operator = operator;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const funcAssignment = new Assignment();
|
|
27
|
-
const funcOrAssignment = new Assignment(funcOr);
|
|
28
|
-
const funcAndAssignment = new Assignment(funcAnd);
|
|
29
|
-
const funcAddAssignment = new Assignment(funcAdd);
|
|
30
|
-
const funcSubtractAssignment = new Assignment(funcSubtract);
|
|
31
|
-
const funcMultiplyAssignment = new Assignment(funcMultiply);
|
|
32
|
-
const funcDivideAssignment = new Assignment(funcDivide);
|
|
33
|
-
const funcRemainderAssignment = new Assignment(funcRemainder);
|
|
34
|
-
const idParenthesesOpen = Symbol();
|
|
35
|
-
const idParenthesesClose = Symbol();
|
|
36
|
-
const idBracketsOpen = Symbol();
|
|
37
|
-
const idBracketsClose = Symbol();
|
|
38
|
-
const idBracesOpen = Symbol();
|
|
39
|
-
const idBracesClose = Symbol();
|
|
40
|
-
const idSemicolon = Symbol();
|
|
41
|
-
const idColon = Symbol();
|
|
42
|
-
const idComma = Symbol();
|
|
43
|
-
const idTilda = Symbol();
|
|
44
|
-
const idDot = Symbol();
|
|
45
|
-
const idQuestion = Symbol();
|
|
46
|
-
const idEllipsis = Symbol();
|
|
47
|
-
const idCast = Symbol();
|
|
48
|
-
const idVar = Symbol();
|
|
49
|
-
const idVal = Symbol();
|
|
50
|
-
const idIf = Symbol();
|
|
51
|
-
const idElse = Symbol();
|
|
52
|
-
const idWhile = Symbol();
|
|
53
|
-
const idExit = Symbol();
|
|
54
|
-
const idReturn = Symbol();
|
|
55
|
-
const idStop = Symbol();
|
|
56
|
-
const idNext = Symbol();
|
|
57
|
-
export class ParserState extends ScriptSpan {
|
|
58
|
-
_fragment;
|
|
19
|
+
export class ParserState extends ParserSpan {
|
|
20
|
+
_tokens = new Map(tokens);
|
|
21
|
+
_assignments = new Set(assignments);
|
|
22
|
+
_punctuators = new Set(punctuators);
|
|
23
|
+
_operators = new Set(operators);
|
|
24
|
+
_value;
|
|
59
25
|
constructor(script) {
|
|
60
26
|
super(script);
|
|
61
27
|
}
|
|
62
|
-
|
|
63
|
-
return this.
|
|
64
|
-
}
|
|
65
|
-
get assignment() {
|
|
66
|
-
return this._fragment;
|
|
67
|
-
}
|
|
68
|
-
get operator() {
|
|
69
|
-
return this._fragment;
|
|
70
|
-
}
|
|
71
|
-
get type() {
|
|
72
|
-
return this._fragment;
|
|
73
|
-
}
|
|
74
|
-
get token() {
|
|
75
|
-
return this._fragment;
|
|
76
|
-
}
|
|
77
|
-
get isOperator() {
|
|
78
|
-
return this._fragment instanceof Constant;
|
|
79
|
-
}
|
|
80
|
-
get isLiteral() {
|
|
81
|
-
return this._fragment instanceof Literal;
|
|
28
|
+
equals(...tokens) {
|
|
29
|
+
return tokens.includes(this.text());
|
|
82
30
|
}
|
|
83
|
-
get
|
|
84
|
-
return this.
|
|
31
|
+
get isEnded() {
|
|
32
|
+
return this._start === this._script.length;
|
|
85
33
|
}
|
|
86
34
|
get isType() {
|
|
87
|
-
return this.
|
|
88
|
-
}
|
|
89
|
-
get isToken() {
|
|
90
|
-
return typeof this._fragment === "string";
|
|
91
|
-
}
|
|
92
|
-
get isParenthesesOpen() {
|
|
93
|
-
return this._fragment === idParenthesesOpen;
|
|
94
|
-
}
|
|
95
|
-
get isParenthesesClose() {
|
|
96
|
-
return this._fragment === idParenthesesClose;
|
|
97
|
-
}
|
|
98
|
-
get isBracketsOpen() {
|
|
99
|
-
return this._fragment === idBracketsOpen;
|
|
100
|
-
}
|
|
101
|
-
get isBracketsClose() {
|
|
102
|
-
return this._fragment === idBracketsClose;
|
|
35
|
+
return this._value instanceof Type;
|
|
103
36
|
}
|
|
104
|
-
get
|
|
105
|
-
return this.
|
|
37
|
+
get isConstant() {
|
|
38
|
+
return this._value instanceof Constant;
|
|
106
39
|
}
|
|
107
|
-
get
|
|
108
|
-
return this.
|
|
109
|
-
}
|
|
110
|
-
get isSemicolon() {
|
|
111
|
-
return this._fragment === idSemicolon;
|
|
112
|
-
}
|
|
113
|
-
get isColon() {
|
|
114
|
-
return this._fragment === idColon;
|
|
115
|
-
}
|
|
116
|
-
get isComma() {
|
|
117
|
-
return this._fragment === idComma;
|
|
118
|
-
}
|
|
119
|
-
get isTilda() {
|
|
120
|
-
return this._fragment === idTilda;
|
|
121
|
-
}
|
|
122
|
-
get isDot() {
|
|
123
|
-
return this._fragment === idDot;
|
|
124
|
-
}
|
|
125
|
-
get isQuestion() {
|
|
126
|
-
return this._fragment === idQuestion;
|
|
127
|
-
}
|
|
128
|
-
get isEllipsis() {
|
|
129
|
-
return this._fragment === idEllipsis;
|
|
130
|
-
}
|
|
131
|
-
get isCast() {
|
|
132
|
-
return this._fragment === idCast;
|
|
133
|
-
}
|
|
134
|
-
get isVar() {
|
|
135
|
-
return this._fragment === idVar;
|
|
136
|
-
}
|
|
137
|
-
get isVal() {
|
|
138
|
-
return this._fragment === idVal;
|
|
40
|
+
get isLiteral() {
|
|
41
|
+
return this._value instanceof Literal;
|
|
139
42
|
}
|
|
140
|
-
get
|
|
141
|
-
return this.
|
|
43
|
+
get isIdentifier() {
|
|
44
|
+
return typeof this._value === "string";
|
|
142
45
|
}
|
|
143
|
-
get
|
|
144
|
-
return this.
|
|
46
|
+
get isAssignment() {
|
|
47
|
+
return this._assignments.has(this.text());
|
|
145
48
|
}
|
|
146
|
-
get
|
|
147
|
-
return this.
|
|
49
|
+
get isPunctuator() {
|
|
50
|
+
return this._punctuators.has(this.text());
|
|
148
51
|
}
|
|
149
|
-
get
|
|
150
|
-
return this.
|
|
52
|
+
get isOperator() {
|
|
53
|
+
return this._operators.has(this.text());
|
|
151
54
|
}
|
|
152
|
-
get
|
|
153
|
-
return this.
|
|
55
|
+
get type() {
|
|
56
|
+
return this._value;
|
|
154
57
|
}
|
|
155
|
-
get
|
|
156
|
-
return this.
|
|
58
|
+
get constant() {
|
|
59
|
+
return this._value;
|
|
157
60
|
}
|
|
158
|
-
get
|
|
159
|
-
return this.
|
|
61
|
+
get literal() {
|
|
62
|
+
return this._value;
|
|
160
63
|
}
|
|
161
|
-
get
|
|
162
|
-
return this.
|
|
64
|
+
get identifier() {
|
|
65
|
+
return this._value;
|
|
163
66
|
}
|
|
164
67
|
openParentheses() {
|
|
165
|
-
if (!this.
|
|
68
|
+
if (!this.equals("(")) {
|
|
166
69
|
this.throwError("missing opening parentheses");
|
|
167
70
|
}
|
|
168
|
-
return this;
|
|
169
71
|
}
|
|
170
72
|
closeParentheses() {
|
|
171
|
-
if (!this.
|
|
73
|
+
if (!this.equals(")")) {
|
|
172
74
|
this.throwError("missing closing parentheses");
|
|
173
75
|
}
|
|
174
|
-
return this;
|
|
175
76
|
}
|
|
176
77
|
openBrackets() {
|
|
177
|
-
if (!this.
|
|
78
|
+
if (!this.equals("[")) {
|
|
178
79
|
this.throwError("missing opening brackets");
|
|
179
80
|
}
|
|
180
|
-
return this;
|
|
181
81
|
}
|
|
182
82
|
closeBrackets() {
|
|
183
|
-
if (!this.
|
|
83
|
+
if (!this.equals("]")) {
|
|
184
84
|
this.throwError("missing closing brackets");
|
|
185
85
|
}
|
|
186
|
-
return this;
|
|
187
86
|
}
|
|
188
87
|
openBraces() {
|
|
189
|
-
if (!this.
|
|
88
|
+
if (!this.equals("{")) {
|
|
190
89
|
this.throwError("missing opening braces");
|
|
191
90
|
}
|
|
192
|
-
return this;
|
|
193
91
|
}
|
|
194
92
|
closeBraces() {
|
|
195
|
-
if (!this.
|
|
93
|
+
if (!this.equals("}")) {
|
|
196
94
|
this.throwError("missing closing braces");
|
|
197
95
|
}
|
|
198
|
-
return this;
|
|
199
96
|
}
|
|
200
|
-
|
|
201
|
-
if (!this.
|
|
97
|
+
assertColon() {
|
|
98
|
+
if (!this.equals(":")) {
|
|
202
99
|
this.throwError("missing colon separator");
|
|
203
100
|
}
|
|
204
|
-
return this;
|
|
205
|
-
}
|
|
206
|
-
clone() {
|
|
207
|
-
const state = new ParserState(this._script);
|
|
208
|
-
state._start = this._start;
|
|
209
|
-
state._end = this._end;
|
|
210
|
-
state._fragment = this._fragment;
|
|
211
|
-
return state;
|
|
212
101
|
}
|
|
213
102
|
next() {
|
|
214
|
-
this.
|
|
215
|
-
while (this._end < this._script.length && this.
|
|
103
|
+
this._value = undefined;
|
|
104
|
+
while (this._end < this._script.length && this._value == null) {
|
|
216
105
|
this._start = this._end;
|
|
217
106
|
const c = this._script.charAt(this._end);
|
|
218
107
|
++this._end;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
this.
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
break;
|
|
238
|
-
case "{":
|
|
239
|
-
this._fragment = idBracesOpen;
|
|
240
|
-
break;
|
|
241
|
-
case "}":
|
|
242
|
-
this._fragment = idBracesClose;
|
|
243
|
-
break;
|
|
244
|
-
case ";":
|
|
245
|
-
this._fragment = idSemicolon;
|
|
246
|
-
break;
|
|
247
|
-
case ":":
|
|
248
|
-
switch (this._script.charAt(this._end)) {
|
|
249
|
-
case ":":
|
|
250
|
-
++this._end;
|
|
251
|
-
this._fragment = idCast;
|
|
252
|
-
break;
|
|
253
|
-
default:
|
|
254
|
-
this._fragment = idColon;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
break;
|
|
258
|
-
case ",":
|
|
259
|
-
this._fragment = idComma;
|
|
260
|
-
break;
|
|
261
|
-
case "~":
|
|
262
|
-
switch (this._script.charAt(this._end)) {
|
|
263
|
-
case ">":
|
|
264
|
-
++this._end;
|
|
265
|
-
this._fragment = idReturn;
|
|
266
|
-
break;
|
|
267
|
-
default:
|
|
268
|
-
this._fragment = idTilda;
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
break;
|
|
272
|
-
case "?":
|
|
273
|
-
switch (this._script.charAt(this._end)) {
|
|
274
|
-
case "?":
|
|
275
|
-
++this._end;
|
|
276
|
-
this._fragment = Type.Unknown;
|
|
277
|
-
break;
|
|
278
|
-
case ":":
|
|
279
|
-
++this._end;
|
|
280
|
-
this._fragment = funcCoalesce;
|
|
281
|
-
break;
|
|
282
|
-
default:
|
|
283
|
-
this._fragment = idQuestion;
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
break;
|
|
287
|
-
case "|":
|
|
288
|
-
switch (this._script.charAt(this._end)) {
|
|
289
|
-
case "=":
|
|
290
|
-
++this._end;
|
|
291
|
-
this._fragment = funcOrAssignment;
|
|
292
|
-
break;
|
|
293
|
-
default:
|
|
294
|
-
this._fragment = funcOr;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
break;
|
|
298
|
-
case "&":
|
|
299
|
-
switch (this._script.charAt(this._end)) {
|
|
300
|
-
case "=":
|
|
301
|
-
++this._end;
|
|
302
|
-
this._fragment = funcAndAssignment;
|
|
303
|
-
break;
|
|
304
|
-
default:
|
|
305
|
-
this._fragment = funcAnd;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
break;
|
|
309
|
-
case ">":
|
|
310
|
-
switch (this._script.charAt(this._end)) {
|
|
311
|
-
case "=":
|
|
312
|
-
++this._end;
|
|
313
|
-
this._fragment = funcGreaterOrEqual;
|
|
314
|
-
break;
|
|
315
|
-
default:
|
|
316
|
-
this._fragment = funcGreaterThan;
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
break;
|
|
320
|
-
case "<":
|
|
321
|
-
switch (this._script.charAt(this._end)) {
|
|
322
|
-
case "=":
|
|
323
|
-
++this._end;
|
|
324
|
-
this._fragment = funcLessOrEqual;
|
|
325
|
-
break;
|
|
326
|
-
default:
|
|
327
|
-
this._fragment = funcLessThan;
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
break;
|
|
331
|
-
case "!":
|
|
332
|
-
switch (this._script.charAt(this._end)) {
|
|
333
|
-
case "=":
|
|
334
|
-
++this._end;
|
|
335
|
-
this._fragment = funcNotEqual;
|
|
336
|
-
break;
|
|
337
|
-
default:
|
|
338
|
-
this._fragment = funcNot;
|
|
339
|
-
break;
|
|
340
|
-
}
|
|
341
|
-
break;
|
|
342
|
-
case "=":
|
|
343
|
-
switch (this._script.charAt(this._end)) {
|
|
344
|
-
case "=":
|
|
345
|
-
++this._end;
|
|
346
|
-
this._fragment = funcEqual;
|
|
347
|
-
break;
|
|
348
|
-
case ">":
|
|
349
|
-
++this._end;
|
|
350
|
-
this._fragment = idExit;
|
|
351
|
-
break;
|
|
352
|
-
default:
|
|
353
|
-
this._fragment = funcAssignment;
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
break;
|
|
357
|
-
case "+":
|
|
358
|
-
switch (this._script.charAt(this._end)) {
|
|
359
|
-
case "=":
|
|
108
|
+
if (isIdentifierStartSymbol(c)) {
|
|
109
|
+
while (isIdentifierSymbol(this._script.charAt(this._end))) {
|
|
110
|
+
++this._end;
|
|
111
|
+
}
|
|
112
|
+
this._value = this._tokens.get(this.text()) ?? this.text();
|
|
113
|
+
}
|
|
114
|
+
else if (isNumericSymbol(c)) {
|
|
115
|
+
const [num, numEnd] = parseLiteralNumber(this._script, this._start);
|
|
116
|
+
this._end = numEnd;
|
|
117
|
+
this._value = new Literal(num);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const token = symbolics.get(c)?.find((i) => this._script.startsWith(i, this._start));
|
|
121
|
+
if (token) {
|
|
122
|
+
this._end = this._start + token.length;
|
|
123
|
+
if (token === "//") {
|
|
124
|
+
while (this._script.charAt(this._end) !== "" &&
|
|
125
|
+
this._script.charAt(this._end) !== "\n") {
|
|
360
126
|
++this._end;
|
|
361
|
-
|
|
362
|
-
break;
|
|
363
|
-
default:
|
|
364
|
-
this._fragment = funcAdd;
|
|
365
|
-
break;
|
|
127
|
+
}
|
|
366
128
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
default:
|
|
375
|
-
this._fragment = funcSubtract;
|
|
376
|
-
break;
|
|
129
|
+
else if (token === "///") {
|
|
130
|
+
this._end = this._script.indexOf("///", this._end);
|
|
131
|
+
if (this._end < 0) {
|
|
132
|
+
this._start = this._end = this._script.length;
|
|
133
|
+
throw new Error("missing closing comment mark");
|
|
134
|
+
}
|
|
135
|
+
this._end += 3;
|
|
377
136
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
++this._end;
|
|
383
|
-
this._fragment = funcMultiplyAssignment;
|
|
384
|
-
break;
|
|
385
|
-
default:
|
|
386
|
-
this._fragment = funcMultiply;
|
|
387
|
-
break;
|
|
137
|
+
else if (token === "@") {
|
|
138
|
+
const [ts, tsEnd] = parseLiteralTimestamp(this._script, this._start);
|
|
139
|
+
this._end = tsEnd;
|
|
140
|
+
this._value = new Literal(ts);
|
|
388
141
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
++this._end;
|
|
394
|
-
this._fragment = funcDivideAssignment;
|
|
395
|
-
break;
|
|
396
|
-
case "/":
|
|
397
|
-
if (this._script.charAt(++this._end) === "/") {
|
|
398
|
-
++this._end;
|
|
399
|
-
while (this._script.charAt(this._end) !== ""
|
|
400
|
-
&& (this._script.charAt(this._end) !== c
|
|
401
|
-
|| this._script.charAt(this._end - 1) !== c
|
|
402
|
-
|| this._script.charAt(this._end - 2) !== c)) {
|
|
403
|
-
++this._end;
|
|
404
|
-
}
|
|
405
|
-
if (this._end >= this._script.length) {
|
|
406
|
-
this._start = this._script.length;
|
|
407
|
-
throw new Error("missing closing comment mark");
|
|
408
|
-
}
|
|
409
|
-
++this._end;
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
while (this._script.charAt(this._end) !== ""
|
|
413
|
-
&& this._script.charAt(this._end) !== "\n") {
|
|
414
|
-
++this._end;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
break;
|
|
418
|
-
default:
|
|
419
|
-
this._fragment = funcDivide;
|
|
420
|
-
break;
|
|
142
|
+
else if (token === "`") {
|
|
143
|
+
const [buf, bufEnd] = parseLiteralBuffer(this._script, this._start);
|
|
144
|
+
this._end = bufEnd;
|
|
145
|
+
this._value = new Literal(buf);
|
|
421
146
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
++this._end;
|
|
427
|
-
this._fragment = funcRemainderAssignment;
|
|
428
|
-
break;
|
|
429
|
-
default:
|
|
430
|
-
this._fragment = funcRemainder;
|
|
431
|
-
break;
|
|
147
|
+
else if (token === "'" || token === "\"") {
|
|
148
|
+
const [str, strEnd] = parseLiteralString(this._script, this._start);
|
|
149
|
+
this._end = strEnd;
|
|
150
|
+
this._value = new Literal(str);
|
|
432
151
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
this._fragment = funcPower;
|
|
436
|
-
break;
|
|
437
|
-
case ".":
|
|
438
|
-
switch (this._script.charAt(this._end)) {
|
|
439
|
-
case ".":
|
|
440
|
-
if (this._script.charAt(++this._end) === ".") {
|
|
441
|
-
++this._end;
|
|
442
|
-
this._fragment = idEllipsis;
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
throw new Error("incomplete ellipsis ...");
|
|
446
|
-
}
|
|
447
|
-
break;
|
|
448
|
-
default:
|
|
449
|
-
this._fragment = idDot;
|
|
450
|
-
break;
|
|
152
|
+
else {
|
|
153
|
+
this._value = this._tokens.get(token);
|
|
451
154
|
}
|
|
452
|
-
break;
|
|
453
|
-
case "@": {
|
|
454
|
-
const [ts, tsEnd] = parseLiteralTimestamp(this._script, this._start);
|
|
455
|
-
this._fragment = new Literal(ts);
|
|
456
|
-
this._end = tsEnd;
|
|
457
|
-
break;
|
|
458
155
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
this._fragment = new Literal(buf);
|
|
462
|
-
this._end = bufEnd;
|
|
463
|
-
break;
|
|
156
|
+
else if (!isWhiteSpaceSymbol(c)) {
|
|
157
|
+
throw new Error(`unexpected symbol ${c}`);
|
|
464
158
|
}
|
|
465
|
-
case "\"":
|
|
466
|
-
case "'": {
|
|
467
|
-
const [str, strEnd] = parseLiteralString(this._script, this._start);
|
|
468
|
-
this._fragment = new Literal(str);
|
|
469
|
-
this._end = strEnd;
|
|
470
|
-
break;
|
|
471
|
-
}
|
|
472
|
-
default:
|
|
473
|
-
if (isTokenStartSymbol(c)) {
|
|
474
|
-
while (isTokenSymbol(this._script.charAt(this._end))) {
|
|
475
|
-
++this._end;
|
|
476
|
-
}
|
|
477
|
-
const token = this._script.substring(this._start, this._end);
|
|
478
|
-
switch (token) {
|
|
479
|
-
case "true":
|
|
480
|
-
this._fragment = valueTrue;
|
|
481
|
-
break;
|
|
482
|
-
case "false":
|
|
483
|
-
this._fragment = valueFalse;
|
|
484
|
-
break;
|
|
485
|
-
case "null":
|
|
486
|
-
this._fragment = valueNull;
|
|
487
|
-
break;
|
|
488
|
-
case "void":
|
|
489
|
-
this._fragment = Type.Void;
|
|
490
|
-
break;
|
|
491
|
-
case "bool":
|
|
492
|
-
case "boolean":
|
|
493
|
-
this._fragment = Type.Boolean;
|
|
494
|
-
break;
|
|
495
|
-
case "time":
|
|
496
|
-
case "timestamp":
|
|
497
|
-
this._fragment = Type.Timestamp;
|
|
498
|
-
break;
|
|
499
|
-
case "f64":
|
|
500
|
-
case "float":
|
|
501
|
-
this._fragment = Type.Float;
|
|
502
|
-
break;
|
|
503
|
-
case "i64":
|
|
504
|
-
case "integer":
|
|
505
|
-
this._fragment = Type.Integer;
|
|
506
|
-
break;
|
|
507
|
-
case "buffer":
|
|
508
|
-
this._fragment = Type.Buffer;
|
|
509
|
-
break;
|
|
510
|
-
case "string":
|
|
511
|
-
this._fragment = Type.String;
|
|
512
|
-
break;
|
|
513
|
-
case "array":
|
|
514
|
-
this._fragment = Type.Array;
|
|
515
|
-
break;
|
|
516
|
-
case "object":
|
|
517
|
-
this._fragment = Type.Object;
|
|
518
|
-
break;
|
|
519
|
-
case "function":
|
|
520
|
-
this._fragment = Type.Function;
|
|
521
|
-
break;
|
|
522
|
-
case "var":
|
|
523
|
-
this._fragment = idVar;
|
|
524
|
-
break;
|
|
525
|
-
case "val":
|
|
526
|
-
this._fragment = idVal;
|
|
527
|
-
break;
|
|
528
|
-
case "if":
|
|
529
|
-
this._fragment = idIf;
|
|
530
|
-
break;
|
|
531
|
-
case "else":
|
|
532
|
-
this._fragment = idElse;
|
|
533
|
-
break;
|
|
534
|
-
case "while":
|
|
535
|
-
this._fragment = idWhile;
|
|
536
|
-
break;
|
|
537
|
-
case "stop":
|
|
538
|
-
this._fragment = idStop;
|
|
539
|
-
break;
|
|
540
|
-
case "next":
|
|
541
|
-
this._fragment = idNext;
|
|
542
|
-
break;
|
|
543
|
-
default:
|
|
544
|
-
this._fragment = token;
|
|
545
|
-
break;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
else if (isNumericSymbol(c)) {
|
|
549
|
-
const [num, numEnd] = parseLiteralNumber(this._script, this._start);
|
|
550
|
-
this._fragment = new Literal(num);
|
|
551
|
-
this._end = numEnd;
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
throw new Error(`unknown symbol ${c}`);
|
|
555
|
-
}
|
|
556
|
-
break;
|
|
557
159
|
}
|
|
558
160
|
}
|
|
559
|
-
if (this._end > this._script.length) {
|
|
161
|
+
if (this._end > this._script.length || this._value == null) {
|
|
560
162
|
this._start = this._end = this._script.length;
|
|
561
163
|
}
|
|
562
164
|
return this;
|
|
563
165
|
}
|
|
564
166
|
}
|
|
167
|
+
const tokens = [
|
|
168
|
+
["var", false],
|
|
169
|
+
["val", false],
|
|
170
|
+
["func", false],
|
|
171
|
+
["function", false],
|
|
172
|
+
["if", false],
|
|
173
|
+
["then", false],
|
|
174
|
+
["else", false],
|
|
175
|
+
["match", false],
|
|
176
|
+
["while", false],
|
|
177
|
+
["do", false],
|
|
178
|
+
["until", false],
|
|
179
|
+
["next", false],
|
|
180
|
+
["exit", false],
|
|
181
|
+
["true", new Literal(true)],
|
|
182
|
+
["false", new Literal(false)],
|
|
183
|
+
["null", new Literal(undefined)],
|
|
184
|
+
["never", false],
|
|
185
|
+
["any", Type.Any],
|
|
186
|
+
["bool", Type.Boolean],
|
|
187
|
+
["boolean", Type.Boolean],
|
|
188
|
+
["time", Type.Timestamp],
|
|
189
|
+
["timestamp", Type.Timestamp],
|
|
190
|
+
["f64", Type.Float],
|
|
191
|
+
["float", Type.Float],
|
|
192
|
+
["i64", Type.Integer],
|
|
193
|
+
["integer", Type.Integer],
|
|
194
|
+
["buffer", Type.Buffer],
|
|
195
|
+
["string", Type.String],
|
|
196
|
+
["?:", funcCoalesce],
|
|
197
|
+
["|", funcOr],
|
|
198
|
+
["or", funcOr],
|
|
199
|
+
["&", funcAnd],
|
|
200
|
+
["and", funcAnd],
|
|
201
|
+
["!", funcNot],
|
|
202
|
+
["not", funcNot],
|
|
203
|
+
["!=", funcNotEquals],
|
|
204
|
+
["==", funcEquals],
|
|
205
|
+
[">", funcGreaterThan],
|
|
206
|
+
[">=", funcGreaterOrEqual],
|
|
207
|
+
["<", funcLessThan],
|
|
208
|
+
["<=", funcLessOrEqual],
|
|
209
|
+
["+", funcAdd],
|
|
210
|
+
["-", funcSubtract],
|
|
211
|
+
["*", funcMultiply],
|
|
212
|
+
["**", funcPower],
|
|
213
|
+
["/", funcDivide],
|
|
214
|
+
["%", funcRemainder],
|
|
215
|
+
[".", funcAt],
|
|
216
|
+
[".?", funcHas],
|
|
217
|
+
["?.", funcOptionalAt],
|
|
218
|
+
["?.?", funcOptionalHas],
|
|
219
|
+
["?[", funcOptionalAt],
|
|
220
|
+
["=", false],
|
|
221
|
+
["|=", funcOr],
|
|
222
|
+
["&=", funcAnd],
|
|
223
|
+
["+=", funcAdd],
|
|
224
|
+
["-=", funcSubtract],
|
|
225
|
+
["*=", funcMultiply],
|
|
226
|
+
["/=", funcDivide],
|
|
227
|
+
["%=", funcRemainder],
|
|
228
|
+
["(", false],
|
|
229
|
+
[")", false],
|
|
230
|
+
["[", funcAt],
|
|
231
|
+
["]", false],
|
|
232
|
+
["{", false],
|
|
233
|
+
["}", false],
|
|
234
|
+
[";", false],
|
|
235
|
+
[":", false],
|
|
236
|
+
[",", false],
|
|
237
|
+
["?", false],
|
|
238
|
+
["->", false],
|
|
239
|
+
["=>", false],
|
|
240
|
+
["..", funcRange],
|
|
241
|
+
["...", false],
|
|
242
|
+
["//", false],
|
|
243
|
+
["///", false],
|
|
244
|
+
["@", false],
|
|
245
|
+
["`", false],
|
|
246
|
+
["'", false],
|
|
247
|
+
["\"", false],
|
|
248
|
+
];
|
|
249
|
+
const assignments = [
|
|
250
|
+
"=",
|
|
251
|
+
"|=",
|
|
252
|
+
"&=",
|
|
253
|
+
"+=",
|
|
254
|
+
"-=",
|
|
255
|
+
"*=",
|
|
256
|
+
"/=",
|
|
257
|
+
"%=",
|
|
258
|
+
];
|
|
259
|
+
const punctuators = [
|
|
260
|
+
"(",
|
|
261
|
+
")",
|
|
262
|
+
"[",
|
|
263
|
+
"]",
|
|
264
|
+
"{",
|
|
265
|
+
"}",
|
|
266
|
+
";",
|
|
267
|
+
":",
|
|
268
|
+
",",
|
|
269
|
+
"->",
|
|
270
|
+
"?",
|
|
271
|
+
"=>",
|
|
272
|
+
".",
|
|
273
|
+
".?",
|
|
274
|
+
"...",
|
|
275
|
+
"//",
|
|
276
|
+
"///",
|
|
277
|
+
"@",
|
|
278
|
+
"`",
|
|
279
|
+
"'",
|
|
280
|
+
"\"",
|
|
281
|
+
];
|
|
282
|
+
const operators = [
|
|
283
|
+
"..",
|
|
284
|
+
"?:",
|
|
285
|
+
"|",
|
|
286
|
+
"or",
|
|
287
|
+
"&",
|
|
288
|
+
"and",
|
|
289
|
+
"!",
|
|
290
|
+
"not",
|
|
291
|
+
"!=",
|
|
292
|
+
"==",
|
|
293
|
+
">",
|
|
294
|
+
">=",
|
|
295
|
+
"<",
|
|
296
|
+
"<=",
|
|
297
|
+
"+",
|
|
298
|
+
"-",
|
|
299
|
+
"*",
|
|
300
|
+
"**",
|
|
301
|
+
"/",
|
|
302
|
+
"%",
|
|
303
|
+
"=",
|
|
304
|
+
"|=",
|
|
305
|
+
"&=",
|
|
306
|
+
"+=",
|
|
307
|
+
"-=",
|
|
308
|
+
"*=",
|
|
309
|
+
"/=",
|
|
310
|
+
"%=",
|
|
311
|
+
];
|
|
312
|
+
export const keywords = new Set();
|
|
313
|
+
const symbolics = new Map();
|
|
314
|
+
for (const [lexeme] of tokens) {
|
|
315
|
+
const first = lexeme.charAt(0);
|
|
316
|
+
if (isIdentifierStartSymbol(first)) {
|
|
317
|
+
keywords.add(lexeme);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
const bucket = symbolics.get(first);
|
|
321
|
+
if (bucket) {
|
|
322
|
+
bucket.push(lexeme);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
symbolics.set(first, [lexeme]);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
for (const bucket of symbolics.values()) {
|
|
330
|
+
bucket.sort((a, b) => b.length - a.length);
|
|
331
|
+
}
|