uuagc

KennedyWarren

Synopsis

- kennedyWarrenLazy :: Options -> Set NontermIdent -> [NontDependencyInformation] -> TypeSyns -> Derivings -> ExecutionPlan
- kennedyWarrenOrder :: Options -> Set NontermIdent -> [NontDependencyInformation] -> TypeSyns -> Derivings -> Either Error (ExecutionPlan, PP_Doc, PP_Doc)
- toGVVertex :: Bool -> Vertex -> ST s PP_Doc
- toGVEdge :: Edge -> ST s PP_Doc
- toGVNontDependencyInfo :: NontDependencyInformationM s -> ST s PP_Doc
- toGVProdDependencyGraph :: ProdDependencyGraphM s -> ST s PP_Doc
- toGVVisitGraph :: VG s PP_Doc
- newtype VGNode = VGNode Int
- newtype VGEdge = VGEdge Int
- newtype VGProd = VGProd (VGEdge, Int)
- data VGState s = VGState {
  - vgNodeNum :: Int
  - vgEdgeNum :: Int
  - vgOutgoing :: IntMap (STRef s (Set VGEdge))
  - vgIncoming :: IntMap (Maybe VGEdge)
  - vgNDI :: IntMap (STRef s (NontDependencyInformationM s))
  - vgInhSynNode :: Map (Identifier, Set Identifier, Set Identifier) VGNode
  - vgNodeInhSyn :: IntMap (Set Identifier, Set Identifier)
  - vgInitial :: Map Identifier VGNode
  - vgEdges :: IntMap (VGNode, VGNode)
  - vgEdgesR :: Map (VGNode, VGNode) VGEdge
  - vgInherited :: IntMap (Set Identifier)
  - vgSynthesized :: IntMap (Set Identifier)
  - vgPending :: IntSet
  - vgChildVisits :: IntMap (STRef s (Map (Identifier, Int) [VGNode]))
  - vgFinalVertices :: IntMap (STRef s (Set (Vertex, Int)))
  - vgProdVisits :: Map (Identifier, Identifier, VGEdge) (STRef s [VisitStep])
  }
- type VG s a = ErrorT String (StateT (VGState s) (ST s)) a
- runVG :: VG s a -> ST s a
- insertInitialNode :: NontDependencyInformationM s -> VG s VGNode
- createPending :: VGNode -> Set Identifier -> Set Identifier -> VG s VGEdge
- selectPending :: VG s VGEdge
- getInherited :: VGEdge -> VG s (Set Identifier)
- getSynthesized :: VGEdge -> VG s (Set Identifier)
- markFinal :: VGEdge -> VG s ()
- getProductions :: VGEdge -> VG s [VGProd]
- onMarkedDepGraph :: (ProdDependencyGraphM s -> ST s a) -> VGProd -> VG s a
- isDepGraphVertexFinal :: VGProd -> Vertex -> VG s Bool
- setDepGraphVerticesFinal :: VGProd -> [Vertex] -> VG s ()
- addChildVisit :: VGProd -> Identifier -> VGEdge -> VG s VisitStep
- addVisitStep :: VGProd -> VisitStep -> VG s ()
- getChildState :: VGProd -> Identifier -> VG s VGNode
- repeatM :: VG s () -> VG s ()
- vgInST :: ST s a -> VG s a
- vgEmptyState :: VGState s
- vgCreateNode :: STRef s (NontDependencyInformationM s) -> Set Identifier -> Set Identifier -> VG s VGNode
- vgCreatePendingEdge :: VGNode -> VGNode -> Set Identifier -> Set Identifier -> VG s VGEdge
- vgDepGraphVertexFinal :: VGNode -> Int -> Vertex -> VG s Bool
- vgFindInitial :: Identifier -> VG s VGNode
- imLookup :: Int -> IntMap a -> a
- traceVG :: String -> VG s ()
- kennedyWarrenVisitM :: Set NontermIdent -> [NontDependencyInformationM s] -> VG s [Maybe Int]
- groupSortBy :: (a -> a -> Ordering) -> [a] -> [[a]]
- type ChildVisits = [(Vertex, Int)]
- foldChildVisits :: VGProd -> (ChildVisits, Int) -> Vertex -> VG s (ChildVisits, Int)
- findChildVisits :: VGProd -> Vertex -> ChildVisits -> VG s (ChildVisits, Int)
- correctInhChilds :: VGProd -> ChildVisits -> VG s ChildVisits
- extraChildSyn :: VGProd -> ChildVisits -> VG s ChildVisits
- isReadyVertex :: VGProd -> ChildVisits -> Vertex -> VG s (Maybe Int)
- isChildSyn :: Vertex -> Bool
- isChildInh :: Vertex -> Bool
- isChildAttr :: Vertex -> Bool
- createLhsInh :: Identifier -> Vertex
- createLhsSyn :: Identifier -> Vertex
- kennedyWarrenExecutionPlan :: Options -> [NontDependencyInformationM s] -> [Maybe Int] -> Set NontermIdent -> TypeSyns -> Derivings -> VG s ExecutionPlan
- exploreGraph :: (VGNode -> Set VGEdge -> Set VGEdge -> a -> VG s a) -> VGNode -> a -> VG s a
- mkNextMap :: Int -> VG s (Map Int StateCtx)
- mkPrevMap :: Int -> VG s (Map Int StateCtx)
- updateCountMap :: Int -> Set VGEdge -> Map Int StateCtx -> VG s (Map Int StateCtx)

# Documentation

kennedyWarrenLazy :: Options -> Set NontermIdent -> [NontDependencyInformation] -> TypeSyns -> Derivings -> ExecutionPlan

kennedyWarrenOrder :: Options -> Set NontermIdent -> [NontDependencyInformation] -> TypeSyns -> Derivings -> Either Error (ExecutionPlan, PP_Doc, PP_Doc)

toGVVertex :: Bool -> Vertex -> ST s PP_Doc

Pretty print a vertex in GraphViz format

toGVEdge :: Edge -> ST s PP_Doc

Pretty print an edge in GraphViz format

toGVNontDependencyInfo :: NontDependencyInformationM s -> ST s PP_Doc

Pretty print a NontDependencyInformation in GraphViz format

toGVProdDependencyGraph :: ProdDependencyGraphM s -> ST s PP_Doc

Pretty print a ProdDependencyGraph in GraphViz format

toGVVisitGraph :: VG s PP_Doc

newtype VGNode

Constructors

VGNode Int |

Instances

Eq VGNode |
Ord VGNode |
Show VGNode |

newtype VGEdge

Constructors

VGEdge Int |

Instances

Eq VGEdge |
Ord VGEdge |
Show VGEdge |

newtype VGProd

Constructors

VGProd (VGEdge, Int) |

Instances

Eq VGProd |
Ord VGProd |
Show VGProd |

data VGState s

Constructors

VGState |
Fields vgNodeNum :: Int vgEdgeNum :: Int vgOutgoing :: IntMap (STRef s (Set VGEdge)) vgIncoming :: IntMap (Maybe VGEdge) vgNDI :: IntMap (STRef s (NontDependencyInformationM s)) vgInhSynNode :: Map (Identifier, Set Identifier, Set Identifier) VGNode vgNodeInhSyn :: IntMap (Set Identifier, Set Identifier) vgInitial :: Map Identifier VGNode vgEdges :: IntMap (VGNode, VGNode) vgEdgesR :: Map (VGNode, VGNode) VGEdge vgInherited :: IntMap (Set Identifier) vgSynthesized :: IntMap (Set Identifier) vgPending :: IntSet vgChildVisits :: IntMap (STRef s (Map (Identifier, Int) [VGNode])) vgFinalVertices :: IntMap (STRef s (Set (Vertex, Int))) vgProdVisits :: Map (Identifier, Identifier, VGEdge) (STRef s [VisitStep])

type VG s a = ErrorT String (StateT (VGState s) (ST s)) a

runVG :: VG s a -> ST s a

Run the VG monad in the ST monad

insertInitialNode :: NontDependencyInformationM s -> VG s VGNode

Insert an initial node for this nonterminal into the visit graph

createPending :: VGNode -> Set Identifier -> Set Identifier -> VG s VGEdge

Create a pending edge from this node with a set of inherited and synthesized attributes

selectPending :: VG s VGEdge

Return an arbitrary pending edge of which the from node is ready

getInherited :: VGEdge -> VG s (Set Identifier)

Get the inherited attributes of an edge

getSynthesized :: VGEdge -> VG s (Set Identifier)

Get the synthesized attributes of an edge

markFinal :: VGEdge -> VG s ()

Mark an edge as final

getProductions :: VGEdge -> VG s [VGProd]

Get all productions for an edge

onMarkedDepGraph :: (ProdDependencyGraphM s -> ST s a) -> VGProd -> VG s a

Execute a function on the dependency graph for this production

isDepGraphVertexFinal :: VGProd -> Vertex -> VG s Bool

Check whether this vertex has been marked as final

setDepGraphVerticesFinal :: VGProd -> [Vertex] -> VG s ()

Mark these vertices final in this production

addChildVisit :: VGProd -> Identifier -> VGEdge -> VG s VisitStep

Add a child visit to this production and return the step for the execution plan

addVisitStep :: VGProd -> VisitStep -> VG s ()

Add a step to the execution plan of this visit

getChildState :: VGProd -> Identifier -> VG s VGNode

Get the state of a child in a certain production

repeatM :: VG s () -> VG s ()

Repeat action untill mzero is encountered

vgInST :: ST s a -> VG s a

Execute a ST action inside the VG monad

vgEmptyState :: VGState s

vgCreateNode :: STRef s (NontDependencyInformationM s) -> Set Identifier -> Set Identifier -> VG s VGNode

Create a new node

vgCreatePendingEdge :: VGNode -> VGNode -> Set Identifier -> Set Identifier -> VG s VGEdge

Create a new pending edge

vgDepGraphVertexFinal :: VGNode -> Int -> Vertex -> VG s Bool

Check whether a vertex is marked final on this node in this production

vgFindInitial :: Identifier -> VG s VGNode

Find the initial node for a nonterminal

imLookup :: Int -> IntMap a -> a

Always succeeding IntMap lookup

traceVG :: String -> VG s ()

Trace inside the vg monad

kennedyWarrenVisitM :: Set NontermIdent -> [NontDependencyInformationM s] -> VG s [Maybe Int]

groupSortBy :: (a -> a -> Ordering) -> [a] -> [[a]]

groupBy that groups all equal (according to the function) elements instead of consequtive equal elements

type ChildVisits = [(Vertex, Int)]

foldChildVisits :: VGProd -> (ChildVisits, Int) -> Vertex -> VG s (ChildVisits, Int)

Helper function for folding over child visits

findChildVisits :: VGProd -> Vertex -> ChildVisits -> VG s (ChildVisits, Int)

Recursively find all visits to childs

correctInhChilds :: VGProd -> ChildVisits -> VG s ChildVisits

Correct inherited child visits after foldChildVisits

extraChildSyn :: VGProd -> ChildVisits -> VG s ChildVisits

Synthesized attributes that can also be evaluated

isReadyVertex :: VGProd -> ChildVisits -> Vertex -> VG s (Maybe Int)

Check if a vertex can be marked final in this step (and is not final yet) and return the visit num

isChildSyn :: Vertex -> Bool

Check if this vertex is a synthesized attribute of a child

isChildInh :: Vertex -> Bool

Check if this vertex is an inherited attribute of a child

isChildAttr :: Vertex -> Bool

Check if this vertex is an attribute of a child

createLhsInh :: Identifier -> Vertex

Create lhs.inh vertex

createLhsSyn :: Identifier -> Vertex

Create lhs.inh vertex

kennedyWarrenExecutionPlan :: Options -> [NontDependencyInformationM s] -> [Maybe Int] -> Set NontermIdent -> TypeSyns -> Derivings -> VG s ExecutionPlan

exploreGraph :: (VGNode -> Set VGEdge -> Set VGEdge -> a -> VG s a) -> VGNode -> a -> VG s a

mkNextMap :: Int -> VG s (Map Int StateCtx)

mkPrevMap :: Int -> VG s (Map Int StateCtx)

updateCountMap :: Int -> Set VGEdge -> Map Int StateCtx -> VG s (Map Int StateCtx)