@@ -5,7 +5,8 @@ import { Token } from "./tokenizer";
5
5
import { TokenType } from "./tokens" ;
6
6
import { ResolverErrors } from "./errors" ;
7
7
8
- const levenshtein = require ( 'fast-levenshtein' ) ;
8
+ import levenshtein from 'fast-levenshtein' ;
9
+ // const levenshtein = require('fast-levenshtein');
9
10
10
11
const RedefineableTokenSentinel = new Token ( TokenType . AT , "" , 0 , 0 , 0 ) ;
11
12
@@ -149,23 +150,20 @@ export class Resolver implements StmtNS.Visitor<void>, ExprNS.Visitor<void> {
149
150
// The global environment
150
151
this . environment = new Environment ( source , null , new Map ( [
151
152
// misc library
152
- [ "get_time" , new Token ( TokenType . NAME , "get_time" , 0 , 0 , 0 ) ] ,
153
+ [ "_int" , new Token ( TokenType . NAME , "_int" , 0 , 0 , 0 ) ] ,
154
+ [ "_int_from_string" , new Token ( TokenType . NAME , "_int_from_string" , 0 , 0 , 0 ) ] ,
155
+ [ "abs" , new Token ( TokenType . NAME , "abs" , 0 , 0 , 0 ) ] ,
156
+ [ "char_at" , new Token ( TokenType . NAME , "char_at" , 0 , 0 , 0 ) ] ,
157
+ [ "error" , new Token ( TokenType . NAME , "error" , 0 , 0 , 0 ) ] ,
158
+ [ "input" , new Token ( TokenType . NAME , "input" , 0 , 0 , 0 ) ] ,
159
+ [ "isinstance" , new Token ( TokenType . NAME , "isinstance" , 0 , 0 , 0 ) ] ,
160
+ [ "max" , new Token ( TokenType . NAME , "max" , 0 , 0 , 0 ) ] ,
161
+ [ "min" , new Token ( TokenType . NAME , "min" , 0 , 0 , 0 ) ] ,
153
162
[ "print" , new Token ( TokenType . NAME , "print" , 0 , 0 , 0 ) ] ,
154
- [ "raw_print" , new Token ( TokenType . NAME , "raw_print" , 0 , 0 , 0 ) ] ,
163
+ [ "random_random" , new Token ( TokenType . NAME , "random_random" , 0 , 0 , 0 ) ] ,
164
+ [ "round" , new Token ( TokenType . NAME , "round" , 0 , 0 , 0 ) ] ,
155
165
[ "str" , new Token ( TokenType . NAME , "str" , 0 , 0 , 0 ) ] ,
156
- [ "error" , new Token ( TokenType . NAME , "error" , 0 , 0 , 0 ) ] ,
157
- [ "prompt" , new Token ( TokenType . NAME , "prompt" , 0 , 0 , 0 ) ] ,
158
- [ "is_float" , new Token ( TokenType . NAME , "is_float" , 0 , 0 , 0 ) ] ,
159
- [ "is_int" , new Token ( TokenType . NAME , "is_int" , 0 , 0 , 0 ) ] ,
160
- [ "is_string" , new Token ( TokenType . NAME , "is_string" , 0 , 0 , 0 ) ] ,
161
- [ "is_function" , new Token ( TokenType . NAME , "is_function" , 0 , 0 , 0 ) ] ,
162
- [ "is_boolean" , new Token ( TokenType . NAME , "is_boolean" , 0 , 0 , 0 ) ] ,
163
- [ "parse_int" , new Token ( TokenType . NAME , "parse_int" , 0 , 0 , 0 ) ] ,
164
- [ "char_at" , new Token ( TokenType . NAME , "char_at" , 0 , 0 , 0 ) ] ,
165
- [ "arity" , new Token ( TokenType . NAME , "arity" , 0 , 0 , 0 ) ] ,
166
- [ "None" , new Token ( TokenType . NAME , "None" , 0 , 0 , 0 ) ] ,
167
- [ "NaN" , new Token ( TokenType . NAME , "NaN" , 0 , 0 , 0 ) ] ,
168
- [ "Infinity" , new Token ( TokenType . NAME , "Infinity" , 0 , 0 , 0 ) ] ,
166
+ [ "time_time" , new Token ( TokenType . NAME , "time_time" , 0 , 0 , 0 ) ] ,
169
167
170
168
// math constants
171
169
[ "math_pi" , new Token ( TokenType . NAME , "math_pi" , 0 , 0 , 0 ) ] ,
@@ -175,7 +173,6 @@ export class Resolver implements StmtNS.Visitor<void>, ExprNS.Visitor<void> {
175
173
[ "math_tau" , new Token ( TokenType . NAME , "math_tau" , 0 , 0 , 0 ) ] ,
176
174
177
175
// math library
178
- [ "math_abs" , new Token ( TokenType . NAME , "math_abs" , 0 , 0 , 0 ) ] ,
179
176
[ "math_acos" , new Token ( TokenType . NAME , "math_acos" , 0 , 0 , 0 ) ] ,
180
177
[ "math_acosh" , new Token ( TokenType . NAME , "math_acosh" , 0 , 0 , 0 ) ] ,
181
178
[ "math_asin" , new Token ( TokenType . NAME , "math_asin" , 0 , 0 , 0 ) ] ,
@@ -185,31 +182,46 @@ export class Resolver implements StmtNS.Visitor<void>, ExprNS.Visitor<void> {
185
182
[ "math_atanh" , new Token ( TokenType . NAME , "math_atanh" , 0 , 0 , 0 ) ] ,
186
183
[ "math_cbrt" , new Token ( TokenType . NAME , "math_cbrt" , 0 , 0 , 0 ) ] ,
187
184
[ "math_ceil" , new Token ( TokenType . NAME , "math_ceil" , 0 , 0 , 0 ) ] ,
188
- [ "math_clz32" , new Token ( TokenType . NAME , "math_clz32" , 0 , 0 , 0 ) ] ,
185
+ [ "math_comb" , new Token ( TokenType . NAME , "math_comb" , 0 , 0 , 0 ) ] ,
186
+ [ "math_copysign" , new Token ( TokenType . NAME , "math_copysign" , 0 , 0 , 0 ) ] ,
189
187
[ "math_cos" , new Token ( TokenType . NAME , "math_cos" , 0 , 0 , 0 ) ] ,
190
188
[ "math_cosh" , new Token ( TokenType . NAME , "math_cosh" , 0 , 0 , 0 ) ] ,
189
+ [ "math_degrees" , new Token ( TokenType . NAME , "math_degrees" , 0 , 0 , 0 ) ] ,
190
+ [ "math_erf" , new Token ( TokenType . NAME , "math_erf" , 0 , 0 , 0 ) ] ,
191
+ [ "math_erfc" , new Token ( TokenType . NAME , "math_erfc" , 0 , 0 , 0 ) ] ,
191
192
[ "math_exp" , new Token ( TokenType . NAME , "math_exp" , 0 , 0 , 0 ) ] ,
193
+ [ "math_exp2" , new Token ( TokenType . NAME , "math_exp2" , 0 , 0 , 0 ) ] ,
192
194
[ "math_expm1" , new Token ( TokenType . NAME , "math_expm1" , 0 , 0 , 0 ) ] ,
195
+ [ "math_fabs" , new Token ( TokenType . NAME , "math_fabs" , 0 , 0 , 0 ) ] ,
196
+ [ "math_factorial" , new Token ( TokenType . NAME , "math_factorial" , 0 , 0 , 0 ) ] ,
193
197
[ "math_floor" , new Token ( TokenType . NAME , "math_floor" , 0 , 0 , 0 ) ] ,
194
- [ "math_fround" , new Token ( TokenType . NAME , "math_fround" , 0 , 0 , 0 ) ] ,
195
- [ "math_hypot" , new Token ( TokenType . NAME , "math_hypot" , 0 , 0 , 0 ) ] ,
196
- [ "math_imul" , new Token ( TokenType . NAME , "math_imul" , 0 , 0 , 0 ) ] ,
198
+ [ "math_fma" , new Token ( TokenType . NAME , "math_fma" , 0 , 0 , 0 ) ] ,
199
+ [ "math_fmod" , new Token ( TokenType . NAME , "math_fmod" , 0 , 0 , 0 ) ] ,
200
+ [ "math_gamma" , new Token ( TokenType . NAME , "math_gamma" , 0 , 0 , 0 ) ] ,
201
+ [ "math_gcd" , new Token ( TokenType . NAME , "math_gcd" , 0 , 0 , 0 ) ] ,
202
+ [ "math_isfinite" , new Token ( TokenType . NAME , "math_isfinite" , 0 , 0 , 0 ) ] ,
203
+ [ "math_isinf" , new Token ( TokenType . NAME , "math_isinf" , 0 , 0 , 0 ) ] ,
204
+ [ "math_isnan" , new Token ( TokenType . NAME , "math_isnan" , 0 , 0 , 0 ) ] ,
205
+ [ "math_isqrt" , new Token ( TokenType . NAME , "math_isqrt" , 0 , 0 , 0 ) ] ,
206
+ [ "math_lcm" , new Token ( TokenType . NAME , "math_lcm" , 0 , 0 , 0 ) ] ,
207
+ [ "math_ldexp" , new Token ( TokenType . NAME , "math_ldexp" , 0 , 0 , 0 ) ] ,
208
+ [ "math_lgamma" , new Token ( TokenType . NAME , "math_lgamma" , 0 , 0 , 0 ) ] ,
197
209
[ "math_log" , new Token ( TokenType . NAME , "math_log" , 0 , 0 , 0 ) ] ,
210
+ [ "math_log10" , new Token ( TokenType . NAME , "math_log10" , 0 , 0 , 0 ) ] ,
198
211
[ "math_log1p" , new Token ( TokenType . NAME , "math_log1p" , 0 , 0 , 0 ) ] ,
199
212
[ "math_log2" , new Token ( TokenType . NAME , "math_log2" , 0 , 0 , 0 ) ] ,
200
- [ "math_log10" , new Token ( TokenType . NAME , "math_log10" , 0 , 0 , 0 ) ] ,
201
- [ "math_max" , new Token ( TokenType . NAME , "math_max" , 0 , 0 , 0 ) ] ,
202
- [ "math_min" , new Token ( TokenType . NAME , "math_min" , 0 , 0 , 0 ) ] ,
213
+ [ "math_nextafter" , new Token ( TokenType . NAME , "math_nextafter" , 0 , 0 , 0 ) ] ,
214
+ [ "math_perm" , new Token ( TokenType . NAME , "math_perm" , 0 , 0 , 0 ) ] ,
203
215
[ "math_pow" , new Token ( TokenType . NAME , "math_pow" , 0 , 0 , 0 ) ] ,
204
- [ "math_random" , new Token ( TokenType . NAME , "math_random" , 0 , 0 , 0 ) ] ,
205
- [ "math_round" , new Token ( TokenType . NAME , "math_round" , 0 , 0 , 0 ) ] ,
206
- [ "math_sign" , new Token ( TokenType . NAME , "math_sign" , 0 , 0 , 0 ) ] ,
216
+ [ "math_radians" , new Token ( TokenType . NAME , "math_radians" , 0 , 0 , 0 ) ] ,
217
+ [ "math_remainder" , new Token ( TokenType . NAME , "math_remainder" , 0 , 0 , 0 ) ] ,
207
218
[ "math_sin" , new Token ( TokenType . NAME , "math_sin" , 0 , 0 , 0 ) ] ,
208
219
[ "math_sinh" , new Token ( TokenType . NAME , "math_sinh" , 0 , 0 , 0 ) ] ,
209
220
[ "math_sqrt" , new Token ( TokenType . NAME , "math_sqrt" , 0 , 0 , 0 ) ] ,
210
221
[ "math_tan" , new Token ( TokenType . NAME , "math_tan" , 0 , 0 , 0 ) ] ,
211
222
[ "math_tanh" , new Token ( TokenType . NAME , "math_tanh" , 0 , 0 , 0 ) ] ,
212
223
[ "math_trunc" , new Token ( TokenType . NAME , "math_trunc" , 0 , 0 , 0 ) ] ,
224
+ [ "math_ulp" , new Token ( TokenType . NAME , "math_ulp" , 0 , 0 , 0 ) ]
213
225
] ) ) ;
214
226
this . functionScope = null ;
215
227
}
@@ -442,9 +454,13 @@ export class Resolver implements StmtNS.Visitor<void>, ExprNS.Visitor<void> {
442
454
this . resolve ( expr . consequent ) ;
443
455
this . resolve ( expr . alternative ) ;
444
456
}
457
+ visitNoneExpr ( expr : ExprNS . None ) : void {
458
+ }
445
459
visitLiteralExpr ( expr : ExprNS . Literal ) : void {
446
460
}
447
461
visitBigIntLiteralExpr ( expr : ExprNS . BigIntLiteral ) : void {
448
462
}
463
+ visitComplexExpr ( expr : ExprNS . Complex ) : void {
464
+ }
449
465
450
466
}
0 commit comments