Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81333 / brainfsck / src / Text
diff options
context:
space:
mode:
diff --git a/homework/81333/brainfsck/src/Text/Brainfsck/Parser.hs b/homework/81333/brainfsck/src/Text/Brainfsck/Parser.hs
deleted file mode 100644
index 28c019a..0000000
--- a/homework/81333/brainfsck/src/Text/Brainfsck/Parser.hs
+++ /dev/null
@@ -1,56 +0,0 @@
-module Text.Brainfsck.Parser
- ( parseText
- ) where
-
-import Control.Applicative
-
-import Data.Attoparsec.ByteString.Char8
-import qualified Data.ByteString.Char8 as B
-import Data.Either (fromRight)
-
-import Text.Brainfsck.Types
-
-goRight :: Parser BFExpr
-goRight = do
- char '>'
- pure BFRight
-
-goLeft :: Parser BFExpr
-goLeft = do
- char '<'
- pure BFLeft
-
-plus :: Parser BFExpr
-plus = do
- char '+'
- pure BFPlus
-
-minus :: Parser BFExpr
-minus = do
- char '-'
- pure BFMinus
-
-get :: Parser BFExpr
-get = do
- char ','
- pure BFGet
-
-put :: Parser BFExpr
-put = do
- char '.'
- pure BFPut
-
-bfsymbol :: Parser BFExpr
-bfsymbol = goRight <|> goLeft <|> plus <|> minus <|> get <|> put <|> loop
-
-loop :: Parser BFExpr
-loop = do
- char '['
- m <- many' bfsymbol
- char ']'
- pure $ BFLoop m
-
-parseText :: B.ByteString -> [BFExpr]
-parseText s =
- fromRight [] $
- parseOnly (many' bfsymbol) $ B.filter ((flip elem) "+-,.<>[]") s
diff --git a/homework/81333/brainfsck/src/Text/Brainfsck/Types.hs b/homework/81333/brainfsck/src/Text/Brainfsck/Types.hs
deleted file mode 100644
index 5dd26f6..0000000
--- a/homework/81333/brainfsck/src/Text/Brainfsck/Types.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Text.Brainfsck.Types where
-
-import qualified Data.ByteString.Char8 as B
-
-data BFExpr
- = BFRight
- | BFLeft
- | BFPlus
- | BFMinus
- | BFGet
- | BFPut
- | BFLoop [BFExpr]
- deriving (Show)
-
-data Blocks = Blocks
- { h :: Int
- , b :: [Int]
- , r :: B.ByteString
- } deriving (Show)
-
-newBlocks :: Blocks
-newBlocks = Blocks {h = 0, b = [0,0 ..], r = ""}
diff --git a/homework/81333/brainfsck/src/Text/Brainfsck/Util.hs b/homework/81333/brainfsck/src/Text/Brainfsck/Util.hs
deleted file mode 100644
index fb2d5ad..0000000
--- a/homework/81333/brainfsck/src/Text/Brainfsck/Util.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Text.Brainfsck.Util where
-
-inc :: [Int] -> Int -> [Int]
-inc b h = take h b <> [b !! h + 1] <> drop (h + 1) b
-
-dec :: [Int] -> Int -> [Int]
-dec b h = take h b <> [b !! h - 1] <> drop (h + 1) b
-
-load :: [Int] -> Int -> Int -> [Int]
-load b h v = take h b <> [v] <> drop (h + 1) b