Graphviz::DOT::Grammar

Grammar for parsing DOT language specs and converting them to specs of Mermaid-JS, PlantUML, or Wolfram Language.

Graphviz::DOT::Grammar

Raku package with a parser and interpreters of Graphviz DOT language.

Languages and formats DOT is translated to:

  • DONE DOT layout formats

    • SVG, EPS, JSON, plain, etc.

  • DONE PlantUML

    • PlantUML uses DOT language, so it was very short and easy format implementation.

  • DONE Mermaid-JS

  • [-] TODO Mathematica

    • DONE Basic vertexes and edges

    • TODO Vertex styles

    • TODO Edge styles

  • TODO Raku

    • Translation to Raku graphs, [AAp1]

    • Based on the Mathematica actions

Usage examples

Here is a graph (see [AAp1]):

use Graph::HexagonalGrid;

my $g = Graph::HexagonalGrid.new(1, 1);
# Graph(vertexes => 6, edges => 6, directed => False)

Translate to Mermaid-JS:

use Graphviz::DOT::Grammar;
$g.dot ==> dot-interpret(a=>'mermaid')

Translate to Mathematica:

$g.dot ==> dot-interpret(a=>'Mathematica')
Graph[{}, {UndirectedEdge["3", "5"], UndirectedEdge["4", "5"], UndirectedEdge["0", "2"], UndirectedEdge["2", "4"], UndirectedEdge["1", "3"], UndirectedEdge["0", "1"]}]

CLI

The package provides the Command Line Interface (CLI) script from-dot. Here is its usage message:

from-dot --help
# Usage:
#   from-dot <text> [-t|--to=<Str>] [-o|--output=<Str>] -- Converts Graphviz DOT language texts or files into Mermaid-JS, Mathematica, Markdown, JSON, Raku, or SVG files.
#   
#     <text>               Input file or DOT spec.
#     -t|--to=<Str>        Format to convert to. (One of 'json', 'mathematica', 'mermaid', 'raku', 'svg', or 'Whatever'.) [default: 'Whatever']
#     -o|--output=<Str>    Output file; if an empty string then the result is printed to stdout. [default: '']

References

[AAp1] Anton Antonov, Graph Raku package, (2024), GitHub/antononcube.

Graphviz::DOT::Grammar v0.1.1

Grammar for parsing DOT language specs and converting them to specs of Mermaid-JS, PlantUML, or Wolfram Language.

Authors

  • Anton Antonov

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Graphviz::DOT::Actions::Common
  • Graphviz::DOT::Actions::Layout
  • Graphviz::DOT::Actions::Mathematica
  • Graphviz::DOT::Actions::MermaidJS
  • Graphviz::DOT::Actions::PlantUML
  • Graphviz::DOT::Actions::Raku
  • Graphviz::DOT::Grammar
  • Graphviz::DOT::Grammarish

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.