From 281425310c5db21f87981eeb9601a71d1974d98d Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 10 Apr 2014 05:25:03 +1000 Subject: Rearranging files --- Brainfuck/Parser.hs | 62 ----------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 Brainfuck/Parser.hs (limited to 'Brainfuck/Parser.hs') diff --git a/Brainfuck/Parser.hs b/Brainfuck/Parser.hs deleted file mode 100644 index 1ea046a..0000000 --- a/Brainfuck/Parser.hs +++ /dev/null @@ -1,62 +0,0 @@ -module Brainfuck.Parser ( - BrainfuckProgram, - BrainCom(..), - - parseBrainfuck - ) where - -import Control.Applicative( some ) -import Text.ParserCombinators.Parsec - - - -type BrainfuckProgram = [BrainCom] - - -data BrainCom = R | L | Inc | Dec | Out | In | OpenLoop | CloseLoop - deriving (Show, Eq) - - - - -parseBrainfuck :: String -> Either ParseError BrainfuckProgram -parseBrainfuck = parse brainfuck "error" - - - - -brainfuck = do - many commentChar - bs <- many fuck - eof - return . concat $ bs - - -fuck = (brainCommand >>= return . (:[])) - <|> loop - "brainfuck command" - - -loop = do - char '[' - many commentChar - bs <- many brainCommand - char ']' - many commentChar - return . concat $ [[OpenLoop],bs,[CloseLoop]] - - -brainCommand = do { b <- brainCom; many commentChar; return b } - - -brainCom = (char '>' >> return R) - <|> (char '<' >> return L) - <|> (char '+' >> return Inc) - <|> (char '-' >> return Dec) - <|> (char '.' >> return Out) - <|> (char ',' >> return In) - "brainfuck command" - - -commentChar = noneOf "><+-.,[]" - -- cgit