aoc2023 day2, codegen fixes, parsing fix
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -80,8 +80,9 @@ processModule base stk name = do
|
||||
top <- get
|
||||
let Right (decls, ops, toks) := partialParse (manySame parseDecl) top.ops toks
|
||||
| Left err => fail (showError src err)
|
||||
let [] := toks | (x :: xs) => fail "extra toks" -- FIXME FC from xs
|
||||
|
||||
let [] := toks
|
||||
| (x :: xs) =>
|
||||
fail (showError src (E (startBounds x.bounds) "extra toks")) -- FIXME FC from xs
|
||||
modify { ops := ops }
|
||||
|
||||
putStrLn "process Decls"
|
||||
|
||||
Reference in New Issue
Block a user