▲ | jasperry 4 days ago | ||||||||||||||||||||||||||||
> If I was routinely working in a language that had a well respected de facto standard parser generator and lexer, and regularly building parsers for little languages for my programs, it would probably be worth mastering these tools. In OCaml, a language highly suited for developing languages in, that de facto standard is the Menhir LR parser generator. It's a modern Yacc with many convenient features, including combinator-like library functions. I honestly enjoy the work of mastering Menhir, poring over the manual, which is all one page: https://gallium.inria.fr/~fpottier/menhir/manual.html | |||||||||||||||||||||||||||||
▲ | debugnik 3 days ago | parent | next [-] | ||||||||||||||||||||||||||||
I gave up on Menhir after I understood how allocation-heavy it is during the hot path, at least in the incremental API which is needed for proper errors; and how much of a giant hack you need to force extra lookahead, which shouldn't be such a big deal for parser generators. These days I just handroll recursive descent parsers with a mutable stream record, `raise_notrace` and maybe some combinators inspired by FParsec for choices, repetition and error messages. I know it's not as rigorous, but at least it's regular code without unexpected limitations. | |||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||
▲ | fuzztester 4 days ago | parent | prev [-] | ||||||||||||||||||||||||||||
>In OCaml, a language highly suited for developing languages in, What makes OCaml suited for that? | |||||||||||||||||||||||||||||
|