Defined Data Type for Grammar files
authorJoachim Breitner <mail@joachim-breitner.de>
Sun, 19 Apr 2009 10:58:37 +0000 (12:58 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Sun, 19 Apr 2009 10:58:37 +0000 (12:58 +0200)
src/Lseed/Grammar.hs [new file with mode: 0644]

diff --git a/src/Lseed/Grammar.hs b/src/Lseed/Grammar.hs
new file mode 100644 (file)
index 0000000..b126d23
--- /dev/null
@@ -0,0 +1,62 @@
+-- | Grammer-like representation for a plant genome
+module Lseed.Grammar where
+
+-- | A complete grammar file
+type GrammarFile = [ GrammarRule ]
+
+type Priority = Int
+type Weight = Int
+
+type UserTag = String
+
+defaultPriority :: Priority
+defaultPriority = 0
+
+defaultWeight :: Weight
+defaultWeight = 1
+
+-- | A single Rule. For now, only single branches
+--   can be matched, not whole subtree structures
+data GrammarRule = GrammarRule
+       { grName :: String
+       , grPriority :: Priority
+       , grWeight :: Weight
+       , grCondition :: Condition
+       , grAction :: GrammarAction
+       }
+       deriving (Read,Show)
+
+data Matchable
+       = MatchLight
+       | MatchTotalLight
+       | MatchLength
+       | MatchTotalLength
+       | MatchDirection
+       | MatchAngle
+       deriving (Read,Show)
+
+data Cmp
+       = LE
+       | Less
+       | Equals
+       | Greater
+       | GE 
+       deriving (Read,Show)
+
+data Condition
+       = Always Bool -- constant conditions
+       | Condition `And` Condition
+       | Condition `Or` Condition
+       | UserTagIs String
+       | NumCond Matchable Cmp Double
+       deriving (Read,Show)
+        
+data GrammarAction
+       = SetLength LengthDescr (Maybe UserTag)
+-- TODO        | AddBranch Double Angle (Maybe (UserTag, UserTag, UserTag))
+       deriving (Read,Show)
+
+data LengthDescr = Absolute Double
+                | Additional Double
+                 | AdditionalRelative Double -- ^ in Percent
+       deriving (Read,Show)