graphviz: add an extra - to all graphviz shorthand to avoid conflicting with --.

Maybe we should rethink the graphviz syntax.
locals-and-roots
Doug Coleman 2016-06-23 23:34:16 -07:00
parent 7db66ff8fe
commit 1f53ae307b
3 changed files with 81 additions and 75 deletions

View File

@ -103,22 +103,22 @@ SYMBOLS: supported-layouts supported-formats ;
"filled" =style
"lightgrey" =color
node[ "filled" =style "white" =color ]
{ "a0" "a1" "a2" "a3" } ~->
{ "a0" "a1" "a2" "a3" } ~-->
"process #1" =label
add
1 <cluster>
node[ "filled" =style ]
{ "b0" "b1" "b2" "b3" } ~->
{ "b0" "b1" "b2" "b3" } ~-->
"process #2" =label
"blue" =color
add
"start" "a0" ->
"start" "b0" ->
"a1" "b3" ->
"b2" "a3" ->
"a3" "a0" ->
"a3" "end" ->
"b3" "end" ->
"start" "a0" -->
"start" "b0" -->
"a1" "b3" -->
"b2" "a3" -->
"a3" "a0" -->
"a3" "end" -->
"b3" "end" -->
"start" add-node[ "Mdiamond" =shape ]
"end" add-node[ "Msquare" =shape ]
;
@ -139,7 +139,7 @@ SYMBOLS: supported-layouts supported-formats ;
edge[ "invis" =style ]
0 add-node[ "invis" =style "none" =shape ]
16 iota [
[ 0 -- ] [ colored-circle add ] bi
[ 0 --- ] [ colored-circle add ] bi
] each ;
: dfa-example ( -- graph )
@ -149,20 +149,20 @@ SYMBOLS: supported-layouts supported-formats ;
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 ]
"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 )
@ -210,23 +210,23 @@ SYMBOLS: supported-layouts supported-formats ;
"<f0> 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 -- )

View File

@ -4,13 +4,19 @@ 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 }
@ -29,9 +35,9 @@ HELP: --
"it looks better to write"
{ $code
"<graph>"
" 1 2 --"
" 3 4 --"
" 5 6 --"
" 1 2 ---"
" 3 4 ---"
" 5 6 ---"
}
"Compare this with the DOT language, where you'd write"
{ $code
@ -44,7 +50,7 @@ HELP: --
}
;
HELP: ->
HELP: -->
{ $values
{ "graph" { $or graph subgraph } }
{ "tail" object }
@ -63,9 +69,9 @@ HELP: ->
"it looks better to write"
{ $code
"<digraph>"
" 1 2 ->"
" 3 4 ->"
" 5 6 ->"
" 1 2 -->"
" 3 4 -->"
" 5 6 -->"
}
"Compare this with the DOT language, where you'd write"
{ $code
@ -78,7 +84,7 @@ HELP: ->
}
;
HELP: --[
HELP: ---[
{ $values
{ "tail" object }
{ "head" object }
@ -94,7 +100,7 @@ HELP: --[
"it looks better to write"
{ $code
"<graph>"
" 1 2 --[ \"red\" =color ]"
" 1 2 ---[ \"red\" =color ]"
}
"Compare this with the DOT language, where you'd write"
{ $code
@ -105,7 +111,7 @@ HELP: --[
}
;
HELP: ->[
HELP: -->[
{ $values
{ "tail" object }
{ "head" object }
@ -157,7 +163,7 @@ 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."
}
;
@ -277,7 +283,7 @@ HELP: node[
}
;
HELP: ~--
HELP: ~---
{ $values
{ "graph" { $or graph subgraph } }
{ "nodes" sequence }
@ -288,9 +294,9 @@ HELP: ~--
"Instead of writing"
{ $code
"<graph>"
" 1 2 --"
" 2 3 --"
" 3 4 --"
" 1 2 ---"
" 2 3 ---"
" 3 4 ---"
}
"you can write"
{ $code
@ -300,13 +306,13 @@ HELP: ~--
"whereas in the DOT language you'd write"
{ $code
"graph {"
" 1 -- 2 -- 3 -- 4"
" 1 --- 2 --- 3 --- 4"
"}"
}
}
;
HELP: ~->
HELP: ~-->
{ $values
{ "graph" { $or graph subgraph } }
{ "nodes" sequence }
@ -324,7 +330,7 @@ HELP: ~->
"you can write"
{ $code
"<digraph>"
" { 1 2 3 4 } ~->"
" { 1 2 3 4 } ~-->"
}
"whereas in the DOT language you'd write"
{ $code
@ -408,17 +414,17 @@ ARTICLE: { "graphviz.notation" "synonyms" } "Aliases that resemble DOT code"
$nl
"Notation for edges without attributes:"
{ $subsections
\ --
\ ->
\ ~--
\ ~->
\ ---
\ -->
\ ~---
\ ~-->
}
"Notation for nodes/edges with local attributes:"
{ $subsections
\ add-node[
\ add-edge[
\ --[
\ ->[
\ ---[
\ -->[
}
"Notation for global attributes:"
{ $subsections

View File

@ -67,10 +67,10 @@ node node-attributes define-=attrs
COMPILE>
ALIAS: -> add-edge ;
ALIAS: -- add-edge ;
ALIAS: ~-> add-path ;
ALIAS: ~-- add-path ;
ALIAS: --> add-edge ;
ALIAS: --- add-edge ;
ALIAS: ~--> add-path ;
ALIAS: ~--- add-path ;
SYNTAX: \ graph[ parse-quotation '[ <graph-attributes> @ add ] append! ;
SYNTAX: \ node[ parse-quotation '[ <node-attributes> @ add ] append! ;
@ -78,8 +78,8 @@ SYNTAX: \ edge[ parse-quotation '[ <edge-attributes> @ add ] append! ;
SYNTAX: \ add-node[ parse-quotation '[ <node> @ add ] append! ;
SYNTAX: \ add-edge[ parse-quotation '[ <edge> @ add ] append! ;
SYNTAX: \ ->[ parse-quotation '[ <edge> @ add ] append! ;
SYNTAX: \ --[ parse-quotation '[ <edge> @ add ] append! ;
SYNTAX: \ -->[ parse-quotation '[ <edge> @ add ] append! ;
SYNTAX: \ ---[ parse-quotation '[ <edge> @ add ] append! ;
! FIXME:
! Can't really do add-path[ & add-nodes[ this way, since they