4 ms·
Recursive decent parsing without lexing (2016)
- ggm 4y agoLookahead is a giant mind-twist. It really confuses me to have to "know" whats in the input stream, ahead of deciding what to do with the thing in hand. In part its because on early OS or languages I used, pushing data back into the input stream wasn't always very reliable (I don't know why: it just never worked) so you always wind up having to do some kind of buffer-size constrained block read fill, asynchronously (in a language without threads) to arrange to HAVE that lookahead buffer, to peek into, to decide what to do. Backtracking is even worse. Its the first problem, plus remembering Data Structures 101 to unwind your structures "just enough" to walk the other leg. Anyone who ever tried the "how hard can it be to read mail headers in 822" has been here, dealing with line-wrap, and the ineffable joy of envelope information (functionally, non existent in the header) on top of the actual decision logic around the various forms of the input allowed in 822.
- tomcam 4y agoI get just the opposite feeling. I love lookahead in a compiler because it makes life so much easier. And if you write a recursive descent parser by hand you get that sweet sweet bonus context for error messages.