An open API service indexing awesome lists of open source software.

https://github.com/scymtym/language.graphviz

Parser and unparser for the GraphViz dot language
https://github.com/scymtym/language.graphviz

graphviz parser

Last synced: 5 months ago
JSON representation

Parser and unparser for the GraphViz dot language

Awesome Lists containing this project

README

          

#+TITLE: language.graphviz README
#+AUTHOR: Jan Moringen
#+EMAIL: jmoringe@techfak.uni-bielefeld.de
#+DESCRIPTION:
#+KEYWORDS: parser, graphviz, dot, esrap
#+LANGUAGE: en

#+OPTIONS: toc:nil num:nil
#+SEQ_TODO: TODO STARTED | DONE

* STARTED Introduction

This library provides functionality for parsing and unparsing the
GraphViz dot language into/from abstract syntax trees.

* STARTED Tutorial

** STARTED Parsing

The ~parser~ module of this library provides functionality for
parsing the text based GraphViz dot language into abstract syntax
trees. The module is contained in the ~language.graphviz.parser~
package. Example:

#+BEGIN_SRC lisp :exports both :results value verbatim
(language.graphviz.parser:parse 'list "digraph { a[b=c]; a->d; }")
#+END_SRC

#+RESULTS:
#+BEGIN_SRC lisp
(:GRAPH
(:STATEMENT
(((:NODE
(:ID (((:NODE-ID NIL :ID "a" :BOUNDS (10 . 11)))) :ATTRIBUTE
(((:ATTRIBUTE NIL :NAME "b" :VALUE "c" :BOUNDS (12 . 15)))))
:BOUNDS (10 . 17)))
((:EDGE
(:FROM (((:NODE-ID NIL :ID "a" :BOUNDS (18 . 19)))) :TO
(((:NODE-ID NIL :ID "d" :BOUNDS (21 . 22)))))
:KIND :DIRECTED))))
:ID NIL :KIND (NIL LANGUAGE.GRAPHVIZ.PARSER::DIGRAPH) :BOUNDS (0 . 25))
NIL
T
#+END_SRC

** STARTED Unparsing

The ~unparser~ module of this library provides functionality for
unparsing abstract syntax trees into the text based GraphViz dot
language. The module is contained in the
~language.graphviz.unparser~ package. Example:

#+BEGIN_SRC lisp :exports both :results output verbatim
(let ((ast (architecture.builder-protocol:with-builder ('list)
(architecture.builder-protocol:node* (:graph :kind '(nil :digraph))
(1 :statement (architecture.builder-protocol:node* (:node)
(1 :id (architecture.builder-protocol:node* (:node-id :id "a")))
(1 :attribute (architecture.builder-protocol:node* (:attribute :name "b" :value "c")))))
(1 :statement (architecture.builder-protocol:node* (:edge :kind :directed)
(1 :from (architecture.builder-protocol:node* (:node-id :id "a")))
(1 :to (architecture.builder-protocol:node* (:node-id :id "c")))))))))
(pprint-logical-block (*standard-output* nil)
(language.graphviz.unparser:serialize 'list ast *standard-output*)))
#+END_SRC

#+RESULTS:
#+BEGIN_SRC dot
digraph {
a [b = "c"];
a -> c;

}
#+END_SRC

* TODO Reference