This demo was created as part of my article Conditional preservation of whitespace when parsing with Marpa::R2.
More-or-less all the coding effort has gone into the problem of handling the various quoting rules (below).
I'm currently (2014-10-10) using Marpa::R2 V 2.096.
Almost all the scripts, input files and output files required to generate these examples are shipped in the MarpaX::Demo::StringParser distro.
The missing script uses Graph::Easy::Marpa::Renderer::GraphViz2 V 2.00 (unreleased), and is omitted to simplify the pre-reqs list. It can be downloaded from here.
Herewith a brief summary of the syntax.
This syntax is a cut-down version of Graphviz's DOT language.
Some sample data might not be acceptable to Graphviz.
If it is, there will be an image on the right-hand-side.
Element | Syntax |
---|---|
Edge names | Either '->' or '--'. |
Node names |
1: Delimited by '[' and ']'. 2: May be quoted with " or '. 3: Escaped characters, using '\', are allowed. 4: Internal spaces in node names are preserved even if not quoted. |
Both edges and nodes can have attributes. | |
Attributes |
1: Delimited by '{' and '}'. 2: Within that, any number of "key : value" pairs separated by ';'. 3: Values may be quoted with " or ' or '<...>' or '<<table>...</table>>'. 4: Escaped characters, using '\', are allowed. 5: Internal spaces in attribute values are preserved even if not quoted. |
Input file # 1 - data/edge.01.dash: |
# Edge with attributes. OK. Output file # 1 - html/edge.01.svg |
Input file # 2 - data/edge.02.dash: |
# Juxtaposed edges (without comma) with attributes. OK. Output file # 2 - html/edge.02.svg |
Input file # 3 - data/edge.03.dash: |
# Edge followed by node. OK. Output file # 3 - html/edge.03.svg |
Input file # 4 - data/edge.04.dash: |
# Edges with fancy arrows. OK. Output file # 4 - html/edge.04.svg |
Input file # 5 - data/edge.05.dash: |
# Edge with attributes. OK. Output file # 5 - html/edge.05.svg |
Input file # 6 - data/edge.06.dash: |
# Juxtaposed edges (without any spacing) without attributes. OK. Output file # 6 - html/edge.06.svg |
Input file # 7 - data/graph.01.dash: |
# Ends with edge without attributes. OK. Output file # 7 - html/graph.01.svg |
Input file # 8 - data/graph.02.dash: |
# Juxtapositioned edges (without comma). OK. Output file # 8 - html/graph.02.svg |
Input file # 9 - data/graph.03.dash: |
# Juxtapositioned edges (with and without commas). OK. Output file # 9 - html/graph.03.svg |
Input file # 10 - data/graph.04.dash: |
# Juxtapositioned edges (-> -> twice). OK. Output file # 10 - html/graph.04.svg |
Input file # 11 - data/node.01.dash: |
# Anonymous node. OK. Output file # 11 - html/node.01.svg |
Input file # 12 - data/node.02.dash: |
# Named node with space. OK. Output file # 12 - html/node.02.svg |
Input file # 13 - data/node.03.dash: |
# Anonymous node with attributes. OK. Output file # 13 - html/node.03.svg |
Input file # 14 - data/node.04.dash: |
# Juxtaposed nodes (without comma) with attributes. OK. Output file # 14 - html/node.04.svg |
Input file # 15 - data/node.05.dash: |
# Named node, with spaces. OK. Output file # 15 - html/node.05.svg |
Input file # 16 - data/node.06.dash: |
# Named node with attributes, with spaces. OK. Output file # 16 - html/node.06.svg |
Input file # 17 - data/node.07.dash: |
# Named node with attributes, with spaces. OK. Output file # 17 - html/node.07.svg |
Input file # 18 - data/node.08.dash: |
# Complete graph. OK. Output file # 18 - html/node.08.svg |
Input file # 19 - data/node.09.dash: |
# Named node with escape chars. OK. Output file # 19 - html/node.09.svg |
Input file # 20 - data/node.10.dash: |
# Named node with [] in name. OK. Output file # 20 - html/node.10.svg |
Input file # 21 - data/node.11.dash: |
# Named node with escape chars. OK. Output file # 21 - html/node.11.svg |
Input file # 22 - data/quote.01.dash: |
# Named node with ; in label. OK. Output file # 22 - html/quote.01.svg |
Input file # 23 - data/quote.02.dash: |
# Named node with ; in label. OK. Output file # 23 - html/quote.02.svg |
Input file # 24 - data/quote.03.dash: |
# Named node with ; in label. OK. Output file # 24 - html/quote.03.svg |
Input file # 25 - data/quote.04.dash: |
# Named node with ; in label. OK. Output file # 25 - html/quote.04.svg |
Input file # 26 - data/quote.05.dash: |
# Named node with ; in label. OK. Output file # 26 - html/quote.05.svg |
Input file # 27 - data/quote.06.dash: |
# Named node with " in label. OK. Output file # 27 - html/quote.06.svg |
Input file # 28 - data/quote.07.dash: |
# Named node with " in label. OK. Output file # 28 - html/quote.07.svg |
Input file # 29 - data/quote.08.dash: |
# Named node with " in label. OK. Output file # 29 - html/quote.08.svg |
Input file # 30 - data/quote.09.dash: |
# Named node with " in label. OK. Output file # 30 - html/quote.09.svg |
Input file # 31 - data/quote.10.dash: |
# Named node with ' in label. OK. Output file # 31 - html/quote.10.svg |
Input file # 32 - data/quote.11.dash: |
# Named node with ' in label. OK. Output file # 32 - html/quote.11.svg |
Input file # 33 - data/quote.12.dash: |
# Named node with ' in label. OK. Output file # 33 - html/quote.12.svg |
Input file # 34 - data/quote.13.dash: |
# Named node with ' in label. OK. Output file # 34 - html/quote.13.svg |
Input file # 35 - data/quote.14.dash: |
# Named node with } in label. OK. Output file # 35 - html/quote.14.svg |
Input file # 36 - data/quote.15.dash: |
# Named node with } in label. OK. Output file # 36 - html/quote.15.svg |
Input file # 37 - data/quote.16.dash: |
# Named node with } in label. OK. Output file # 37 - html/quote.16.svg |
Input file # 38 - data/quote.17.dash: |
# Named node with } in label. OK. Output file # 38 - html/quote.17.svg |
Input file # 39 - data/quote.18.dash: |
# Named node with } in label. OK. Output file # 39 - html/quote.18.svg |
Input file # 40 - data/quote.19.dash: |
# Named node with < in label. OK. Output file # 40 - html/quote.19.svg |
Input file # 41 - data/quote.20.dash: |
# Named node with > in label. OK. Output file # 41 - html/quote.20.svg |
Input file # 42 - data/quote.21.dash: |
# Named node with << in label. OK. Output file # 42 - html/quote.21.svg |
Input file # 43 - data/quote.22.dash: |
# Named node with >> in label. OK. Output file # 43 - html/quote.22.svg |
Input file # 44 - data/table.01.dash: |
# Node with HTML-style and ' in label. OK. Output file # 44 - html/table.01.svg |
Input file # 45 - data/table.02.dash: |
# Node with HTML-style and " in label. OK. Output file # 45 - html/table.02.svg |
Input file # 46 - data/table.03.dash: |
# Node with HTML-style and " and ' in label. OK. Output file # 46 - html/table.03.svg |
Input file # 47 - data/table.04.dash: |
# Node with HTML-style and ' and " in label. OK. Output file # 47 - html/table.04.svg |
Input file # 48 - data/table.05.dash: |
# Node with HTML-style and ' label. OK. Output file # 48 - html/table.05.svg |
Input file # 49 - data/table.06.dash: |
# Node with HTML-style and " label. OK. Output file # 49 - html/table.06.svg |
Input file # 50 - data/table.07.dash: |
# Node with HTML-style entities in label. OK. Output file # 50 - html/table.07.svg |
Input file # 51 - data/utf8.01.dash: |
# Graph with utf8 attributes. OK. Output file # 51 - html/utf8.01.svg |
Author
|
|
Date
|
2014-10-10
|
OS
|
Debian V 7.6
|
Perl
|
5.18.2
|