mevento 3.0.0 → 3.0.1

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 (2) hide show
  1. package/dist/cjs/index.d.ts +349 -0
  2. package/package.json +1 -1
@@ -0,0 +1,349 @@
1
+ declare class TokenType {
2
+ static id: number;
3
+ static comma: number;
4
+ static semi: number;
5
+ static numberConst: number;
6
+ static stringConst: number;
7
+ static equal: number;
8
+ static lparen: number;
9
+ static rparen: number;
10
+ static eol: number;
11
+ static eof: number;
12
+ static lbrace: number;
13
+ static rbrace: number;
14
+ static lbracket: number;
15
+ static rbracket: number;
16
+ static great: number;
17
+ static greatEq: number;
18
+ static less: number;
19
+ static lessEq: number;
20
+ static eqeq: number;
21
+ static IF: number;
22
+ static ELSE: number;
23
+ static TRUE: number;
24
+ static FALSE: number;
25
+ static NULL: number;
26
+ static not: number;
27
+ static notEq: number;
28
+ static and: number;
29
+ static or: number;
30
+ static plus: number;
31
+ static minus: number;
32
+ static div: number;
33
+ static mult: number;
34
+ static mod: number;
35
+ static invalid: number;
36
+ static colon: number;
37
+ static WHILE_TILL: number;
38
+ static FOR_LOOP: number;
39
+ static up: number;
40
+ static down: number;
41
+ static with: number;
42
+ static in: number;
43
+ static TILL: number;
44
+ static BREAK: number;
45
+ static CONTINUE: number;
46
+ static nullity: number;
47
+ static RETURN: number;
48
+ }
49
+ declare class Token {
50
+ type: number;
51
+ value: any;
52
+ line?: number;
53
+ col?: number;
54
+ constructor(type: number, value: any, line?: number, col?: number);
55
+ static from(type: number, value: any): Token;
56
+ toString(): string;
57
+ }
58
+ declare class LexerDictionary {
59
+ lang: string;
60
+ keywords: {
61
+ [key: string]: string;
62
+ };
63
+ constructor(lang: string, keywords: {
64
+ [key: string]: string;
65
+ });
66
+ }
67
+ /**
68
+ * Parser
69
+ */
70
+ declare abstract class AST {
71
+ line?: number;
72
+ col?: number;
73
+ constructor(line?: number, col?: number);
74
+ dump(): string;
75
+ }
76
+ declare class RootAST extends AST {
77
+ body: AST[];
78
+ source: string;
79
+ name: string;
80
+ constructor(body: AST[], name: string, source: string);
81
+ dump(): string;
82
+ }
83
+ declare class BlockStatementAST extends AST {
84
+ body: AST[];
85
+ constructor(body: AST[], token: Token);
86
+ toString(): string;
87
+ }
88
+ declare class IdentifierAST extends AST {
89
+ value: string;
90
+ constructor(token: Token);
91
+ toString(): string;
92
+ }
93
+ declare class LiteralAST extends AST {
94
+ value: any;
95
+ raw: string;
96
+ constructor(token: Token, raw: string);
97
+ toString(): string;
98
+ }
99
+ declare class AssignmentExpressionAST extends AST {
100
+ identifier: AST;
101
+ init: AST;
102
+ constructor(identifier: AST, init: AST);
103
+ toString(): string;
104
+ }
105
+ declare class ExpressionStatementAST extends AST {
106
+ expression: AST;
107
+ constructor(expression: AST);
108
+ toString(): string;
109
+ }
110
+ declare class CallExpressionAST extends AST {
111
+ callee: IdentifierAST;
112
+ arguments: AST[];
113
+ constructor(callee: IdentifierAST, ags: AST[]);
114
+ toString(): string;
115
+ }
116
+ declare class BinaryExpressionAST extends AST {
117
+ left: AST;
118
+ operation: Token;
119
+ right: AST;
120
+ constructor(left: AST, operation: Token, right: AST);
121
+ toString(): string;
122
+ }
123
+ declare class UnaryExpressionAST extends AST {
124
+ operation: Token;
125
+ argument: AST;
126
+ constructor(operation: Token, argument: AST);
127
+ toString(): string;
128
+ }
129
+ declare class IfStatementAST extends AST {
130
+ test: AST;
131
+ consequent: AST;
132
+ alternate?: AST;
133
+ constructor(test: AST, consequent: AST, alternate?: AST);
134
+ toString(): string;
135
+ }
136
+ declare class LogicalExpressionAST extends AST {
137
+ left: AST;
138
+ operator: Token;
139
+ right: AST;
140
+ constructor(left: AST, operator: Token, right: AST);
141
+ toString(): string;
142
+ }
143
+ declare class IndexAccessorAST extends AST {
144
+ owner: AST;
145
+ key: AST;
146
+ computed: boolean;
147
+ constructor(owner: AST, key: AST, computed?: boolean);
148
+ toString(): string;
149
+ }
150
+ declare class ObjectExpression extends AST {
151
+ properties: AST[];
152
+ constructor(props: AST[], startToken?: Token, endToken?: Token);
153
+ toString(): string;
154
+ }
155
+ declare class ArrayExpression extends AST {
156
+ elements: AST[];
157
+ constructor(props: AST[], start?: AST, end?: AST);
158
+ toString(): string;
159
+ }
160
+ declare class ObjectProperty extends AST {
161
+ key: AST;
162
+ value: AST;
163
+ constructor(key: AST, value: AST);
164
+ }
165
+ declare class WhileLoopStatement extends AST {
166
+ test: AST;
167
+ body: AST;
168
+ retain: boolean;
169
+ constructor(test: AST, body: AST, startToken?: Token, endToken?: Token, retain?: boolean);
170
+ }
171
+ declare class ForLoopStatement extends AST {
172
+ init: AssignmentExpressionAST;
173
+ test: AST;
174
+ update: AST;
175
+ direction: Token;
176
+ body: AST;
177
+ retain: boolean;
178
+ constructor(init: AssignmentExpressionAST, test: AST, update: AST, direction: Token, body: AST, startToken?: Token, endToken?: Token, retain?: boolean);
179
+ }
180
+ declare class ForOfStatement extends AST {
181
+ identifier: AST;
182
+ collection: AST;
183
+ body: AST;
184
+ retain: boolean;
185
+ constructor(identifier: AST, collection: AST, body: AST, startToken?: Token, endToken?: Token, retain?: boolean);
186
+ }
187
+ declare class TupleExpression extends AST {
188
+ first: AST;
189
+ second: AST;
190
+ constructor(first: AST, second: AST);
191
+ }
192
+ declare class BreakAST extends AST {
193
+ constructor(line?: number, col?: number);
194
+ }
195
+ declare class ReturnAST extends AST {
196
+ value?: AST;
197
+ constructor(value?: AST, line?: number, col?: number);
198
+ }
199
+ declare class ContinueAST extends AST {
200
+ constructor(line?: number, col?: number);
201
+ }
202
+ declare class LoopControl {
203
+ }
204
+ declare class BreakBranch extends LoopControl {
205
+ }
206
+ declare class ContinueBranch extends LoopControl {
207
+ }
208
+ declare class ReturnBranch {
209
+ value: any;
210
+ constructor(value: any);
211
+ }
212
+ type Func = (node: any) => any;
213
+ declare abstract class ANodeVisitor {
214
+ protected _nodesVisitors: {
215
+ [k: string]: Func;
216
+ };
217
+ protected registerVisitor(type: any, visitor: Func): void;
218
+ abstract visit(node: AST): any;
219
+ }
220
+ declare abstract class NodeVisitor extends ANodeVisitor {
221
+ constructor();
222
+ visit(node: AST): any;
223
+ protected assignProperty(owner: any, property: any, value: any): any;
224
+ protected abstract visitRootAST(node: RootAST): any;
225
+ protected abstract visitBlockStatementAST(node: BlockStatementAST): any;
226
+ protected abstract visitIdentifierAST(node: IdentifierAST): any;
227
+ protected abstract visitLiteralAST(node: AST): any;
228
+ protected abstract visitAssignmentExpressionAST(node: AssignmentExpressionAST): any;
229
+ protected abstract visitExpressionStatementAST(node: ExpressionStatementAST): any;
230
+ protected abstract visitCallExpressionAST(node: CallExpressionAST): any;
231
+ protected abstract visitBinaryExpressionAST(node: BinaryExpressionAST): any;
232
+ protected abstract visitUnaryExpressionAST(node: UnaryExpressionAST): any;
233
+ protected abstract visitIfStatementAST(node: IfStatementAST): any;
234
+ protected abstract visitLogicalExpressionAST(node: LogicalExpressionAST): any;
235
+ protected abstract visitIndexAccessorAST(node: IndexAccessorAST): any;
236
+ protected abstract visitObjectProperty(node: AST): any;
237
+ protected abstract visitObjectExpression(ast: AST): any;
238
+ protected abstract visitArrayExpression(ast: AST): any;
239
+ protected abstract visitBreakAST(node: BreakAST): any;
240
+ protected abstract visitWhileLoopStatement(node: WhileLoopStatement): any;
241
+ protected abstract visitForLoopStatement(node: ForLoopStatement): any;
242
+ protected abstract visitForOfStatement(node: ForOfStatement): any;
243
+ protected abstract visitContinueAST(node: ContinueAST): any;
244
+ protected abstract visitReturnAST(node: ReturnAST): any;
245
+ }
246
+ declare class MEventScope {
247
+ name: string;
248
+ parent?: MEventScope;
249
+ memory: {
250
+ [k: string]: any;
251
+ };
252
+ constructor(name: string, memory: {
253
+ [k: string]: any;
254
+ }, parent?: MEventScope);
255
+ resolve(key: string): any;
256
+ change(key: string, value: any, declare?: boolean): boolean;
257
+ }
258
+ type MEventoFBinding = (args: any[], vm: MEvento) => any;
259
+ declare class MEvento extends NodeVisitor {
260
+ rootScope: MEventScope;
261
+ protected currentScope?: MEventScope;
262
+ debug: boolean;
263
+ private static _globalFunctionsRegistry;
264
+ private static _cache;
265
+ protected _functionsRegistry: {
266
+ [k: string]: MEventoFBinding;
267
+ };
268
+ protected _functionResolver?: (name: string) => MEventoFBinding | undefined;
269
+ constructor();
270
+ protected resolve(name: string): any;
271
+ protected changeVariable(name: string, value: any): any;
272
+ protected pushScope(name: string): void;
273
+ protected popScope(): void;
274
+ protected log(message: any): void;
275
+ protected visitRootAST(node: RootAST): any;
276
+ protected visitBlockStatementAST(node: BlockStatementAST): any;
277
+ protected visitIdentifierAST(node: IdentifierAST): any;
278
+ protected visitLiteralAST(node: AST): any;
279
+ protected visitAssignmentExpressionAST(node: AssignmentExpressionAST): any;
280
+ protected visitExpressionStatementAST(node: ExpressionStatementAST): any;
281
+ protected visitCallExpressionAST(node: CallExpressionAST): any;
282
+ protected visitBinaryExpressionAST(node: BinaryExpressionAST): any;
283
+ protected visitUnaryExpressionAST(node: UnaryExpressionAST): any;
284
+ protected visitIfStatementAST(node: IfStatementAST): any;
285
+ protected visitLogicalExpressionAST(node: LogicalExpressionAST): any;
286
+ protected visitIndexAccessorAST(node: IndexAccessorAST): any;
287
+ protected visitObjectProperty(node: AST): any;
288
+ protected visitObjectExpression(ast: AST): any;
289
+ protected visitArrayExpression(ast: AST): any;
290
+ protected visitBreakAST(node: BreakAST): BreakBranch;
291
+ protected visitWhileLoopStatement(node: WhileLoopStatement): any;
292
+ protected visitForLoopStatement(node: ForLoopStatement): any;
293
+ protected visitForOfStatement(node: ForOfStatement): any;
294
+ protected visitContinueAST(node: ContinueAST): ContinueBranch;
295
+ protected visitReturnAST(node: ReturnAST): any;
296
+ protected _declareForIdentifier(node: AST, value: any): any;
297
+ resolveArguments(args: AST[]): any;
298
+ setFunctionResolver(resolver: (name: string) => MEventoFBinding | undefined): void;
299
+ resolveFunction(name: string): MEventoFBinding | undefined;
300
+ registerFunction(id: string, fn: MEventoFBinding): void;
301
+ unregisterFunction(id: string): void;
302
+ execute(source: string, cache?: boolean, input?: {
303
+ [k: string]: any;
304
+ }): any;
305
+ static compile(source: string, cache?: boolean): AST;
306
+ static register(id: string, fn: MEventoFBinding): void;
307
+ static unregister(id: string): void;
308
+ static run(source: string, cache?: boolean, input?: {
309
+ [k: string]: any;
310
+ }): any;
311
+ static newInstance(): MEvento;
312
+ clone(): MEvento;
313
+ newAsyncInstance(): MEventoAsync;
314
+ }
315
+ declare class MEventoAsync extends MEvento {
316
+ constructor();
317
+ protected visitRootAST(node: RootAST): Promise<any>;
318
+ protected visitBlockStatementAST(node: BlockStatementAST): Promise<any>;
319
+ protected visitIdentifierAST(node: AST): Promise<any>;
320
+ protected visitLiteralAST(node: LiteralAST): Promise<any>;
321
+ protected visitAssignmentExpressionAST(node: AssignmentExpressionAST): Promise<any>;
322
+ protected visitExpressionStatementAST(node: ExpressionStatementAST): Promise<any>;
323
+ protected visitCallExpressionAST(node: CallExpressionAST): Promise<any>;
324
+ protected visitBinaryExpressionAST(node: BinaryExpressionAST): Promise<string | number | boolean>;
325
+ protected visitUnaryExpressionAST(node: UnaryExpressionAST): Promise<number | boolean>;
326
+ protected visitIfStatementAST(node: IfStatementAST): Promise<any>;
327
+ protected visitLogicalExpressionAST(node: LogicalExpressionAST): Promise<any>;
328
+ protected visitIndexAccessorAST(node: IndexAccessorAST): Promise<any>;
329
+ protected visitObjectProperty(node: AST): Promise<void>;
330
+ protected visitObjectExpression(ast: AST): Promise<any>;
331
+ protected visitArrayExpression(ast: AST): Promise<any[]>;
332
+ protected visitWhileLoopStatement(node: WhileLoopStatement): Promise<any[] | ReturnBranch>;
333
+ protected visitForLoopStatement(node: ForLoopStatement): Promise<any[] | ReturnBranch>;
334
+ protected visitForOfStatement(node: ForOfStatement): Promise<any[] | ReturnBranch>;
335
+ protected visitReturnAST(node: ReturnAST): Promise<any>;
336
+ resolveArgumentsAsync(args: AST[]): Promise<any[]>;
337
+ registerFunction(id: string, fn: MEventoFBinding): void;
338
+ unregisterFunction(id: string): void;
339
+ execute(source: string, cache?: boolean, input?: {
340
+ [k: string]: any;
341
+ }): Promise<any>;
342
+ static run(source: string, cache?: boolean, input?: {
343
+ [k: string]: any;
344
+ }): Promise<any>;
345
+ static newInstance(): MEventoAsync;
346
+ clone(): MEventoAsync;
347
+ }
348
+
349
+ export { AST, ArrayExpression, AssignmentExpressionAST, BinaryExpressionAST, BlockStatementAST, BreakAST, BreakBranch, CallExpressionAST, ContinueAST, ContinueBranch, ExpressionStatementAST, ForLoopStatement, ForOfStatement, IdentifierAST, IfStatementAST, IndexAccessorAST, LexerDictionary, LiteralAST, LogicalExpressionAST, LoopControl, MEventScope, MEvento, MEventoAsync, type MEventoFBinding, NodeVisitor, ObjectExpression, ObjectProperty, ReturnAST, ReturnBranch, RootAST, Token, TokenType, TupleExpression, UnaryExpressionAST, WhileLoopStatement };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mevento",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",