Skip to content

Commit

Permalink
Fix code errors
Browse files Browse the repository at this point in the history
* debugging leftovers
  • Loading branch information
0rphee committed Jul 16, 2024
1 parent 0906de8 commit 00f3927
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ main :: IO ()
main = do
(Options sourceCodePath) <- runCmdOptions
putStrLn $ "FILEPATH: " <> sourceCodePath
assemblyCode <- T.readFile "asm/colors.asm"
assemblyCode <- T.readFile sourceCodePath
T.putStrLn assemblyCode
T.putStrLn $ T.replicate 10 "-"
mayStatements <- Expr.mainLocal assemblyCode
Expand Down
4 changes: 2 additions & 2 deletions src/Bin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ trans labelMap instrLoc = \case
putWord16le . either fromIntegral id

firstPass :: [Statement] -> ProgramInfo
firstPass ls = traceShowId $ go ls 0 (ProgramInfo mempty mempty mempty)
firstPass ls = go ls 0 (ProgramInfo mempty mempty mempty)
where
go :: [Statement] -> Int -> ProgramInfo -> ProgramInfo
go [] offset accum = accum
go [] _offset accum = accum
go (x : xs) offset acc = case x of
Ins newInstr ->
let newOffset = offset + getInstOffset newInstr
Expand Down
10 changes: 5 additions & 5 deletions src/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ parseNum base cond ending numberOfDigits = try $ do
textToInt :: Text -> Int
textToInt = T.foldl (\acc x -> acc * base + digitToInt x) 0

-- parseBin :: Num b => Int -> Parser b
parseBin n = parseNum 2 (\ch -> ch == '0' || ch == '1') 'b' n
parseBin :: Num b => Int -> Parser b
parseBin = parseNum 2 (\ch -> ch == '0' || ch == '1') 'b'

parseBin8 :: Parser Word8
parseBin8 = parseBin 8
Expand All @@ -135,8 +135,8 @@ parseBin12 = parseBin 12
parseBin16 :: Parser Word16
parseBin16 = parseBin 16

-- parseHex :: Num b => Int -> Parser b
parseHex n = parseNum 16 isHexDigit 'h' n
parseHex :: Num b => Int -> Parser b
parseHex = parseNum 16 isHexDigit 'h'

parseHex8 :: Parser Word8
parseHex8 = parseHex 2
Expand Down Expand Up @@ -307,5 +307,5 @@ mainLocal assemblyCode = do
putStrLn $ errorBundlePretty err
pure Nothing
Right statements -> do
traverse_ print statements
-- traverse_ print statements
pure $ Just statements

0 comments on commit 00f3927

Please sign in to comment.