I'm looking for a LL(1) parser generator in OCaml... Can anybody help me with this?
-
3Isn't it called a [recursive descent parser](http://en.wikipedia.org/wiki/Recursive_descent_parser)? ;-) OCaml/SML also has LEX/YACC tooling, and I am sure there are a number of Parser-Generator/Combinator libraries. Not exactly sure *what* is being looked for from the post -- perhaps do some research and say "like this, but not like that"? – Nov 09 '11 at 19:37
-
Please [don't add signatures or taglines to your posts](http://stackoverflow.com/faq#signatures). – user229044 Nov 11 '11 at 16:38
4 Answers
Well, LALR parsers can parse a strict superset of the languages which can be parsed by LL parsers. So I would advise simply using ocamlyacc which ships with Ocaml and is an LALR(1) parser generator. This may require some minor rewriting of the grammar, but it shouldn't be too hard.

- 5,628
- 22
- 31
-
3[menhir](http://gallium.inria.fr/~fpottier/menhir/) is superior to ocamlyacc in all respects. – gasche Nov 09 '11 at 21:38
-
2LALR (ocamlyacc) is a strict subset of LR (menhir); LR is _not_ a superset of LL nor the other way round!! – lambdapower Nov 10 '11 at 00:41
I have heard good things about Menhir
The home page says at the top:
Menhir is a LR(1) parser generator for the OCaml programming language. That is, Menhir compiles LR(1) grammar specifications down to OCaml code. Menhir was designed and implemented by François Pottier and Yann Régis-Gianas.
Menhir is 90% compatible with ocamlyacc. Legacy ocamlyacc grammar specifications are accepted and compiled by Menhir. The resulting parsers run and produce correct parse trees.
Planck LL(n) parser combinator library: https://bitbucket.org/camlspotter/planck/overview
It has started as my toy project, and there is no actual users, but I could implement OCaml syntax lexer/parser with Planck which are 100% compatible with the originals.
I do not recommend to use it but if you are interested... try it.

- 8,990
- 23
- 27
Stream parser as included in camlp4 are (at best of my knowledge) LL(1) parser. see http://caml.inria.fr/pub/docs/manual-camlp4/manual003.html

- 8,172
- 2
- 27
- 32