ArticleslgStudy

computer science

Berkeley Yacc

Berkeley Yacc is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Berkeley Yacc rather than just read about it. In short: Berkeley Yacc (byacc) is a Unix parser generator designed to be compatible with Yacc. It was originally written by Robert Corbett and released in 1989.

Key takeaways

  • Berkeley Yacc belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Berkeley Yacc to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Berkeley Yacc from memory before moving on to harder problems.

Reference excerpt

Berkeley Yacc (byacc) is a Unix parser generator designed to be compatible with Yacc. It was originally written by Robert Corbett and released in 1989. Due to its liberal license and because it was faster than the AT&T Yacc, it quickly became the most popular version of Yacc. It has the advantages of being written in ANSI C89 and being public domain software. It contains features not available in Yacc, such as reentrancy, which is implemented in a way that is broadly compatible with GNU Bison.

History In 1985, Robert Corbett developed an original LALR parser generator based on a 1982 paper by DeRemer and Pennello. Corbett wrote it as part of his research towards the Ph.D. he received from University of California, Berkeley in June 1985. It was originally named Byson and was incompatible with Yacc but it was subsequently renamed Bison and became the basis of GNU Bison. Later in 1985, Corbett developed his LALR parser generator, making it Yacc-compatible and naming it Zeus but subsequently renaming it Zoo. Corbett published the source code for Zoo in a Usenet newsgroup but it went mostly unnoticed until later in September 1989 when Corbett posted on the comp.compilers newsgroup about putting the source code on an FTP server. There was discussion about renaming it and by October 1989 it had become known as Berkeley Yacc (byacc). In 1995, Chris Dodd developed BtYacc, a backtracking derivative of Berkeley Yacc to support parsing context-sensitive languages like C++, based on a 1993 paper by Merrill describing similar modifications to AT&T Yacc. Its backtracking and semantic disambiguation capabilities allow it to generate parsers for ambiguous grammars. A rule parsed but rejected by semantic information can be rolled back, so that the parser can try another rule. However, it has also been criticized for needing side-effect free trial actions and its inflexible handling of shift-reduce conflicts. In 1997, Vadim Maslov took over maintenance of BtYacc to support a COBOL parser developed by his company. By 1999, the last 3.0 release, had been converted to C++, making it no longer implemented in C. In 2000, Thomas E. Dickey ported Berkeley Yacc to OpenVMS to facilitate porting tin to VMS. After failing to find another maintainer, Dickey has maintained Berkeley Yacc since February 2002. A significant update was the conversion from K&R C to ANSI C89. In 2014, Tom Shields integrated BtYacc backtracking into Berkeley Yacc effectively subsuming BtYacc and again supporting C (instead of only C++) in Dickey releases since April 2014.

Languages Parser generators typically deal with three languages: the language a generator is implemented in, the language a generated parser is implemented in and of course the metalanguage that describes whatever a generated parser should parse. A fourth language could be considered whatever language a generated parser parses but parser generators do not handle such directly, instead just focusing on generating a parser from a given description while letting the generated parser deal with such. Yacc is written in C and generates parsers in C from its own Yacc metalanguage descriptions. This is also how Berkely Yacc works (thus its compatibility), however, a number of derivatives have been created to allow it to generate parsers in languages other than C. Ray Lischner developed perl-byacc (pbyacc) from byacc 1.6, so that it could also generate parsers in Perl. Later Richard "Rick" Ohnemus ported the patches from byacc 1.6 to byacc 1.8. And later in 1996, Jake Donham developed p5yacc from perl-yacc 1.8.2 so that its generated Perl parsers would use Perl 5 classes. In 1994, Mike Kleyn developed tyacc from perl-yacc 1.8.2 so that it could also generate parsers in Tcl In 1997, Bob Jamison developed BYACC/Java (later called BYACC/J or byaccj) from byacc 1.8, so that it could also generate parsers in Java. In 2000, Bruce Bahnsen merged in the Java parser capabilities of BYACC/J into perl-yacc and added the ability to generate parsers in Python. In 2013, Thomas Dickerson made further improvements on it deeming it PyByacc. In 2003, Dave Bodenstab merged tyacc and p5yacc to develop a PERL-TCL-YACC rebasing it from 4.8 release of yacc from FreeBSD (a byacc derivative).

See also Comparison of parser generators

References

External links Official website

Worked examples

Example 1 — a first encounter with Berkeley Yacc

Start with the simplest possible case. Write down what Berkeley Yacc claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Berkeley Yacc before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Berkeley Yacc ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Berkeley Yacc

In research
Berkeley Yacc appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Berkeley Yacc in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Berkeley Yacc is common in secondary-school and first-year university syllabi. It links to neighbouring topics Compiling tools, Free software programmed in C, Parser generators, so understanding it makes those chapters shorter.
In everyday life
Look for Berkeley Yacc outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Berkeley Yacc” →

How to study Berkeley Yacc in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Berkeley Yacc means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Berkeley Yacc out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Berkeley Yacc in simple terms?

Berkeley Yacc (byacc) is a Unix parser generator designed to be compatible with Yacc. It was originally written by Robert Corbett and released in 1989.

Why does Berkeley Yacc matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Berkeley Yacc?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Berkeley Yacc.

Tags

  • Compiling tools
  • Free software programmed in C
  • Parser generators
  • Public-domain software with source code

Keep exploring