Skip to content

Commit 4a11b28

Browse files
committed
change module to es2020 and fix formatting
1 parent 58c3213 commit 4a11b28

File tree

5 files changed

+41
-43
lines changed

5 files changed

+41
-43
lines changed

src/cse-machine/interpreter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ export function* generateCSEMachineStateStream(
437437
cmdEvaluators[command.instrType](command, context, control, stash, isPrelude)
438438
} else {
439439
// this is a scheme value
440-
throw new Error("scheme removed")
440+
throw new Error('scheme removed')
441441
}
442442

443443
// Push undefined into the stack if both control and stash is empty
@@ -1048,9 +1048,9 @@ const cmdEvaluators: { [type: string]: CmdEvaluator } = {
10481048
// as schemers like using the REPL, and that always assumes that the environment is reset
10491049
// to the main environment.
10501050
if (
1051-
(next &&
1052-
!(isInstr(next) && next.instrType === InstrType.ENVIRONMENT) &&
1053-
!control.canAvoidEnvInstr())
1051+
next &&
1052+
!(isInstr(next) && next.instrType === InstrType.ENVIRONMENT) &&
1053+
!control.canAvoidEnvInstr()
10541054
) {
10551055
control.push(
10561056
instr.envInstr(currentEnvironment(context), currentTransformers(context), command.srcNode)

src/evaluator.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
import { BasicEvaluator } from "conductor/dist/conductor/runner";
2-
import { IRunnerPlugin } from "conductor/dist/conductor/runner/types";
3-
import { initialise } from "conductor/dist/conductor/runner/util";
4-
import { Context, runInContext, createContext } from "./index";
5-
import { Value, Chapter, Variant } from "./types";
1+
import { BasicEvaluator } from 'conductor/dist/conductor/runner'
2+
import { IRunnerPlugin } from 'conductor/dist/conductor/runner/types'
3+
import { initialise } from 'conductor/dist/conductor/runner/util'
4+
import { Context, runInContext, createContext } from './index'
5+
import { Value, Chapter, Variant } from './types'
66

77
class JsSlangEvaluator extends BasicEvaluator {
8-
private ctx: Context;
8+
private ctx: Context
99

10-
async evaluateChunk(chunk: string): Promise<void> {
11-
const res = await runInContext(chunk, this.ctx);
12-
if (res.status === "error") {
13-
console.error(res);
14-
} else {
15-
this.ctx = res.context;
16-
if (res.status === "finished") return res.value;
17-
}
10+
async evaluateChunk(chunk: string): Promise<void> {
11+
const res = await runInContext(chunk, this.ctx)
12+
if (res.status === 'error') {
13+
console.error(res)
14+
} else {
15+
this.ctx = res.context
16+
if (res.status === 'finished') return res.value
1817
}
18+
}
1919

20-
constructor(conductor: IRunnerPlugin) {
21-
super(conductor);
20+
constructor(conductor: IRunnerPlugin) {
21+
super(conductor)
2222

23-
const rawDisplay = (value: Value, str: string, _externalContext: any) => {
24-
this.conductor.sendOutput((str === undefined ? '' : str + ' ') + String(value));
25-
return value;
26-
};
23+
const rawDisplay = (value: Value, str: string, _externalContext: any) => {
24+
this.conductor.sendOutput((str === undefined ? '' : str + ' ') + String(value))
25+
return value
26+
}
2727

28-
this.ctx = createContext(Chapter.SOURCE_4, Variant.DEFAULT, undefined, [], undefined, {
29-
rawDisplay: rawDisplay,
30-
prompt: rawDisplay,
31-
alert: rawDisplay,
32-
visualiseList: (_v: Value) => {
33-
throw new Error('List visualizer is not enabled')
34-
}
35-
});
28+
this.ctx = createContext(Chapter.SOURCE_4, Variant.DEFAULT, undefined, [], undefined, {
29+
rawDisplay: rawDisplay,
30+
prompt: rawDisplay,
31+
alert: rawDisplay,
32+
visualiseList: (_v: Value) => {
33+
throw new Error('List visualizer is not enabled')
34+
}
35+
})
3636

37-
console.log("Evaluator initialised!");
38-
}
37+
console.log('Evaluator initialised!')
38+
}
3939
}
4040

41-
initialise(JsSlangEvaluator);
41+
initialise(JsSlangEvaluator)

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ export async function runFilesInContext(
222222
}
223223

224224
let result: Result
225-
226-
// FIXME: Clean up state management so that the `parseError` function is pure.
227-
// This is not a huge priority, but it would be good not to make use of
228-
// global state.
225+
226+
// FIXME: Clean up state management so that the `parseError` function is pure.
227+
// This is not a huge priority, but it would be good not to make use of
228+
// global state.
229229
;({ result, verboseErrors } = await sourceFilesRunner(
230230
p => Promise.resolve(files[p]),
231231
entrypointFilePath,

src/runner/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ async function sourceRunner(
4646
const theOptions = _.merge({ ...DEFAULT_SOURCE_OPTIONS }, options)
4747
context.variant = determineVariant(context, options)
4848

49-
if (
50-
context.chapter === Chapter.FULL_JS
51-
) {
49+
if (context.chapter === Chapter.FULL_JS) {
5250
return runners.fulljs(program, context, theOptions)
5351
}
5452

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"module": "ESNext",
3+
"module": "es2020",
44
"target": "es2020",
55
"lib": [
66
"es2021.string",

0 commit comments

Comments
 (0)