-
-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Not seeing any references to an actual docopt formal grammar yet, I am writing a PEG grammar for use in Python with Tatsu (https://tatsu.readthedocs.io). I am hopeful that it will be usable with other PEG parser generators but am not well enough versed in the area to know by how much they differ in syntax.
I would like to work with others interested in developing a formal grammar for docopt. I'm not fixed on Tatsu or even PEG though I suspect PEG grammars will provide more accurate results for the corner cases.
I appended a sketch of the steps I believe necessary to develop the grammar. I've written a grammar for the usage examples section. Now I need to take a step back and write the frame work to snag each major section. Divide and conquer seemed like the best approach. In a day or so, I could post the grammar and test cases to github.
So, any information in this area or would anyone like to collaborate ?
Philip
Unix Utility Usage Grammar
Or, a formal grammar for the docopy language.
First identify which elements must be parsed and which (if any) may be discarded (or perhaps remain free form text).
Characterize the delineations of each section sufficiently to write regular expression matchers for their start and end, or span.
Write a grammar to parse to just the sections out as blocks of free form text. This forms the framework within which the section parsers will operate.
For each section independently write a grammar to parse the it.
One by one, incorporate the section parsers into the framework.