Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am implementing a grammar in CUP, and it would often be helpful to see everything at a glance. This could also be useful in finding errors quickly.

Are there any programs out there that will visualize grammar in the CUP syntax? Or can you think of a very easy way of doing it (for instance, convert the grammar to another format that program X can read).

share|improve this question
Some warning on the bright yellow would be nice... My eyes hurt... – Yannis Jan 23 '12 at 3:23
@YannisRizos Just be happy there aren't flashing rainbow GIFs. – Glenn Nelson Jan 23 '12 at 3:25
ANTLR has excellent visualisation, at least of parse trees. (I don't recall if you can visualise the grammar itself). I've never heard of CUP, so I don't know if there's some reason to prefer it, or indeed if the two are interchangeable. – Steve Bennett Jan 24 '12 at 21:33
last updated 2009? – Paul Jun 19 '12 at 19:40

You might need to convert it to another format first.

You could generate a graph of the grammar by using a combination of ANTLRWorks and GraphViz.

Someone did something similar here to generate graphs for the Ruby, JavaScript, and Java 1.5 grammars.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.