Adding spread operator. starting to build a stdlib. omg

This commit is contained in:
Dustin Swan 2026-02-02 21:20:39 -07:00
parent 216fe6bd30
commit 9edee10508
No known key found for this signature in database
GPG key ID: 30D46587E2100467
7 changed files with 102 additions and 14 deletions

View file

@ -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);
*/