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