UMinho Haskell Libraries (1.0)ContentsIndex
Language.ContextFree.CfgM
Portability portable
Stability provisional
Maintainer jas@di.uminho.pt
Contents
Context-free grammars with actions.
Examples
Description
Regular Expressions in Haskell. Code Included in the Lecture Notes on Language Processing (with a functional flavour).
Synopsis
data Cfg m sy = Cfg {
terminals :: [sy]
nonterminals :: [sy]
root :: sy
prods :: [[(sy, m)]]
}
type ProdM m sy = (sy, m)
(|->) :: a -> [a] -> [a]
(<$>) :: a -> b -> (a, b)
($->) :: Monad m => a -> [(a, m ())] -> [(a, m ())]
(<$$>) :: MonadState s m => t -> (s -> s) -> (t, m ())
(<*>) :: a -> [a] -> [a]
(<$*>) :: Monad m => a -> [(a, m ())] -> [(a, m ())]
exExpa :: MonadState Int m => Cfg (m ()) [Char]
data Exp
= AddExp Exp Exp
| MulExp Exp Exp
| Number Int
| Var String
exExpb :: MonadState [Exp] m => Cfg (m ()) [Char]
exExpc :: MonadState [Exp] m => Cfg (m ()) [Char]
Context-free grammars with actions.
data Cfg m sy
Datatype of context-free grammars with actions.
Constructors
Cfg
terminals :: [sy]
nonterminals :: [sy]
root :: sy
prods :: [[(sy, m)]]
Instances
(Show sy, ??? m sy) => Show (Cfg m sy)
type ProdM m sy = (sy, m)
Type synonym for productions with actions
(|->) :: a -> [a] -> [a]
Create a production from LHS and RHS.
(<$>) :: a -> b -> (a, b)
Create a production with action from a production and an action.
($->) :: Monad m => a -> [(a, m ())] -> [(a, m ())]
Create a production with empty LHS action.
(<$$>) :: MonadState s m => t -> (s -> s) -> (t, m ())
Create a production with a state-modifying action
(<*>) :: a -> [a] -> [a]
Construct list of RHS symbols with actions. The first argument is a symbol with action.
(<$*>) :: Monad m => a -> [(a, m ())] -> [(a, m ())]
Construct list of RHS symbols with actions. The first argument is a symbol without action.
Examples
exExpa :: MonadState Int m => Cfg (m ()) [Char]
data Exp
Constructors
AddExp Exp Exp
MulExp Exp Exp
Number Int
Var String
exExpb :: MonadState [Exp] m => Cfg (m ()) [Char]
exExpc :: MonadState [Exp] m => Cfg (m ()) [Char]
Produced by Haddock version 0.6