diff options
Diffstat (limited to 'app/IR.hs')
| -rw-r--r-- | app/IR.hs | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,5 +1,6 @@ module IR where +import Data.Char (isNumber) import Data.List (mapAccumL) import qualified Data.Map as M @@ -18,7 +19,8 @@ data Id = data PrlgInt = CallI Int [PrlgInt] - | LiteralI Int + | AtomI Int + | NumI Int | ListI [PrlgInt] (Maybe PrlgInt) -- only exists before desugaring | VarI Int Int -- VarI localIndex strTableString | VoidI @@ -38,7 +40,9 @@ strtablize t@(StrTable nxt fwd rev) str = internPrlg :: StrTable -> PrlgStr -> (StrTable, PrlgInt) internPrlg = go where - go t (LiteralS str) = LiteralI <$> strtablize t str + go t (LiteralS str) + | all isNumber str = (t, NumI $ read str) + | otherwise = AtomI <$> strtablize t str go t (CallS str ps) = let (t', i) = strtablize t str in CallI i <$> mapAccumL go t' ps |
