News for hackers. Stuff that matters.
Re:Compiler Construction by Niklaus Wirth [pdf] by jcranmer on Friday January 31, 2020 @05:10PM (#22206408)
The current go compiler uses a hand-written parser, judging from it's source.

The benefit of having a BNF grammar for your language is rightfully enormous, and all modern languages definitely lay out their lexing grammar and BNFs explicitly in their specification. But there are downsides. Debugging LALR grammars is painful; error conditions are almost uniformly painful. Many languages make tokenization dependent on the current context of a parse for language ergonomic reasons [1], and you might not be able to specify the action in the right place in your automated parser generator. Hell, the language might not even conform to the LL(k) or LALR(1) your parser generator translates.

[1] I'd say this is context-sensitive lexing, but the resulting grammar isn't context-sensitive. Just somewhat more complicated than a naive translation of the grammar would indicate.

There are no comments on this comment yet.