Skip to Content
lex & yacc, 2nd Edition
book

lex & yacc, 2nd Edition

by John Levine, Doug Brown, Tony Mason
October 1992
Intermediate to advanced
384 pages
7h 8m
English
O'Reilly Media, Inc.
Content preview from lex & yacc, 2nd Edition

Appendix B. AT&T Yacc

Options

AT&T yacc is distributed with most versions of UNIX, except for the most recent verions of Berkeley UNIX, which have Berkeley yacc. If you’re not sure which version of yacc you have, try running it with no arguments. If it says:

    fatal error: cannot open input file, line 1

it’s AT&T yacc. If it gives you a summary of the command syntax, it’s Berkeley yacc.

Yacc processes a file containing a grammar and generates source code for a parser. By convention, the grammar file has a .y extension. The file that yacc generates is named y.tab.c.

The syntax of the yacc command is:

yacc [options]file

where options are as follows:

-d

Generates the header file y.tab.h that contains definitions of token names.

-l

Omits #line constructs in the generated code.

-t

Includes runtime debugging code when y.tab.c is compiled.

-v

Produces the file y.output, which contains a listing of all of the states in the generated parser and other useful information.

In order to compile the parser generated by yacc, you must supply a main routine and a supporting routine, yyerror. The UNIX library liby.a contains default versions of these routines.

See Chapter 7, A Reference for Yacc Grammars , for information on yacc specifications.

Error Messages

This section discusses correcting problems and errors reported by yacc, aside from the shift/reduce and reduce/reduce errors discussed in Chapter 8, Yacc Ambiguities and Conflicts . The error messages are organized alphabetically.

%d rules never reduced ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

The GNU Make Book

The GNU Make Book

John Graham-Cumming
Learn LLVM 12

Learn LLVM 12

Kai Nacke
flex & bison

flex & bison

John Levine

Publisher Resources

ISBN: 9781565920002Errata Page