From 71992db7d0e51f87934f7d9c0cf9ddbd3a8d0300 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Wed, 14 Dec 2022 20:47:29 +0100 Subject: lists --- app/IR.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/IR.hs') diff --git a/app/IR.hs b/app/IR.hs index 631cd16..f17547d 100644 --- a/app/IR.hs +++ b/app/IR.hs @@ -6,6 +6,7 @@ import qualified Data.Map as M data PrlgStr = CallS String [PrlgStr] | LiteralS String + | ListS [PrlgStr] (Maybe PrlgStr) deriving (Show) data Id = @@ -18,6 +19,7 @@ data Id = data PrlgInt = CallI Id [PrlgInt] --TODO this should be Int | LiteralI Int + | ListI [PrlgInt] (Maybe PrlgInt) -- only exists before desugaring | VarI Int Int -- VarI localIndex strTableString | VoidI deriving (Show) @@ -40,3 +42,7 @@ internPrlg = go go t (CallS str ps) = let (t', i) = strtablize t str in CallI (Id i $ length ps) <$> mapAccumL go t' ps + go t (ListS elems Nothing) = flip ListI Nothing <$> mapAccumL go t elems + go t (ListS elems (Just tail)) = + let (t', tail') = go t tail + in flip ListI (Just tail') <$> mapAccumL go t' elems -- cgit v1.2.3