create lil' demo program.
This commit is contained in:
parent
6fe8660061
commit
12aa28bb7f
16
src/main.mjs
16
src/main.mjs
|
@ -1,4 +1,20 @@
|
|||
import { parse } from "./parse.mjs";
|
||||
import { compile } from "./compile.mjs";
|
||||
import { execute } from "./execute.mjs";
|
||||
|
||||
|
||||
|
||||
const lines = parse("main = a b → a").lines;
|
||||
const program = compile(lines);
|
||||
|
||||
function prettify (code) {
|
||||
if (Array.isArray(code)) {
|
||||
return prettify(code[0]).concat(prettify(code[1]));
|
||||
}
|
||||
if (code === 0) {
|
||||
return "λ";
|
||||
}
|
||||
return code.toString();
|
||||
}
|
||||
|
||||
console.log(execute(program.env.get("main"))(1)(2));
|
||||
|
|
Loading…
Reference in New Issue