DOC PREVIEW
Berkeley COMPSCI 164 - Bison and JBison

This preview shows page 1-2-3-4-5-6-7-8-9-63-64-65-66-67-68-69-70-71-126-127-128-129-130-131-132-133-134 out of 134 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 134 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

IntroductionConditions for Using BisonGNU GENERAL PUBLIC LICENSEPreambleTERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATIONAppendix: How to Apply These Terms to Your New ProgramsThe Concepts of BisonLanguages and Context-Free GrammarsFrom Formal Rules to Bison InputSemantic ValuesSemantic ActionsWriting GLR ParsersUsing GLR on Unambiguous GrammarsUsing GLR to Resolve AmbiguitiesConsiderations when Compiling GLR ParsersLocationsBison Output: the Parser FileStages in Using BisonThe Overall Layout of a Bison GrammarExamplesReverse Polish Notation CalculatorDeclarations for rpcalcGrammar Rules for rpcalcExplanation of inputExplanation of lineExplanation of exprThe rpcalc Lexical AnalyzerThe Controlling FunctionThe Error Reporting RoutineRunning Bison to Make the ParserCompiling the Parser FileInfix Notation Calculator: calcSimple Error RecoveryLocation Tracking Calculator: ltcalcDeclarations for ltcalcGrammar Rules for ltcalcThe ltcalc Lexical Analyzer.Multi-Function Calculator: mfcalcDeclarations for mfcalcGrammar Rules for mfcalcThe mfcalc Symbol TableExercisesBison Grammar FilesOutline of a Bison GrammarThe prologueThe Bison Declarations SectionThe Grammar Rules SectionThe epilogueSymbols, Terminal and NonterminalSyntax of Grammar RulesRecursive RulesDefining Language SemanticsData Types of Semantic ValuesMore Than One Value TypeActionsData Types of Values in ActionsActions in Mid-RuleTracking LocationsData Type of LocationsActions and LocationsDefault Action for LocationsBison DeclarationsToken Type NamesOperator PrecedenceThe Collection of Value TypesNonterminal SymbolsPerforming Actions before ParsingFreeing Discarded SymbolsSuppressing Conflict WarningsThe Start-SymbolA Pure (Reentrant) ParserBison Declaration SummaryMultiple Parsers in the Same ProgramParser C-Language InterfaceThe Parser Function yyparseThe Lexical Analyzer Function yylexCalling Convention for yylexSemantic Values of TokensTextual Locations of TokensCalling Conventions for Pure ParsersThe Error Reporting Function yyerrorSpecial Features for Use in ActionsJBison: A Java InterfaceThe generated Java parserAdditional declarations recognized by JBisonRunning JBisonThe Bison Parser AlgorithmLook-Ahead TokensShift/Reduce ConflictsOperator PrecedenceWhen Precedence is NeededSpecifying Operator PrecedencePrecedence ExamplesHow Precedence WorksContext-Dependent PrecedenceParser StatesReduce/Reduce ConflictsMysterious Reduce/Reduce ConflictsGeneralized LR (GLR) ParsingStack Overflow, and How to Avoid ItError RecoveryHandling Context DependenciesSemantic Info in Token TypesLexical Tie-insLexical Tie-ins and Error RecoveryDebugging Your ParserUnderstanding Your ParserTracing Your ParserInvoking BisonBison OptionsOption Cross KeyYacc LibraryFrequently Asked QuestionsParser Stack OverflowHow Can I Reset the ParserStrings are DestroyedC++ ParsersImplementing Gotos/LoopsBison SymbolsGlossaryCopying This ManualGNU Free Documentation LicenseADDENDUM: How to use this License for your documentsIndexBison and JBisonThe Yacc-compatible Parser Generator9 February 2005, Bison Version 2.0by Charles Donnelly and Richard StallmanThis manual is for GNU Bison (version 2.0, 9 February 2005), the GNU parser generator.Copyrightc 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1998, 1999, 2000, 2001, 2002, 2003,2004, 2005 Free Software Foundation, Inc.Permission is granted to copy, distribute and/or modify this document underthe terms of the GNU Free Documentation License, Version 1.1 or any laterversion published by the Free Software Foundation; with no Invariant Sections,with the Front-Cover texts being “A GNU Manual,” and with the Back-CoverTexts as in (a) below. A copy of the license is included in the section entitled“GNU Free Documentation License.”(a) The FSF’s Back-Cover Text is: “You have freedom to copy and modifythis GNU Manual, like GNU software. Copies published by the Free SoftwareFoundation raise funds for GNU development.”Published by the Free Software Foundation59 Temple Place, Suite 330Boston, MA 02111-1307 USAPrinted copies are available from the Free Software Foundation.ISBN 1-882114-44-2Cover art by Etienne Suvasa.iTable of ContentsIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Conditions for Using Bison . . . . . . . . . . . . . . . . . . . . 3GNU GENERAL PUBLIC LICENSE . . . . . . . . . . 5Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION ANDMODIFICATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Appendix: How to Apply These Terms to Your New Programs . . . . . 101 The Concepts of Bison . . . . . . . . . . . . . . . . . . . . 111.1 Languages and Context-Free Grammars . . . . . . . . . . . . . . . . . . . . . . 111.2 From Formal Rules to Bison Input . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.3 Semantic Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.4 Semantic Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.5 Writing GLR Parsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.5.1 Using GLR on Unambiguous Grammars . . . . . . . . . . . . . . . . . 151.5.2 Using GLR to Resolve Ambiguities . . . . . . . . . . . . . . . . . . . . . . 171.5.3 Considerations when Compiling GLR Parsers. . . . . . . . . . . . . 191.6 Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201.7 Bison Output: the Parser File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201.8 Stages in Using Bison. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211.9 The Overall Layout of a Bison Grammar . . . . . . . . . . . . . . . . . . . . . 212 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232.1 Reverse Polish Notation Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . 232.1.1 Declarations for rpcalc . . . . . . . . . …


View Full Document

Berkeley COMPSCI 164 - Bison and JBison

Documents in this Course
Lecture 8

Lecture 8

40 pages

Load more
Download Bison and JBison
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Bison and JBison and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Bison and JBison 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?