The Different Approach to A Parser - Parser Combinators
Some time ago I've looked into building parser for simple logical language used by imap_detach Tool. I used there parsimonious module which uses PEG grammars. Recently I learned about another parsing technique - Parser Combinators. The idea comes from functional programming and is about combining (with help of higher order functions - so called combinators) simple parsing functions, which parse primitive tokens, into more complex parsing functions, which parse parts of text and further combine those into more complex ones, ending finally with one function, which parses all given data. I first met with parser combinators in Rust library nom. Here parsers and combinators are express as macros, which is convenient on one side (concise syntax), but can lead to pretty cryptic error messages and one cannot rely much on editor's help with auto-completions, context help etc.. I used nom to build very simple URI parser. I was wondering also if parser combinators are available for Python and how they would compare with other approaches - like above mentioned PEG grammars.
Continue reading The Different Approach to A Parser - Parser Combinators →