Gazelle Grammar Visualization
Posted by josh at April 10th, 2008
I’ve been quiet about Gazelle news lately, but since I wrote last I’ve hit 3 of my 6 goals for Gazelle 0.2, and one that I hadn’t thought to include. To review those goals and see which ones I’ve completed:
complete Strong-LL(k) lookahead support.(it’s not 100% complete yet, but it’s definitely solid enough for a 0.2 release)a command-line compiler program (gzlc) that takes reasonable options and is simple enough to use by reading its –help- a “tour” section for the manual
- a command-line program (gzlparse) that can output the parse tree in a useful format, so you can see how Gazelle parses your input text.
a test suite, so that when people report bugs I can add the bugs to the test suite and not regress.- (stretch): make Gazelle self-hosting, so that the parser is more robust and easier to understand than the hand-written recursive descent parser I’m currently using. I don’t want people to have to deal with corner-case parser bugs.
a way to visualize grammars, to spot-check them against your expectations
It’s the grammar visualization that I forgot to include. I mentioned parse tree visualization a few blog posts ago, but this is different — one is visualizing how a bunch of text got parsed, the other is visualizing the grammar itself.
It still has room for improvement, but here is what my grammar visualization currently looks like for JSON. You can see an NFA for each one of your rules, a DFA for each state of lookahead, and the DFAs that do the lexing.
The latest code from Git (note that I recently moved from repo.or.cz to Github) can generate these grammar dumps — just pass ‘-d’ to gzlc.
Keep on the good works!
I’ve read your “Gazelle” blog and the Gazelle manual, and amen!
I was sick of language in the style of ANT/MAVEN pseudo-language XML-Hell.
For doing some language transformation and some DSL (in my day job), I was looking into parsing.
I’ve looked into ANTLR (pragmatic book) but something didn’t fit: the embedding of action into the grammar file (I have to redo the grammar file if I want to generate in another language ? WTF)
The other solution I found is doing the grammar inside the language like Parsec from the Haskell World, no more beautiful (very common for DSL in the Lisp world too).
I found about GOLD in your blog, look good, but since it is a Windows-only thing…
So basically no tools fit my need, maybe Gazelle at version 1.0
Question:
Have you any rational for your grammar syntax ? Instead of using BNF/EBNF of SDF ?
I will look into your release 0.2,
Thanks for the good work.
(note: I can’t get the formating of my comment correct…?)
Pascal