{- |
Description: Type class for context-free grammars.
License: GNU LGPLv3
Maintainer: paul.bittner@uni-ulm.de

Type class for context-free grammars.
-}
module Grammar where

-- | Classification of nodes for feature traces and presence condition.
-- (See Section 3.1 in the paper.)
data NodeType = Mandatory | Optional | Wrapper deriving (Int -> NodeType -> ShowS
[NodeType] -> ShowS
NodeType -> String
(Int -> NodeType -> ShowS)
-> (NodeType -> String) -> ([NodeType] -> ShowS) -> Show NodeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodeType] -> ShowS
$cshowList :: [NodeType] -> ShowS
show :: NodeType -> String
$cshow :: NodeType -> String
showsPrec :: Int -> NodeType -> ShowS
$cshowsPrec :: Int -> NodeType -> ShowS
Show, NodeType -> NodeType -> Bool
(NodeType -> NodeType -> Bool)
-> (NodeType -> NodeType -> Bool) -> Eq NodeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodeType -> NodeType -> Bool
$c/= :: NodeType -> NodeType -> Bool
== :: NodeType -> NodeType -> Bool
$c== :: NodeType -> NodeType -> Bool
Eq)

-- | Type class for context-free grammars.
class Show g => Grammar g where
  -- | Tells for each grammar symbol which node type it has (e.g., if it is 'Mandatory' in the AST).
  nodetypeof :: g -> NodeType