4 ms·
I've looked at yacc + bison a couple times and always turned away before even attempting to write parsers in them. It's ugly as hell and I figure sprinkling cod
by jstimpfle 11y ago
I've looked at yacc + bison a couple times and always turned away before even attempting to write parsers in them. It's ugly as hell and I figure sprinkling code is hard to understand and thus insecure.
However, have you tried parser combinators? Parsec (a Haskell library) is really nice if it fits your grammar.
Here is one guy who simulated that in Python, also very nice:
http://jayconrod.com/posts/37/ http://jayconrod.com/posts/37/
- kccqzy 11y agoParsec is good but it's a rather old library. For more specialised needs there are even better choices in Haskell: (taken from Gabriel Gonzalez's recent post) * attoparsec remains the king of speed, generating parsers competitive in speed with C * trifecta remains the king of error messages, generating gorgeous clang-style errors * earley is a newcomer but deals with context-free grammars, while other parser combinatory are basically recursive descent parsers * and good old alex+happy for direct yacc+bison equivalent * I should probably mention that in certain simple cases you don't even need a parser combinator library to parse things. Just a good old `StateT (Text, r) [] ()` or similar can do wonders.