Skip to content

Commit

Permalink
Use mrlib/graph to find dot for FSM visualization.
Browse files Browse the repository at this point in the history
  • Loading branch information
emina committed May 9, 2017
1 parent 9b811d6 commit 600425a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sdsl/fsm/viz.rkt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#lang racket

(require racket/draw)
(require racket/draw (only-in mrlib/graph find-dot))

(provide automaton->bitmap automaton->dot)

(define (automaton->bitmap a)
(define-values (p p-out p-in p-err)
(subprocess #f #f #f (find-executable-path "dot") "-Tjpeg"))
(automaton->dot a p-in)
(close-output-port p-in)
(read-bitmap p-out 'jpeg))
(match (find-dot)
[#f a]
[dot
(define-values (p p-out p-in p-err)
(subprocess #f #f #f dot "-Tjpeg"))
(automaton->dot a p-in)
(close-output-port p-in)
(read-bitmap p-out 'jpeg)]))

(define (automaton->dot a [port (current-output-port)])
(fprintf port "digraph fsm {\n")
Expand Down

0 comments on commit 600425a

Please sign in to comment.