-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a grammar for the Plan language #18
Comments
As for python solutions with PEG, the documentation for https://github.com/erikrose/parsimonious looks good. |
More banging on PEG.js reveals a pretty powerful parser for these cases:
Here's the sample it parses:
and the resulting output:
Also, error messages are somewhat automatic. For example, leaving off the 3rd date for the H1 line (it requires 3 dates), I get the following error message:
|
Good reference for PEG is the research paper : http://www.brynosaurus.com/pub/lang/peg.pdf |
It would be useful to define a simple grammar for the plan language. Documenting the language would be easier and changes can be more easily coded.
Have a look at the PEG.js online tester for an example of a simple grammar parser. There is something for Python, but I'm not sure how easily it can be used. Perhaps start with a PEG.js version and convert? Whatever the way, this kind of parsing is more robust and easier to modify I think.
I hacked up the following on http://pegjs.org/online:
which parses these examples:
The text was updated successfully, but these errors were encountered: