4 ms·
GCC used to use bison. I don't think GCC became a major project recently. But you're correct that recursive descent is more efficient. Not everything is efficie
by gnulinux 8y ago
GCC used to use bison. I don't think GCC became a major project recently. But you're correct that recursive descent is more efficient. Not everything is efficiency though (parsers are usually 1% of compile time since they're dirt cheap compared to code generator and especially static analyzer and optimizer). Bison makes parsing extremely simple. I can't see why anyone would use recursive descent unless they're a super major project and need to squeeze every ms.
- wwright 8y agoA big part of why tools move away from Bison and ANTLR isn’t performance, but UX (especially error reporting)
- gnulinux 8y agoIn my experience recursive descent doesn't have any better error reporting than Bison or ANTLR. Parser combinators are much better if error reporting is what you're aiming for. Also, for LALR/LR parsers like Bison/ANTLR, the canonical trick is to encode errors in your grammar, which really isn't a huge deal. E.g. in pseudocode suite: stmt ';' stmt {/* ok */} | one_line_stmt NEWLINE stmt {raise("you need a ';' there buddy");} | // other rules ; obviously this won't be useful for every case in general, otherwise why use ';' at all, but in most cases it'll give a helpful error. Some more powerful parsers like Earley Algorithm have much worse error reporting.
- ksherlock 8y agocontext sensitive grammars.
- gnulinux 8y agoYou can deal with context sensitive grammars with "lexer trick" or multiple pass parsers.