Why I write recursive descent parsers, despite their issues (2020)
1–10 of 89 posts
Re: Why I write recursive descent parsers, despite their issues (2020)
#2Recursive decent parsers can simply be implemented with recusive functions. Implementing semantic checks becomes easy with additional parameters.
Re: Why I write recursive descent parsers, despite their issues (2020)
#3I recently wrote a small C compiler that uses a recursive decent parser while this should not be possible if you just look at the syntax grammar. Why, because it looks at some semantic information about the class of identifiers, whether they are variables of typedefs for example. On the otherhand this is not very surprising, because in the days C was developed, easy parsing was a practical implication of it not being…
What a waste of time. I failed miserably.
However, I also realized that the only semantic information needed was to keep track of typedefs. That made recursive descent practical and effective.
Re: Why I write recursive descent parsers, despite their issues (2020)
#4I recently wrote a small C compiler that uses a recursive decent parser while this should not be possible if you just look at the syntax grammar. Why, because it looks at some semantic information about the class of identifiers, whether they are variables of typedefs for example. On the otherhand this is not very surprising, because in the days C was developed, easy parsing was a practical implication of it not being…
Re: Why I write recursive descent parsers, despite their issues (2020)
#5Re: Why I write recursive descent parsers, despite their issues (2020)
#6Re: Why I write recursive descent parsers, despite their issues (2020)
#7Re: Why I write recursive descent parsers, despite their issues (2020)
#8Re: Why I write recursive descent parsers, despite their issues (2020)
#9In 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
Re: Why I write recursive descent parsers, despite their issues (2020)
#10I wonder who it is that likes other kinds of parser. Over the last ~10 years or so I've read several articles arguing that recursive descent parsers are in fact great on HN. And they seem to be both the easiest to get started with and what almost all production-grade systems use. I've seen very little in the way of anything arguing for any other approaches.
In between "easiest to get started with" and "what production-grade systems use", there is "easy to actually finish a medium-sized project with." I think LR parsers still defend that middle ground pretty well.