Yacc

Source: Wikipedia, the free encyclopedia.
Yacc
Original author(s)Stephen C. Johnson
Repository
Written in
Cross-platform
TypeCommand
LicensePlan 9: MIT License

Yacc (Yet Another Compiler-Compiler) is a

forward-compatible Yacc replacement.[3]

History

In the early 1970s,

Al Aho to Donald Knuth's work on LR parsing, which served as the basis for Yacc.[4] Yacc was influenced by[6] and received its name in reference to TMG compiler-compiler.[7]

Yacc was originally written in the

Version 3 Unix,[8] and a full description of Yacc was published in 1975.[6]

Johnson used Yacc to create the Portable C Compiler.[8] Bjarne Stroustrup also attempted to use Yacc to create a formal specification of C++, but "was defeated by C's syntax".[9] While finding it unsuitable for a formal specification of the language, Stroustrup did proceed to use Yacc to implement Cfront, the first implementation of C++.[10]

In a 2008 interview, Johnson reflected that "the contribution Yacc made to the spread of Unix and C is what I'm proudest of".[11]

Description

The input to Yacc is a grammar with snippets of C code (called "actions") attached to its rules. Its output is a shift-reduce parser in C that executes the C snippets associated with each rule as soon as the rule is recognized. Typical actions involve the construction of parse trees. Using an example from Johnson, if the call node(label, left, right) constructs a binary parse tree node with the specified label and children, then the rule

expr : expr '+' expr  { $$ = node('+', $1, $3); }

recognizes summation expressions and constructs nodes for them. The special identifiers $$, $1 and $3 refer to items on the parser's

stack.[6]

Yacc produces only a parser (phrase analyzer) which can be used alone in the case of

IEEE POSIX P1003.2 standard defines the functionality and requirements for both Lex and Yacc.[12]

Some versions of AT&T Yacc have become open source. For example, source code is available with the standard distributions of Plan 9.[13]

Impact

Yacc and similar programs (largely reimplementations) have been very popular. Yacc itself used to be available as the default parser generator on most Unix systems, though it has since been supplanted by more recent, largely compatible, programs such as

GNU Bison, MKS Yacc, and Abraxas PCYACC. An updated version of the original AT&T Yacc is included as part of Sun's OpenSolaris project. Each offers slight improvements and additional features over the original Yacc, but the concept and basic syntax have remained the same.[14]

Yacc was also one of several UNIX tools available for Charles River Data Systems'

Among the languages that were first implemented with Yacc are

Yacc has also been rewritten for other languages, including

See also

References

  1. ^ "The A-Z of Programming Languages: YACC". Computerworld. Archived from the original on 31 January 2013. Retrieved 30 November 2012.
  2. .
  3. .
  4. ^ a b Morris, Richard (1 October 2009). "Stephen Curtis Johnson: Geek of the Week". Red Gate Software. Retrieved 19 January 2018.
  5. ^ . pp. 675, 684: After the TMG version of B was working, Thompson rewrote B in itself(a bootstrapping step).…When Johnson returned to Bell Labs in 1973, he was disconcerted to find that the language whose seeds he had brought to Canada had evolved back home; even his own yacc program had been rewritten in C, by Alan Snyder.
  6. ^ a b c d Johnson, Stephen C. (1975). Yacc: Yet Another Compiler-Compiler (Technical report). Murray Hill, New Jersey: AT&T Bell Laboratories. 32. Retrieved 31 January 2020.
  7. ^ "Early Translator Writing Systems". Atlas Computer Laboratory.
  8. ^ (PDF) (Technical report). CSTR. Bell Labs. 139.
  9. ^ Stroustrup, Bjarne. "A History of C++: 1979−1991" (PDF).
  10. ^ a b Stroustrup, Bjarne. "Cfront source code".
  11. ^ Hamilton, Naomi (2008-07-09). "Yacc, Unix, and advice from Bell Labs alumni Stephen Johnson". www.computerworld.com. Archived from the original on 2020-08-22. Retrieved 2020-11-10.
  12. The Single UNIX Specification, Version 4 from The Open Group
    .
  13. ^ "plan9: UC Berkeley release of Plan 9 under the GPLv2". GitHub. 26 December 2017. Retrieved 2 January 2018.
  14. ^ Bison Manual: History
  15. ^ The Insider's Guide To The Universe (PDF). Charles River Data Systems, Inc. 1983. p. 13.
  16. ^ "UNIX Special: Profs Kernighan & Brailsford". Computerphile. September 30, 2015. Archived from the original on 2021-12-11.
  17. .
  18. ^ "OCaml User's Manual: Chapter 12 Lexer and parser generators (ocamllex, ocamlyacc)". Retrieved 25 Nov 2013.
  19. ^ "Yacc.go: A version of Yacc for the Go Programming Language". Retrieved 15 July 2017.
  20. ^ "CL-Yacc: A Common Lisp version of Yacc".
  21. ^ "yecc: An Erlang implementation of Yacc".
  22. ^ John Levine (August 2009), flex & bison, O'Reilly Media

External links

  • Playground environment for learning and testing syntax
This page is based on the copyrighted Wikipedia article: Yacc. Articles is available under the CC BY-SA 3.0 license; additional terms may apply.Privacy Policy