Parser combinator that can generate grammar description?

I've been looking at the parser combinator crates, and have realized that there is one feature I'd like which the widely used parser combinator crates done seem to support. The feature is to be able to generate a human-friendly description of the grammar. My current suspicion is that I'll have to write a combinator library of my own, but thought I'd ask here in case such a thing already exists.

The goal is to create a voice control (and voice programming) tool. So the parser is for relatively simple spoken phrases. This the fancy error reporting implemented in the crates isn't helpful like it would be if you're parsing a malformed text file. However, as the set of recognized commands gets long (and might be dynamically generated) it would be great to be able to present to the user a crib sheet that shows all the commands that they could say, with appropriate help messages.

My current thinking is that something like the impl Trait approach of combine could work well to define a data structure that can serve both needs. Any other ideas?

1 Like