5 ms·
Does a single production compiler use lex and yacc to generate any part of their system, beyond maybe a first pass to test out syntax before it gets rewritten i
by runevault 2y ago
Does a single production compiler use lex and yacc to generate any part of their system, beyond maybe a first pass to test out syntax before it gets rewritten into a hand written parser/lexer? I'm not going to say none exist since I don't know literally every production compiler ever written, but I have never heard of one that used them for the final code.
- pansa2 2y agoI think Ruby does? IIRC its source code includes a 10,000+ line “parse.y” file which is converted to C code using Yacc.
- runevault 2y agoInteresting, I'll have to look into this because I'd never heard that before and now I'm curious. A language with as much going on as Ruby was not one I would have picked as a candidate for yacc
- runevault 2y agoJust went and looked in the github repo. 16,000+ line .y file. I can't imagine that is pleasant to maintain.
- thomascountz 2y agoExcitingly, Ruby 3.3+ shipped with a new alternative parser called Prism[0]! See also: [1][2]. [0]: https://github.com/ruby/prism https://github.com/ruby/prism [1]: https://railsatscale.com/2023-06-12-rewriting-the-ruby-parser/ https://railsatscale.com/2023-06-12-rewriting-the-ruby-parse... [2]: https://railsatscale.com/2024-04-16-prism-in-2024/ https://railsatscale.com/2024-04-16-prism-in-2024/
- rnart 2y agoYes, OCaml with its very complex syntax and hundreds of features uses the OCaml equivalents of Lex/Yacc. It is a myth that one cannot use Lex/Yacc in production.
- ufo 2y agoPython notably switched from hand written recursive descent, to a PEG based parser generator. But indeed, last I checked, recursive descent was the most common choice overall.