summaryrefslogtreecommitdiff
path: root/Thue/Parser.hs
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-04-10 05:25:03 +1000
committerJed Barber <jjbarber@y7mail.com>2014-04-10 05:25:03 +1000
commit281425310c5db21f87981eeb9601a71d1974d98d (patch)
treebef4643d906c93622c311fef2cf758fe94f1f651 /Thue/Parser.hs
parente8695600977769008f285f9958eb043cca1b9b29 (diff)
Rearranging files
Diffstat (limited to 'Thue/Parser.hs')
-rw-r--r--Thue/Parser.hs84
1 files changed, 0 insertions, 84 deletions
diff --git a/Thue/Parser.hs b/Thue/Parser.hs
deleted file mode 100644
index 2ee41ae..0000000
--- a/Thue/Parser.hs
+++ /dev/null
@@ -1,84 +0,0 @@
-module Thue.Parser (
- ThueProgram(..),
- ThueRule(..),
- ThueState,
-
- parseThue
- ) where
-
-import Control.Applicative( some )
-import Text.ParserCombinators.Parsec
-
-
-
-data ThueProgram = ThueProgram { thueRules :: [ThueRule]
- , thueInitialState :: ThueState }
- deriving (Show, Eq)
-
-
-data ThueRule = ThueRule { original :: ThueState
- , replacement :: ThueState }
- deriving (Show, Eq)
-
-
-type ThueState = String
-
-
-
-
-parseThue :: String -> Either ParseError ThueProgram
-parseThue = parse thue "error"
-
-
-
-
-thue = do
- rs <- many rule
- separatorLine
- i <- initialState
- eof
- return (ThueProgram rs i)
-
-
-rule = do
- o <- ruleState
- separator
- r <- state
- eol
- return (ThueRule o r)
-
-
-separatorLine = whiteSpace >> separator >> whiteSpace >> eol
-separator = string "::="
- <?> "rule separator"
-
-
-initialState = do
- s <- state `sepEndBy` eol
- return (concat s)
-
-
-ruleState = some ruleStateChar
-
-
-ruleStateChar = noneOf "\n\r:"
- <|> try (char ':' >> notFollowedBy (string ":=") >> return ':')
- <?> "state character"
-
-
-state = many stateChar
-
-
-stateChar = noneOf "\n\r"
- <?> "state character"
-
-
-whiteSpace = many (oneOf "\t ")
-
-
-eol = try (string "\r\n")
- <|> try (string "\n\r")
- <|> try (string "\r")
- <|> try (string "\n")
- <?> "end of line"
-