Thursday, June 30, 2011

Visualizing parsers

Parcon 0.1.22 is out, with a really cool new feature: parser visualization. Parcon now includes the ability to generate graphs from parsers that describe what those parsers do.

There are still some kinks to be worked out, and I'll save a detailed blog post on Parcon graphing for when those are fixed, but the basic thing works. For example, the expression evaluator Parcon example (which is present on the PyPI page for Parcon), when converted to a graph via this:
term.graph().draw("test-graph2.png")

results in this (click on the image to view a larger version):



In order for graphing to work, you have to have Graphviz installed, and specifically you need to have the dot program installed. You do not, however, need this installed to use Parcon, and in fact, you don't even need it to call graph(); you just need it when you actually call draw().

You'll probably notice some of the kinks. Two of the major ones are that InfixExpr doesn't display any representation of the functions it was passed, and the child parsers for Then and First are displayed out of order. Once I get those, and a few others, solved, I'll write a more detailed post on visualizing parsers with Parcon.

But you've got to admit, even as it is it's pretty cool.

3 comments:

  1. The site is down ATM. http://www.isup.me/http://www.opengroove.org/

    ReplyDelete
  2. Thanks for letting me know. It turned out it was due to a circuit breaker tripping. (I wrote a post a few hours ago on the blog explaining it.) It's back up now, though, thank goodness.

    ReplyDelete
  3. The Poker Room at the Wynn | Mapyro
    목포 출장마사지 pin › poker › pin › poker Poker Room at the Wynn 동해 출장안마 · Encore 나주 출장샵 Lobby · Poker Room · Table Games · Poker Room. The Wynn 당진 출장샵 poker room features some of the biggest poker 양산 출장안마 tournaments around.

    ReplyDelete