-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Rename Agenda to Control - Simplify Environment - Evaluate until target step - Support Assignment - Break down LocalVariableDeclarationStatement with VariableInitializer - Return Promise<Result>
- Loading branch information
Showing
7 changed files
with
284 additions
and
308 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { parse } from "../ast/parser"; | ||
import { Control, Environment, evaluate, Stash } from "./interpreter"; | ||
import { Context, Error, Finished, Result } from "./types"; | ||
|
||
export const runECEvaluator = ( | ||
files: Partial<Record<string, string>>, | ||
entrypointFilePath: string, | ||
context: Context, | ||
targetStep: number = Infinity, | ||
): Promise<Result> => { | ||
try { | ||
const code = files[entrypointFilePath]; | ||
const compilationUnit = parse(code!); | ||
|
||
context.control.push(compilationUnit!); | ||
const value = evaluate(context, targetStep); | ||
|
||
return new Promise((resolve, _) => { | ||
resolve({ status: 'finished', context, value } as Finished); | ||
}); | ||
} catch { | ||
return new Promise((resolve, _) => { | ||
resolve({ status: 'error' } as Error); | ||
}); | ||
} | ||
} | ||
|
||
export const createContext = (): Context => ({ | ||
errors: [], | ||
|
||
control: new Control(), | ||
stash: new Stash(), | ||
environment: new Environment(), | ||
|
||
totalSteps: Infinity, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.