Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Query: any good venue for sample lex&yacc or flex&bison programs
Date: Tue, 02 Sep 2008 13:26:29
Message-Id: 200809021528.31285.shrdlu@unlimitedmail.org
In Reply to: [gentoo-user] Query: any good venue for sample lex&yacc or flex&bison programs by Kevin O'Gorman
1 On Tuesday 2 September 2008, 07:01, Kevin O'Gorman wrote:
2
3 > I've been teaching myself scanners over the summer, thinking to teach
4 > my students this fall.
5 >
6 > It was hard because just about all of the examples are inadequate for
7 > one of these reasons:
8 > 1 They are pure lex, or pure yacc, not a combination. Ditto flex
9 > and bison. Most of such sample programs work okay, but they're not
10 > what's needed. Getting the parser and scanner to work together is the
11 > key thing.
12 > 2 They are spotty in their coverage of features
13 > 3 They are incomplete and fail to compile as presented; the
14 > documentation is very old-style UNIX in general, and very hard to
15 > learn the necessary fixes from it.
16 > 4 They are old and fail on modern versions of the software
17 > 5 They are just plain broken
18 >
19 > This applies to examples in the texinfo pages, the 2003 O'Reilly book,
20 > and online manuals.
21 >
22 > This is a very serious problem for learning these tools in their
23 > combined form. I'm relatively good at dealing with such stuff (having
24 > decades of practice), but I would not expect my undergrads to be able
25 > to learn with these materials.
26 >
27 > I was finally able to cobble together a working flex/bison parser from
28 > the bison-bridge example in an appendix to the flex info page. I'd
29 > like to share it, and perhaps other _working_ sample programs to the
30 > web at large. Does anyone know of a better venue for this than just
31 > some random page on my school's web server? I would like other people
32 > to be able to find this stuff and perhaps add to it or otherwise
33 > improve on it.
34
35 When I had to study the subject, I found these documents (in addition to
36 the dragon book, which was of course the primary source of information
37 for the underlying theory):
38
39 http://epaperpress.com/lexandyacc/
40 http://www.kiv.zcu.cz/~lobaz/fjp/yacc/compiler_flex_bison.pdf
41 http://www.ibm.com/developerworks/linux/library/l-lexyac.html
42
43 The above documents all contain examples of using lex+yacc together to
44 build an interpreter for simple languages, which is enough for an
45 undergrad course imho. Also, I seem to remember that the flex and bison
46 online manuals and the examples therein were quite accurate (but I might
47 be wrong, it was some time ago).
48
49 I think a good place to discuss lex/yacc issues and get pointers to
50 resources is the comp.compilers newsgroup, see
51 http://compilers.iecc.com/index.phtml for more information, especially
52 the FAQ section.
53
54 Another good place (maybe even better, since it's targeted to beginners)
55 is the compilers 101 mailing list, see
56 http://tech.groups.yahoo.com/group/compilers101/ for more information.

Replies

Subject Author
Re: [gentoo-user] Query: any good venue for sample lex&yacc or flex&bison programs Kevin O'Gorman <kogorman@×××××.com>