Please consider the latest edition.
-
Chapter 1 Lex and Yacc
-
The Simplest Lex Program
-
Recognizing Words with Lex
- Symbol Tables
-
Grammars
- Parser-Lexer Communication
-
The Parts of Speech Lexer
- A Yacc Parser
- The Rules Section
-
Running Lex and Yacc
-
Lex vs. Hand-written Lexers
-
Exercises
-
-
Chapter 2 Using Lex
-
Regular Expressions
- Examples of Regular Expressions
-
A Word Counting Program
-
Parsing a Command Line
- Start States
-
A C Source Code Analyzer
-
Summary
-
Exercises
-
-
Chapter 3 Using Yacc
-
Grammars
- Recursive Rules
-
Shift/Reduce Parsing
- What Yacc Cannot Parse
-
A Yacc Parser
- The Definition Section
- The Rules Section
- Symbol Values and Actions
-
The Lexer
- Compiling and Running a Simple Parser
-
Arithmetic Expressions and Ambiguity
- When Not to Use Precedence Rules
-
Variables and Typed Tokens
- Symbol Values and %union
-
Symbol Tables
-
Functions and Reserved Words
- Reserved Words in the Symbol Table
- Interchangeable Function and Variable Names
-
Building Parsers with Make
-
Summary
-
Exercises
-
-
Chapter 4 A Menu Generation Language
-
Overview of the MGL
-
Developing the MGL
-
Building the MGL
- Initialization
-
Screen Processing
-
Termination
-
Sample MGL Code
-
Exercises
-
-
Chapter 5 Parsing SQL
-
A Quick Overview of SQL
- Relational Data Bases
- Manipulating Relations
-
Three Ways to Use SQL
-
The Syntax Checker
- The Lexer
- Error and Main Routines
-
The Parser
- Definitions
- Top Level Rules
- The Schema Sublanguage
- Base Tables
- View Definition
- Privilege Definitions
- The Module Sublanguage
- Cursor Definitions
- The Manipulation Sublanguage
- Simple Statements
- FETCH Statements
- INSERT Statements
- DELETE Statements
- UPDATE Statements
- Scalar Expressions
- SELECT Statements
- Table Expressions
- Search Conditions
- Odds and Ends
- Using the Syntax Checker
- Embedded SQL
- Changes to the Lexer
- Changes to the Parser
- Auxiliary Routines
- Using the Preprocessor
- Exercises
-
-
Chapter 6 A Reference for Lex Specifications
-
Structure of a Lex Specification
- Definition Section
- Rules Section
- User Subroutines
-
BEGIN
- Bugs
- Ambiguous Lookahead
- AT&T Lex
- Flex
- Character Translations
- Context Sensitivity
- Left Context
- Right Context
- Definitions (Substitutions)
- Bugs
-
ECHO
- Include Operations (Logical Nesting of Files)
- File Chaining with yywrap()
- File Nesting
- AT&T Lex
- Flex
- MKS Lex
- Abraxas Pclex
- POSIX Lex
- Include Operations (Logical Nesting of Files)
-
Input from Strings
- AT&T Lex
- Flex
- Abraxas Pclex
- MKS Lex
- POSIX Lex
- input()
-
Internal Tables (%N Declarations)
- lex Library
- main()
- Other Library Routines
- lex Library
-
Line Numbers and yylineno
- Literal Block
-
Multiple Lexers in One Program
- Combined Lexers
- Multiple Lexers
- Using the p Flag
- Faking It
-
output()
-
Portability of Lex Lexers
- Porting Lex Specifications
- Porting Generated C Lexers
- Libraries
- Buffer Sizes
- Character Sets
-
Regular Expression Syntax
- Metacharacters
- POSIX Extensions
-
REJECT
-
Returning Values from yylex()
- Start States
-
unput()
-
yyinput(), yyoutput(), yyunput()
-
yyleng
-
yyless()
-
yylex()
- User Code in yylex()
-
yymore()
-
yytext
- Enlarging yytext
- AT&T and MKS Lex
- Flex
- Pclex
-
yywrap()
-
-
Chapter 7 A Reference for Yacc Grammars
-
Structure of a Yacc Grammar
- Symbols
- Definition Section
- Rules Section
- User Subroutines Section
-
Actions
- Embedded Actions
- Symbol Types for Embedded Actions
- Obsolescent Feature
-
Ambiguity and Conflicts
- Types of Conflicts
- Shift/Reduce Conflicts
- Reduce/Reduce Conflicts
- Types of Conflicts
-
Bugs in Yacc
- Real Bugs
- Error Handling
- Declaring Literal Tokens
- Infinite Recursion
- Unreal Bugs
- Interchanging Precedences
- Embedded Actions
- Real Bugs
-
End Marker
-
Error Token and Error Recovery
-
%ident Declaration
-
Inherited Attributes ($0)
- Symbol Types for Inherited Attributes
-
Lexical Feedback
-
Literal Block
-
Literal Tokens
-
Portability of Yacc Parsers
- Porting Yacc Grammars
- Porting Generated C Parsers
- Libraries
- Character Codes
-
Precedence, Associativity, and Operator Declarations
- Precedence and Associativity
- Precedence
- Associativity
- Operator Declarations
- Using Precedence and Associativity to Resolve Conflicts
- Typical Uses of Precedence
- Precedence and Associativity
-
Recursive Rules
- Left and Right Recursion
-
Rules
-
Special Characters
-
Start Declaration
-
Symbol Values
- Declaring Symbol Types
- Calculator Example
- Explicit Symbol Types
-
Tokens
- Token Numbers
- Token Values
-
%type Declaration
-
%union Declaration
-
Variant and Multiple Grammars
- Combined Parsers
- Multiple Parsers
- Using the -p Flag
- Faking It
- Recursive Parsing
- Lexers for Multiple Parsers
-
y.output Files
-
Yacc Library
- main()
- yyerror()
-
YYABORT
-
YYACCEPT
-
YYBACKUP
-
yyclearin
-
yydebug and YYDEBUG
-
YYDEBUG
- yydebug
-
yyerrok
-
YYERROR
-
yyerror()
-
yyparse()
-
YYRECOVERING()
-
-
Chapter 8 Yacc Ambiguities and Conflicts
-
The Pointer Model and Conflicts
- Types of Conflicts
- Parser States
- Contents of y.output
- Reduce/Reduce Conflicts
- Shift/Reduce Conflicts
- Review of Conflicts in y.output
-
Common Examples of Conflicts
- Expression Grammars
-
IF—THEN—ELSE
- Nested List Grammer
-
How Do I Fix the Conflict?
-
IF—THEN—ELSE (Shift/Reduce)
- Loop Within a Loop (Shift/Reduce)
- Expression Precedence (Shift/Reduce)
- Limited Lookahead (Shift/Reduce or Reduce/Reduce)
- Overlap of Alternatives (Reduce/Reduce)
-
Summary
-
Exercises
-
-
Chapter 9 Error Reporting and Recovery
-
Error Reporting
- Better Lex Error Reports
-
Error Recovery
- Yacc Error Recovery
- Where to Put Error Tokens
-
Compiler Error Recovery
-
Exercises
-
-
Appendix AT&T Lex
-
Error Messages
-
-
Appendix AT&T Yacc
-
Options
-
Error Messages
-
-
Appendix Berkeley Yacc
-
Options
-
Error Messages
- Fatal Errors
- Regular Errors
- Warnings
- Informative Messages
-
-
Appendix GNU Bison
-
Differences
-
-
Appendix Flex
-
Flex Differences
-
Options
-
Error Messages
-
Flex Versions of Lexer Examples
-
-
Appendix MKS lex and yacc
-
Differences
-
New Features
-
-
Appendix Abraxas lex and yacc
-
Differences
-
New Features
-
-
Appendix POSIX lex and yacc
-
Options
-
Differences
-
-
Appendix MGL Compiler Code
-
MGL Yacc Source
-
MGL Lex Source
-
Supporting C Code
-
-
Appendix SQL Parser Code
-
Yacc Parser
-
Cross-reference
-
-
Appendix SQL Parser Code
-
Lex Scanner
-
Supporting Code
-
-
Glossary
-
Bibliography
- Title:
- lex & yacc, Second Edition
- By:
- Doug Brown, John Levine, Tony Mason
- Publisher:
- O'Reilly Media
- Formats:
-
- Safari Books Online
- Print Release:
- October 1992
- Pages:
- 388
- Print ISBN:
- 978-1-56592-000-2
- | ISBN 10:
- 1-56592-000-7
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal featured on the cover of lex & yacc is a Victoria crowned pigeon, one of the largest members of the pigeon family. Unlike other birds, the crowned pigeon drinks water by immersing its bill and sucking. Incubation of the eggs (generally two) is shared by these monogamous birds, the male warming them by day, the female by night. The Victoria crowned pigeon is light and dark blue with purple markings and a fanlike head crest of lacy, light blue feathers. Though protected by law in its native country of New Guinea, it is nonetheless an easy target for hunters for its plumage and is in danger of extinction. Unix and its attendant programs can be unruly beasts. Nutshell Handbooks(R) help you tame them.
...
Edie Freedman designed this cover and the entire Unix bestiary that appears on other Nutshell Handbooks. The beasts themselves are adapted from 19th-century engravings from the Dover Pictorial Archive. The cover layout was produced with QuarkXPress 3.1 using the ITC Garamond font.
The inside layout was fomatted in sqtroff using ITC Garamond Light and ITC Garamond Book fonts, and was designed by Edie Freeman. The figures were created in Aldus Freehand 3.1 by Chris Reilley.
