diff --git a/src/Lexer.hs b/src/Lexer.hs index d704dad..210eb58 100644 --- a/src/Lexer.hs +++ b/src/Lexer.hs @@ -4,11 +4,11 @@ module Lexer where import Control.Applicative +import Data.Maybe import Text.Regex.TDFA import Text.Regex.TDFA.String ( ) import Tokens -import Util -- Chars that cannot appear in a symbol, for use inside character -- class. We have to put the brackets first for regex syntax reasons. @@ -76,7 +76,7 @@ getToken s = Just (text, token) -> (drop (length text) s, token) tokenize :: String -> [Token] -tokenize str = collectMaybes $ getTokens str +tokenize str = catMaybes $ getTokens str where getTokens [] = [] getTokens s = let (s', t) = getToken s in t : getTokens s' diff --git a/src/Linker.hs b/src/Linker.hs index b0f00f5..874ca53 100644 --- a/src/Linker.hs +++ b/src/Linker.hs @@ -282,7 +282,7 @@ link (codeB, dataB, codeSymbols, dataSymbols) = , dataLen = fromIntegral $ B.length dataB } shdrData = sectionHeader info (length allSymbols) - shStringList = collectMaybes (map snd shdrData) + shStringList = mapMaybe snd shdrData shstrtabData = strtab shStringList symstrtabData = strtab allSymbols in if all (\phe -> B.length phe == phelen) phdr diff --git a/src/Util.hs b/src/Util.hs index 05bdd2c..0dbb2f3 100644 --- a/src/Util.hs +++ b/src/Util.hs @@ -11,11 +11,6 @@ class Pretty a where fixedPoint :: Eq a => a -> (a -> a) -> a fixedPoint x f = let fx = f x in if x == fx then x else fixedPoint fx f -collectMaybes :: [Maybe a] -> [a] -collectMaybes [] = [] -collectMaybes (Nothing : ms) = collectMaybes ms -collectMaybes (Just a : ms) = a : collectMaybes ms - leftover :: Integral n => n -> n -> n leftover f x = (f - x) `mod` f