2 ms·
For a few reasons. One, because actually building the lexer and parser from scratch is a useful exercise in a learning context, which is what this is. Two, be
by pdpi 2y ago
For a few reasons.
One, because actually building the lexer and parser from scratch is a useful exercise in a learning context, which is what this is.
Two, because the book wants to teach Pratt parsers, rather than LALR parsers. There’s a lot of literature out there on LALR parsers and generated parsers in general, but precious little on handrolled parsers. Covering material that hasn’t been covered to hell and back is a Good Thing.
Three, because lex and yacc generate C, and the book has two implementations of the interpreter, in C and Java. You could’ve used ANTLR to generate both parsers, but lex/yacc would only cater to the C version
And finally, because not everybody is on a POSIX system. Before WSL, using anything Unix-y on Windows was miserable. These days it’s mostly fine, but using WSL means you’re not actually building windows-native stuff anymore.