Advanced Search
Start Your Free Trial

Overview

Other Readers Also Read...
sed & awk, 2nd Edition

sed & awk, 2nd Edition
by Dale Dougherty; Arnold Robbins

Top Sellers in this Category

Head First Design Patterns

Head First Design Patterns
by Eric Freeman; Elisabeth Robson; Kathy Sierra; Bert Bates

Regular Expressions Cookbook

Regular Expressions Cookbook
by Jan Goyvaerts; Steven Levithan

The Ruby Programming Language, 1st Edition

The Ruby Programming Language, 1st Edition
by David Flanagan; Yukihiro Matsumoto

This book shows you how to use two Unix utilities, lex and yacc, 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 and yacc, and Abraxas PCYACC

Amazon.com® Reader Reviews (Ranked by Helpfulness)

Average Amazon.com® Rating: 4.0 out of 5 rating Based on 35 Ratings

Very good guide to an old but useful programming tool - 2006-06-25
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
Yacc (yet another compiler compiler) and its companion lex (lexical analyzer) are primarily intended to allow quick and easy development of small special-purpose languages. The common mistake is assuming that they are only useful for creating compilers for massively complex eccentric languages. This is not the case, though you could no doubt use them for such a purpose.

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.

A good book to have when using lex & yacc - 2006-12-14
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
I like this book because it is a good compromise between lex & yacc man pages and the theory found in books such as the Dragon book. You will get valuable information about the how and why of the tools that will help you to produce a quality grammar without being overwhelmed by details.

Not bad, but not necessary either - 2009-10-16
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
You'd be hard pressed to argue the book does much more than reiterate the man pages and documentation for the two tools. It's nice to read with the tone and flow of a text, but there is nothing here that isn't online. Heck, it points you to the online references whenever there is information that would make the book more expensive to print. For example when talking about flex options it says there are hundreds (what, maybe a 25-50 page index? couple lines per option) and to go to the online documentation. Well, OK, I bought a book though, maybe I wanted my information in print. I guess you have to use both, which defeats the purpose of buying the book at all. Examples are poorly chosen, they exemplify a concept not relating flex/bison themselves and by chance use a hodgepodge of the things you wanted to learn about. For example, instead of creating an example to show you how an individual aspects of flex works he does a few (well) then tosses all the others into a giant multipage example at the end. Thanks for making me sift through code I don't care about to see the meaning of individual flex function/features/variables. I think a bunch of well chosen and small examples would have been better. But you know, that would have been more work and made the book larger...

The bottom line is, internet searches and the online documentation have everything the book has to say and more.

It's definitely not worth $30, $19 is pushing it. I've honestly never been impressed with O'Reilly, I own 5 books from them. Apress publishes the best non-classroom technical manuals in my opinion.

FYI, flex & bison have nothing (fundamentally) to do with UNIX/Linux/BSD. But be prepared to read an O'Reilly by Linux guy style book in true fashion. I'd peg this as the anemic and low-context instruction Linux guys love to write (wastes a lot of your time, makes them feel smart).

A compiler construction essential - 2007-10-21
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
This item is a definite must for coursework dealing with scanning and parsing. I thought that I would be fine if I just relied on web sources to assist me in Lex assignments, but as a deadline approached and I still had no results I turned to this book. The content is clear, concise, and absolutely fantastic. If you want to know how to work with Lex and Yacc, this is the book you need.

Not a Mind Meld - 2006-08-23
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
To me a great book flows into your mind, magically providing the information in the order you need it. Of course it depends on whose reading it, but this book, though well worth the 96 cents bargain bin price I paid for it, does not build the constructs in my head the way I'd like.

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.

Some information on this page was provided using data from Amazon.com®. View at Amazon >


About Safari Books Online • Terms of Service • Privacy Policy • Contact Us • Corporate Licenses • Help • Accessibility | See us on FacebookSee us on Linked InSee us on TwitterRSS

Copyright 2009 Safari Books Online. All rights reserved.