3 ms·
I think it's important to write your own parser, at some point. Though, for the purpose of learning you need someone to guide you. If you're learning this stuf
by john567 5y ago
I think it's important to write your own parser, at some point. Though, for the purpose of learning you need someone to guide you.
If you're learning this stuff you need a simple challenge to work through the end.
With regards to lex and yacc, I absolut detest these tools. They are horrible but they do work. And if you just want a functioning parser they'll do. My main criticism of these tools are the horrible errors you might end up with and the lack of sensible extension points.
If it is your first foray into parsers, I do think a simple grammar and handwritten lexer/parser is a good first step. Iterate some on that, then use tools to help with the verbose stuff.
Though to be honest, I enjoy writing parsers by hand. So, I'm a bit biased.
- jjice 5y agoSo we did build the DDL handwritten and did well on that portion of the product, but given the constraint of me being the only person to write the parser for the DML, along with having to be done and error free in three weeks where I was also occupied, all while being written in C, I felt yacc really helped a lot there. The big thing for this particular project was all the pitfalls of C with having to track memory allocations and passing arrays of pointers around and mentally keeping track. Yacc streamlined this a lot. If this was a production project and not a class I took along side four other, hand writing would be a serious option I'd consider (mostly for error reporting purposes like you mentioned), but I might even lean towards getting an MVP done in a parser generator and eventually converting over to handwritten if the need arose.
- mbrodersen 5y agoI agree. Lex/yacc is on my “worst software I have ever used” list. Especially given how easy it is to write parsers.