jgh2@unix.cis.pittsburgh.edu (John G. Hardie) (05/23/89)
Hello world. I was wondering if anyone out there knows a good tutorial on the use of lex and yacc to generate a parser. I understand some things about how parsers work, but am woefully ignorant about the functioning of these two programs. I would like to play with them a bit, but don't know how to get started. (the unix man pages were, uh, less than enlightening, and the programmer docs were almost as bad. I suppose that I could learn how to use the programs using this documentation, but I'd like a slightly more readable tutorial if one is available) Thanks, John -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= John G. Hardie jgh2@unix.cis.pittsburgh.edu Dept. of Physics, Univ of Pittsburgh jgh2@vms.cis.pittsburgh.edu An ounce of inaccuracy saves a pound of explanation
jal@wsu-cs.uucp (Jason Leigh) (05/24/89)
I replied by email and as usual it bounced back, but in regards to a tutorial for Lax and Yucc ;^) I thought Sun Microsystems' manual was pretty good. If you want a tutorial-like book there is one called: Introduction to compiler construction with UNIX Axel T. Schreiner, H. George;Friedman, Jr. -- Englewood Cliffs, N.J. : Prentice Hall, c1985. 194 p. ; 29 cm. -- (Prentice-Hall software series) Bibliography: p. <189>; which seems pretty good. Chances are you will find it in the library. -- Jason Leigh
A1S@PSUVM.BITNET (Andrew Snyder) (05/24/89)
I too would like more info on these programs, INCLUDING where I can find the user's docs. Thanks, Andrew A1S @ PSUVM Have a day. :-|
UH2@PSUVM.BITNET (Lee Sailer) (05/24/89)
The Unix programmer docs are one good place to look for how to get the most out of lex and yacc, or their clones. However, it helps a lot if you already know a lot about writing compilers, so you might also take a careful look at the textbooks used in undergrad compiler writing courses. I *believe* that the compiler book by Aho and Ullman uses lex and yacc for its examples, but that is from far distant memory. Your last bet might be to find one of the bookstores that specializes in Unix books, and call them for a lex/yacc book. See Unix Review ads for phone numbers.
elg@killer.DALLAS.TX.US (Eric Green) (05/25/89)
in article <18158@unix.cis.pittsburgh.edu>, jgh2@unix.cis.pittsburgh.edu (John G. Hardie) says: > I was wondering if anyone out there knows a good tutorial on the use > of lex and yacc to generate a parser. I understand some things about > how parsers work, but am woefully ignorant about the functioning of > these two programs. I would like to play with them a bit, but don't > know how to get started. (the unix man pages were, uh, less than > enlightening, and the programmer docs were almost as bad. I suppose Book #1: _Introduction to Copmiler Construction with UNIX_, Axel T. Schreiner and H. George Friedman, Jr. Publisher: Prentice-Hall. ISBN 0-13-474396-2. Synopsis: Tells how to write Lex and Yacc definitions, tells how to do Yacc error recovery and other such "tricks of the Yacc trade", gives copious examples. Will NOT teach you how to write a compiler -- you're assumed to already know that. Simply runs you through the Unix tools to build a simple compiler. Book #2: The "New Dragon Book": _Compilers: Principles, Techniques, and Tools. Aho, Sethi, Ullman. Addison-Wesley ISBN 0-201-10088-6. Nearly definitive reference of current "state of the art". Tells about the algorithms underlying Lex and Yacc, amongst other things. Gives some example Yacc and Lex, e.g. a simple desk calculator on page 259, but not much. The entire book is nearly impenetrable for someone who hasn't taken a "Formal Languages" course, or who hasn't touched discrete math/logic in eons. Would greatly benefit from being re-written into English. Still, there's something to be said about having the definitive reference on your shelf, in case you get tired of dealing with black boxes and wonder what's REALLY happening. Just scan a formal languages book first (Ullman collaborated on one '78 ways that was pretty good, but I forget the title offhand). I got these through the Unix Bookstore, a few years back. There may be more up-to-date books available now. I don't have their number handy, maybe a couple of unix.wizards can help? -- | // Eric Lee Green P.O. Box 92191, Lafayette, LA 70509 | | // ..!{ames,decwrl,mit-eddie,osu-cis}!killer!elg (318)989-9849 | | // Join the Church of HAL, and worship at the altar of all computers | |\X/ with three-letter names (e.g. IBM and DEC). White lab coats optional.|
utoddl@ecsvax.UUCP (Todd M. Lewis) (05/25/89)
One source I found helpful is the 2nd edition of _Compiler_Construction_ by Pyster. In his first edition he used a subset of Pascal to produce a compiler for a subset of Pascal. In the 2nd edition, he uses readily available tools (lex and yacc) to build parts of a C compiler. What it lacks in thorough definitions of lex and yacc it makes up for in examples. (I'm not entirely sure the title is correct. The author is.) _____ | Todd M. Lewis Disclaimer: If you want my employer's ||\/| utoddl@ecsvax.uncecs.edu ideas, you'll have to || || utoddl@ecsvax.bitnet _buy_ them. | || |___ (Never write a program bigger than your screen.)
doug@xdos.UUCP (Doug "It's A Feature" Merritt) (05/28/89)
In article <89144.101348UH2@PSUVM> UH2@PSUVM.BITNET (Lee Sailer) writes: >I *believe* that the compiler book by Aho and Ullman uses lex and yacc >for its examples, but that is from far distant memory. Yes, the "Dragon Book" does discuss lex and yacc (its formal name is "Compilers -- Principles, Techniques, and Tools", currently in its second edition). Also see "Compiler Construction Under Unix" for an in-depth discussion of using Yacc. Alan Hollub was going to be coming out with an excellent compiler construction book (I saw the material), but I don't know if it's hit the streets yet. >Your last bet might be to find one of the bookstores that specializes >in Unix books, and call them for a lex/yacc book. One such with an excellent inventory is "Jim Joyce's Unix Bookstore", which does a mail order business out of San Francisco. Call (415) 626-7581 (from memory but 99% likely to be correct). Jim is a friend of mine, I vouch for this as a reliable business. He also gives great recommendations, and is very knowledgeable, far more so than any other bookstore owner (he used to be a CS professor at Berkeley). I used to give commercial courses in these subjects, but I'm not currently planning any. Doug P.S. Mention my name, I'm sure he'd be pleased to hear I'm putting in a good word for him! :-) -- Doug Merritt {pyramid,apple}!xdos!doug Member, Crusaders for a Better Tomorrow Professional Wildeyed Visionary "Welcome to Mars; now go home!" (Seen on a bumper sticker off Phobos)