I was playing recently with parsers and I wanted to have a clear way of displaying railroad diagrams for the Python Grammar to make a quick comparison of DFAs and NDFAs (maybe even before and after some simplification steps). Because everything is already invented, I found this webpage that allows you to upload some grammar in W3C’s EBN notation and it generates nice interactive diagrams. I have adapted the Python Grammar to this notation and you can visualize the grammar very quickly:
- Go to https://www.bottlecaps.de/rr/ui
- Click the “Edit Grammar” tab.
- Paste the contents of this gist:
- Click the “View Diagram” tab.
Some cool examples: