summaryrefslogtreecommitdiff
path: root/thue.hs
diff options
context:
space:
mode:
Diffstat (limited to 'thue.hs')
-rw-r--r--thue.hs59
1 files changed, 59 insertions, 0 deletions
diff --git a/thue.hs b/thue.hs
new file mode 100644
index 0000000..8c56a2e
--- /dev/null
+++ b/thue.hs
@@ -0,0 +1,59 @@
+
+import Text.Combinators.Parsec
+
+
+
+data ThueProgram = ThueProgram { substitutionRules :: [Rule]
+ , initialState :: State }
+ deriving (Show)
+
+
+data Rule = Rule { original :: State
+ , replacement :: State }
+ deriving (Show)
+
+
+type State = String
+
+
+
+
+parseThue :: String -> Either ParseError ThueProgram
+parseThue = parse thue "error"
+
+
+
+
+thue = do
+ rs <- many ruleLine
+ separatorLine
+ i <- stateLine
+ return (ThueProgram rs i)
+
+
+ruleLine = do
+ r <- rule
+ eol
+ return r
+
+
+rule = do
+ o <- state
+ separator
+ r <- state
+ return (Rule o r)
+
+
+separatorLine = separator >> eol
+separator = string "::="
+
+
+stateLine = do
+ s <- state
+ eol
+ return s
+
+
+state =
+
+