Yacc

Yacc
Original author(s)Stephen C. Johnson
Repository
Written inC
Operating systemUnix, Unix-like, Plan 9, Inferno
PlatformCross-platform
TypeCommand
LicensePlan 9: MIT License

Yacc (Yet Another Compiler-Compiler) is a computer program for the Unix operating system developed by Stephen C. Johnson. It is a lookahead left-to-right rightmost derivation (LALR) parser generator, generating a LALR parser (the part of a compiler that tries to make syntactic sense of the source code) based on a formal grammar, written in a notation similar to Backus–Naur form (BNF).[1] Yacc is supplied as a standard utility on BSD and AT&T Unix.[2] GNU-based Linux distributions include Bison, a forward-compatible Yacc replacement.[3]

History

In the early 1970s, Stephen C. Johnson, a computer scientist at Bell Labs / AT&T, developed Yacc because he wanted to insert an exclusive or operator into a B language compiler[4] (developed using McIlroy's TMG compiler-compiler[5]), but it turned out to be a hard task. As a result, he was directed by his colleague at Bell Labs 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 B programming language, but was soon rewritten in C by Alan Snyder.[5] It appeared as part of 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 scannerless parsing however, full syntactic analysis typically requires an external lexical analyzer to perform a tokenization stage first (word analysis), which is then followed by the parsing stage proper.[6] Lexical analyzer generators, such as Lex or Flex, are widely available for this purpose. The 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 Berkeley Yacc, 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' UNOS operating system under Bell Laboratories license.[15]

Among the languages that were first implemented with Yacc are AWK, C++,[10] eqn and Pic.[16] Yacc was also used on Unix to implement the Portable C Compiler, as well as parsers for such programming languages as FORTRAN 77, Ratfor, APL, bc, m4, etc.[8][17]

Yacc has also been rewritten for other languages, including OCaml,[18] Ratfor, ML, Ada, Pascal, Java, PHP, Python, Ruby, Go,[19] Common Lisp[20] and Erlang.[21]

  • Berkeley Yacc: The Berkeley implementation of Yacc quickly became more popular than AT&T Yacc itself because of its performance and lack of reuse restrictions.[22]
  • LALR parser: The underlying parsing algorithm in Yacc-generated parsers.
  • Bison: The GNU version of Yacc.
  • Lex (and Flex lexical analyser), a token parser commonly used in conjunction with Yacc (and Bison).
  • BNF is a metasyntax used to express context-free grammars: that is a formal way to describe context-free languages.
  • PLY (Python Lex-Yacc) is an alternative implementation of Lex and Yacc in Python.

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. ^ Levine, John (1992). Lex & yacc. Sebastopol, CA: O'Reilly & Associates. p. xx. ISBN 1-56592-000-7.
  3. ^ Levine, John (2009). Flex & bison. Sebastopol, Calif: O'Reilly Media. p. xv. ISBN 978-0-596-15597-1.
  4. ^ a b Morris, Richard (1 October 2009). "Stephen Curtis Johnson: Geek of the Week". Red Gate Software. Retrieved 19 January 2018.
  5. ^ a b Ritchie, Dennis M. (April 1993). "The Development of the C Language". History of programming languages---II. Association for Computing Machinery, Inc. (published 1996-01-01). doi:10.1145/234286.1057834. ISBN 0-201-89502-1. 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. ^ a b c McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (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. ^ lex – Shell and Utilities Reference, The Single UNIX Specification, Version 4 from The Open Group, yacc – Shell and Utilities Reference, 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. ^ Kernighan, Brian W.; Pike, Rob (1984). The Unix Programming Environment. Prentice Hall. ISBN 0-13-937681-X.
  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
  • Playground environment for learning and testing syntax

Read other articles:

Congreso Nacional de Chile LV periodo Congreso Nacional (2017)Inicio de sesiones 11 de marzo de 2018Fin de sesiones 10 de marzo de 2022ComposiciónMiembros 43 senadores155 diputadosMayoría de la cámara alta Chile Vamos (simple)Mayoría de la cámara baja Chile Vamos (simple)Sucesión LIV periodo Congreso Nacional de Chile LVI periodo [editar datos en Wikidata] El LV periodo legislativo del Congreso Nacional de Chile correspondió a la legislatura del Congreso Nacional tras las ele...

 

8x8, 6x6, and 4x4 off-road trucks MAN Category 1 MAN Category 1 5,000 kg 4×4 cargo truck of the German Bundeswehr. When fitted with a winch, the Bundeswehr designation for this vehicle is Type 461 LKW 5t mil gl MW Pritsche, without a winch, the designation is Type 451 LKW 5t mil gl PritscheType8x8, 6x6, and 4x4 off-road trucksPlace of originWest GermanyService historyUsed byWest Germany, Belgium, France, Canada, Austria, USA, Estonia and probably othersProduction historyManufa...

 

United States historic placeJerome H. Remick and Company BuildingU.S. National Register of Historic Places Jerome H.Remick and Company Building from across Library StreetLocation1250 Library StreetDetroit, MichiganCoordinates42°20′4″N 83°2′49″W / 42.33444°N 83.04694°W / 42.33444; -83.04694Built1907ArchitectAlmon C. VarneyArchitectural styleEarly CommercialNRHP reference No.96000804[1]Added to NRHPJuly 25, 1996 The Jerome H. Remick and...

Part of a series on Ahmadiyya Beliefs and practices Tawhid Five Pillars of Islam Six articles of faith Bay'ah Distinct views Mirza Ghulam Ahmad Prophethood Jesus Jihad Evolution Days of remembrance Caliphate Day Eid al-Adha Eid al-Fitr Promised Messiah Day Promised Reformer Day Foundational texts and sciences Quran Sunnah (Hadith, Sirah) Aqidah (creed) Tafsir (exegesis) Fiqh (jurisprudence) Sharia (law) Key literature Rūhānī Khazā᾽in Malfūzāt Tafsīr-e-Kabīr Haqā'iq al-Furqān Revie...

 

Historic church in New York, United States United States historic placeDurham Memorial A.M.E. Zion ChurchU.S. National Register of Historic Places Durham Memorial A.M.E. Zion Church, December 2009Show map of New YorkShow map of the United StatesLocation174 E. Eagle St., Buffalo, New YorkCoordinates42°53′0″N 78°52′7″W / 42.88333°N 78.86861°W / 42.88333; -78.86861Area0.7 acres (0.28 ha)Built1920ArchitectGreenstein, LouisNRHP reference No.830016...

 

Kiichi Nakai中井貴一LahirKiichi NakaiTahun aktif1981 - sekarang Kiichi Nakai (中井 貴一code: ja is deprecated , Nakai Kiichi, lahir 18 September 1961) adalah seorang aktor asal Jepang. Dikenal di luar negeri setelah membintangi film Warriors of Heaven and Earth karya He Ping. Nakai memenangkan penghargaan Aktor Pendukung Terbaik pada tahun 1994 (untuk 47 Ronin) dan penghargaan Aktor Terbaik dalam Japan Academy pada tahun 2003 (untuk Mibu Gishi Den). Kakaknya, Kie Nakai adalah jug...

MBK EntertainmentNama asliMBK 엔터테인먼트SebelumnyaGM Planning (1999–2007)Core Contents Media (2007–2014)Kode emitenUnlisted companyIndustriMusikEntertainmentGenreK-popR&Bnu-discoDidirikan09 Januari 2007 (2007-01-09) (Core Contents Media)14 Oktober 2014 (2014-10-14) (MBK Entertainment)PendiriKim Kwang-sooDitutup2022KantorpusatYeoksam, Gangnam, Seoul, Korea SelatanTokohkunciKim Tae-kyung (CEO)JasaProduksi musikLisensiDistribusi rekamanManajemen artisIndukCJ E&M Mus...

 

Emperor Abdication LawNational Diet Long title The Law for Special Exception of the Imperial House Law concerning Abdication, etc. of Emperor CitationLaw No. 63 of Heisei 29Enacted byHouse of RepresentativesEnacted2 June 2017Enacted byHouse of CouncillorsEnacted9 June 2017Effective16 June 2017Administered byCabinet SecretariatImperial Household AgencyLegislative historyFirst chamber: House of RepresentativesBill titleThe Bill for Special Exception of the Imperial House Law conc...

 

Koordinat: 43°38′48″N 79°23′25″W / 43.64667°N 79.39028°W / 43.64667; -79.39028 Festival Film Internasional TorontoFestival tersebut bermarkas besar di TIFF Bell Lightbox, yang dibuka pada 2010.LokasiToronto, Ontario, KanadaDidirikan1976Jumlah filmterendah, 85 (1978); terbanyak, 460 (1984)[1]BahasaInternasional[www.tiff.net Situs web resmi] Festival Film Internasional Toronto (bahasa Inggris: Toronto International Film Festival, disingkat TIFF, d...

Comic book series This article is about the 2006 comic by Slave Labor Graphics based on the Disney TV cartoon. For the 1995 series by Marvel Comics based on the Disney TV cartoon, see Gargoyles (TV series) § Marvel. For the Marvel Comics characters named Gargoyle, see Gargoyle (comics). For other uses, see Gargoyle (disambiguation). GargoylesCover of Gargoyles #1 by Greg GulerPublication informationPublisherSlave Labor Graphics, Dynamite EntertainmentScheduleBi-monthly (Slave Labor Grap...

 

2011 film Men in HopeFilm posterDirected byJiří VejdělekWritten byJiří VejdělekStarringJiří MacháčekBolek PolívkaPetra HřebíčkováRelease date 25 August 2011 (2011-08-25) Running time115 minutesCountryCzech RepublicLanguageCzechBudget20,000,000 CZKBox office95,387,066 CZK[1] Men in Hope (Czech: Muži v naději) is a 2011 Czech romantic sex comedy film written and directed by Jiří Vejdělek.[2][3] Plot Ondřej (Jiří Macháček), a timid ...

 

Param Singh BhatiaLahir8 September 1988 (umur 35)Mumbai, Maharashtra, IndiaKebangsaanIndianAlmamaterBillimoria High SchoolSmt. M.M.K CollegePekerjaanaktorTahun aktif2013-sekarang Param Singh (lahir 8 September 1988) adalah aktor televisi India yang dikenal karena bermain Randhir Singh Shekhawat di Sadda Haq. Karier Param adalah aktor terlatih dari Barry John Acting Studio. Setelah menyelesaikan pelatihannya, ia melakukan beberapa pertunjukan panggung dan iklan (Hero Bikes, Dulux, Mo...

Lego theme Lego ElvesSubjectElvesLicensed fromThe Lego GroupAvailability2015–2019Total sets42[1]CharactersEmily Jones, Naida, Farran, Azari, Aira and Sophie JonesOfficial websiteTV SeriesLego Elves Lego Elves: Secrets of Elvendale Lego Elves (stylized as LEGO Elves) was a Lego product line produced by The Lego Group that was launched in 2015.[2][3] It was accompanied by the Lego Elves animated television series and webisode series that began with a min...

 

Oasis Knebworth 1996 Oasis Knebworth 1996 Álbum ao vivo de Oasis Lançamento 19 de novembro de 2021 Gravação 10–11 de agosto de 1996 Local(is) Knebworth HouseHertfordshireInglaterra Gênero(s) Rockbritpop Duração 100:34 Gravadora(s) Big Brother Cronologia de Oasis Familiar to Millions (2000) Oasis Knebworth 1996 é um álbum ao vivo e documentário da banda de rock britânica Oasis. O documentário foi lançado em 23 de setembro de 2021, sendo dirigido por Jake Scott, enquanto o á...

 

Fictional character of the Drakengard series Fictional character NierDrakengard characterOfficial artwork by Akihiko Yoshida featuring the two versions of the Nier protagonistFirst gameNier (2010)Created byYoko TaroDesigned byAkihiko YoshidaVoiced by English Jamieson Price (elder protagonist)Zach Aguilar (Replicant young protagonist)Ray Chase (Replicant older protagonist)) Japanese Ken'ichirō Matsuda (elder protagonist)Nobuhiko Okamoto (Replicant young protagonist)Koji Yusa (Replicant older ...

Kenampakan Jalan Knez Mihailova. Jalan Knez Mihailova atau Jalan Pangeran Mihailova (bahasa Serbia: Улица Кнез Михаилова (Улица Кнеза Михаила), Ulica Knez Mihailova, (Ulica Kneza Mihaila)) adalah zona pejalan kaki di kota Beograd yang juga menjadi salah satu marka tanah tertua di kota tersebut. Jalan ini dinamai dari Mihailo Obrenović III, Pangeran Serbia. Jalan ini dihiasi oleh bangunan-bangunan yang dibangun pada akhir tahun 1870-an. Jalan sepanjang s...

 

HarapanDesaKantor Kepala Desa HarapanNegara IndonesiaProvinsiSumatera UtaraKabupatenDairiKecamatanTanah PinemKode pos22253Kode Kemendagri12.11.06.2003 Luas... km²Jumlah penduduk... jiwaKepadatan... jiwa/km² Harapan merupakan salah satu desa yang ada di kecamatan Tanah Pinem, Kabupaten Dairi, provinsi Sumatera Utara, Indonesia. Pemerintahan Desa Harapan terdiri dari Dusun Kuta Mbaru Atas, Kuta Mbaru Bawah, Kuta Mbaru Impres, Lau Meciho I, Lau Meciho II, Lau Meciho III. Galeri Gereja GBK...

 

Cruise ship Carnival Venezia Carnival Venezia at the Royal Naval Dockyard in Bermuda, 2023 History Bahamas NameCosta Venezia (2019–2023)Carnival Venezia (2023–present) NamesakeVenice, Italy OwnerCarnival Corporation & plc Operator Costa Cruises (2019–2023) Carnival Cruise Line (2023–present) Port of registry Genoa,  Italy (2019–2023) Nassau,  Bahamas (2023–present)[1] OrderedApril 2016 Builder Fincantieri Monfalcone, Italy Cost$780 million[2] Yard num...

American professional gamer (born 1992) XpecialChu in 2015Current teamTeamHarrisburg UniversityRoleCoachGameLeague of LegendsPersonal informationNameAlex ChuBorn1991 or 1992 (age 31–32)[1]Temple City, California, United StatesNationalityAmericanCareer informationPlaying career2011–2018RoleSupportCoaching career2018–presentTeam historyAs player:2011–2014Team SoloMid2014Team Curse2015Team Liquid2016Apex Gaming2017Team Dignitas2018Phoenix12018GGS AcademyAs coach:...

 

1959 Indian filmSumangaliTheatrical release posterDirected byM. K. R. NambiarScreenplay byEn Thangai Natarajan (dialogues)Story byVaduvur Duraisami IyengarProduced byV. ThandavamStarringK. BalajiE. V. SarojaC. S. PandianCinematographyS. S. NathanEdited byM. S. ParthasarathyMusic byM. Ranga RaoProductioncompanyRajeswari FilmsRelease date 14 January 1959 (1959-01-14) CountryIndiaLanguageTamil Sumangali is a 1959 Indian Tamil language drama film directed by M. K. R. Nambiar.[1...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!