3 ms·
You can put a breakpoint on a function in a recursive descent parser and see the call stack. You can't put a breakpoint on a grammar production in Yacc and see
by kazinator 4y ago
You can put a breakpoint on a function in a recursive descent parser and see the call stack. You can't put a breakpoint on a grammar production in Yacc and see the parser stack as a call stack in your debugger.
A grammar can be recovered easily only from a very clean Yacc file. A Yacc file can be a hot mess of ad-hoc predecence and associativity overrides which basically requires a specialist with a "Ph. D. in Yacc" to figure out.
GNU Bison (and only that implementation of the Yacc idea) has only recently added the possibility of the grammar having multiple start symbols: e.g. useful if you want to just parse an expression, rather than a file full of definitions.
In recursive descent, you just call whatever function you want, e.g. parse_expr(...).