aoc2023 day2, codegen fixes, parsing fix

This commit is contained in:
2024-10-23 20:29:52 -07:00
parent 0843ae93e1
commit 8c8cdf4f7f
8 changed files with 147 additions and 5 deletions

View File

@@ -133,7 +133,9 @@ termToJS env (CCase t alts) f =
(Var nm) => maybeCaseStmt env nm alts
t' => do
-- TODO refactor nm to be a JSExp with Var{} or Dot{}
let nm = "sc$\{show env.depth}"
-- FIXME sc$ seemed to shadow something else, lets get this straightened out
-- we need fresh names that are not in env (i.e. do not play in debruijn)
let nm = "_sc$\{show env.depth}"
let env' = { depth $= S } env
JSnoc (JConst nm t') (maybeCaseStmt env' nm alts)

View File

@@ -124,7 +124,7 @@ letExpr = do
alts <- startBlock $ someSame $ letAssign
keyword' "in"
scope <- typeExpr
pure $ foldl (\ acc, (n,fc,v) => RLet fc n (RImplicit fc) v acc) scope alts
pure $ foldl (\ acc, (n,fc,v) => RLet fc n (RImplicit fc) v acc) scope (reverse alts)
where
letAssign : Parser (Name,FC,Raw)
letAssign = do