I am learning parsing, bison & lex. I am looking for a clear & complete tutorial/example that demonstrates all of:
- C++ (not C) Abstract Syntax Tree.
- Re-entrant lexer.
- Re-entrant parser.
- Reading from a string (vs. from file) would be nice as well.
I have found multiple examples and tutorials, but each typically meets only few of the above requirements. So far my best tutorial is from Chapter 3-2 in the Oreilly book by John Levine – it has AST; all C though, meets only Re_1 above. I welcome recommendations for nice examples / tutorials, real life open source projects. For example I saw MySql .yy file – looks well written, but too big/complex for beginner like me.
In the end I combined several examples to get what I wanted. The top two examples were from John Levine’s book on bison&flex (2nd edition), ISBN-10: 0596155972. The other one was from a phpcompiler website which unfortunaltly as of 2017-02-28 no longer exists. I am leaving the link here, in case the site is archived somewhere: http://www.phpcompiler.org/articles/reentrantparser.html
Thanks Adrien, here is an archived version (works as of 2017-03-02):
http://web.archive.org/web/20120520150851/http://www.phpcompiler.org/articles/reentrantparser.html