@bikky/replication 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/.idea/Replication.iml +12 -0
- package/.idea/compiler.xml +6 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +3 -1
- package/Expressions/Compiler/Grammar/Accessors.d.ts +32 -0
- package/Expressions/Compiler/Grammar/Accessors.js +227 -0
- package/Expressions/Compiler/Grammar/Accessors.js.map +1 -0
- package/Expressions/Compiler/Grammar/ControlFlow.d.ts +38 -0
- package/Expressions/Compiler/Grammar/ControlFlow.js +178 -0
- package/Expressions/Compiler/Grammar/ControlFlow.js.map +1 -0
- package/Expressions/Compiler/Grammar/Declarations.d.ts +22 -0
- package/Expressions/Compiler/Grammar/Declarations.js +84 -0
- package/Expressions/Compiler/Grammar/Declarations.js.map +1 -0
- package/Expressions/Compiler/Grammar/Function.d.ts +30 -0
- package/Expressions/Compiler/Grammar/Function.js +292 -0
- package/Expressions/Compiler/Grammar/Function.js.map +1 -0
- package/Expressions/Compiler/Grammar/General.d.ts +55 -0
- package/Expressions/Compiler/Grammar/General.js +248 -0
- package/Expressions/Compiler/Grammar/General.js.map +1 -0
- package/Expressions/Compiler/Grammar/Maths.d.ts +26 -0
- package/Expressions/Compiler/Grammar/Maths.js +164 -0
- package/Expressions/Compiler/Grammar/Maths.js.map +1 -0
- package/Expressions/Compiler/Grammar/Misc.d.ts +20 -0
- package/Expressions/Compiler/Grammar/Misc.js +50 -0
- package/Expressions/Compiler/Grammar/Misc.js.map +1 -0
- package/Expressions/Compiler/Grammar/Preprocessors.d.ts +18 -0
- package/Expressions/Compiler/Grammar/Preprocessors.js +43 -0
- package/Expressions/Compiler/Grammar/Preprocessors.js.map +1 -0
- package/Expressions/Compiler/Grammar/Struct.d.ts +21 -0
- package/Expressions/Compiler/Grammar/Struct.js +42 -0
- package/Expressions/Compiler/Grammar/Struct.js.map +1 -0
- package/Expressions/Compiler/Grammar/Tokens.d.ts +7 -0
- package/Expressions/Compiler/Grammar/Tokens.js +270 -0
- package/Expressions/Compiler/Grammar/Tokens.js.map +1 -0
- package/Expressions/Compiler/Grammar/Types.d.ts +35 -0
- package/Expressions/Compiler/Grammar/Types.js +230 -0
- package/Expressions/Compiler/Grammar/Types.js.map +1 -0
- package/Expressions/Compiler/GrammarRegistry.d.ts +20 -0
- package/Expressions/Compiler/GrammarRegistry.js +51 -0
- package/Expressions/Compiler/GrammarRegistry.js.map +1 -0
- package/Expressions/Compiler/Parser/Checks.d.ts +8 -0
- package/Expressions/Compiler/Parser/Checks.js +40 -0
- package/Expressions/Compiler/Parser/Checks.js.map +1 -0
- package/Expressions/Compiler/Parser/Enums.d.ts +73 -0
- package/Expressions/Compiler/Parser/Enums.js +77 -0
- package/Expressions/Compiler/Parser/Enums.js.map +1 -0
- package/Expressions/Compiler/Parser/Interfaces.d.ts +118 -0
- package/Expressions/Compiler/Parser/Interfaces.js +112 -0
- package/Expressions/Compiler/Parser/Interfaces.js.map +1 -0
- package/Expressions/Compiler/Parser/MatchGrammar.d.ts +15 -0
- package/Expressions/Compiler/Parser/MatchGrammar.js +128 -0
- package/Expressions/Compiler/Parser/MatchGrammar.js.map +1 -0
- package/Expressions/Compiler/Parser/MatchRepeatingRule.d.ts +4 -0
- package/Expressions/Compiler/Parser/MatchRepeatingRule.js +51 -0
- package/Expressions/Compiler/Parser/MatchRepeatingRule.js.map +1 -0
- package/Expressions/Compiler/Parser/MatchRule.d.ts +4 -0
- package/Expressions/Compiler/Parser/MatchRule.js +57 -0
- package/Expressions/Compiler/Parser/MatchRule.js.map +1 -0
- package/Expressions/Compiler/Parser/Parser.d.ts +26 -0
- package/Expressions/Compiler/Parser/Parser.js +67 -0
- package/Expressions/Compiler/Parser/Parser.js.map +1 -0
- package/Expressions/Compiler/Parser/Tokenizer.d.ts +12 -0
- package/Expressions/Compiler/Parser/Tokenizer.js +138 -0
- package/Expressions/Compiler/Parser/Tokenizer.js.map +1 -0
- package/Expressions/Compiler/Parser/TypesAndPrint.d.ts +29 -0
- package/Expressions/Compiler/Parser/TypesAndPrint.js +15 -0
- package/Expressions/Compiler/Parser/TypesAndPrint.js.map +1 -0
- package/Expressions/Compiler/Parser/Updates.d.ts +10 -0
- package/Expressions/Compiler/Parser/Updates.js +79 -0
- package/Expressions/Compiler/Parser/Updates.js.map +1 -0
- package/Networking.d.ts +3 -0
- package/Networking.js +19 -5
- package/Networking.js.map +1 -1
- package/package.json +28 -28
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { NodeType, TokenType } from "../Parser/Enums.js";
|
|
2
|
+
import { GrammarRegistry } from "../GrammarRegistry.js";
|
|
3
|
+
import { Versions } from "../../../Constants/Versions.js";
|
|
4
|
+
var ExpressionSyntaxError = GrammarRegistry.ExpressionSyntaxError;
|
|
5
|
+
export function IsStructNode(node) {
|
|
6
|
+
return node.type === NodeType.STRUCT;
|
|
7
|
+
}
|
|
8
|
+
GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.STRUCT, [[
|
|
9
|
+
{ type: TokenType.KEYWORD, value: "struct" },
|
|
10
|
+
{ type: TokenType.IDENTIFIER, name: "name" },
|
|
11
|
+
{ type: TokenType.OPERATOR, value: "{" },
|
|
12
|
+
{
|
|
13
|
+
type: NodeType.PROPERTY_SIGNATURE,
|
|
14
|
+
name: "members",
|
|
15
|
+
repeat: [1, Number.POSITIVE_INFINITY],
|
|
16
|
+
repeatSeparator: { type: TokenType.OPERATOR, value: "," }
|
|
17
|
+
},
|
|
18
|
+
{ type: TokenType.OPERATOR, value: "}" }
|
|
19
|
+
]], {
|
|
20
|
+
runtimeExecute(scope, node, outputType) {
|
|
21
|
+
throw new ExpressionSyntaxError(`Structs are not currently supported`, node);
|
|
22
|
+
},
|
|
23
|
+
compileTimeTraversal(scope, node, outputType) {
|
|
24
|
+
throw new ExpressionSyntaxError(`Structs are not currently supported`, node);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export function IsPropertySignatureNode(node) {
|
|
28
|
+
return node.type === NodeType.PROPERTY_SIGNATURE;
|
|
29
|
+
}
|
|
30
|
+
GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.PROPERTY_SIGNATURE, [[
|
|
31
|
+
{ type: TokenType.IDENTIFIER, name: "identifier" },
|
|
32
|
+
{ type: TokenType.OPERATOR, value: ":" },
|
|
33
|
+
{ type: [NodeType.TYPE_UNION, NodeType.TYPE_DEFINITION], name: "type" },
|
|
34
|
+
]], {
|
|
35
|
+
runtimeExecute(scope, node, outputType) {
|
|
36
|
+
throw new ExpressionSyntaxError(`Structs are not currently supported`, node);
|
|
37
|
+
},
|
|
38
|
+
compileTimeTraversal(scope, node, outputType) {
|
|
39
|
+
throw new ExpressionSyntaxError(`Structs are not currently supported`, node);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=Struct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Struct.js","sourceRoot":"","sources":["Struct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG1D,IAAO,qBAAqB,GAAG,eAAe,CAAC,qBAAqB,CAAC;AAarE,MAAM,UAAU,YAAY,CAAC,IAAU;IACtC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM,CAAC;AACtC,CAAC;AAED,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC1D,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC5C,EAAE,IAAI,EAAE,SAAS,CAA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M,IAAI,qBAAqB,CAAC,qCAAqC,EAAE,IAAI,CAAC,CAAC;IAC9E,CAAC;IACD,oBAAoB,CAAC,KAAK,EAAE,IAA2B,EAAE,UAAU;QAClE,MAAM,IAAI,qBAAqB,CAAC,qCAAqC,EAAE,IAAI,CAAC,CAAC;IAC9E,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GrammarInterfaces } from "../Parser/Interfaces.js";
|
|
2
|
+
import TokenCategoryRule = GrammarInterfaces.TokenCategoryRule;
|
|
3
|
+
import Token = GrammarInterfaces.Token;
|
|
4
|
+
export declare const EAST_Tokens: {
|
|
5
|
+
[category: string]: TokenCategoryRule;
|
|
6
|
+
};
|
|
7
|
+
export declare function isToken(object: any): object is Token;
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { TokenPrecedence, TokenType } from "../Parser/Enums.js";
|
|
2
|
+
import { GrammarRegistry } from "../GrammarRegistry.js";
|
|
3
|
+
import { ChainNumber, ChainString } from "../../TypeRegistry/Primitive.js";
|
|
4
|
+
import { GrammarInterfaces } from "../Parser/Interfaces.js";
|
|
5
|
+
var ExpressionSyntaxError = GrammarRegistry.ExpressionSyntaxError;
|
|
6
|
+
var isAssignableCompile = GrammarInterfaces.isAssignableCompile;
|
|
7
|
+
var collapseTypeLive = GrammarInterfaces.collapseTypeLive;
|
|
8
|
+
import { ErrorStack } from "../../../Constants/Errors.js";
|
|
9
|
+
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
10
|
+
export const EAST_Tokens = {
|
|
11
|
+
Builtin_BlockComment: {
|
|
12
|
+
type: TokenType.BLOCK_COMMENT,
|
|
13
|
+
versions: [/\/\*(.|\n|\r)*?\*\//g],
|
|
14
|
+
debug_name: "Block Comment",
|
|
15
|
+
precedence: TokenPrecedence.Block,
|
|
16
|
+
execution: {
|
|
17
|
+
runtimeExecute(scope, currentNode, outputType) {
|
|
18
|
+
return {
|
|
19
|
+
type: null,
|
|
20
|
+
value: null
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
24
|
+
if (outputType !== null) {
|
|
25
|
+
throw new ExpressionSyntaxError("Block comments cannot return values", currentNode);
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
Builtin_LineComment: {
|
|
32
|
+
type: TokenType.LINE_COMMENT,
|
|
33
|
+
versions: [/\/\/.*/g],
|
|
34
|
+
debug_name: "Line Comment",
|
|
35
|
+
precedence: TokenPrecedence.Line,
|
|
36
|
+
execution: {
|
|
37
|
+
runtimeExecute(scope, currentNode, outputType) {
|
|
38
|
+
return {
|
|
39
|
+
type: null,
|
|
40
|
+
value: null
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
44
|
+
if (outputType !== null) {
|
|
45
|
+
throw new ExpressionSyntaxError("Line comments cannot return values", currentNode);
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
Buildin_BlockString: {
|
|
52
|
+
type: TokenType.BLOCK_STRING,
|
|
53
|
+
versions: [/`(.|\n|\r)*?`/g],
|
|
54
|
+
debug_name: "Block String",
|
|
55
|
+
precedence: TokenPrecedence.Block,
|
|
56
|
+
execution: {
|
|
57
|
+
runtimeExecute(scope, node, outputType) {
|
|
58
|
+
return {
|
|
59
|
+
type: ChainString,
|
|
60
|
+
value: node.data.slice(1, -1),
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
64
|
+
return {
|
|
65
|
+
type: [ChainString],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
Builtin_LineString: {
|
|
71
|
+
type: TokenType.LINE_STRING,
|
|
72
|
+
versions: [/(?:".*?")|(?:'.*?')/g],
|
|
73
|
+
debug_name: "String",
|
|
74
|
+
precedence: TokenPrecedence.Intricate_Builtins,
|
|
75
|
+
execution: {
|
|
76
|
+
runtimeExecute(scope, node, outputType) {
|
|
77
|
+
return {
|
|
78
|
+
type: ChainString,
|
|
79
|
+
value: node.data.slice(1, -1),
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
83
|
+
return {
|
|
84
|
+
type: [ChainString],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
Builtin_Preprocessor: {
|
|
90
|
+
type: TokenType.PREPROCESSOR,
|
|
91
|
+
versions: [/#.*/gm],
|
|
92
|
+
debug_name: "Preprocessor Directive",
|
|
93
|
+
precedence: TokenPrecedence.Line,
|
|
94
|
+
execution: {
|
|
95
|
+
runtimeExecute(scope, currentNode, outputType) {
|
|
96
|
+
throw new ExpressionSyntaxError("Preprocessor directives are not yet supported", currentNode);
|
|
97
|
+
},
|
|
98
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
99
|
+
throw new ExpressionSyntaxError("Preprocessor directives are not yet supported", currentNode);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
//Precedence 3 so that it is a lower priority than number (because of '.').
|
|
104
|
+
Builtin_Hex: {
|
|
105
|
+
type: TokenType.HEX,
|
|
106
|
+
versions: [/\b0x[0-9abcdef]+\b/g],
|
|
107
|
+
debug_name: "Hex Number",
|
|
108
|
+
precedence: TokenPrecedence.Intricate_Builtins,
|
|
109
|
+
execution: {
|
|
110
|
+
runtimeExecute(scope, currentNode, outputType) {
|
|
111
|
+
return {
|
|
112
|
+
type: ChainNumber,
|
|
113
|
+
value: parseInt(currentNode.data, 16),
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
117
|
+
return {
|
|
118
|
+
type: [ChainNumber],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
//Precedence 2 so that it is a lower priority than float and hex.
|
|
124
|
+
Builtin_Integer: {
|
|
125
|
+
type: TokenType.INTEGER,
|
|
126
|
+
versions: [/\b[0-9]+\b/g],
|
|
127
|
+
debug_name: "Integer",
|
|
128
|
+
precedence: TokenPrecedence.Standard_Builtins,
|
|
129
|
+
execution: {
|
|
130
|
+
runtimeExecute(scope, currentNode, outputType) {
|
|
131
|
+
return {
|
|
132
|
+
type: ChainNumber,
|
|
133
|
+
value: parseInt(currentNode.data),
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
137
|
+
return {
|
|
138
|
+
type: [ChainNumber],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
Builtin_Float: {
|
|
144
|
+
type: TokenType.FLOAT,
|
|
145
|
+
versions: [/\b([0-9]+[.][0-9]+([eE][0-9]+)?)|([0-9]+[fF])\b/g],
|
|
146
|
+
debug_name: "Float",
|
|
147
|
+
precedence: TokenPrecedence.Intricate_Builtins,
|
|
148
|
+
execution: {
|
|
149
|
+
runtimeExecute(scope, currentNode, outputType) {
|
|
150
|
+
return {
|
|
151
|
+
type: ChainNumber,
|
|
152
|
+
value: parseFloat(currentNode.data),
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
156
|
+
return {
|
|
157
|
+
type: [ChainNumber],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
//Lower priority than builtin, keyword and hex.
|
|
163
|
+
Identifier: {
|
|
164
|
+
type: TokenType.IDENTIFIER,
|
|
165
|
+
versions: [/\b[a-zA-Z_][a-zA-Z0-9_]+\b/g],
|
|
166
|
+
debug_name: "Identifier",
|
|
167
|
+
precedence: TokenPrecedence.User_Identifiers,
|
|
168
|
+
execution: {
|
|
169
|
+
runtimeExecute(scope, node, outputType) {
|
|
170
|
+
let data = scope.local[node.data] || scope.global[node.data];
|
|
171
|
+
if (data !== undefined) {
|
|
172
|
+
let type = collapseTypeLive(scope, node, data.value, data.type);
|
|
173
|
+
return {
|
|
174
|
+
type: type,
|
|
175
|
+
value: data.value,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
type: null,
|
|
180
|
+
value: null
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
runtimeExecuteWithValidation(scope, node, outputType) {
|
|
184
|
+
let data = scope.local[node.data] || scope.global[node.data];
|
|
185
|
+
if (!data) {
|
|
186
|
+
throw new Error(`Identifier ${node.data} not found in current scope.`);
|
|
187
|
+
}
|
|
188
|
+
if (outputType) {
|
|
189
|
+
let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
|
|
190
|
+
if (!isAssignableCompile(scope.version, outputType, data.type, node, stack)) {
|
|
191
|
+
throw new ExpressionSyntaxError(`Variable returns types ${data.type} but expected ${outputType}\n` + stack.toString(`GT_IDEN_01`), node);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (data !== undefined) {
|
|
195
|
+
let type = collapseTypeLive(scope, node, data.value, data.type);
|
|
196
|
+
return {
|
|
197
|
+
type: type,
|
|
198
|
+
value: data.value,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
type: null,
|
|
203
|
+
value: null
|
|
204
|
+
};
|
|
205
|
+
},
|
|
206
|
+
compileTimeTraversal(scope, node, outputType) {
|
|
207
|
+
let data = scope.local[node.data] || scope.global[node.data];
|
|
208
|
+
if (!data) {
|
|
209
|
+
throw new Error(`Identifier ${node.data} not found in current scope.`);
|
|
210
|
+
}
|
|
211
|
+
if (outputType) {
|
|
212
|
+
let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
|
|
213
|
+
if (!isAssignableCompile(scope.version, outputType, data.type, node, stack)) {
|
|
214
|
+
throw new ExpressionSyntaxError(`Variable returns types ${data.type} but expected ${outputType}\n` + stack.toString(`GT_IDEN_01`), node);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
type: data.type,
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
//The regex for this might be a bit limited, it should probably be revisited.
|
|
224
|
+
Builtin_Whitespace: {
|
|
225
|
+
type: TokenType.WHITESPACE,
|
|
226
|
+
versions: [/[ \t\r\n]+/g],
|
|
227
|
+
debug_name: "Whitespace",
|
|
228
|
+
precedence: TokenPrecedence.Intricate_Builtins,
|
|
229
|
+
execution: {
|
|
230
|
+
runtimeExecute(scope, node, outputType) {
|
|
231
|
+
throw new ExpressionSyntaxError("Whitespace is not supported", node);
|
|
232
|
+
},
|
|
233
|
+
compileTimeTraversal(scope, node, outputType) {
|
|
234
|
+
throw new ExpressionSyntaxError("Whitespace is not supported", node);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
Operator: {
|
|
239
|
+
versions: [new Set([".", "(", ")", "[]", "[", "]", "{}", ",", "=", ":", "=>", "==", "!=", "<", "<=", ">", ">=", "+", "-", "*", "/", "%", "&&", "||", "&", "|", "^", "~"])],
|
|
240
|
+
type: TokenType.OPERATOR,
|
|
241
|
+
debug_name: "Operator",
|
|
242
|
+
precedence: TokenPrecedence.Operators,
|
|
243
|
+
execution: {
|
|
244
|
+
runtimeExecute(scope, node, outputType) {
|
|
245
|
+
throw new ExpressionSyntaxError("Raw operators are not supported", node);
|
|
246
|
+
},
|
|
247
|
+
compileTimeTraversal(scope, node, outputType) {
|
|
248
|
+
throw new ExpressionSyntaxError("Raw operators are not supported", node);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
Keyword: {
|
|
253
|
+
versions: [new Set(["if", "else", "while", "for", "return", "break", "continue", "switch", "case", "default", "struct", "var", "function"])],
|
|
254
|
+
type: TokenType.KEYWORD,
|
|
255
|
+
debug_name: "Keyword",
|
|
256
|
+
precedence: TokenPrecedence.Standard_Builtins,
|
|
257
|
+
execution: {
|
|
258
|
+
runtimeExecute(scope, node, outputType) {
|
|
259
|
+
throw new ExpressionSyntaxError("Raw keywords are not supported", node);
|
|
260
|
+
},
|
|
261
|
+
compileTimeTraversal(scope, node, outputType) {
|
|
262
|
+
throw new ExpressionSyntaxError("Raw keywords are not supported", node);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
export function isToken(object) {
|
|
268
|
+
return "type" in object && typeof TokenType[object.type] !== "undefined";
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=Tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tokens.js","sourceRoot":"","sources":["Tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,IAAO,qBAAqB,GAAG,eAAe,CAAC,qBAAqB,CAAC;AAGrE,IAAO,mBAAmB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC;AAEnE,IAAO,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,kDAAkD;AAClD,MAAM,CAAC,MAAM,WAAW,GAA8C;IACrE,oBAAoB,EAAE;QACrB,IAAI,EAAE,SAAS,CAAC,aAAa;QAC7B,QAAQ,EAAE,CAAC,sBAAsB,CAAC;QAClC,UAAU,EAAE,eAAe;QAC3B,UAAU,E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
|
|
|
1
|
+
import { GrammarInterfaces } from "../Parser/Interfaces.js";
|
|
2
|
+
import { NodeType } from "../Parser/Enums.js";
|
|
3
|
+
import { ArrayAccessSequenceNode } from "./Accessors.js";
|
|
4
|
+
import { FunctionCallNode } from "./Function.js";
|
|
5
|
+
import { ParenthetisedExpressionNode } from "./General.js";
|
|
6
|
+
import { LiteralNode } from "./Misc.js";
|
|
7
|
+
import EAST_Token = GrammarInterfaces.EAST_Token;
|
|
8
|
+
import Node = GrammarInterfaces.Node;
|
|
9
|
+
import EAST_Complex_Node = GrammarInterfaces.EAST_Complex_Node;
|
|
10
|
+
export interface TypeDefinitionNode extends GrammarInterfaces.EAST_Complex_Node {
|
|
11
|
+
type: NodeType.TYPE_DEFINITION;
|
|
12
|
+
values: {
|
|
13
|
+
type: EAST_Token;
|
|
14
|
+
array?: EAST_Token[];
|
|
15
|
+
dictKey?: EAST_Token;
|
|
16
|
+
mapKey?: EAST_Token;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare function IsDeclarationTypeNode(node: Node): node is TypeDefinitionNode;
|
|
20
|
+
export interface TypeUnionNode extends EAST_Complex_Node {
|
|
21
|
+
type: NodeType.TYPE_UNION;
|
|
22
|
+
values: {
|
|
23
|
+
lhs: TypeDefinitionNode;
|
|
24
|
+
rhs: TypeDefinitionNode;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare function IsTypeIntersectionNode(node: Node): node is TypeUnionNode;
|
|
28
|
+
export interface CastNode extends EAST_Complex_Node {
|
|
29
|
+
type: NodeType.CAST;
|
|
30
|
+
values: {
|
|
31
|
+
expression: ArrayAccessSequenceNode | FunctionCallNode | ParenthetisedExpressionNode | EAST_Token | LiteralNode;
|
|
32
|
+
castType: TypeDefinitionNode | TypeUnionNode;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare function IsCastNode(node: Node): node is CastNode;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { GrammarInterfaces } from "../Parser/Interfaces.js";
|
|
2
|
+
import { CollectionType, NodeType, TokenType } from "../Parser/Enums.js";
|
|
3
|
+
import { GrammarRegistry } from "../GrammarRegistry.js";
|
|
4
|
+
import { Versions } from "../../../Constants/Versions.js";
|
|
5
|
+
import { ValidExpressionTypes } from "../../TypeRegistry/Registry.js";
|
|
6
|
+
var GetTypeChain = ValidExpressionTypes.GetTypeChain;
|
|
7
|
+
var ExpressionSyntaxError = GrammarRegistry.ExpressionSyntaxError;
|
|
8
|
+
var assertIsAssignable = GrammarInterfaces.isAssignableCompile;
|
|
9
|
+
var isAssignableCompile = GrammarInterfaces.isAssignableCompile;
|
|
10
|
+
import { ErrorStack } from "../../../Constants/Errors.js";
|
|
11
|
+
var collapseTypeLive = GrammarInterfaces.collapseTypeLive;
|
|
12
|
+
export function IsDeclarationTypeNode(node) {
|
|
13
|
+
return node.type === NodeType.TYPE_DEFINITION;
|
|
14
|
+
}
|
|
15
|
+
//TODO: Support intersection compile-time values.
|
|
16
|
+
GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.TYPE_DEFINITION, [
|
|
17
|
+
[
|
|
18
|
+
{ type: TokenType.IDENTIFIER, value: "Map" },
|
|
19
|
+
{ type: TokenType.OPERATOR, value: "<" },
|
|
20
|
+
{ type: TokenType.IDENTIFIER, name: "mapKey" },
|
|
21
|
+
{ type: TokenType.OPERATOR, value: "," },
|
|
22
|
+
{ type: TokenType.IDENTIFIER, name: "type" },
|
|
23
|
+
{ type: TokenType.OPERATOR, value: ">" },
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
{ type: TokenType.IDENTIFIER, name: "type" },
|
|
27
|
+
{ type: TokenType.OPERATOR, value: "[]", repeat: [0, 2], name: "array" },
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
{ type: TokenType.OPERATOR, value: "{" },
|
|
31
|
+
{ type: TokenType.OPERATOR, value: "[" },
|
|
32
|
+
{ type: TokenType.IDENTIFIER, name: "dictKey" },
|
|
33
|
+
{ type: TokenType.OPERATOR, value: "]" },
|
|
34
|
+
{ type: TokenType.OPERATOR, value: ":" },
|
|
35
|
+
{ type: TokenType.IDENTIFIER, name: "type" },
|
|
36
|
+
{ type: TokenType.OPERATOR, value: "}" },
|
|
37
|
+
],
|
|
38
|
+
], {
|
|
39
|
+
runtimeExecute(scope, currentNode, outputType) {
|
|
40
|
+
var style = CollectionType.Single;
|
|
41
|
+
if (currentNode.values.array) {
|
|
42
|
+
style = currentNode.values.array.length == 2 ? CollectionType.Array2 : CollectionType.Array;
|
|
43
|
+
}
|
|
44
|
+
if (currentNode.values.dictKey) {
|
|
45
|
+
style = CollectionType.Dict;
|
|
46
|
+
}
|
|
47
|
+
if (currentNode.values.mapKey) {
|
|
48
|
+
style = CollectionType.Map;
|
|
49
|
+
}
|
|
50
|
+
const type = GetTypeChain(currentNode.values.type.data, style);
|
|
51
|
+
if (!type) {
|
|
52
|
+
throw new ExpressionSyntaxError(`Unknown type '${currentNode.values.type.data}'`, currentNode);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
castType: [type],
|
|
56
|
+
type: null,
|
|
57
|
+
value: null,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
61
|
+
var style = CollectionType.Single;
|
|
62
|
+
if (currentNode.values.array) {
|
|
63
|
+
style = currentNode.values.array.length == 2 ? CollectionType.Array2 : CollectionType.Array;
|
|
64
|
+
}
|
|
65
|
+
if (currentNode.values.dictKey) {
|
|
66
|
+
style = CollectionType.Dict;
|
|
67
|
+
}
|
|
68
|
+
if (currentNode.values.mapKey) {
|
|
69
|
+
style = CollectionType.Map;
|
|
70
|
+
}
|
|
71
|
+
const type = GetTypeChain(currentNode.values.type.data, style);
|
|
72
|
+
if (!type) {
|
|
73
|
+
throw new ExpressionSyntaxError(`Unknown type '${currentNode.values.type.data}'`, currentNode);
|
|
74
|
+
}
|
|
75
|
+
let stack = new ErrorStack({ Version: scope.version, SourceFile: currentNode.file.sourceLocation });
|
|
76
|
+
if (outputType && !assertIsAssignable(scope.version, outputType, [type], currentNode, stack)) {
|
|
77
|
+
throw new ExpressionSyntaxError(`Type '${currentNode.values.type.data}' does not match expected type.\n\n` + stack.toString(`GT_CAST_TD_01`), currentNode);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
castType: [type],
|
|
81
|
+
type: null
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
export function IsTypeIntersectionNode(node) {
|
|
86
|
+
return node.type === NodeType.TYPE_UNION;
|
|
87
|
+
}
|
|
88
|
+
GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.TYPE_UNION, [
|
|
89
|
+
[{ type: NodeType.TYPE_DEFINITION, name: "lhs" }],
|
|
90
|
+
[{ type: TokenType.OPERATOR, value: "|" }],
|
|
91
|
+
[{ type: [NodeType.TYPE_UNION, NodeType.TYPE_DEFINITION], name: "rhs" }],
|
|
92
|
+
], {
|
|
93
|
+
runtimeExecute(scope, currentNode, outputType) {
|
|
94
|
+
const lhs = currentNode.values.lhs.execute.runtimeExecute(scope, currentNode.values.lhs, outputType);
|
|
95
|
+
const rhs = currentNode.values.rhs.execute.runtimeExecute(scope, currentNode.values.rhs, outputType);
|
|
96
|
+
if (!lhs.castType || !rhs.castType) {
|
|
97
|
+
throw new ExpressionSyntaxError(`Cannot intersect types`, currentNode);
|
|
98
|
+
}
|
|
99
|
+
let castType = [...lhs.castType, ...rhs.castType];
|
|
100
|
+
let stack = new ErrorStack({ Version: scope.version, SourceFile: currentNode.file.sourceLocation });
|
|
101
|
+
if (outputType && assertIsAssignable(scope.version, outputType, castType, currentNode, stack)) {
|
|
102
|
+
throw new ExpressionSyntaxError(`Type does not match expected type.\n\n` + stack.toString(`GT_CAST_UN_01`), currentNode);
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
castType,
|
|
106
|
+
type: null,
|
|
107
|
+
value: null,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
compileTimeTraversal(scope, currentNode, outputType) {
|
|
111
|
+
const lhs = currentNode.values.lhs.execute.compileTimeTraversal(scope, currentNode.values.lhs, outputType);
|
|
112
|
+
const rhs = currentNode.values.rhs.execute.compileTimeTraversal(scope, currentNode.values.rhs, outputType);
|
|
113
|
+
if (!lhs?.castType || !rhs?.castType) {
|
|
114
|
+
throw new ExpressionSyntaxError(`Cannot intersect types`, currentNode);
|
|
115
|
+
}
|
|
116
|
+
let castType = [...lhs.castType, ...rhs.castType];
|
|
117
|
+
let stack = new ErrorStack({ Version: scope.version, SourceFile: currentNode.file.sourceLocation });
|
|
118
|
+
if (outputType && assertIsAssignable(scope.version, outputType, castType, currentNode, stack)) {
|
|
119
|
+
throw new ExpressionSyntaxError(`Type does not match expected type.\n\n` + stack.toString(`GT_CAST_UN_02`), currentNode);
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
castType,
|
|
123
|
+
type: null
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
export function IsCastNode(node) {
|
|
128
|
+
return node.type === NodeType.CAST;
|
|
129
|
+
}
|
|
130
|
+
GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.CAST, [[
|
|
131
|
+
{
|
|
132
|
+
type: [
|
|
133
|
+
NodeType.ARRAY_ACCESS_SEQUENCE,
|
|
134
|
+
NodeType.FUNCTION_CALL,
|
|
135
|
+
NodeType.PARENTHETISED_EXPRESSION,
|
|
136
|
+
TokenType.BUILTIN,
|
|
137
|
+
NodeType.LITERAL,
|
|
138
|
+
TokenType.IDENTIFIER,
|
|
139
|
+
],
|
|
140
|
+
name: "expression"
|
|
141
|
+
},
|
|
142
|
+
{ type: TokenType.OPERATOR, value: ":" },
|
|
143
|
+
{ type: [NodeType.TYPE_DEFINITION, NodeType.TYPE_UNION], name: "castType" }
|
|
144
|
+
]], {
|
|
145
|
+
runtimeExecute(scope, node, outputType) {
|
|
146
|
+
const castTypes = node.values.castType.execute.runtimeExecute(scope, node, null);
|
|
147
|
+
if (!castTypes.castType) {
|
|
148
|
+
throw new ExpressionSyntaxError(`Cannot cast to invalid cast sequence`, node);
|
|
149
|
+
}
|
|
150
|
+
let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
|
|
151
|
+
if (outputType && !isAssignableCompile(scope.version, outputType, castTypes.castType, node, stack)) {
|
|
152
|
+
throw new ExpressionSyntaxError(`Type does not match expected type.\n\n` + stack.toString(`GT_CAST_CAST_01`), node);
|
|
153
|
+
}
|
|
154
|
+
let value = node.values.expression.execute.runtimeExecute(scope, node.values.expression, castTypes.castType);
|
|
155
|
+
let finalType = collapseTypeLive(scope, node, value.value, castTypes.castType);
|
|
156
|
+
if (!finalType) {
|
|
157
|
+
throw new ExpressionSyntaxError(`Value is not castable to type.`, node);
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
type: finalType,
|
|
161
|
+
value: value.value
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
compileTimeTraversal(scope, node, outputType) {
|
|
165
|
+
const castTypes = node.values.castType.execute.compileTimeTraversal(scope, node, null);
|
|
166
|
+
if (!castTypes?.castType) {
|
|
167
|
+
throw new ExpressionSyntaxError(`Cannot cast to invalid cast sequence`, node);
|
|
168
|
+
}
|
|
169
|
+
let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
|
|
170
|
+
if (outputType && !isAssignableCompile(scope.version, outputType, castTypes.castType, node, stack)) {
|
|
171
|
+
throw new ExpressionSyntaxError(`Type does not match expected type.\n\n` + stack.toString(`GT_CAST_CAST_02`), node);
|
|
172
|
+
}
|
|
173
|
+
let value = node.values.expression.execute.compileTimeTraversal(scope, node.values.expression, castTypes.castType);
|
|
174
|
+
if (!value?.type) {
|
|
175
|
+
throw new ExpressionSyntaxError(`Cannot cast expression that returns void to a value.`, node);
|
|
176
|
+
}
|
|
177
|
+
let valid = false;
|
|
178
|
+
for (let type of value.type) {
|
|
179
|
+
if (isAssignableCompile(scope.version, castTypes.castType, [type], node, stack)) {
|
|
180
|
+
valid = true;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (!valid) {
|
|
185
|
+
throw new ExpressionSyntaxError(`Cannot cast value to type, there is no overlap between the operands.`, node);
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
type: castTypes.castType,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
//-------------------------------------------------FORCE CAST-----------------------------------------------
|
|
193
|
+
//Disabled for now - might be supplanted but the newly fixed cast operator above.
|
|
194
|
+
// export interface ForceCastNode extends EAST_Complex_Node {
|
|
195
|
+
// type: NodeType.FORCE_CAST;
|
|
196
|
+
// values: {
|
|
197
|
+
// expression:
|
|
198
|
+
// | ArrayAccessSequenceNode
|
|
199
|
+
// | FunctionCallNode
|
|
200
|
+
// | ParenthetisedExpressionNode
|
|
201
|
+
// | EAST_Token
|
|
202
|
+
// | LiteralNode
|
|
203
|
+
// | MemberAccessNode;
|
|
204
|
+
// castType: EAST_Token;
|
|
205
|
+
// };
|
|
206
|
+
// }
|
|
207
|
+
//
|
|
208
|
+
// export function IsForceCastNode(node: Node): node is ForceCastNode {
|
|
209
|
+
// return node.type === NodeType.FORCE_CAST;
|
|
210
|
+
// }
|
|
211
|
+
//
|
|
212
|
+
// GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.FORCE_CAST, [
|
|
213
|
+
// {
|
|
214
|
+
// type: [
|
|
215
|
+
// NodeType.ARRAY_ACCESS_SEQUENCE,
|
|
216
|
+
// NodeType.FUNCTION_CALL,
|
|
217
|
+
// NodeType.PARENTHETISED_EXPRESSION,
|
|
218
|
+
// TokenType.BUILTIN,
|
|
219
|
+
// NodeType.LITERAL,
|
|
220
|
+
// TokenType.IDENTIFIER
|
|
221
|
+
// ],
|
|
222
|
+
// name: "expression"
|
|
223
|
+
// },
|
|
224
|
+
// { type: TokenType.OPERATOR, value: ":" },
|
|
225
|
+
// { type: TokenType.OPERATOR, value: "=" },
|
|
226
|
+
// { type: [ TokenType.IDENTIFIER ],
|
|
227
|
+
// name: "castType"
|
|
228
|
+
// }
|
|
229
|
+
// ]);
|
|
230
|
+
//# sourceMappingURL=Types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.js","sourceRoot":"","sources":["Types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIzE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAK1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,IAAO,YAAY,GAAG,oBAAoB,CAAC,YAAY,CAAC;AACxD,IAAO,qBAAqB,GAAG,eAAe,CAAC,qBAAqB,CAAC;AAErE,IAAO,kBAAkB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC;AAElE,IAAO,mBAAmB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,IAAO,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;AAa7D,MAAM,UAAU,qBAAqB,CAAC,IAAU;IAC/C,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,eAAe,CAAC;AAC/C,CAAC;AACD,iDAAiD;AACjD,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,EAAE;IAClE;QACC,EAAE,IAAI,EAAE,SAAS,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE;QAC5C,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;Q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MAAM"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NodeNames, NodeType } from "./Parser/Enums.js";
|
|
2
|
+
import { GrammarInterfaces } from "./Parser/Interfaces.js";
|
|
3
|
+
import { ExpressionNode } from "./Grammar/General.js";
|
|
4
|
+
export declare namespace GrammarRegistry {
|
|
5
|
+
import ExpressionSource = GrammarInterfaces.ExpressionSource;
|
|
6
|
+
import EAST_Token = GrammarInterfaces.EAST_Token;
|
|
7
|
+
import Node = GrammarInterfaces.Node;
|
|
8
|
+
import Rule = GrammarInterfaces.Rule;
|
|
9
|
+
import NodeExecution = GrammarInterfaces.NodeExecution;
|
|
10
|
+
import EAST_Complex_Node = GrammarInterfaces.EAST_Complex_Node;
|
|
11
|
+
function AddRule<NodeTokenType extends EAST_Complex_Node>(version: string, name: (typeof NodeType)[NodeNames], rules: Rule[][], execute: NodeExecution<NodeTokenType>): void;
|
|
12
|
+
function getRule(versionIdx: number, name: (typeof NodeType)[NodeNames]): GrammarInterfaces.NodeDefinition;
|
|
13
|
+
function MarkIncidentLocation(source: ExpressionSource, location: number): string;
|
|
14
|
+
class ExpressionSyntaxError extends Error {
|
|
15
|
+
source: ExpressionSource;
|
|
16
|
+
location: number;
|
|
17
|
+
constructor(msg: string, source: ExpressionSource, location: number);
|
|
18
|
+
constructor(msg: string, node: EAST_Token | ExpressionNode | Node);
|
|
19
|
+
}
|
|
20
|
+
}
|