lex & yacc Second Edition
Use the Amazon App to scan ISBNs and compare prices.
This book shows you how to use two Unix utilities, lex andyacc, in program development. These tools help programmers build compilers and interpreters, but they also have a wider range of applications.The second edition contains completely revised tutorial sections for novice users and reference sections for advanced users. This edition is twice the size of the first and has an expanded index.The following material has been added:
- Each utility is explained in a chapter that covers basic usage and simple, stand-alone applications
- How to implement a full SQL grammar, with full sample code
- Major MS-DOS and Unix versions of lex and yacc are explored in depth, including AT&T lex and yacc, Berkeley yacc, Berkeley/GNU Flex, GNU Bison, MKS lex andyacc, and Abraxas PCYACC
Frequently bought together
Customers who viewed this item also viewed
Editorial Reviews
From the Publisher
About the Author
Gregory Satir helps develop online publishing tools in the Portland, Oregon, office of Electronic Book Technologies. He graduated with a B.S. in computer science from Brown University. Doug Brown is a consultant/contractor in Beaverton, Oregon. He has been developing software for circuit simulation, synthesis, and testing since 1977. Doug coauthored lex & yacc, another O'Reilly & Associates Nutshell Handbook. He received an M.S. in electrical engineering from the University of Illinois at Urbana-Champaign in 1976.
John R. Levine writes, lectures, and consults on Unix and compiler topics. He moderates the online comp.compilers discussion group at Usenet. He worked on Unix versions Lotus 1-2-3 and the Norton Utilities and was one of the architects of AIX for the IBM RT PC. He received a Ph.D in computer science from Yale in 1984.
Tony Mason is currently a member of the AFS development team at Transarc Corporation, a small start-up company specializing in distributed systems software. Previously, he worked with the Distributed Systems Group at Stanford University in the area of distributed operating systems and data communications. He received a B.S. in mathematics from the University of Chicago in 1987.
Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.
Product details
- Publisher : O'Reilly Media; Second edition (February 1, 1995)
- Language : English
- Paperback : 388 pages
- ISBN-10 : 1565920007
- ISBN-13 : 978-1565920002
- Item Weight : 1.22 pounds
- Dimensions : 6 x 0.95 x 9 inches
- Best Sellers Rank: #1,022,721 in Books (See Top 100 in Books)
- #54 in Software Utilities
- #304 in Unix Operating System
- #631 in Computer Operating Systems (Books)
- Customer Reviews:
Customer reviews
Top reviews from the United States
There was a problem filtering reviews right now. Please try again later.
Unfortunately, there is much it does not explain at all. For example, how do I process conditional statements, how do I deal with functions and procedures, how do I incorporate classes in my language.
The book needs a second volume which picks up where this one ends.
Lex and Yacc are commonly used together. Yacc uses a formal grammar to parse an input stream, something which lex cannot do using simple regular expressions since lex is limited to simple finite state automata. However, yacc cannot read from a simple input stream - it requires a series of tokens. Lex is often used to provide yacc with these tokens. As a result, building an application in lex and yacc is often used as an exercise in classes on programming languages and the theory of computation to demonstrate key concepts.
The book starts out building a simple character-driven calculator, and then moves on to build a menu generation language that produces C code that uses the standard "curses" library to draw menus on the screen. The final application is a SQL parser which includes a quick overview of both relational databases and SQL. Some readers will dislike the fact that Lex and Yacc are only capable of generating C code. Thus, the logical conclusion is that you must be able to write C code in order to use these tools. While it would be nice if the sections about the menu generation language and the SQL parser had some information about how to do typechecking and other such things, this book is not about writing a compiler/interpreter using Lex & Yacc. Rather it is just a beginner's guide.
The sections about shift/reduce and reduce/reduce conflicts are especially helpful, as are the sections going over the differences and caveats relating to the major versions of lex and yacc such as AT&T's Lex & YACC, GNU's Flex & Bison, and Berkeley's Yacc. In summary, if you've never used lex or yacc before and think they might be useful tools for you, and you already know the C programming language, this is a handy book to have.
Authors should always proofread their books with novices, not the experts. Experts fill in the gaps as they read and don't notice if the logic is missing a link. In chap 2, "Using Lex", there is the sentence: "Lex itself doesn't produce an executable program; instead it translates the lex specification into a file containing a C routine called yylex(). Your program calls yylex() to run the lexer."
I waited with baited breath for what it means to "run the lexer". Does it return a token each time you call it? Does it analyze all the input then return? The text ignores this detail and merrily goes on into other details. The chapter is called "Using Lex", but the authors omit how you use it! Of course you can scrounge around in the examples and finally root it out, but a book should paint a crystal clear picture, get you oriented, then drop in the details to build your understanding.
The book looks so promising, sort of like the beauty of the original "The C Programming Language" by Kernighan and Ritchie, but disappoints in it's fragmented exposition.
I did take a compiler course with the "dragon book" years ago and write a parser, so I'm not totally in the dark, but I expected this book to lay the subject out in a much clearer way. But it is still a good book to have and read "offline".
I hope the authors take a crack at another edition and explain it all better.
Top reviews from other countries
Lex and yacc are powerful tools for software engineers, providing efficient ways for parsing source code (and lyric works, if you write any...)
On the other hand, versatility goes along with complexity. Doug Brown understands how to systematically dissect the field into consecutive steps, each accompanied by well chosen examples, leading the reader safely through the jungle of regular expressions, EBNF, symbol tables, grammars and tokens. This book is a good refresher for experienced software developers but a beginner should be aware that the study of the art of compiler construction is inevitable to fully deploy the massive amount of knowledge packed up in this book. Surely not a bedside reading, as you feel the urge to hack in the lines of the examples and see what they do. Considering the mature state of both tools I was not sure if this edition was a good choice - now I am glad to own it.
C'est un livre technique, connu pour son haut niveau, une sorte de
bible pour les specialistes, j'en avais besoin et ait été content de
le trouver chez amazon.







