Books in Print

 [image of the Head of a GNU] [ English ]


Flex: The Lexical Scanner Generator

by G. T. Nicol

drawing of GNU flexing
128 Pages, plus detachable Quick Reference Card.
Cover Price: $20.00
February 1993, for Flex Version 2.3.7
ISBN 1-882114-21-3
Plastic spine
Order Now!



GNU Press Home Page
Books In Print
Software on CD
ISBN List
GNU Gear Page
Clothing
Wall Art
Other Fan Gear
Order Form
For Authors
For Resellers
For Teachers
Contact Us
FSF Home Page
GNU Project Home

This manual is primarily designed as a reference but can also be used as an introduction to Flex. The manual has many examples, ranging from a simple scanner that replaces one work with another, to more complex examples such as a jargon converter. The manual contains a chapter providing useful snippets that you can include in your own scanners to handle comments, dates, numbers, and the like. There is a short chapter with a quick overview of Lex, comparing and contrasting it to Flex. There is also a long chapter on how Flex interfaces with Bison and C.

Flex is a lexical scanner generator. It converts a high-level description into a C program that can perform multiple tasks. It can read a file; group the characters within it into units such as numbers, keywords or strings; return tokens that match the types of unit and more.

One example of Flex's usefulness is as a translator. In a compiler, the syntax checker must receive a stream of tokens that represent parts of its grammar, not plain characters. A lexical scanner like Flex sits between the file and the syntax checker. It reads the file, groups the characters, and passes tokens to the syntax checker in a vocabulary it can understand.

The languages used by a programmer to create a description for the scanner is a high-level language that is much more suitable for describing scanners than the C language is. Although you can write scanners in C or similar languages, Flex is quicker and much more convenient. Flex produces fast scanners and is largely POSIX compatible.





Please send comments on these web pages to webmasters@www.gnu.org, send other questions to gnu@gnu.org.

Copyright © 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

Updated: $Date: 2006/05/01 10:04:13 $ $Author: ramprasadb $