@dseict/psc-interpreter 0.0.1 → 0.0.2
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/dist/PSCLexerBase.d.ts +9 -0
- package/dist/PSCLexerBase.d.ts.map +1 -0
- package/dist/PSCLexerBase.js +92 -0
- package/dist/PSCLexerBase.js.map +1 -0
- package/dist/_antlr/PSCLexer.d.ts +71 -0
- package/dist/_antlr/PSCLexer.d.ts.map +1 -0
- package/dist/_antlr/PSCLexer.js +253 -0
- package/dist/_antlr/PSCLexer.js.map +1 -0
- package/dist/_antlr/PSCParser.d.ts +475 -0
- package/dist/_antlr/PSCParser.d.ts.map +1 -0
- package/dist/_antlr/PSCParser.js +3075 -0
- package/dist/_antlr/PSCParser.js.map +1 -0
- package/dist/_antlr/PSCParserVisitor.d.ts +256 -0
- package/dist/_antlr/PSCParserVisitor.d.ts.map +1 -0
- package/dist/_antlr/PSCParserVisitor.js +257 -0
- package/dist/_antlr/PSCParserVisitor.js.map +1 -0
- package/dist/error.d.ts +32 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +60 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +692 -0
- package/dist/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// Generated from ./PSCParser.g4 by ANTLR 4.13.2
|
|
2
|
+
import { ParseTreeVisitor } from 'antlr4';
|
|
3
|
+
import { ProgramContext } from "./PSCParser.js";
|
|
4
|
+
import { AddOpContext } from "./PSCParser.js";
|
|
5
|
+
import { MulOpContext } from "./PSCParser.js";
|
|
6
|
+
import { ExpOpContext } from "./PSCParser.js";
|
|
7
|
+
import { CompOpContext } from "./PSCParser.js";
|
|
8
|
+
import { ExprContext } from "./PSCParser.js";
|
|
9
|
+
import { OrExprContext } from "./PSCParser.js";
|
|
10
|
+
import { AndExprContext } from "./PSCParser.js";
|
|
11
|
+
import { CompExprContext } from "./PSCParser.js";
|
|
12
|
+
import { AddExprContext } from "./PSCParser.js";
|
|
13
|
+
import { MulExprContext } from "./PSCParser.js";
|
|
14
|
+
import { ExpExprContext } from "./PSCParser.js";
|
|
15
|
+
import { UnaryExprContext } from "./PSCParser.js";
|
|
16
|
+
import { NotExprContext } from "./PSCParser.js";
|
|
17
|
+
import { PrimaryExprContext } from "./PSCParser.js";
|
|
18
|
+
import { GroupExprContext } from "./PSCParser.js";
|
|
19
|
+
import { AtomContext } from "./PSCParser.js";
|
|
20
|
+
import { LitsContext } from "./PSCParser.js";
|
|
21
|
+
import { IntLitsContext } from "./PSCParser.js";
|
|
22
|
+
import { FloatLitsContext } from "./PSCParser.js";
|
|
23
|
+
import { ArrayLitsContext } from "./PSCParser.js";
|
|
24
|
+
import { StmtsContext } from "./PSCParser.js";
|
|
25
|
+
import { StmtContext } from "./PSCParser.js";
|
|
26
|
+
import { BlockContext } from "./PSCParser.js";
|
|
27
|
+
import { IfStmtContext } from "./PSCParser.js";
|
|
28
|
+
import { WhileStmtContext } from "./PSCParser.js";
|
|
29
|
+
import { DoWhileStmtContext } from "./PSCParser.js";
|
|
30
|
+
import { RepeatUntilStmtContext } from "./PSCParser.js";
|
|
31
|
+
import { ForStmtContext } from "./PSCParser.js";
|
|
32
|
+
import { AsmStmtContext } from "./PSCParser.js";
|
|
33
|
+
import { LvalueContext } from "./PSCParser.js";
|
|
34
|
+
import { InputStmtContext } from "./PSCParser.js";
|
|
35
|
+
import { OutputStmtContext } from "./PSCParser.js";
|
|
36
|
+
import { SubprogramContext } from "./PSCParser.js";
|
|
37
|
+
import { ReturnStmtContext } from "./PSCParser.js";
|
|
38
|
+
/**
|
|
39
|
+
* This interface defines a complete generic visitor for a parse tree produced
|
|
40
|
+
* by `PSCParser`.
|
|
41
|
+
*
|
|
42
|
+
* @param <Result> The return type of the visit operation. Use `void` for
|
|
43
|
+
* operations with no return type.
|
|
44
|
+
*/
|
|
45
|
+
export default class PSCParserVisitor extends ParseTreeVisitor {
|
|
46
|
+
/**
|
|
47
|
+
* Visit a parse tree produced by `PSCParser.program`.
|
|
48
|
+
* @param ctx the parse tree
|
|
49
|
+
* @return the visitor result
|
|
50
|
+
*/
|
|
51
|
+
visitProgram;
|
|
52
|
+
/**
|
|
53
|
+
* Visit a parse tree produced by `PSCParser.addOp`.
|
|
54
|
+
* @param ctx the parse tree
|
|
55
|
+
* @return the visitor result
|
|
56
|
+
*/
|
|
57
|
+
visitAddOp;
|
|
58
|
+
/**
|
|
59
|
+
* Visit a parse tree produced by `PSCParser.mulOp`.
|
|
60
|
+
* @param ctx the parse tree
|
|
61
|
+
* @return the visitor result
|
|
62
|
+
*/
|
|
63
|
+
visitMulOp;
|
|
64
|
+
/**
|
|
65
|
+
* Visit a parse tree produced by `PSCParser.expOp`.
|
|
66
|
+
* @param ctx the parse tree
|
|
67
|
+
* @return the visitor result
|
|
68
|
+
*/
|
|
69
|
+
visitExpOp;
|
|
70
|
+
/**
|
|
71
|
+
* Visit a parse tree produced by `PSCParser.compOp`.
|
|
72
|
+
* @param ctx the parse tree
|
|
73
|
+
* @return the visitor result
|
|
74
|
+
*/
|
|
75
|
+
visitCompOp;
|
|
76
|
+
/**
|
|
77
|
+
* Visit a parse tree produced by `PSCParser.expr`.
|
|
78
|
+
* @param ctx the parse tree
|
|
79
|
+
* @return the visitor result
|
|
80
|
+
*/
|
|
81
|
+
visitExpr;
|
|
82
|
+
/**
|
|
83
|
+
* Visit a parse tree produced by `PSCParser.orExpr`.
|
|
84
|
+
* @param ctx the parse tree
|
|
85
|
+
* @return the visitor result
|
|
86
|
+
*/
|
|
87
|
+
visitOrExpr;
|
|
88
|
+
/**
|
|
89
|
+
* Visit a parse tree produced by `PSCParser.andExpr`.
|
|
90
|
+
* @param ctx the parse tree
|
|
91
|
+
* @return the visitor result
|
|
92
|
+
*/
|
|
93
|
+
visitAndExpr;
|
|
94
|
+
/**
|
|
95
|
+
* Visit a parse tree produced by `PSCParser.compExpr`.
|
|
96
|
+
* @param ctx the parse tree
|
|
97
|
+
* @return the visitor result
|
|
98
|
+
*/
|
|
99
|
+
visitCompExpr;
|
|
100
|
+
/**
|
|
101
|
+
* Visit a parse tree produced by `PSCParser.addExpr`.
|
|
102
|
+
* @param ctx the parse tree
|
|
103
|
+
* @return the visitor result
|
|
104
|
+
*/
|
|
105
|
+
visitAddExpr;
|
|
106
|
+
/**
|
|
107
|
+
* Visit a parse tree produced by `PSCParser.mulExpr`.
|
|
108
|
+
* @param ctx the parse tree
|
|
109
|
+
* @return the visitor result
|
|
110
|
+
*/
|
|
111
|
+
visitMulExpr;
|
|
112
|
+
/**
|
|
113
|
+
* Visit a parse tree produced by `PSCParser.expExpr`.
|
|
114
|
+
* @param ctx the parse tree
|
|
115
|
+
* @return the visitor result
|
|
116
|
+
*/
|
|
117
|
+
visitExpExpr;
|
|
118
|
+
/**
|
|
119
|
+
* Visit a parse tree produced by `PSCParser.unaryExpr`.
|
|
120
|
+
* @param ctx the parse tree
|
|
121
|
+
* @return the visitor result
|
|
122
|
+
*/
|
|
123
|
+
visitUnaryExpr;
|
|
124
|
+
/**
|
|
125
|
+
* Visit a parse tree produced by `PSCParser.notExpr`.
|
|
126
|
+
* @param ctx the parse tree
|
|
127
|
+
* @return the visitor result
|
|
128
|
+
*/
|
|
129
|
+
visitNotExpr;
|
|
130
|
+
/**
|
|
131
|
+
* Visit a parse tree produced by `PSCParser.primaryExpr`.
|
|
132
|
+
* @param ctx the parse tree
|
|
133
|
+
* @return the visitor result
|
|
134
|
+
*/
|
|
135
|
+
visitPrimaryExpr;
|
|
136
|
+
/**
|
|
137
|
+
* Visit a parse tree produced by `PSCParser.groupExpr`.
|
|
138
|
+
* @param ctx the parse tree
|
|
139
|
+
* @return the visitor result
|
|
140
|
+
*/
|
|
141
|
+
visitGroupExpr;
|
|
142
|
+
/**
|
|
143
|
+
* Visit a parse tree produced by `PSCParser.atom`.
|
|
144
|
+
* @param ctx the parse tree
|
|
145
|
+
* @return the visitor result
|
|
146
|
+
*/
|
|
147
|
+
visitAtom;
|
|
148
|
+
/**
|
|
149
|
+
* Visit a parse tree produced by `PSCParser.lits`.
|
|
150
|
+
* @param ctx the parse tree
|
|
151
|
+
* @return the visitor result
|
|
152
|
+
*/
|
|
153
|
+
visitLits;
|
|
154
|
+
/**
|
|
155
|
+
* Visit a parse tree produced by `PSCParser.intLits`.
|
|
156
|
+
* @param ctx the parse tree
|
|
157
|
+
* @return the visitor result
|
|
158
|
+
*/
|
|
159
|
+
visitIntLits;
|
|
160
|
+
/**
|
|
161
|
+
* Visit a parse tree produced by `PSCParser.floatLits`.
|
|
162
|
+
* @param ctx the parse tree
|
|
163
|
+
* @return the visitor result
|
|
164
|
+
*/
|
|
165
|
+
visitFloatLits;
|
|
166
|
+
/**
|
|
167
|
+
* Visit a parse tree produced by `PSCParser.arrayLits`.
|
|
168
|
+
* @param ctx the parse tree
|
|
169
|
+
* @return the visitor result
|
|
170
|
+
*/
|
|
171
|
+
visitArrayLits;
|
|
172
|
+
/**
|
|
173
|
+
* Visit a parse tree produced by `PSCParser.stmts`.
|
|
174
|
+
* @param ctx the parse tree
|
|
175
|
+
* @return the visitor result
|
|
176
|
+
*/
|
|
177
|
+
visitStmts;
|
|
178
|
+
/**
|
|
179
|
+
* Visit a parse tree produced by `PSCParser.stmt`.
|
|
180
|
+
* @param ctx the parse tree
|
|
181
|
+
* @return the visitor result
|
|
182
|
+
*/
|
|
183
|
+
visitStmt;
|
|
184
|
+
/**
|
|
185
|
+
* Visit a parse tree produced by `PSCParser.block`.
|
|
186
|
+
* @param ctx the parse tree
|
|
187
|
+
* @return the visitor result
|
|
188
|
+
*/
|
|
189
|
+
visitBlock;
|
|
190
|
+
/**
|
|
191
|
+
* Visit a parse tree produced by `PSCParser.ifStmt`.
|
|
192
|
+
* @param ctx the parse tree
|
|
193
|
+
* @return the visitor result
|
|
194
|
+
*/
|
|
195
|
+
visitIfStmt;
|
|
196
|
+
/**
|
|
197
|
+
* Visit a parse tree produced by `PSCParser.whileStmt`.
|
|
198
|
+
* @param ctx the parse tree
|
|
199
|
+
* @return the visitor result
|
|
200
|
+
*/
|
|
201
|
+
visitWhileStmt;
|
|
202
|
+
/**
|
|
203
|
+
* Visit a parse tree produced by `PSCParser.doWhileStmt`.
|
|
204
|
+
* @param ctx the parse tree
|
|
205
|
+
* @return the visitor result
|
|
206
|
+
*/
|
|
207
|
+
visitDoWhileStmt;
|
|
208
|
+
/**
|
|
209
|
+
* Visit a parse tree produced by `PSCParser.repeatUntilStmt`.
|
|
210
|
+
* @param ctx the parse tree
|
|
211
|
+
* @return the visitor result
|
|
212
|
+
*/
|
|
213
|
+
visitRepeatUntilStmt;
|
|
214
|
+
/**
|
|
215
|
+
* Visit a parse tree produced by `PSCParser.forStmt`.
|
|
216
|
+
* @param ctx the parse tree
|
|
217
|
+
* @return the visitor result
|
|
218
|
+
*/
|
|
219
|
+
visitForStmt;
|
|
220
|
+
/**
|
|
221
|
+
* Visit a parse tree produced by `PSCParser.asmStmt`.
|
|
222
|
+
* @param ctx the parse tree
|
|
223
|
+
* @return the visitor result
|
|
224
|
+
*/
|
|
225
|
+
visitAsmStmt;
|
|
226
|
+
/**
|
|
227
|
+
* Visit a parse tree produced by `PSCParser.lvalue`.
|
|
228
|
+
* @param ctx the parse tree
|
|
229
|
+
* @return the visitor result
|
|
230
|
+
*/
|
|
231
|
+
visitLvalue;
|
|
232
|
+
/**
|
|
233
|
+
* Visit a parse tree produced by `PSCParser.inputStmt`.
|
|
234
|
+
* @param ctx the parse tree
|
|
235
|
+
* @return the visitor result
|
|
236
|
+
*/
|
|
237
|
+
visitInputStmt;
|
|
238
|
+
/**
|
|
239
|
+
* Visit a parse tree produced by `PSCParser.outputStmt`.
|
|
240
|
+
* @param ctx the parse tree
|
|
241
|
+
* @return the visitor result
|
|
242
|
+
*/
|
|
243
|
+
visitOutputStmt;
|
|
244
|
+
/**
|
|
245
|
+
* Visit a parse tree produced by `PSCParser.subprogram`.
|
|
246
|
+
* @param ctx the parse tree
|
|
247
|
+
* @return the visitor result
|
|
248
|
+
*/
|
|
249
|
+
visitSubprogram;
|
|
250
|
+
/**
|
|
251
|
+
* Visit a parse tree produced by `PSCParser.returnStmt`.
|
|
252
|
+
* @param ctx the parse tree
|
|
253
|
+
* @return the visitor result
|
|
254
|
+
*/
|
|
255
|
+
visitReturnStmt;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=PSCParserVisitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PSCParserVisitor.js","sourceRoot":"","sources":["../../src/_antlr/PSCParserVisitor.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,OAAO,EAAC,gBAAgB,EAAC,MAAM,QAAQ,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE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U,CAAiC;IAC3C;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,aAAa,CAAoC;IACjD;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,gBAAgB,CAAuC;IACvD;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,gBAAgB,CAAuC;IACvD;;;;OAIG;IACH,oBAAoB,CAA2C;IAC/D;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,eAAe,CAAsC;IACrD;;;;OAIG;IACH,eAAe,CAAsC;IACrD;;;;OAIG;IACH,eAAe,CAAsC;CACrD"}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ParserRuleContext } from "antlr4";
|
|
2
|
+
export declare class PSCSyntaxError extends Error {
|
|
3
|
+
constructor(line: number, column: number, msg: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class AccessNonExistingVariableError extends Error {
|
|
6
|
+
constructor(ctx: ParserRuleContext | undefined, variable: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class OperationValueTypeMismatchError extends Error {
|
|
9
|
+
constructor(ctx: ParserRuleContext | undefined, operator: string, expectedType: string, got: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class ConditionNotBooleanError extends Error {
|
|
12
|
+
constructor(ctx: ParserRuleContext | undefined, got: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class ForRangeNotIntegerError extends Error {
|
|
15
|
+
constructor(ctx: ParserRuleContext | undefined, got: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class ForVariableReuseError extends Error {
|
|
18
|
+
constructor(ctx: ParserRuleContext | undefined, name: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class InvalidArrayIndexError extends Error {
|
|
21
|
+
constructor(ctx: ParserRuleContext | undefined, index: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class ArrayAccessNotArrayError extends Error {
|
|
24
|
+
constructor(ctx: ParserRuleContext | undefined, got: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class UnmatchedArgumentsError extends Error {
|
|
27
|
+
constructor(ctx: ParserRuleContext | undefined, name: string, expectedParams: number, gotParams: number);
|
|
28
|
+
}
|
|
29
|
+
export declare class ImpossibleError extends Error {
|
|
30
|
+
constructor(ctx: ParserRuleContext | undefined, message: string);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAahD,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG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|
+
return `(from ln ${ctx.start.line} col ${ctx.start.column} to ln ${ctx.stop.line} col ${ctx.stop.column})`;
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
return `(at ln ${ctx.start.line} col ${ctx.start.column})`;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class PSCSyntaxError extends Error {
|
|
11
|
+
constructor(line, column, msg) {
|
|
12
|
+
super(`Syntax error at line ${line}, column ${column}: ${msg}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class AccessNonExistingVariableError extends Error {
|
|
16
|
+
constructor(ctx, variable) {
|
|
17
|
+
super(`Cannot access variable ${variable}, which does not exists. ${ctx && generateLineColMessage(ctx)}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class OperationValueTypeMismatchError extends Error {
|
|
21
|
+
constructor(ctx, operator, expectedType, got) {
|
|
22
|
+
super(`${operator} can only be applied to ${expectedType}, got ${got}. ${ctx && generateLineColMessage(ctx)}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class ConditionNotBooleanError extends Error {
|
|
26
|
+
constructor(ctx, got) {
|
|
27
|
+
super(`A condition must be evaluated to a boolean, got ${got}. ${ctx && generateLineColMessage(ctx)}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class ForRangeNotIntegerError extends Error {
|
|
31
|
+
constructor(ctx, got) {
|
|
32
|
+
super(`For loop range must evaluate to an integer, got ${got}. ${ctx && generateLineColMessage(ctx)}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class ForVariableReuseError extends Error {
|
|
36
|
+
constructor(ctx, name) {
|
|
37
|
+
super(`Cannot reuse loop variable '${name}' in a for loop. ${ctx && generateLineColMessage(ctx)}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class InvalidArrayIndexError extends Error {
|
|
41
|
+
constructor(ctx, index) {
|
|
42
|
+
super(`Array index ${index} is invalid. ${ctx && generateLineColMessage(ctx)}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class ArrayAccessNotArrayError extends Error {
|
|
46
|
+
constructor(ctx, got) {
|
|
47
|
+
super(`Cannot access an array index on a non-array value, got ${got}. ${ctx && generateLineColMessage(ctx)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class UnmatchedArgumentsError extends Error {
|
|
51
|
+
constructor(ctx, name, expectedParams, gotParams) {
|
|
52
|
+
super(`Subprogram ${name} expects ${expectedParams} arguments, but got ${gotParams}. ${ctx && generateLineColMessage(ctx)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class ImpossibleError extends Error {
|
|
56
|
+
constructor(ctx, message) {
|
|
57
|
+
super(`The following error should not be possible. Please report this bug:\n${message}. ${ctx && generateLineColMessage(ctx)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAEA,SAAS,sBAAsB,CAAC,GAAsB;IACpD,IACE,GAAG,CAAC,IAAI;QACR,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EACzE,CAAC;QACD,OAAO,YAAY,GAAG,CAAC,KAAK,CAAC,IAAI,QAAQ,GAAG,CAAC,KAAK,CAAC,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,IAAI,QAAQ,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;IAC7G,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,GAAG,CAAC,KAAK,CAAC,IAAI,QAAQ,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;IAC7D,CAAC;AACH,CAAC;AAED,MAAM,O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GAAG,IAAI,sBAAsB,CAAC,GAAG,CAAC,EAAE,CACzE,CAAC;IACJ,CAAC;CACF;AACD,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,GAAkC,EAAE,GAAW;QACzD,KAAK,CACH,0DAA0D,GAAG,KAAK,GAAG,IAAI,sBAAsB,CAAC,GAAG,CAAC,EAAE,CACvG,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YACE,GAAkC,EAClC,IAAY,EACZ,cAAsB,EACtB,SAAiB;QAEjB,KAAK,CACH,cAAc,IAAI,YAAY,cAAc,uBAAuB,SAAS,KAAK,GAAG,IAAI,sBAAsB,CAAC,GAAG,CAAC,EAAE,CACtH,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,GAAkC,EAAE,OAAe;QAC7D,KAAK,CACH,wEAAwE,OAAO,KAAK,GAAG,IAAI,sBAAsB,CAAC,GAAG,CAAC,EAAE,CACzH,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type InterpreterOptions = {
|
|
2
|
+
strictVariableScope: boolean;
|
|
3
|
+
arrayStartIndex: number;
|
|
4
|
+
outputFunction?: (output: string) => void;
|
|
5
|
+
inputFunction?: () => Promise<string>;
|
|
6
|
+
};
|
|
7
|
+
export declare function interpret(code: string, options?: Partial<InterpreterOptions>): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuDA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GACpC,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|