From 71992db7d0e51f87934f7d9c0cf9ddbd3a8d0300 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Wed, 14 Dec 2022 20:47:29 +0100 Subject: lists --- app/Compiler.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/Compiler.hs') diff --git a/app/Compiler.hs b/app/Compiler.hs index 67ca20f..84a63a4 100644 --- a/app/Compiler.hs +++ b/app/Compiler.hs @@ -6,6 +6,16 @@ import qualified Data.Map as M import Code (Code, Datum(..), Heap, Instr(..), heapStruct) import IR (Id(..), PrlgInt(..), StrTable(..)) +desugarPrlg :: Int -> PrlgInt -> PrlgInt +desugarPrlg list = go + where + go (CallI id ps) = CallI id $ map go ps + go (ListI (x:xs) t) = + CallI Id {str = list, arity = 2} [go x, go (ListI xs t)] + go (ListI [] Nothing) = LiteralI list + go (ListI [] (Just x)) = go x + go x = x + varname :: String -> Bool varname ('_':_) = True varname (c:_) = isUpper c -- cgit v1.2.3