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
- Host: GitHub
- URL: https://github.com/scymtym/language.graphviz
- Owner: scymtym
- License: lgpl-3.0
- Created: 2021-05-28T10:47:46.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-14T13:34:21.000Z (about 5 years ago)
- Last Synced: 2025-08-17T10:36:57.461Z (10 months ago)
- Topics: graphviz, parser
- Language: Common Lisp
- Homepage:
- Size: 25.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: COPYING
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