What is the advantage of using a parser generator like happy as opposed to using parser combinators?

后端 未结 5 1267
情歌与酒
情歌与酒 2021-01-31 17:44

To learn how to write and parse a context-free grammar I want to choose a tool. For Haskell, there are two big options: Happy, which generates a parser from a grammar descriptio

5条回答
  •  离开以前
    2021-01-31 18:29

    Naive parser combinators do not allow left-recursion in grammar rules and I haven't found a library that does.

    Happy does allow full BNF in language spec, and some useful staff like priority rules. So, for complicated cases Happy and parser generators in general are much better. However, in case of simple, stupid languages with LL(k) parseable grammars, I would use a parser combinator library as more maintainer-friendly.

提交回复
热议问题