LL(1) parser generator in OCaml

我怕爱的太早我们不能终老 提交于 2020-01-04 05:43:11

问题


I'm looking for a LL(1) parser generator in OCaml... Can anybody help me with this?


回答1:


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.




回答2:


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.




回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/8070511/ll1-parser-generator-in-ocaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!