Fix bind names not having special colors by adding BindNameNode.

This commit is contained in:
Robbie Gleichman 2016-11-26 13:46:05 -08:00
parent dd821cbb47
commit 533392f3c1
5 changed files with 6 additions and 21 deletions

View File

@ -26,15 +26,8 @@ syntaxNodeIsEmbeddable n = case n of
ApplyNode _ -> True
-- TODO make PatternApplyNode embeddable
PatternApplyNode _ _ -> False
NameNode _ -> False
LiteralNode _ -> True
FunctionDefNode _ -> False
GuardNode _ -> False
CaseNode _ -> False
BranchNode -> False
CaseResultNode -> False
-- Don't use a catch all (i.e. irrefutable) pattern here so that if other
-- SyntaxNodes are added we will get a warning here.
_ -> False
-- | A syntaxNodeCanEmbed if it can contain other nodes
syntaxNodeCanEmbed :: SyntaxNode -> Bool
@ -43,17 +36,8 @@ syntaxNodeCanEmbed n = case n of
x@(NestedApplyNode _ _) -> True -- This case should not happen
-- TODO make PatternApplyNode embed
PatternApplyNode _ _ -> False
NameNode _ -> False
LiteralNode _ -> False
FunctionDefNode _ -> False
GuardNode _ -> False
CaseNode _ -> False
BranchNode -> False
CaseResultNode -> False
-- Don't use a catch all (i.e. irrefutable) pattern here so that if other
-- SyntaxNodes are added we will get a warning here.
extractSyntaxNode :: ING.LNode SgNamedNode -> SyntaxNode
_ -> False
extractSyntaxNode = snd . snd
findParents :: ING.Graph gr => gr a b -> ING.Node -> [ING.Node]

View File

@ -484,7 +484,7 @@ showTopLevelBinds gr@(SyntaxGraph _ _ _ binds) = do
addBind (patName, Right port) = do
uniquePatName <- getUniqueName patName
let
icons = toNames [(uniquePatName, NameNode patName)]
icons = toNames [(uniquePatName, BindNameNode patName)]
edges = [makeSimpleEdge (justName uniquePatName, port)]
edgeGraph = syntaxGraphFromNodesEdges icons edges
pure edgeGraph

View File

@ -179,6 +179,7 @@ nodeToIcon (ApplyNode n) = ApplyAIcon n
nodeToIcon (NestedApplyNode x edges) = nestedApplySyntaxNodeToIcon x edges
nodeToIcon (PatternApplyNode s n) = PAppIcon n s
nodeToIcon (NameNode s) = TextBoxIcon s
nodeToIcon (BindNameNode s) = BindTextBoxIcon s
nodeToIcon (LiteralNode s) = TextBoxIcon s
nodeToIcon (FunctionDefNode n) = FlatLambdaIcon n
nodeToIcon (GuardNode n) = GuardIcon n

View File

@ -45,6 +45,7 @@ data SyntaxNode =
| NestedApplyNode Int [(SgNamedNode, Edge)]
| PatternApplyNode String Int -- Destructors as used in patterns
| NameNode String -- Identifiers or symbols
| BindNameNode String
| LiteralNode String -- Literal values like the string "Hello World"
| FunctionDefNode Int-- Function definition (ie. lambda expression)
| GuardNode Int

View File

@ -1,6 +1,5 @@
-- TODO Now --
-- Embed PatternApplyNodes. Need to be careful that they are not embedded by ApplyNodes, and ApplyNodes do not embed PatternApplyNodes.
-- Put the binds in a specially colored box (e.g. the y in "y = f x") should not be white text in a white box. This is a regression.
-- TODO Later --
-- Add documentation.