bambinos / formulae

Formulas for mixed-effects models in Python

Home Page:https://bambinos.github.io/formulae/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parser generators

brandonwillard opened this issue · comments

It looks like you're doing a lot of low-level parser generator work by hand. Have you considered using an existing pure Python parser package like rply? We've had a lot of success with that package in hy.

Brandon,

Thank you for pointing to these two libraries, I wasn't aware of them when I started with this project.

However, the fact that I'm doing a lot of low-level parser work by hand is because I'm a beginner on this topic and the book I used as inspiration taught how to do everything by hand. I know this is not the most efficient approach at all, but it also served me to learn. Also, I think that what I've done so far is close to a final version of the parsing capabilities I need (I'm planning to add one more operator and that's it).

After you wrote this issue I've updated the Features.ipynb notebook. Maybe that is useful to clarify what this small library can do so far.

Thank you!!

Yes, as a learning experience, creating your own parser, lexer, etc., can be very worthwhile.

If you have a good high-level understanding of the grammar/language you're implementing, and know what sort of properties it has—and, thus, the features your parser, lexer, etc., will need—then writing your own implementations should be straightforward.

If not, parser generator libraries like these can help clarify the grammar/language being implemented by forcing some structure. Plus, they often have errors and checks that prevent and/or anticipate unintended inconsistencies, the kind that can prevent a lot of difficult debugging work down the line.