diff --git a/extra/compiler/cfg/graphviz/graphviz.factor b/extra/compiler/cfg/graphviz/graphviz.factor index 59ce890bb8..47d709c4ff 100644 --- a/extra/compiler/cfg/graphviz/graphviz.factor +++ b/extra/compiler/cfg/graphviz/graphviz.factor @@ -1,25 +1,10 @@ ! Copyright (C) 2011 Alex Vondrak. ! See http://factorcode.org/license.txt for BSD license - -USING: accessors fry io io.directories io.pathnames -io.streams.string kernel math math.parser namespaces -prettyprint sequences splitting strings tools.annotations - -compiler.cfg -compiler.cfg.builder -compiler.cfg.debugger -compiler.cfg.linearization -compiler.cfg.finalization -compiler.cfg.optimizer -compiler.cfg.rpo - -compiler.cfg.value-numbering -compiler.cfg.value-numbering.graph - -graphviz -graphviz.notation -graphviz.render -; +USING: accessors compiler.cfg compiler.cfg.builder +compiler.cfg.debugger compiler.cfg.finalization compiler.cfg.rpo +graphviz graphviz.notation graphviz.render io.directories +io.pathnames io.streams.string kernel math math.parser +namespaces sequences splitting ; FROM: compiler.cfg.linearization => number-blocks ; IN: compiler.cfg.graphviz @@ -48,8 +33,8 @@ IN: compiler.cfg.graphviz : cfgviz ( cfg -- graph ) - [graph "t" =labelloc ]; - [node "box" =shape "Courier" =fontname 10 =fontsize ]; + graph[ "t" =labelloc ] + node[ "box" =shape "Courier" =fontname 10 =fontsize ] swap [ [ add-cfg-vertex ] [ add-cfg-edges ] bi ] each-basic-block ; diff --git a/extra/graphviz/graphviz-docs.factor b/extra/graphviz/graphviz-docs.factor index c581d98eb5..253a8e9207 100644 --- a/extra/graphviz/graphviz-docs.factor +++ b/extra/graphviz/graphviz-docs.factor @@ -607,8 +607,8 @@ $nl "" ": K_n ( n -- )" " " -" [node \"point\" =shape ]; " -" [graph \"t\" =labelloc \"circo\" =layout ];" +" node[ \"point\" =shape ]" +" graph[ \"t\" =labelloc \"circo\" =layout ]" "" " over number>string \"K \" prepend =label" "" @@ -636,15 +636,15 @@ $nl ":: partite-set ( n color -- cluster )" " color " " color =color" -" [node color =color ];" +" node[ color =color ]" " n [" " number>string color prepend add-node" " ] each ;" "" ":: K_n,m ( n m -- )" " " -" [node \"point\" =shape ];" -" [graph \"t\" =labelloc \"dot\" =layout \"LR\" =rankdir ];" +" node[ \"point\" =shape ]" +" graph[ \"t\" =labelloc \"dot\" =layout \"LR\" =rankdir ]" "" " n \"#FF0000\" partite-set" " m \"#0000FF\" partite-set" @@ -678,8 +678,8 @@ $nl "" ": C_n ( n -- )" " " -" [graph \"t\" =labelloc \"circo\" =layout ];" -" [node \"point\" =shape ];" +" graph[ \"t\" =labelloc \"circo\" =layout ]" +" node[ \"point\" =shape ]" " over number>string \"C \" prepend =label" " swap add-cycle" " preview ;" @@ -707,8 +707,8 @@ $nl "" ": W_n ( n -- )" " " -" [graph \"t\" =labelloc \"twopi\" =layout ];" -" [node \"point\" =shape ];" +" graph[ \"t\" =labelloc \"twopi\" =layout ]" +" node[ \"point\" =shape ]" " over number>string \"W \" prepend =label" " over add-node" " over 1 - add-cycle" @@ -736,13 +736,13 @@ $nl " 0 " " \"filled\" =style" " \"lightgrey\" =color" -" [node \"filled\" =style \"white\" =color ];" +" node[ \"filled\" =style \"white\" =color ]" " { \"a0\" \"a1\" \"a2\" \"a3\" } ~->" " \"process #1\" =label" " add" "" " 1 " -" [node \"filled\" =style ];" +" node[ \"filled\" =style ]" " { \"b0\" \"b1\" \"b2\" \"b3\" } ~->" " \"process #2\" =label" " \"blue\" =color" @@ -756,8 +756,8 @@ $nl " \"a3\" \"end\" ->" " \"b3\" \"end\" ->" "" -" \"start\" [add-node \"Mdiamond\" =shape ];" -" \"end\" [add-node \"Msquare\" =shape ];" +" \"start\" add-node[ \"Mdiamond\" =shape ]" +" \"end\" add-node[ \"Msquare\" =shape ]" "preview" } { $image "resource:extra/graphviz/gallery/cluster.png" } @@ -777,16 +777,16 @@ $nl " [ 16 * \"#%2x0000\" sprintf =fillcolor ] tri ;" "" "" -" [graph \"3,3\" =size \"circo\" =layout ];" +" graph[ \"3,3\" =size \"circo\" =layout ]" "" -" [node \"filled\" =style" +" node[ \"filled\" =style" " \"circle\" =shape" " \"true\" =fixedsize" -" \"\" =label ];" +" \"\" =label ]" "" -" [edge \"invis\" =style ];" +" edge[ \"invis\" =style ]" "" -" 0 [add-node \"invis\" =style \"none\" =shape ];" +" 0 add-node[ \"invis\" =style \"none\" =shape ]" "" " 16 [" " [ 0 -- ] [ colored-circle add ] bi" @@ -805,23 +805,23 @@ $nl "" " \"LR\" =rankdir" " \"8,5\" =size" -" [node \"doublecircle\" =shape ];" +" node[ \"doublecircle\" =shape ]" " { \"LR_0\" \"LR_3\" \"LR_4\" \"LR_8\" } add-nodes" -" [node \"circle\" =shape ];" -" \"LR_0\" \"LR_2\" [-> \"SS(B)\" =label ];" -" \"LR_0\" \"LR_1\" [-> \"SS(S)\" =label ];" -" \"LR_1\" \"LR_3\" [-> \"S($end)\" =label ];" -" \"LR_2\" \"LR_6\" [-> \"SS(b)\" =label ];" -" \"LR_2\" \"LR_5\" [-> \"SS(a)\" =label ];" -" \"LR_2\" \"LR_4\" [-> \"S(A)\" =label ];" -" \"LR_5\" \"LR_7\" [-> \"S(b)\" =label ];" -" \"LR_5\" \"LR_5\" [-> \"S(a)\" =label ];" -" \"LR_6\" \"LR_6\" [-> \"S(b)\" =label ];" -" \"LR_6\" \"LR_5\" [-> \"S(a)\" =label ];" -" \"LR_7\" \"LR_8\" [-> \"S(b)\" =label ];" -" \"LR_7\" \"LR_5\" [-> \"S(a)\" =label ];" -" \"LR_8\" \"LR_6\" [-> \"S(b)\" =label ];" -" \"LR_8\" \"LR_5\" [-> \"S(a)\" =label ];" +" node[ \"circle\" =shape ]" +" \"LR_0\" \"LR_2\" ->[ \"SS(B)\" =label ]" +" \"LR_0\" \"LR_1\" ->[ \"SS(S)\" =label ]" +" \"LR_1\" \"LR_3\" ->[ \"S($end)\" =label ]" +" \"LR_2\" \"LR_6\" ->[ \"SS(b)\" =label ]" +" \"LR_2\" \"LR_5\" ->[ \"SS(a)\" =label ]" +" \"LR_2\" \"LR_4\" ->[ \"S(A)\" =label ]" +" \"LR_5\" \"LR_7\" ->[ \"S(b)\" =label ]" +" \"LR_5\" \"LR_5\" ->[ \"S(a)\" =label ]" +" \"LR_6\" \"LR_6\" ->[ \"S(b)\" =label ]" +" \"LR_6\" \"LR_5\" ->[ \"S(a)\" =label ]" +" \"LR_7\" \"LR_8\" ->[ \"S(b)\" =label ]" +" \"LR_7\" \"LR_5\" ->[ \"S(a)\" =label ]" +" \"LR_8\" \"LR_6\" ->[ \"S(b)\" =label ]" +" \"LR_8\" \"LR_5\" ->[ \"S(a)\" =label ]" "preview" } { $image "resource:extra/graphviz/gallery/fsm.png" } @@ -836,66 +836,66 @@ $nl "USING: graphviz graphviz.notation graphviz.render ;" "" "" -" [graph \"LR\" =rankdir \"8,8\" =size ];" -" [node 8 =fontsize \"record\" =shape ];" +" graph[ \"LR\" =rankdir \"8,8\" =size ]" +" node[ 8 =fontsize \"record\" =shape ]" "" -" \"node0\" [add-node" +" \"node0\" add-node[" " \" 0x10ba8| \" =label" -" ];" -" \"node1\" [add-node" +" ]" +" \"node1\" add-node[" " \" 0xf7fc4380| | |-1\" =label" -" ];" -" \"node2\" [add-node" +" ]" +" \"node2\" add-node[" " \" 0xf7fc44b8| | |2\" =label" -" ];" -" \"node3\" [add-node" +" ]" +" \"node3\" add-node[" " \" 3.43322790286038071e-06|44.79998779296875|0\" =label" -" ];" -" \"node4\" [add-node" +" ]" +" \"node4\" add-node[" " \" 0xf7fc4380| | |2\" =label" -" ];" -" \"node5\" [add-node" +" ]" +" \"node5\" add-node[" " \" (nil)| | |-1\" =label" -" ];" -" \"node6\" [add-node" +" ]" +" \"node6\" add-node[" " \" 0xf7fc4380| | |1\" =label" -" ];" -" \"node7\" [add-node" +" ]" +" \"node7\" add-node[" " \" 0xf7fc4380| | |2\" =label" -" ];" -" \"node8\" [add-node" +" ]" +" \"node8\" add-node[" " \" (nil)| | |-1\" =label" -" ];" -" \"node9\" [add-node" +" ]" +" \"node9\" add-node[" " \" (nil)| | |-1\" =label" -" ];" -" \"node10\" [add-node" +" ]" +" \"node10\" add-node[" " \" (nil)| | |-1\" =label" -" ];" -" \"node11\" [add-node" +" ]" +" \"node11\" add-node[" " \" (nil)| | |-1\" =label" -" ];" -" \"node12\" [add-node" +" ]" +" \"node12\" add-node[" " \" 0xf7fc43e0| | |1\" =label" -" ];" +" ]" "" -" \"node0\" \"node1\" [-> \"f0\" =tailport \"f0\" =headport ];" -" \"node0\" \"node2\" [-> \"f1\" =tailport \"f0\" =headport ];" -" \"node1\" \"node3\" [-> \"f0\" =tailport \"f0\" =headport ];" -" \"node1\" \"node4\" [-> \"f1\" =tailport \"f0\" =headport ];" -" \"node1\" \"node5\" [-> \"f2\" =tailport \"f0\" =headport ];" -" \"node4\" \"node3\" [-> \"f0\" =tailport \"f0\" =headport ];" -" \"node4\" \"node6\" [-> \"f1\" =tailport \"f0\" =headport ];" -" \"node4\" \"node10\" [-> \"f2\" =tailport \"f0\" =headport ];" -" \"node6\" \"node3\" [-> \"f0\" =tailport \"f0\" =headport ];" -" \"node6\" \"node7\" [-> \"f1\" =tailport \"f0\" =headport ];" -" \"node6\" \"node9\" [-> \"f2\" =tailport \"f0\" =headport ];" -" \"node7\" \"node3\" [-> \"f0\" =tailport \"f0\" =headport ];" -" \"node7\" \"node1\" [-> \"f1\" =tailport \"f0\" =headport ];" -" \"node7\" \"node8\" [-> \"f2\" =tailport \"f0\" =headport ];" -" \"node10\" \"node11\" [-> \"f1\" =tailport \"f0\" =headport ];" -" \"node10\" \"node12\" [-> \"f2\" =tailport \"f0\" =headport ];" -" \"node11\" \"node1\" [-> \"f2\" =tailport \"f0\" =headport ];" +" \"node0\" \"node1\" ->[ \"f0\" =tailport \"f0\" =headport ]" +" \"node0\" \"node2\" ->[ \"f1\" =tailport \"f0\" =headport ]" +" \"node1\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ]" +" \"node1\" \"node4\" ->[ \"f1\" =tailport \"f0\" =headport ]" +" \"node1\" \"node5\" ->[ \"f2\" =tailport \"f0\" =headport ]" +" \"node4\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ]" +" \"node4\" \"node6\" ->[ \"f1\" =tailport \"f0\" =headport ]" +" \"node4\" \"node10\" ->[ \"f2\" =tailport \"f0\" =headport ]" +" \"node6\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ]" +" \"node6\" \"node7\" ->[ \"f1\" =tailport \"f0\" =headport ]" +" \"node6\" \"node9\" ->[ \"f2\" =tailport \"f0\" =headport ]" +" \"node7\" \"node3\" ->[ \"f0\" =tailport \"f0\" =headport ]" +" \"node7\" \"node1\" ->[ \"f1\" =tailport \"f0\" =headport ]" +" \"node7\" \"node8\" ->[ \"f2\" =tailport \"f0\" =headport ]" +" \"node10\" \"node11\" ->[ \"f1\" =tailport \"f0\" =headport ]" +" \"node10\" \"node12\" ->[ \"f2\" =tailport \"f0\" =headport ]" +" \"node11\" \"node1\" ->[ \"f2\" =tailport \"f0\" =headport ]" "preview" } { $image "resource:extra/graphviz/gallery/record.png" } diff --git a/extra/graphviz/graphviz-tests.factor b/extra/graphviz/graphviz-tests.factor index b92938edee..6f22a70438 100644 --- a/extra/graphviz/graphviz-tests.factor +++ b/extra/graphviz/graphviz-tests.factor @@ -55,23 +55,23 @@ SYMBOLS: supported-layouts supported-formats ; : K_n ( n -- graph ) - [node "point" =shape ]; - [graph "t" =labelloc "circo" =layout ]; + node[ "point" =shape ] + graph[ "t" =labelloc "circo" =layout ] over number>string "K " prepend =label swap 2 [ first2 add-edge ] each-combination ; :: partite-set ( n color -- cluster ) color color =color - [node color =color ]; + node[ color =color ] n [ number>string color prepend add-node ] each ; :: K_n,m ( n m -- graph ) - [node "point" =shape ]; - [graph "t" =labelloc "dot" =layout "LR" =rankdir ]; + node[ "point" =shape ] + graph[ "t" =labelloc "dot" =layout "LR" =rankdir ] n "#FF0000" partite-set m "#0000FF" partite-set add-edge @@ -82,15 +82,15 @@ SYMBOLS: supported-layouts supported-formats ; : C_n ( n -- graph ) - [graph "t" =labelloc "circo" =layout ]; - [node "point" =shape ]; + graph[ "t" =labelloc "circo" =layout ] + node[ "point" =shape ] over number>string "C " prepend =label swap add-cycle ; : W_n ( n -- graph ) - [graph "t" =labelloc "twopi" =layout ]; - [node "point" =shape ]; + graph[ "t" =labelloc "twopi" =layout ] + node[ "point" =shape ] over number>string "W " prepend =label over add-node over 1 - add-cycle @@ -102,12 +102,12 @@ SYMBOLS: supported-layouts supported-formats ; 0 "filled" =style "lightgrey" =color - [node "filled" =style "white" =color ]; + node[ "filled" =style "white" =color ] { "a0" "a1" "a2" "a3" } ~-> "process #1" =label add 1 - [node "filled" =style ]; + node[ "filled" =style ] { "b0" "b1" "b2" "b3" } ~-> "process #2" =label "blue" =color @@ -119,8 +119,8 @@ SYMBOLS: supported-layouts supported-formats ; "a3" "a0" -> "a3" "end" -> "b3" "end" -> - "start" [add-node "Mdiamond" =shape ]; - "end" [add-node "Msquare" =shape ]; + "start" add-node[ "Mdiamond" =shape ] + "end" add-node[ "Msquare" =shape ] ; : colored-circle ( i -- node ) @@ -131,13 +131,13 @@ SYMBOLS: supported-layouts supported-formats ; : colored-circles-example ( -- graph ) - [graph "3,3" =size "circo" =layout ]; - [node "filled" =style + graph[ "3,3" =size "circo" =layout ] + node[ "filled" =style "circle" =shape "true" =fixedsize - "" =label ]; - [edge "invis" =style ]; - 0 [add-node "invis" =style "none" =shape ]; + "" =label ] + edge[ "invis" =style ] + 0 add-node[ "invis" =style "none" =shape ] 16 [ [ 0 -- ] [ colored-circle add ] bi ] each ; @@ -146,87 +146,87 @@ SYMBOLS: supported-layouts supported-formats ; "LR" =rankdir "8,5" =size - [node "doublecircle" =shape ]; + node[ "doublecircle" =shape ] { "LR_0" "LR_3" "LR_4" "LR_8" } add-nodes - [node "circle" =shape ]; - "LR_0" "LR_2" [-> "SS(B)" =label ]; - "LR_0" "LR_1" [-> "SS(S)" =label ]; - "LR_1" "LR_3" [-> "S($end)" =label ]; - "LR_2" "LR_6" [-> "SS(b)" =label ]; - "LR_2" "LR_5" [-> "SS(a)" =label ]; - "LR_2" "LR_4" [-> "S(A)" =label ]; - "LR_5" "LR_7" [-> "S(b)" =label ]; - "LR_5" "LR_5" [-> "S(a)" =label ]; - "LR_6" "LR_6" [-> "S(b)" =label ]; - "LR_6" "LR_5" [-> "S(a)" =label ]; - "LR_7" "LR_8" [-> "S(b)" =label ]; - "LR_7" "LR_5" [-> "S(a)" =label ]; - "LR_8" "LR_6" [-> "S(b)" =label ]; - "LR_8" "LR_5" [-> "S(a)" =label ]; + node[ "circle" =shape ] + "LR_0" "LR_2" ->[ "SS(B)" =label ] + "LR_0" "LR_1" ->[ "SS(S)" =label ] + "LR_1" "LR_3" ->[ "S($end)" =label ] + "LR_2" "LR_6" ->[ "SS(b)" =label ] + "LR_2" "LR_5" ->[ "SS(a)" =label ] + "LR_2" "LR_4" ->[ "S(A)" =label ] + "LR_5" "LR_7" ->[ "S(b)" =label ] + "LR_5" "LR_5" ->[ "S(a)" =label ] + "LR_6" "LR_6" ->[ "S(b)" =label ] + "LR_6" "LR_5" ->[ "S(a)" =label ] + "LR_7" "LR_8" ->[ "S(b)" =label ] + "LR_7" "LR_5" ->[ "S(a)" =label ] + "LR_8" "LR_6" ->[ "S(b)" =label ] + "LR_8" "LR_5" ->[ "S(a)" =label ] ; : record-example ( -- graph ) - [graph "LR" =rankdir "8,8" =size ]; - [node 8 =fontsize "record" =shape ]; + graph[ "LR" =rankdir "8,8" =size ] + node[ 8 =fontsize "record" =shape ] - "node0" [add-node + "node0" add-node[ " 0x10ba8| " =label - ]; - "node1" [add-node + ] + "node1" add-node[ " 0xf7fc4380| | |-1" =label - ]; - "node2" [add-node + ] + "node2" add-node[ " 0xf7fc44b8| | |2" =label - ]; - "node3" [add-node + ] + "node3" add-node[ " 3.43322790286038071e-06|44.79998779296875|0" =label - ]; - "node4" [add-node + ] + "node4" add-node[ " 0xf7fc4380| | |2" =label - ]; - "node5" [add-node + ] + "node5" add-node[ " (nil)| | |-1" =label - ]; - "node6" [add-node + ] + "node6" add-node[ " 0xf7fc4380| | |1" =label - ]; - "node7" [add-node + ] + "node7" add-node[ " 0xf7fc4380| | |2" =label - ]; - "node8" [add-node + ] + "node8" add-node[ " (nil)| | |-1" =label - ]; - "node9" [add-node + ] + "node9" add-node[ " (nil)| | |-1" =label - ]; - "node10" [add-node + ] + "node10" add-node[ " (nil)| | |-1" =label - ]; - "node11" [add-node + ] + "node11" add-node[ " (nil)| | |-1" =label - ]; - "node12" [add-node + ] + "node12" add-node[ " 0xf7fc43e0| | |1" =label - ]; + ] - "node0" "node1" [-> "f0" =tailport "f0" =headport ]; - "node0" "node2" [-> "f1" =tailport "f0" =headport ]; - "node1" "node3" [-> "f0" =tailport "f0" =headport ]; - "node1" "node4" [-> "f1" =tailport "f0" =headport ]; - "node1" "node5" [-> "f2" =tailport "f0" =headport ]; - "node4" "node3" [-> "f0" =tailport "f0" =headport ]; - "node4" "node6" [-> "f1" =tailport "f0" =headport ]; - "node4" "node10" [-> "f2" =tailport "f0" =headport ]; - "node6" "node3" [-> "f0" =tailport "f0" =headport ]; - "node6" "node7" [-> "f1" =tailport "f0" =headport ]; - "node6" "node9" [-> "f2" =tailport "f0" =headport ]; - "node7" "node3" [-> "f0" =tailport "f0" =headport ]; - "node7" "node1" [-> "f1" =tailport "f0" =headport ]; - "node7" "node8" [-> "f2" =tailport "f0" =headport ]; - "node10" "node11" [-> "f1" =tailport "f0" =headport ]; - "node10" "node12" [-> "f2" =tailport "f0" =headport ]; - "node11" "node1" [-> "f2" =tailport "f0" =headport ]; + "node0" "node1" ->[ "f0" =tailport "f0" =headport ] + "node0" "node2" ->[ "f1" =tailport "f0" =headport ] + "node1" "node3" ->[ "f0" =tailport "f0" =headport ] + "node1" "node4" ->[ "f1" =tailport "f0" =headport ] + "node1" "node5" ->[ "f2" =tailport "f0" =headport ] + "node4" "node3" ->[ "f0" =tailport "f0" =headport ] + "node4" "node6" ->[ "f1" =tailport "f0" =headport ] + "node4" "node10" ->[ "f2" =tailport "f0" =headport ] + "node6" "node3" ->[ "f0" =tailport "f0" =headport ] + "node6" "node7" ->[ "f1" =tailport "f0" =headport ] + "node6" "node9" ->[ "f2" =tailport "f0" =headport ] + "node7" "node3" ->[ "f0" =tailport "f0" =headport ] + "node7" "node1" ->[ "f1" =tailport "f0" =headport ] + "node7" "node8" ->[ "f2" =tailport "f0" =headport ] + "node10" "node11" ->[ "f1" =tailport "f0" =headport ] + "node10" "node12" ->[ "f2" =tailport "f0" =headport ] + "node11" "node1" ->[ "f2" =tailport "f0" =headport ] ; :: with-global-value ( value variable quot -- ) diff --git a/extra/graphviz/notation/notation-docs.factor b/extra/graphviz/notation/notation-docs.factor index a8a5bc47b0..6464447986 100644 --- a/extra/graphviz/notation/notation-docs.factor +++ b/extra/graphviz/notation/notation-docs.factor @@ -4,13 +4,13 @@ USING: graphviz graphviz.attributes help.markup help.syntax kernel present sequences ; IN: graphviz.notation -{ add-edge [add-edge -- ~-- [-- } related-words -{ add-edge [add-edge -> ~-> [-> } related-words +{ add-edge \ \add-edge[ \ \-- \ \~-- \ \--[ } related-words +{ add-edge \ \add-edge[ \ \-> \ \~-> \ \->[ } related-words { - [add-node [add-edge [-- [-> [node [edge [graph ]; + \ \add-node[ \ \add-edge[ \ \--[ \ \->[ \ \node[ \ \edge[ \ \graph[ } related-words -HELP: -- +HELP: \-- { $values { "graph" { $or graph subgraph } } { "tail" object } @@ -78,13 +78,13 @@ HELP: -> } ; -HELP: [-- +HELP: \--[ { $values { "tail" object } { "head" object } { "edge" edge } } -{ $description "Shorthand for " { $link } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that undirected " { $link graph } "s read more like graphs in the DOT language." } +{ $description "Shorthand for " { $link } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that undirected " { $link graph } "s read more like graphs in the DOT language." } { $examples "Instead of writing" { $code @@ -94,7 +94,7 @@ HELP: [-- "it looks better to write" { $code "" - " 1 2 [-- \"red\" =color ];" + " 1 2 --[ \"red\" =color ]" } "Compare this with the DOT language, where you'd write" { $code @@ -105,13 +105,13 @@ HELP: [-- } ; -HELP: [-> +HELP: \->[ { $values { "tail" object } { "head" object } { "edge" edge } } -{ $description "Shorthand for " { $link } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that directed " { $link graph } "s read more like digraphs in the DOT language." } +{ $description "Shorthand for " { $link } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that directed " { $link graph } "s read more like digraphs in the DOT language." } { $examples "Instead of writing" { $code @@ -121,7 +121,7 @@ HELP: [-> "it looks better to write" { $code "" - " 1 2 [-> \"red\" =color ];" + " 1 2 ->[ \"red\" =color ]" } "Compare this with the DOT language, where you'd write" { $code @@ -132,23 +132,13 @@ HELP: [-> } ; -HELP: ]; -{ $values - { "graph" { $or graph subgraph } } - { "statement" object } - { "graph'" { $or graph subgraph } } -} -{ $description "Synonym for " { $link add } " meant to be the \"other half\" of various " { $vocab-link "graphviz.notation" } " words like " { $links [add-edge [add-node [graph } ", etc." } -{ $examples "Refer to the documentation for the complementary words listed below." } -; - -HELP: [add-edge +HELP: \add-edge[ { $values { "tail" object } { "head" object } { "edge" edge } } -{ $description "Shorthand for " { $link } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that setting an " { $link edge } "'s " { $slot "attributes" } " reads more like the equivalent in the DOT language." } +{ $description "Shorthand for " { $link } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that setting an " { $link edge } "'s " { $slot "attributes" } " reads more like the equivalent in the DOT language." } { $examples "Instead of writing" { $code @@ -158,7 +148,7 @@ HELP: [add-edge "it looks better to write" { $code "" - " 1 2 [add-edge \"red\" =color ];" + " 1 2 add-edge[ \"red\" =color ]" } "Compare this with the DOT language, where you'd write" { $code @@ -167,16 +157,16 @@ HELP: [add-edge "}" } $nl - "This has the advantage over " { $link [-- } " and " { $link [-> } " of reading nicely for both directed " { $emphasis "and" } " undirected " { $link graph } "s." + "This has the advantage over " { $link \ --[ } " and " { $link \ ->[ } " of reading nicely for both directed " { $emphasis "and" } " undirected " { $link graph } "s." } ; -HELP: [add-node +HELP: \add-node[ { $values { "id" object } { "node" node } } -{ $description "Shorthand for " { $link } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that setting a " { $link node } "'s " { $slot "attributes" } " reads more like the equivalent in the DOT language." } +{ $description "Shorthand for " { $link } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that setting a " { $link node } "'s " { $slot "attributes" } " reads more like the equivalent in the DOT language." } { $examples "Instead of writing" { $code @@ -186,7 +176,7 @@ HELP: [add-node "it looks better to write" { $code "" - " \"foo\" [add-node \"red\" =color ];" + " \"foo\" add-node[ \"red\" =color ]" } "Compare this with the DOT language, where you'd write" { $code @@ -197,11 +187,11 @@ HELP: [add-node } ; -HELP: [edge +HELP: \edge[ { $values { "attrs" edge-attributes } } -{ $description "Shorthand for " { $link } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link edge-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } +{ $description "Shorthand for " { $link } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link edge-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } { $examples "Instead of writing" { $code @@ -211,22 +201,22 @@ HELP: [edge "it looks better to write" { $code "" - " [edge \"red\" =color ];" + " edge[ \"red\" =color ]" } "Compare this with the DOT language, where you'd write" { $code "graph {" - " [edge color=\"red\" ];" + " edge[ color=\"red\" ]" "}" } } ; -HELP: [graph +HELP: \graph[ { $values { "attrs" graph-attributes } } -{ $description "Shorthand for " { $link } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link graph-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } +{ $description "Shorthand for " { $link } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link graph-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } { $notes "This word is rendered redundant by the " { $link graph } " and " { $link subgraph } " methods defined by " { $vocab-link "graphviz.notation" } " for setting attributes. Sometimes it still might look better to delineate certain attribute-setting code." } { $examples "Instead of writing" @@ -237,12 +227,12 @@ HELP: [graph "it looks better to write" { $code "" - " [graph \"LR\" =rankdir \"blah\" =label ];" + " [graph \"LR\" =rankdir \"blah\" =label ]" } "Compare this with the DOT language, where you'd write" { $code "graph {" - " [graph rankdir=\"LR\" label=\"blah\" ];" + " [graph rankdir=\"LR\" label=\"blah\" ]" "}" } $nl @@ -262,11 +252,11 @@ HELP: [graph } ; -HELP: [node +HELP: \node[ { $values { "attrs" node-attributes } } -{ $description "Shorthand for " { $link } " to be used with " { $link ]; } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link node-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } +{ $description "Shorthand for " { $link } " to be used with " { $link \ ] } " and attribute-setting generic words (see " { $link { "graphviz.notation" "=attrs" } } ") so that adding " { $link node-attributes } " to a " { $link graph } " or " { $link subgraph } " reads more like the equivalent in the DOT language." } { $examples "Instead of writing" { $code @@ -276,12 +266,12 @@ HELP: [node "it looks better to write" { $code "" - " [node \"red\" =color ];" + " node[ \"red\" =color ]" } "Compare this with the DOT language, where you'd write" { $code "graph {" - " [node color=\"red\" ];" + " node[ color=\"red\" ]" "}" } } @@ -425,20 +415,16 @@ $nl } "Notation for nodes/edges with local attributes:" { $subsections - [add-node - [add-edge - [-- - [-> + \ \add-node[ + \ \add-edge[ + \ \--[ + \ \->[ } "Notation for global attributes:" { $subsections - [node - [edge - [graph -} -"Word to \"close off\" notation for attributes:" -{ $subsections - ]; + \ \node[ + \ \edge[ + \ \graph[ } ; diff --git a/extra/graphviz/notation/notation.factor b/extra/graphviz/notation/notation.factor index 53e2e56a57..84de8f890f 100644 --- a/extra/graphviz/notation/notation.factor +++ b/extra/graphviz/notation/notation.factor @@ -1,10 +1,8 @@ ! Copyright (C) 2011 Alex Vondrak. ! See http://factorcode.org/license.txt for BSD license. USING: accessors fry generic generic.parser generic.standard -kernel present quotations sequences slots words -graphviz -graphviz.attributes -; +graphviz graphviz.attributes kernel parser present quotations +sequences slots words ; IN: graphviz.notation << @@ -74,16 +72,14 @@ ALIAS: -- add-edge ALIAS: ~-> add-path ALIAS: ~-- add-path -ALIAS: [graph -ALIAS: [node -ALIAS: [edge +SYNTAX: \graph[ parse-quotation '[ @ add ] append! ; +SYNTAX: \node[ parse-quotation '[ @ add ] append! ; +SYNTAX: \edge[ parse-quotation '[ @ add ] append! ; -ALIAS: [add-node -ALIAS: [add-edge -ALIAS: [-> -ALIAS: [-- - -ALIAS: ]; add +SYNTAX: \add-node[ parse-quotation '[ @ add ] append! ; +SYNTAX: \add-edge[ parse-quotation '[ @ add ] append! ; +SYNTAX: \->[ parse-quotation '[ @ add ] append! ; +SYNTAX: \--[ parse-quotation '[ @ add ] append! ; ! Can't really do add-path[ & add-nodes[ this way, since they ! involve multiple objects.