mirror of
https://github.com/rgleichman/glance.git
synced 2024-09-11 15:05:41 +03:00
Working on pseudocode for new stateful collapseNodes algorithm in graph_algs.txt.
This commit is contained in:
parent
78dde11454
commit
4f87457639
@ -38,6 +38,7 @@ data Icon = ResultIcon | BranchIcon | TextBoxIcon String | GuardIcon Int
|
||||
deriving (Show, Eq)
|
||||
|
||||
-- TODO remove Ints from SyntaxNode data constructors.
|
||||
-- TODO Add NestedApplyNode, and NestedPatternApplyNode
|
||||
data SyntaxNode = ApplyNode Int-- Function application
|
||||
| PatternApplyNode String Int -- Destructors as used in patterns
|
||||
| NameNode String -- Identifiers or symbols
|
||||
|
@ -1,5 +1,29 @@
|
||||
-- Pseudocode for collapsing a syntax graph.
|
||||
|
||||
-- New stateful algorithm
|
||||
|
||||
-- Note: Node refers to the FGL node, which is just an integer. The node label has to be looked up separately in the graph.
|
||||
-- The node label has all of the information about the node such as what SyntaxNode it represents.
|
||||
|
||||
collapseNodes :: SyntaxGrrah -> SyntaxGraph
|
||||
collapseNodes originalGraph = finalGraph where
|
||||
-- findTreeRoots returns a list of nodes that will embed other nodes, but are not embedded themselves.
|
||||
-- These nodes are thus each a root of a collapsed node tree.
|
||||
treeRoots = findTreeRoots originalGraph
|
||||
-- Now collapse each tree of nodes
|
||||
finalGraph = foldl' collapseTree originalGraph treeRoots
|
||||
|
||||
collapseTree :: SyntaxGraph -> Node -> SyntaxGraph
|
||||
collapseTree oldGraph rootNode = newGraph where
|
||||
childrenToEmbed = findChildrenToEmbed rootNode oldGraph
|
||||
|
||||
-- TODO
|
||||
|
||||
findChildrenToEmbed :: Node -> SyntaxGraph -> [Node]
|
||||
findChildrenToEmbed = -- TODO
|
||||
|
||||
|
||||
-- OLD ALGORITHM
|
||||
-- To make the problem simpler, collapseNodes just cares about the
|
||||
collapseNodes :: SyntaxGraph -> SyntaxGraph
|
||||
collapseNodes inGraph = graphFold foldFunc initialOutputGraph inGraph where
|
||||
|
Loading…
Reference in New Issue
Block a user