suggestions work again, improve error reporting
This commit is contained in:
parent
9050581a10
commit
69175c8cb1
12 changed files with 259 additions and 282 deletions
|
|
@ -460,53 +460,6 @@
|
|||
// }
|
||||
// }
|
||||
|
||||
// function parseLiteral(text: string, type: string, env: Environment): [ResolvedType,Environment] {
|
||||
// // dirty
|
||||
// if (type === "Int") {
|
||||
// return parseAsInt(text, env);
|
||||
// }
|
||||
// if (type === "Double") {
|
||||
// return parseAsDouble(text, env);
|
||||
// }
|
||||
// return makeError(env, new Error("Failed to parse"));
|
||||
// }
|
||||
|
||||
// function parseAsDouble(text: string, env: Environment): [ResolvedType,Environment] {
|
||||
// if (text !== '') {
|
||||
// const num = Number(text);
|
||||
// if (!Number.isNaN(num)) {
|
||||
// return [{
|
||||
// kind: "value",
|
||||
// i: num,
|
||||
// t: Double,
|
||||
// unification: new Map(),
|
||||
// }, env];
|
||||
// }
|
||||
// }
|
||||
// return makeError(env, new Error("Failed to parse as Double"));
|
||||
// }
|
||||
// function parseAsInt(text: string, env: Environment): [ResolvedType,Environment] {
|
||||
// if (text !== '') {
|
||||
// try {
|
||||
// return [{
|
||||
// kind: "value",
|
||||
// i: BigInt(text),
|
||||
// t: Int,
|
||||
// unification: new Map(),
|
||||
// }, env]; // may throw
|
||||
// }
|
||||
// catch {}
|
||||
// }
|
||||
// return makeError(env, new Error("Failed to parse as Int"));
|
||||
// }
|
||||
|
||||
// const literalParsers = [parseAsDouble, parseAsInt];
|
||||
|
||||
// export function attemptParseLiteral(text: string, env: Environment): Dynamic[] {
|
||||
// return literalParsers.map(parseFn => parseFn(text, env))
|
||||
// .map(([resolved]) => resolved)
|
||||
// .filter((resolved) => (resolved.kind !== "unknown" && resolved.kind !== "error")) as unknown as Dynamic[];
|
||||
// }
|
||||
|
||||
// export function scoreResolved(resolved: ResolvedType, outPriority: (s:ResolvedType) => number) {
|
||||
// const bias = outPriority(resolved);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue