@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.
Files changed (76) hide show
  1. package/.idea/Replication.iml +12 -0
  2. package/.idea/compiler.xml +6 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/vcs.xml +3 -1
  6. package/Expressions/Compiler/Grammar/Accessors.d.ts +32 -0
  7. package/Expressions/Compiler/Grammar/Accessors.js +227 -0
  8. package/Expressions/Compiler/Grammar/Accessors.js.map +1 -0
  9. package/Expressions/Compiler/Grammar/ControlFlow.d.ts +38 -0
  10. package/Expressions/Compiler/Grammar/ControlFlow.js +178 -0
  11. package/Expressions/Compiler/Grammar/ControlFlow.js.map +1 -0
  12. package/Expressions/Compiler/Grammar/Declarations.d.ts +22 -0
  13. package/Expressions/Compiler/Grammar/Declarations.js +84 -0
  14. package/Expressions/Compiler/Grammar/Declarations.js.map +1 -0
  15. package/Expressions/Compiler/Grammar/Function.d.ts +30 -0
  16. package/Expressions/Compiler/Grammar/Function.js +292 -0
  17. package/Expressions/Compiler/Grammar/Function.js.map +1 -0
  18. package/Expressions/Compiler/Grammar/General.d.ts +55 -0
  19. package/Expressions/Compiler/Grammar/General.js +248 -0
  20. package/Expressions/Compiler/Grammar/General.js.map +1 -0
  21. package/Expressions/Compiler/Grammar/Maths.d.ts +26 -0
  22. package/Expressions/Compiler/Grammar/Maths.js +164 -0
  23. package/Expressions/Compiler/Grammar/Maths.js.map +1 -0
  24. package/Expressions/Compiler/Grammar/Misc.d.ts +20 -0
  25. package/Expressions/Compiler/Grammar/Misc.js +50 -0
  26. package/Expressions/Compiler/Grammar/Misc.js.map +1 -0
  27. package/Expressions/Compiler/Grammar/Preprocessors.d.ts +18 -0
  28. package/Expressions/Compiler/Grammar/Preprocessors.js +43 -0
  29. package/Expressions/Compiler/Grammar/Preprocessors.js.map +1 -0
  30. package/Expressions/Compiler/Grammar/Struct.d.ts +21 -0
  31. package/Expressions/Compiler/Grammar/Struct.js +42 -0
  32. package/Expressions/Compiler/Grammar/Struct.js.map +1 -0
  33. package/Expressions/Compiler/Grammar/Tokens.d.ts +7 -0
  34. package/Expressions/Compiler/Grammar/Tokens.js +270 -0
  35. package/Expressions/Compiler/Grammar/Tokens.js.map +1 -0
  36. package/Expressions/Compiler/Grammar/Types.d.ts +35 -0
  37. package/Expressions/Compiler/Grammar/Types.js +230 -0
  38. package/Expressions/Compiler/Grammar/Types.js.map +1 -0
  39. package/Expressions/Compiler/GrammarRegistry.d.ts +20 -0
  40. package/Expressions/Compiler/GrammarRegistry.js +51 -0
  41. package/Expressions/Compiler/GrammarRegistry.js.map +1 -0
  42. package/Expressions/Compiler/Parser/Checks.d.ts +8 -0
  43. package/Expressions/Compiler/Parser/Checks.js +40 -0
  44. package/Expressions/Compiler/Parser/Checks.js.map +1 -0
  45. package/Expressions/Compiler/Parser/Enums.d.ts +73 -0
  46. package/Expressions/Compiler/Parser/Enums.js +77 -0
  47. package/Expressions/Compiler/Parser/Enums.js.map +1 -0
  48. package/Expressions/Compiler/Parser/Interfaces.d.ts +118 -0
  49. package/Expressions/Compiler/Parser/Interfaces.js +112 -0
  50. package/Expressions/Compiler/Parser/Interfaces.js.map +1 -0
  51. package/Expressions/Compiler/Parser/MatchGrammar.d.ts +15 -0
  52. package/Expressions/Compiler/Parser/MatchGrammar.js +128 -0
  53. package/Expressions/Compiler/Parser/MatchGrammar.js.map +1 -0
  54. package/Expressions/Compiler/Parser/MatchRepeatingRule.d.ts +4 -0
  55. package/Expressions/Compiler/Parser/MatchRepeatingRule.js +51 -0
  56. package/Expressions/Compiler/Parser/MatchRepeatingRule.js.map +1 -0
  57. package/Expressions/Compiler/Parser/MatchRule.d.ts +4 -0
  58. package/Expressions/Compiler/Parser/MatchRule.js +57 -0
  59. package/Expressions/Compiler/Parser/MatchRule.js.map +1 -0
  60. package/Expressions/Compiler/Parser/Parser.d.ts +26 -0
  61. package/Expressions/Compiler/Parser/Parser.js +67 -0
  62. package/Expressions/Compiler/Parser/Parser.js.map +1 -0
  63. package/Expressions/Compiler/Parser/Tokenizer.d.ts +12 -0
  64. package/Expressions/Compiler/Parser/Tokenizer.js +138 -0
  65. package/Expressions/Compiler/Parser/Tokenizer.js.map +1 -0
  66. package/Expressions/Compiler/Parser/TypesAndPrint.d.ts +29 -0
  67. package/Expressions/Compiler/Parser/TypesAndPrint.js +15 -0
  68. package/Expressions/Compiler/Parser/TypesAndPrint.js.map +1 -0
  69. package/Expressions/Compiler/Parser/Updates.d.ts +10 -0
  70. package/Expressions/Compiler/Parser/Updates.js +79 -0
  71. package/Expressions/Compiler/Parser/Updates.js.map +1 -0
  72. package/Networking.d.ts +3 -0
  73. package/Networking.js +19 -5
  74. package/Networking.js.map +1 -1
  75. package/package.json +28 -28
  76. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,248 @@
1
+ import { GrammarInterfaces } from "../Parser/Interfaces.js";
2
+ import { NodeType, TokenType } from "../Parser/Enums.js";
3
+ import { GrammarRegistry } from "../GrammarRegistry.js";
4
+ import { Versions } from "../../../Constants/Versions.js";
5
+ import { CONTROL_FLOW_STATEMENTS } from "./ControlFlow.js";
6
+ var SpecialType = GrammarInterfaces.SpecialType;
7
+ var ExpressionSyntaxError = GrammarRegistry.ExpressionSyntaxError;
8
+ var isAssignableCompile = GrammarInterfaces.isAssignableCompile;
9
+ import { ErrorStack } from "../../../Constants/Errors.js";
10
+ import { describeObject } from "../../../Constants/SerialisationTypes.js";
11
+ export function IsFileNode(node) {
12
+ return node.type === NodeType.FILE;
13
+ }
14
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.FILE, [[
15
+ {
16
+ type: [NodeType.COMMENT, NodeType.PREPROCESSOR_COMMAND, NodeType.FUNCTION_DECLARATION, NodeType.DECLARATION, NodeType.EXPRESSION],
17
+ name: "lines",
18
+ repeat: [0, Number.POSITIVE_INFINITY]
19
+ }
20
+ ]], {
21
+ runtimeExecute(scope, node, outputType) {
22
+ let output = null;
23
+ for (const line of node.values.lines) {
24
+ let result = line.execute.runtimeExecute(scope, line, null);
25
+ if (result) {
26
+ if (output) {
27
+ throw new ExpressionSyntaxError(`Cannot output more than one value from an expression`, node);
28
+ }
29
+ else {
30
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
31
+ if (!isAssignableCompile(scope.version, result.type ? [result.type] : null, outputType, node, stack)) {
32
+ throw new Error(`Cannot assign "${result.type}" to "${outputType}".\n` + stack.toString(`EXP_GR_GFN_01`));
33
+ }
34
+ output = result;
35
+ }
36
+ }
37
+ if (result.interrupt) {
38
+ throw new ExpressionSyntaxError(`Cannot ${result.interrupt} from a file`, node);
39
+ }
40
+ }
41
+ if (!output && outputType) {
42
+ throw new ExpressionSyntaxError(`Expression requires that a value is returned matching ${outputType.map((e) => describeObject(e)).join(",")}`, node);
43
+ }
44
+ return output ?? {
45
+ type: null,
46
+ value: undefined
47
+ };
48
+ },
49
+ compileTimeTraversal(scope, node, outputType) {
50
+ let output = null;
51
+ for (const line of node.values.lines) {
52
+ let result = line.execute.compileTimeTraversal(scope, line, null);
53
+ if (result) {
54
+ if (output) {
55
+ throw new ExpressionSyntaxError(`Cannot output more than one value from an expression`, node);
56
+ }
57
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
58
+ if (!isAssignableCompile(scope.version, result.type, outputType, node, stack)) {
59
+ throw new Error(`Cannot assign "${result.type}" to "${outputType}".\n` + stack.toString(`EXP_GR_GFN_01`));
60
+ }
61
+ output = result;
62
+ }
63
+ }
64
+ if (!output && outputType) {
65
+ throw new ExpressionSyntaxError(`Expression requires that a value is returned matching ${outputType.map((e) => describeObject(e)).join(",")}`, node);
66
+ }
67
+ return output;
68
+ }
69
+ });
70
+ export function IsBlockNode(node) {
71
+ return node.type === NodeType.BLOCK;
72
+ }
73
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.BLOCK, [[
74
+ { type: TokenType.OPERATOR, value: "{" },
75
+ {
76
+ type: [
77
+ NodeType.COMMENT,
78
+ NodeType.DECLARATION,
79
+ NodeType.STATEMENT,
80
+ ...CONTROL_FLOW_STATEMENTS,
81
+ SpecialType.INPUT_TYPES
82
+ ],
83
+ input: [SpecialType.INPUT_TYPES],
84
+ name: "lines",
85
+ repeat: [0, Number.POSITIVE_INFINITY]
86
+ },
87
+ { type: TokenType.OPERATOR, value: "}" }
88
+ ]], {
89
+ runtimeExecute(scope, node, outputType) {
90
+ for (const line of node.values.lines) {
91
+ let result = line.execute.runtimeExecute(scope, line, null);
92
+ if (result.interrupt === "return") {
93
+ return {
94
+ value: result.value,
95
+ type: result.type
96
+ };
97
+ }
98
+ else if (result.interrupt) {
99
+ throw new ExpressionSyntaxError(`Cannot ${result.interrupt} from a file`, node);
100
+ }
101
+ }
102
+ if (outputType) {
103
+ throw new ExpressionSyntaxError(`Block requires that a value is returned matching ${outputType.map((e) => describeObject(e)).join(",")}`, node);
104
+ }
105
+ return {
106
+ type: null,
107
+ value: undefined
108
+ };
109
+ },
110
+ compileTimeTraversal(scope, node, outputType) {
111
+ for (const line of node.values.lines) {
112
+ let result = line.execute.compileTimeTraversal(scope, line, null);
113
+ if (result) {
114
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
115
+ let valid = isAssignableCompile(scope.version, result.type, outputType, node, stack);
116
+ if (!valid) {
117
+ throw new Error(`Cannot assign "${result.type}" to "${outputType}".\n` + stack.toString(`EXP_GR_GFN_01`));
118
+ }
119
+ }
120
+ }
121
+ if (outputType) {
122
+ throw new ExpressionSyntaxError(`Block requires that a value is returned matching ${outputType.map((e) => describeObject(e)).join(",")}`, node);
123
+ }
124
+ return {
125
+ type: null,
126
+ value: undefined
127
+ };
128
+ }
129
+ });
130
+ export function IsStatementNode(node) {
131
+ return node.type === NodeType.STATEMENT;
132
+ }
133
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.STATEMENT, [[
134
+ { type: NodeType.EXPRESSION, unroll: true },
135
+ { type: TokenType.OPERATOR, value: ";" }
136
+ ]], {
137
+ runtimeExecute(scope, node, outputType) {
138
+ return node.values.expression.execute.runtimeExecute(scope, node.values.expression, outputType);
139
+ },
140
+ compileTimeTraversal(scope, node, outputType) {
141
+ return node.values.expression.execute.compileTimeTraversal(scope, node.values.expression, outputType);
142
+ }
143
+ });
144
+ export function IsExpressionNode(node) {
145
+ return node.type === NodeType.EXPRESSION;
146
+ }
147
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.EXPRESSION, [[
148
+ {
149
+ type: [
150
+ NodeType.MEMBER_ACCESS,
151
+ NodeType.FORCE_CAST,
152
+ NodeType.ARRAY_ACCESS_SEQUENCE,
153
+ NodeType.FUNCTION_CALL,
154
+ NodeType.CAST,
155
+ NodeType.BINARY_EXPRESSION,
156
+ NodeType.PARENTHETISED_EXPRESSION,
157
+ NodeType.UNARY_EXPRESSION,
158
+ NodeType.ASSIGNMENT,
159
+ TokenType.BUILTIN,
160
+ NodeType.LITERAL,
161
+ TokenType.IDENTIFIER,
162
+ ],
163
+ name: "expression"
164
+ }
165
+ ]], {
166
+ runtimeExecute(scope, node, outputType) {
167
+ return node.values.expression.execute.runtimeExecute(scope, node.values.expression, outputType);
168
+ },
169
+ compileTimeTraversal(scope, node, outputType) {
170
+ return node.values.expression.execute.compileTimeTraversal(scope, node.values.expression, outputType);
171
+ }
172
+ });
173
+ export function IsParenthetisedExpressionNode(node) {
174
+ return node.type === NodeType.PARENTHETISED_EXPRESSION;
175
+ }
176
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.PARENTHETISED_EXPRESSION, [[
177
+ { type: TokenType.OPERATOR, value: "(" },
178
+ { type: NodeType.EXPRESSION, unroll: true },
179
+ { type: TokenType.OPERATOR, value: ")" }
180
+ ]], {
181
+ runtimeExecute(scope, node, outputType) {
182
+ return node.values.expression.execute.runtimeExecute(scope, node.values.expression, outputType);
183
+ },
184
+ compileTimeTraversal(scope, node, outputType) {
185
+ return node.values.expression.execute.compileTimeTraversal(scope, node.values.expression, outputType);
186
+ }
187
+ });
188
+ export function IdentifierNode(node) {
189
+ return node.type === NodeType.IDENTIFIER;
190
+ }
191
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.IDENTIFIER, [[
192
+ { type: TokenType.IDENTIFIER, name: "name" },
193
+ ]], {
194
+ runtimeExecute(scope, node, outputType) {
195
+ let lookupName = node.values.name.data;
196
+ let appendix = "";
197
+ let value = scope.local[lookupName] ?? scope.global[lookupName];
198
+ if (!value) {
199
+ throw new ExpressionSyntaxError(`Error: "${lookupName}" doesn't exist in this scope.` + appendix, node);
200
+ }
201
+ let selectedType;
202
+ let errorStack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
203
+ for (let type of value.type) {
204
+ if (type.kind == "value") {
205
+ if (type.isAssignable(scope.version, !!scope.data, value, errorStack)) {
206
+ selectedType = type;
207
+ break;
208
+ }
209
+ }
210
+ else {
211
+ //TODO: Do better typechecking for functions.
212
+ if (typeof value === "function") {
213
+ selectedType = type;
214
+ break;
215
+ }
216
+ }
217
+ }
218
+ if (!selectedType) {
219
+ throw new ExpressionSyntaxError(`Error: "${lookupName}"'s contents don't have a valid value.` + errorStack.toString(`EXP_GR_GEN_ID_01`), node);
220
+ }
221
+ if (!isAssignableCompile(scope.version, value.type, outputType, node, errorStack)) {
222
+ throw new ExpressionSyntaxError(`Error: "${lookupName}" is not assignable to the expected type.`, node);
223
+ }
224
+ return {
225
+ type: selectedType,
226
+ value: value.value
227
+ };
228
+ },
229
+ compileTimeTraversal(scope, node, outputType) {
230
+ let lookupName = node.values.name.data;
231
+ let value = scope.local[lookupName] ?? scope.global[lookupName];
232
+ if (!value) {
233
+ let appendix = "";
234
+ //Kinda hacky, but since expressions are PascalCase by default, we can do a hard-coded reminder here.
235
+ //TODO: Actually check to see if the upper-case version exists.
236
+ if (lookupName[0].toLowerCase() == lookupName[0]) {
237
+ appendix = ` Did you mean to write "${lookupName[0].toUpperCase() + lookupName.slice(1)}"?`;
238
+ }
239
+ throw new ExpressionSyntaxError(`Error: "${lookupName}" doesn't exist in this scope.` + appendix, node);
240
+ }
241
+ let errorStack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
242
+ if (!isAssignableCompile(scope.version, value.type, outputType, node, errorStack)) {
243
+ throw new ExpressionSyntaxError(`Error: "${lookupName}" is not assignable to the expected type.`, node);
244
+ }
245
+ return value;
246
+ }
247
+ });
248
+ //# sourceMappingURL=General.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"General.js","sourceRoot":"","sources":["General.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,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;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAM3D,IAAO,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC;AAKnD,IAAO,qBAAqB,GAAG,eAAe,CAAC,qBAAqB,CAAC;AACrE,IAAO,mBAAmB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAiB1E,MAAM,UAAU,UAAU,CAAC,IAAU;IACpC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC;AACpC,CAAC;AAED,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxD;YACC,IAAI,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,oBAAoB,EAAE,QAAQ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;IACD,oBAAoB,CAAC,KAAK,EAAE,IAAoB,EAAE,UAAU;QAC3D,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QAEvC,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAEhE,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,IAAI,QAAQ,GAAG,EAAE,CAAC;YAClB,qGAAqG;YACrG,+DAA+D;YAC/D,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClD,QAAQ,GAAG,2BAA2B,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;YAC7F,CAAC;YACD,MAAM,IAAI,qBAAqB,CAAC,WAAW,UAAU,gCAAgC,GAAG,QAAQ,EAAE,IAAI,CAAC,CAAC;QACzG,CAAC;QAED,IAAI,UAAU,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QAElG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC;YACnF,MAAM,IAAI,qBAAqB,CAAC,WAAW,UAAU,2CAA2C,EAAE,IAAI,CAAC,CAAC;QACzG,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { GrammarInterfaces } from "../Parser/Interfaces.js";
2
+ import { NodeType } from "../Parser/Enums.js";
3
+ import { ArrayAccessSequenceNode } from "./Accessors.js";
4
+ import { ExpressionNode, ParenthetisedExpressionNode } from "./General.js";
5
+ import { FunctionCallNode } from "./Function.js";
6
+ import { LiteralNode } from "./Misc.js";
7
+ import EAST_Token = GrammarInterfaces.EAST_Token;
8
+ import EAST_Complex_Node = GrammarInterfaces.EAST_Complex_Node;
9
+ import Node = GrammarInterfaces.Node;
10
+ export interface BinaryExpressionNode extends EAST_Complex_Node {
11
+ type: NodeType.BINARY_EXPRESSION;
12
+ values: {
13
+ lhs: ArrayAccessSequenceNode | FunctionCallNode | ParenthetisedExpressionNode | UnaryExpressionNode | LiteralNode | EAST_Token;
14
+ operator: EAST_Token;
15
+ rhs: ExpressionNode;
16
+ };
17
+ }
18
+ export declare function IsBinaryExpressionNode(node: Node): node is BinaryExpressionNode;
19
+ export interface UnaryExpressionNode extends GrammarInterfaces.EAST_Complex_Node {
20
+ type: NodeType.UNARY_EXPRESSION;
21
+ values: {
22
+ operator: EAST_Token;
23
+ value: ExpressionNode;
24
+ };
25
+ }
26
+ export declare function IsUnaryExpressionNode(node: Node): node is UnaryExpressionNode;
@@ -0,0 +1,164 @@
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 { ChainBoolean, ChainNumber } from "../../TypeRegistry/Primitive.js";
6
+ import { isToken } from "./Tokens.js";
7
+ var ExpressionSyntaxError = GrammarRegistry.ExpressionSyntaxError;
8
+ var isAssignableCompile = GrammarInterfaces.isAssignableCompile;
9
+ import { ErrorStack } from "../../../Constants/Errors.js";
10
+ export function IsBinaryExpressionNode(node) {
11
+ return node.type === NodeType.BINARY_EXPRESSION;
12
+ }
13
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.BINARY_EXPRESSION, [[
14
+ {
15
+ type: [
16
+ /* no recursion or assignments on the lhs */
17
+ NodeType.ARRAY_ACCESS_SEQUENCE,
18
+ NodeType.FUNCTION_CALL,
19
+ NodeType.PARENTHETISED_EXPRESSION,
20
+ NodeType.UNARY_EXPRESSION,
21
+ TokenType.BUILTIN,
22
+ NodeType.LITERAL,
23
+ TokenType.IDENTIFIER
24
+ ],
25
+ name: "lhs"
26
+ },
27
+ {
28
+ type: TokenType.OPERATOR,
29
+ values: ["==", "!=", ">", "<", ">=", "<=", "-", "+", "/", "*"],
30
+ name: "operator"
31
+ },
32
+ { type: NodeType.EXPRESSION, name: "rhs" }
33
+ ]], {
34
+ runtimeExecute(scope, node, outputType) {
35
+ const { lhs, rhs, operator } = node.values;
36
+ const resultType = ["==", "!=", "<", ">", "<=", ">="].includes(operator.data) ? ChainBoolean : ChainNumber;
37
+ const inputTypes = ["==", "!="].includes(operator.data) ? [ChainBoolean, ChainNumber] : [ChainNumber];
38
+ const left = lhs.execute.runtimeExecute(scope, lhs, inputTypes);
39
+ const right = rhs.execute.runtimeExecute(scope, rhs, inputTypes);
40
+ let value;
41
+ switch (operator.data) {
42
+ case "+":
43
+ value = left.value + right.value;
44
+ break;
45
+ case "-":
46
+ value = left.value - right.value;
47
+ break;
48
+ case "*":
49
+ value = left.value * right.value;
50
+ break;
51
+ case "/":
52
+ value = left.value / right.value;
53
+ break;
54
+ case "==":
55
+ value = left.value === right.value;
56
+ break;
57
+ case "!=":
58
+ value = left.value !== right.value;
59
+ break;
60
+ case "<":
61
+ value = left.value < right.value;
62
+ break;
63
+ case "<=":
64
+ value = left.value <= right.value;
65
+ break;
66
+ case ">":
67
+ value = left.value > right.value;
68
+ break;
69
+ case ">=":
70
+ value = left.value >= right.value;
71
+ break;
72
+ default:
73
+ throw new ExpressionSyntaxError(`Unsupported binary operator: ${operator.data}`, operator);
74
+ }
75
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
76
+ if (!isAssignableCompile(scope.version, outputType, [resultType], node, stack)) {
77
+ throw new ExpressionSyntaxError(`Invalid output type for binary expression: ${operator.data}\n` + stack.toString("EXP_GM_BEN_01"), operator);
78
+ }
79
+ return {
80
+ type: resultType,
81
+ value
82
+ };
83
+ },
84
+ compileTimeTraversal(scope, node, outputType) {
85
+ const { lhs, rhs, operator } = node.values;
86
+ if (!["+", "-", "*", "/", "==", "!=", ">", ">=", "<", "<="].includes(operator.data)) {
87
+ throw new ExpressionSyntaxError(`Unsupported binary operator: ${operator.data}`, operator);
88
+ }
89
+ const resultType = ["==", "!=", "<", ">", "<=", ">="].includes(operator.data) ? [ChainBoolean] : [ChainNumber];
90
+ const inputTypes = ["==", "!="].includes(operator.data) ? [ChainBoolean, ChainNumber] : [ChainNumber];
91
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
92
+ if (outputType && isAssignableCompile(scope.version, outputType, resultType, node, stack)) {
93
+ throw new ExpressionSyntaxError(`Invalid output type for binary expression: ${operator.data}\n` + stack.toString("EXP_GM_BEN_02"), operator);
94
+ }
95
+ if (isToken(lhs)) {
96
+ lhs.execute.compileTimeTraversal(scope, lhs, inputTypes);
97
+ }
98
+ else {
99
+ lhs.execute.compileTimeTraversal(scope, lhs, inputTypes);
100
+ }
101
+ rhs.execute.compileTimeTraversal(scope, rhs, inputTypes);
102
+ return {
103
+ type: resultType,
104
+ style: CollectionType.Single
105
+ };
106
+ }
107
+ });
108
+ export function IsUnaryExpressionNode(node) {
109
+ return node.type === NodeType.UNARY_EXPRESSION;
110
+ }
111
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.UNARY_EXPRESSION, [[
112
+ { type: TokenType.OPERATOR, values: ["!", "-"], name: "operator" },
113
+ { type: NodeType.EXPRESSION, name: "value" }
114
+ ]], {
115
+ runtimeExecute(scope, currentNode, outputType) {
116
+ const { operator, value } = currentNode.values;
117
+ switch (operator.data) {
118
+ case "!": {
119
+ const evaluated = value.execute.runtimeExecute(scope, value, [ChainBoolean]);
120
+ return {
121
+ type: evaluated.type,
122
+ value: !evaluated.value
123
+ };
124
+ }
125
+ case "-": {
126
+ const evaluated = value.execute.runtimeExecute(scope, value, [ChainNumber]);
127
+ return {
128
+ type: evaluated.type,
129
+ value: -evaluated.value
130
+ };
131
+ }
132
+ }
133
+ throw new ExpressionSyntaxError(`Unsupported unary operator: ${operator.data}`, operator);
134
+ },
135
+ compileTimeTraversal(scope, node, outputType) {
136
+ const { operator, value } = node.values;
137
+ switch (operator.data) {
138
+ case "!": {
139
+ let result = value.execute.compileTimeTraversal(scope, value, [ChainBoolean]);
140
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
141
+ if (!isAssignableCompile(scope.version, outputType, result?.type ?? null, node, stack)) {
142
+ throw new ExpressionSyntaxError(`Unary expression outputs type that conflicts with required type: ${operator.data}\n` + stack.toString("EXP_GM_UNE_01"), operator);
143
+ }
144
+ return {
145
+ type: result?.type ?? null,
146
+ style: CollectionType.Single
147
+ };
148
+ }
149
+ case "-": {
150
+ let result = value.execute.compileTimeTraversal(scope, value, [ChainNumber]);
151
+ let stack = new ErrorStack({ Version: scope.version, SourceFile: node.file.sourceLocation });
152
+ if (!isAssignableCompile(scope.version, outputType, result?.type ?? null, node, stack)) {
153
+ throw new ExpressionSyntaxError(`Unary expression outputs type that conflicts with required type: ${operator.data}\n` + stack.toString("EXP_GM_UNE_02"), operator);
154
+ }
155
+ return {
156
+ type: result?.type ?? null,
157
+ style: CollectionType.Single
158
+ };
159
+ }
160
+ }
161
+ throw new ExpressionSyntaxError(`Unsupported unary operator: ${operator.data}`, operator);
162
+ }
163
+ });
164
+ //# sourceMappingURL=Maths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Maths.js","sourceRoot":"","sources":["Maths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MA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,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC7E,IAAI,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;gBAC7F,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;oBACxF,MAAM,IAAI,qBAAqB,CAAC,oEAAoE,QAAQ,CAAC,IAAI,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAC;gBACpK,CAAC;gBACD,OAAO;oBACN,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,IAAI;oBAC1B,KAAK,EAAE,cAAc,CAAC,MAAM;iBAC5B,CAAC;YACH,CAAC;QACF,CAAC;QACD,MAAM,IAAI,qBAAqB,CAAC,+BAA+B,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC3F,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { GrammarInterfaces } from "../Parser/Interfaces.js";
2
+ import { NodeType } from "../Parser/Enums.js";
3
+ import { ExpressionNode } from "./General.js";
4
+ import EAST_Token = GrammarInterfaces.EAST_Token;
5
+ import Node = GrammarInterfaces.Node;
6
+ export interface LiteralNode extends GrammarInterfaces.EAST_Complex_Node {
7
+ type: NodeType.LITERAL;
8
+ values: {
9
+ value: EAST_Token;
10
+ };
11
+ }
12
+ export declare function IsLiteralNode(node: Node): node is LiteralNode;
13
+ export interface AssignmentNode extends GrammarInterfaces.EAST_Complex_Node {
14
+ type: NodeType.ASSIGNMENT;
15
+ values: {
16
+ lhs: EAST_Token;
17
+ rhs: ExpressionNode;
18
+ };
19
+ }
20
+ export declare function IsAssignmentNode(node: Node): node is AssignmentNode;
@@ -0,0 +1,50 @@
1
+ import { Versions } from "../../../Constants/Versions.js";
2
+ import { GrammarRegistry } from "../GrammarRegistry.js";
3
+ import { NodeType, TokenType } from "../Parser/Enums.js";
4
+ var ExpressionSyntaxError = GrammarRegistry.ExpressionSyntaxError;
5
+ export function IsLiteralNode(node) {
6
+ return node.type === NodeType.LITERAL;
7
+ }
8
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.LITERAL, [[
9
+ { type: [TokenType.FLOAT, TokenType.INTEGER, TokenType.HEX, TokenType.BLOCK_STRING, TokenType.LINE_STRING], name: "value" }
10
+ ]], {
11
+ runtimeExecute(scope, node, outputType) {
12
+ return node.values.value.execute.runtimeExecute(scope, node.values.value, outputType);
13
+ },
14
+ compileTimeTraversal(scope, node, outputType) {
15
+ return node.values.value.execute.compileTimeTraversal(scope, node.values.value, outputType);
16
+ }
17
+ });
18
+ export function IsAssignmentNode(node) {
19
+ return node.type === NodeType.ASSIGNMENT;
20
+ }
21
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.ASSIGNMENT, [[
22
+ { type: [TokenType.IDENTIFIER, TokenType.BUILTIN], name: "lhs" },
23
+ { type: TokenType.OPERATOR, value: "=" },
24
+ { type: NodeType.EXPRESSION, name: "rhs" }
25
+ ]], {
26
+ runtimeExecute(scope, node, outputType) {
27
+ const { lhs, rhs } = node.values;
28
+ const evaluated = rhs.execute.runtimeExecute(scope, rhs, outputType);
29
+ if (!evaluated.type) {
30
+ throw new ExpressionSyntaxError(`Cannot assign expression returning never to variable ${lhs.data}`, node);
31
+ }
32
+ scope.local[lhs.data] = {
33
+ type: [evaluated.type],
34
+ value: evaluated.value,
35
+ };
36
+ return evaluated;
37
+ },
38
+ compileTimeTraversal(scope, node, outputType) {
39
+ const { lhs, rhs } = node.values;
40
+ const evaluated = rhs.execute.compileTimeTraversal(scope, rhs, outputType);
41
+ if (!evaluated?.type) {
42
+ throw new ExpressionSyntaxError(`Cannot assign expression returning never to variable ${lhs.data}`, node);
43
+ }
44
+ scope.local[lhs.data] = {
45
+ type: evaluated.type,
46
+ };
47
+ return evaluated;
48
+ }
49
+ });
50
+ //# sourceMappingURL=Misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Misc.js","sourceRoot":"","sources":["Misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIzD,IAAO,qBAAqB,GAAG,eAAe,CAAC,qBAAqB,CAAC;AAWrE,MAAM,UAAU,aAAa,CAAC,IAAU;IACvC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,OAAO,CAAC;AACvC,CAAC;AAED,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;QAC3D,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;KAC3H,CAAC,EAAE;IACH,cAAc,CAAC,KAAK,EAAE,IAAiB,EAAE,UAAU;QAClD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACvF,CAAC;IACD,oBAAoB,CAAC,KAAK,EAAE,IAAiB,EAAE,UAAU;QACxD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC7F,CA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BAAoB,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3E,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,qBAAqB,CAAC,wDAAwD,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;QAC3G,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG;YACvB,IAAI,EAAE,SAAS,CAAC,IAAI;SACpB,CAAA;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { GrammarInterfaces } from "../Parser/Interfaces.js";
2
+ import { NodeType } from "../Parser/Enums.js";
3
+ import EAST_Token = GrammarInterfaces.EAST_Token;
4
+ import Node = GrammarInterfaces.Node;
5
+ export interface CommentNode extends GrammarInterfaces.EAST_Complex_Node {
6
+ type: NodeType.COMMENT;
7
+ values: {
8
+ comment: EAST_Token[];
9
+ };
10
+ }
11
+ export declare function IsCommentNode(node: Node): node is CommentNode;
12
+ export interface PreprocessorCommandNode extends GrammarInterfaces.EAST_Complex_Node {
13
+ type: NodeType.PREPROCESSOR_COMMAND;
14
+ values: {
15
+ command: EAST_Token;
16
+ };
17
+ }
18
+ export declare function IsPreprocessorCommandNode(node: Node): node is PreprocessorCommandNode;
@@ -0,0 +1,43 @@
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 IsCommentNode(node) {
6
+ return node.type === NodeType.COMMENT;
7
+ }
8
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.COMMENT, [[
9
+ {
10
+ type: [TokenType.BLOCK_COMMENT, TokenType.LINE_COMMENT],
11
+ name: "comment",
12
+ repeat: [1, Number.POSITIVE_INFINITY]
13
+ }
14
+ ]], {
15
+ runtimeExecute(scope, node) {
16
+ // Do nothing
17
+ return {
18
+ type: null,
19
+ value: null
20
+ };
21
+ },
22
+ compileTimeTraversal(scope, node) {
23
+ // Do nothing
24
+ return null;
25
+ }
26
+ });
27
+ export function IsPreprocessorCommandNode(node) {
28
+ return node.type === NodeType.PREPROCESSOR_COMMAND;
29
+ }
30
+ GrammarRegistry.AddRule(Versions.v1_0_0, NodeType.PREPROCESSOR_COMMAND, [[
31
+ {
32
+ type: [TokenType.PREPROCESSOR /*, NodeType.PRECISION_STATEMENT*/],
33
+ name: "command"
34
+ }
35
+ ]], {
36
+ runtimeExecute(scope, node) {
37
+ throw new ExpressionSyntaxError(`Preprocessor commands cannot be executed at runtime`, node);
38
+ },
39
+ compileTimeTraversal(scope, node) {
40
+ throw new ExpressionSyntaxError(`Preprocessor commands are not currently supported`, node);
41
+ }
42
+ });
43
+ //# sourceMappingURL=Preprocessors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Preprocessors.js","sourceRoot":"","sources":["Preprocessors.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;AAWrE,MAAM,UAAU,aAAa,CAAC,IAAU;IACvC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,OAAO,CAAC;AACvC,CAAC;AAED,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;QAC3D;YACC,IAAI,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,SAAS,CAAC,YAAY,CAAC;YACvD,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC;SACrC;KACD,CAAC,EAAE;IACH,cAAc,CAAC,KAAK,EAAE,IAAiB;QACtC,aAAa;QACb,OAAO;YACN,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;SACX,CAAC;IACH,CAAC;IACD,oBAAoB,CAAC,KAAK,EAAE,IAAiB;QAC5C,aAAa;QACb,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC,CAAC;AAUH,MAAM,UAAU,yBAAyB,CAAC,IAAU;IACnD,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,oBAAoB,CAAC;AACpD,CAAC;AAED,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACxE;YACC,IAAI,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,kCAAkC,CAAC;YACjE,IAAI,EAAE,SAAS;SACf;KACD,CAAC,EAAE;IACH,cAAc,CAAC,KAAK,EAAE,IAA6B;QAClD,MAAM,IAAI,qBAAqB,CAAC,qDAAqD,EAAE,IAAI,CAAC,CAAC;IAC9F,CAAC;IACD,oBAAoB,CAAC,KAAK,EAAE,IAA6B;QACxD,MAAM,IAAI,qBAAqB,CAAC,mDAAmD,EAAE,IAAI,CAAC,CAAC;IAC5F,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { GrammarInterfaces } from "../Parser/Interfaces.js";
2
+ import { NodeType } from "../Parser/Enums.js";
3
+ import EAST_Token = GrammarInterfaces.EAST_Token;
4
+ import Node = GrammarInterfaces.Node;
5
+ import { TypeDefinitionNode } from "./Types.js";
6
+ export interface StructNode extends GrammarInterfaces.EAST_Complex_Node {
7
+ type: NodeType.STRUCT;
8
+ values: {
9
+ name: EAST_Token;
10
+ members: PropertySignatureNode[];
11
+ };
12
+ }
13
+ export declare function IsStructNode(node: Node): node is StructNode;
14
+ export interface PropertySignatureNode extends GrammarInterfaces.EAST_Complex_Node {
15
+ type: NodeType.PROPERTY_SIGNATURE;
16
+ values: {
17
+ identifier: EAST_Token;
18
+ type: TypeDefinitionNode;
19
+ };
20
+ }
21
+ export declare function IsPropertySignatureNode(node: Node): node is PropertySignatureNode;