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).

  • 3
    Some warning on the bright yellow would be nice... My eyes hurt... – yannis Jan 23 '12 at 3:23
  • 1
    @YannisRizos Just be happy there aren't flashing rainbow GIFs. – user7007 Jan 23 '12 at 3:25
  • 1
    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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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