Start reading flex & bison: Text Processing Tools on your Kindle in under a minute. Don't have a Kindle? Get your Kindle here or start reading now with a free Kindle Reading App.

Deliver to your Kindle or other device


Try it free

Sample the beginning of this book for free

Deliver to your Kindle or other device

Sorry, this item is not available in
Image not available for
Image not available

flex & bison: Text Processing Tools [Kindle Edition]

John Levine

Print List Price: £19.99
Kindle Price: £18.99 includes VAT* & free wireless delivery via Amazon Whispernet
You Save: £1.00 (5%)
* Unlike print books, digital books are subject to VAT.

Free Kindle Reading App Anybody can read Kindle books—even without a Kindle device—with the FREE Kindle app for smartphones, tablets and computers.

To get the free app, enter your e-mail address or mobile phone number.


Amazon Price New from Used from
Kindle Edition £18.99  
Paperback £19.99  
Kindle Delivers Sign-up to receive email updates and get a Free Kindle Book

Book Description

If you need to parse or process text data in Linux or Unix, this useful book explains how to use flex and bison to solve your problems quickly. flex & bison is the long-awaited sequel to the classic O'Reilly book, lex & yacc. In the nearly two decades since the original book was published, the flex and bison utilities have proven to be more reliable and more powerful than the original Unix tools.

flex & bison covers the same core functionality vital to Linux and Unix program development, along with several important new topics. You'll find revised tutorials for novices and references for advanced users, as well as an explanation of each utility's basic usage and simple, standalone applications you can create with them. With flex & bison, you'll discover the wide range of uses these flexible tools offer.

  • Address syntax crunching that regular expressions tools can't handle
  • Build compilers and interpreters, and handle a wide range of text processing functions
  • Interpret code, configuration files, or any other structured format
  • Learn key programming techniques, including abstract syntax trees and symbol tables
  • Implement a full SQL grammar-with complete sample code
  • Use new features such as pure (reentrant) lexers and parsers, powerful GLR parsers, and interfaces to C++

Product Description

Book Description

Text Processing Tools

From the Publisher

Shows programmers how to use two Unix utilities, lex and yacc, in program development. You'll find tutorial sections for novice users, reference sections for advanced users, and a detailed index. Major MS-DOS and Unix versions of lex and yacc are explored in depth. Also covers Bison and Flex.

Product details

  • Format: Kindle Edition
  • File Size: 679 KB
  • Print Length: 292 pages
  • Simultaneous Device Usage: Unlimited
  • Publisher: O'Reilly Media; 1 edition (5 Aug. 2009)
  • Sold by: Amazon Media EU S.à r.l.
  • Language: English
  • ASIN: B0043D2DYQ
  • Text-to-Speech: Enabled
  • X-Ray:
  • Word Wise: Not Enabled
  • Amazon Bestsellers Rank: #593,034 Paid in Kindle Store (See Top 100 Paid in Kindle Store)
  •  Would you like to give feedback on images?

More About the Author

Discover books, learn about writers, and more.

Customer Reviews

There are no customer reviews yet on
5 star
4 star
3 star
2 star
1 star
Most Helpful Customer Reviews on (beta) 3.6 out of 5 stars  11 reviews
11 of 11 people found the following review helpful
4.0 out of 5 stars Bison and Flex are your buddies. 22 Dec. 2010
By K. Ferrio - Published on
I learned to use lex and yacc long ago, painfully and perhaps poorly, partly from snippets which may or may not have been good examples and partly from reading the generated scanning and parsing code. I imagine that my experience was typical. The old metaphor about how sausage is made is apt. And although I have since used other parser generators much more than I ever used bison, bison was the right tool for some recent projects. So I decided to take a look at John Levine's updated book, which is written in the helpfully assuring voice you'd expect, demonstrating experience though well chosen examples and seasoned with interesting historical notes.

General Observations:

* Levine makes no apologies for the tools. Where there be dragons, he offers practical advice on slaying them or -- better -- walking around them. (It seems like there was a Monty Python sketch about this, or should have been.)

* Generally well written, could have used some more editing to smooth out some convoluted bits.

* More than the usual number of errors, mostly minor and all readily fixable, in the examples.

* There is apparently no code available for download. This may not be a bad thing. I found myself thinking more than usual as I typed, which means I needed to go through the exercise. You're not going to learn how to parse and scan in the real world just by reading about it.

* The exercises are few but highly relevant. You should at least read them even if you have no time to do them.

* The index is good, but you probably won't need it.

Suggestions for Reading Order:

In general, each chapter read is expected to be read as a whole, from beginning to end. Internal back-references within chapters are frequent and effectively demand linear reading and comprehension. This seems to be a deliberate design choice, to avoid the need for more repetition than is absolutely essential. [Insert awful joke about left recursion here.]

The chapters, read as wholes, need not be read in ordinal order. This order worked well for me:

[1,] 2, 3, 7, 8

What You Get

Chapter 1 is the usual get-our-feet-wet chapter. If you don't like what you see, you're done.
Chapters 2 and 3 demonstrate how to apply flex and bison, respectively. Chapter 2 includes simple actions in the scanner, so that the examples *do* something. Old hands will recognize this; new students will see their patience rewarded in Chapter 3 where all but the simplest actions are placed in the parser, relieving the scanner of ill-suited tasks.

Chapter 4 presents a workable parser for SQL. It's an interesting choice and can be skipped if you're pressed for time.

Chapters 5 and 6 are useful references for flex and bison. These are not the typically disappointing rehash of man pages or online documentation. The information is clear, concise and full of essential observations and advice. You can skip these chapters but you will return to them. These two chapters are pretty much the manuals I wish I had when I started using lex and yacc.

Chapter 7 is one of the most coherent *practical* discussions of ambiguity and conflicts I've seen. It's about as good as possible without building the state machines, and Levine leverages the reports generated by bison to avoid discussion of first and follow sets. Instead Levine provides an informal and pragmatic pattern for reasoning about shift/reduce conflicts reported by bison, including the classic if/then/else anti-pattern. This is concise coaching which will help you anticipate and resolve common problems. Levine gently encourages the reader to think carefully about whether ambiguities may be a sign of bad language design and not just conflicts to be resolved by ad hoc rules.

Chapter 8 provides a brief but informative discussion of reporting and recovering from errors. If your language is ever going to have users, you'll have to deal with errors. Error-reporting is easy. Useful error-reporting is a little harder. And error-recovery is non-trivial for all but trivial languages. Levine provides some practical examples which serve to underscore the virtue of failing fast over flailing hard.

Chapter 9 collects some recent developments in flex and bison, some of which may be suitable for production. If you just need to get a parser going quickly and reliably in C for a simple language, or you can call C libraries, then flex and bison are your buddies. Levine provides a frank and fair assessment of the current (ca. 2009) support for implementing C++ parsers and scanners. Along with pure parsers and GLR parsing, these are advanced topics in the sense that their implementations in bison/flex are less mature than LALR targeting C implementation. Levine offers much practical advice which might be summed up as, "I could, but should I?" If the answer for your application is 'Yes, I need to cut against the historical grain of bison/flex,' then you'll do well to become familiar with some of the newer parser-generating kits which were created for that purpose. But if the significance of the question is not obvious, then this book will help you break it down into smaller parts and begin to answer it.

Overall, this is a must-read for anyone trying to make effective use of flex and bison. You could do it the hard way, but your job is going to be hard enough anyway. So you might as well get a good start from someone who knows the stuff inside and out. This book does that.
2 of 2 people found the following review helpful
5.0 out of 5 stars good parser tutorial 16 Aug. 2012
By Dwight Walker - Published on
Format:Paperback|Verified Purchase
I wanted this book for months. I was trying to write Qt code for Nokia MeeGo and it has an inbuilt parser.

flex and bison are open source parsers and scanners that generate C code that is compiled to process tokens in a computer language or any other structured data. Someone has even used flex and bison on chemical formulae to check they are correct!

This lived up to what I expected and has many quite deep examples. I will be reading snippets to get my head round parsing lingo and scripting to let me generate Qt or other scripting or data intensive coding on Linux or UNIX or Windows with mingw or similar UNIX emulators on Windows.

This guy is a legend.

It is well worth the read for a computer programmer. I did a BSc in computer science so the Backus Naur Form (BNF) was used in Pascal programming way back at the University of Queensland when I studying as an undergraduate.

It is not for non-technical folk. Don't buy it unless you can understand computer languages. If you can though, buy it as it will deepen your knowledge to handle intractable computing problems in the Web or large data repositories in the semantic Web or mobile phone application sphere like where I am at present trying to make headway.

This is a good string to your bow to attack intractable data or programming problems on new platforms or with large amounts of data that can be formidable in C or even Python.

Why I bought it was because I had an introduction to computer science and it introduced me to compiler theory and this is a much more thorough book on compiler theory and computer language parsing and processing which will help get your head around computer language issues like in mobile phones apps and frameworks.
3.0 out of 5 stars Decent book 4 Sept. 2013
By Danelle D. Gilliam - Published on
Format:Kindle Edition|Verified Purchase
Decent book. Helped me in my class. Use in addition to things on the internet for the full benefit of the book.
5.0 out of 5 stars Good getting started guide.. 6 Jan. 2013
By Byron Faber - Published on
Format:Kindle Edition|Verified Purchase
Good getting started guide. The book on a whole has been a good source to getting started with bison/flex and covers all the basics with some examples. 'While some may argue they could figure out just as much from online resources and manuals, I found this format more convenient and better organized then rummaging around the internet and in GNU manuals...
5.0 out of 5 stars Useful for learning Flex and BIson 26 Nov. 2012
By Derrik Walker II - Published on
Format:Kindle Edition|Verified Purchase
Started learning Lex and YACC with Programming in the UNIX environment, then moved to Flex and Bison with this book. Going from the Legacy to the modern was pretty seamless.
Were these reviews helpful?   Let us know

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
First post:
Prompts for sign-in

Search Customer Discussions
Search all Amazon discussions

Look for similar items by category