4 ms·
Ask HN: Best approach to designing a parser / creating your programming language
I've been writing a parser in Haskell Parsec to parse a subset of Haskell;
I didnt stick to anything like BNF and it turns out to be much more daunting task than expected.
When designing a parser for a (subset of) known language (or creating your own programming language), are things like BNF fundemental to a good design? What toolkits or frameworks can be employed in the planning process?
Any tips or approaches (or readings) on the best way to strike a balance between theoretical formalization v.s. implementing something that actually works and have good performance and easy to debug?
- richardjam73 3y agoI haven't used parsec but I have used fparsec and I found that usage of the "operator precedence parser" was very useful in parsing expressions. It also sped up parsing a lot. As for BNF, it is like a standard that your parser should follow. A map for when parsing gets complex. You may not need it for a simple parser.