O'Reilly logo

lex & yacc, 2nd Edition by Tony Mason, John Levine, Doug Brown

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. Berkeley Yacc

Berkeley yacc is a nearly exact reimplementation of AT&T yacc with few extra features.

Options

Berkeley yacc’s options are the same as AT&T yacc’s with these additions:

-b pref

Uses pref as the prefix for generated files instead of y.

-r

Generates separate files for code and tables. The code file is named y.code.c, and the tables file is named y.tab.c.

There is no library for Berkeley yacc; you have to provide your own versions of main() and yyerror().

Error Messages

This section discusses correcting problems and errors reported by Berkeley yacc, aside from the shift/reduce and reduce/reduce errors discussed in Chapter 8, Yacc Ambiguities and Conflicts . Each error message starts with a letter f for fatal error, e for error, or w for warning. Yacc gives up as soon as it sees an error or fatal error. Most of the error message also include the input filename and line number, which we omit here.

Fatal Errors

f - cannot open file

Yacc couldn’t open a file. If it’s a name you specified, make sure the file exists and is readable. If it’s one of yacc’s temporary or output file, make sure that the appropriate directory is readable and there is not already a read-only version of the given file.

f - out of space f - too many gotos f - too many states f - maximum table size exceeded

An internal table overflowed, or insufficient virtual memory was available. Unless you have a stupendously huge grammar with tens of thousands of tokens and rules, this probably represents ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required