summaryrefslogtreecommitdiff
path: root/app/Compiler.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Compiler.hs')
-rw-r--r--app/Compiler.hs10
1 files changed, 10 insertions, 0 deletions
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