On Tuesday 2 September 2008, 07:01, Kevin O'Gorman wrote: > I've been teaching myself scanners over the summer, thinking to teach > my students this fall. > > It was hard because just about all of the examples are inadequate for > one of these reasons: > 1 They are pure lex, or pure yacc, not a combination. Ditto flex > and bison. Most of such sample programs work okay, but they're not > what's needed. Getting the parser and scanner to work together is the > key thing. > 2 They are spotty in their coverage of features > 3 They are incomplete and fail to compile as presented; the > documentation is very old-style UNIX in general, and very hard to > learn the necessary fixes from it. > 4 They are old and fail on modern versions of the software > 5 They are just plain broken > > This applies to examples in the texinfo pages, the 2003 O'Reilly book, > and online manuals. > > This is a very serious problem for learning these tools in their > combined form. I'm relatively good at dealing with such stuff (having > decades of practice), but I would not expect my undergrads to be able > to learn with these materials. > > I was finally able to cobble together a working flex/bison parser from > the bison-bridge example in an appendix to the flex info page. I'd > like to share it, and perhaps other _working_ sample programs to the > web at large. Does anyone know of a better venue for this than just > some random page on my school's web server? I would like other people > to be able to find this stuff and perhaps add to it or otherwise > improve on it.
When I had to study the subject, I found these documents (in addition to the dragon book, which was of course the primary source of information for the underlying theory): http://epaperpress.com/lexandyacc/ http://www.kiv.zcu.cz/~lobaz/fjp/yacc/compiler_flex_bison.pdf http://www.ibm.com/developerworks/linux/library/l-lexyac.html The above documents all contain examples of using lex+yacc together to build an interpreter for simple languages, which is enough for an undergrad course imho. Also, I seem to remember that the flex and bison online manuals and the examples therein were quite accurate (but I might be wrong, it was some time ago). I think a good place to discuss lex/yacc issues and get pointers to resources is the comp.compilers newsgroup, see http://compilers.iecc.com/index.phtml for more information, especially the FAQ section. Another good place (maybe even better, since it's targeted to beginners) is the compilers 101 mailing list, see http://tech.groups.yahoo.com/group/compilers101/ for more information.

