Skip to content

Commit

Permalink
parse hex/bin nums
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorTaelin committed Oct 30, 2024
1 parent d12cb17 commit 9b9955f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
7 changes: 5 additions & 2 deletions src/Kind/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ parseUse = parseLocal "use" Use

parseSet = withSrc $ char_end '*' >> return Set


parseFloat = withSrc $ P.try $ do
-- Parse optional negative sign
sign <- P.option id $ P.char '-' >> return negate
Expand All @@ -439,7 +438,11 @@ parseFloat = withSrc $ P.try $ do
-- Apply the sign to the final value
return $ Flt (sign value)

parseNum = withSrc $ Num . read <$> P.many1 digit
parseNum = withSrc $ P.choice
[ P.try (string_skp "0x") >> (Num . read . ("0x" ++) <$> P.many1 P.hexDigit)
, P.try (string_skp "0b") >> (Num . read . ("0b" ++) <$> P.many1 (oneOf "01"))
, Num . read <$> P.many1 digit
]

parseOp2 = withSrc $ do
opr <- P.try $ do
Expand Down
25 changes: 0 additions & 25 deletions src/Kind/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -136,28 +136,3 @@ data Env a = Env (State -> Res a) -- monadic checker
-- UNCOMMENT THIS TO DEBUG THE TYPE CHECKER
-- debug a b = trace a b
debug a b = b

-- -- Global Memory
-- memory :: IORef (IM.IntMap Word64)
-- memory = unsafePerformIO $ newIORef IM.IntMap.empty
-- [># NOINLINE memory #<]

-- -- Function to mutate the global IntMap
-- swap :: Word64 -> Word64 -> Word64
-- swap key val = unsafePerformIO $ do
-- mem <- readIORef memory
-- let newMem = IntMap.insert (fromIntegral key) val mem
-- writeIORef memory mem













0 comments on commit 9b9955f

Please sign in to comment.