diff options
Removed old homeworks
1 files changed, 0 insertions, 60 deletions
| -rw-r--r-- | homework/81248/brainfsck/src/Brainfsck/Parse.hs | 60 |
diff --git a/homework/81248/brainfsck/src/Brainfsck/Parse.hs b/homework/81248/brainfsck/src/Brainfsck/Parse.hs deleted file mode 100644 index 1a9625d..0000000 --- a/homework/81248/brainfsck/src/Brainfsck/Parse.hs +++ /dev/null @@ -1,60 +0,0 @@ -module Brainfsck.Parse - ( parse - , ps - ) where - -import Prelude hiding (takeWhile) - -import Data.Functor (($>)) -import Data.Either (fromRight) -import Data.Foldable (asum) - -import Data.ByteString (ByteString) - -import Data.Attoparsec.ByteString.Char8 hiding (parse) - -import Brainfsck.Types -expr :: Parser Expr -expr = asum - [ goRight - , goLeft - , incr - , decr - , out - , inp - , loop - ] - -eatComments :: Parser () -eatComments = takeWhile (\x -> x `notElem` ("><+-,.[]" :: String)) $> () - -comments :: Parser a -> Parser a -comments p = eatComments *> p <* eatComments - -goRight :: Parser Expr -goRight = comments $ char '>' $> GoRight - -goLeft :: Parser Expr -goLeft = comments $ char '<' $> GoLeft - -incr :: Parser Expr -incr = comments $ char '+' $> Incr - -decr :: Parser Expr -decr = comments $ char '-' $> Decr - -out :: Parser Expr -out = comments $ char '.' $> Out - -inp :: Parser Expr -inp = comments $ char ',' $> In - -loop :: Parser Expr -loop = comments $ Loop <$> - (char '[' *> comments (many' expr) <* char ']') - -parse :: ByteString -> Either String [Expr] -parse = parseOnly (many' expr <* endOfInput) - -ps :: ByteString -> [Expr] -ps = fromRight [] . parse |
