Adding spread operator. starting to build a stdlib. omg
This commit is contained in:
parent
216fe6bd30
commit
9edee10508
7 changed files with 102 additions and 14 deletions
11
src/main.ts
11
src/main.ts
|
|
@ -2,21 +2,29 @@ import { evaluate } from './interpreter'
|
|||
import type { Env } from './env'
|
||||
import { tokenize } from './lexer'
|
||||
import { Parser } from './parser'
|
||||
import cgCode from './counter.cg?raw';
|
||||
import { runApp } from './runtime';
|
||||
import { builtins } from './builtins';
|
||||
|
||||
import counterApp from './counter.cg?raw';
|
||||
import stdlibCode from './stdlib.cg?raw';
|
||||
import testCode from './test.cg?raw';
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 800;
|
||||
canvas.height = 600;
|
||||
document.body.appendChild(canvas);
|
||||
|
||||
const cgCode = stdlibCode + '\n' + testCode;
|
||||
|
||||
const tokens = tokenize(cgCode);
|
||||
const parser = new Parser(tokens);
|
||||
const ast = parser.parse();
|
||||
console.log(ast);
|
||||
|
||||
const env: Env = new Map(Object.entries(builtins));
|
||||
const res = evaluate(ast, env);
|
||||
console.log(res);
|
||||
/*
|
||||
const appRecord = evaluate(ast, env);
|
||||
|
||||
console.log(appRecord);
|
||||
|
|
@ -29,3 +37,4 @@ const update = appRecord.fields.update;
|
|||
const view = appRecord.fields.view;
|
||||
|
||||
runApp({ init, update, view }, canvas);
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue