home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / info / bison.info-1 (.txt) < prev    next >
GNU Info File  |  1994-12-22  |  50KB  |  848 lines

  1. This is Info file bison.info, produced by Makeinfo-1.54 from the input
  2. file /home/gd2/gnu/bison/bison.texinfo.
  3.    This file documents the Bison parser generator.
  4.    Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation,
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided also
  10. that the sections entitled "GNU General Public License" and "Conditions
  11. for Using Bison" are included exactly as in the original, and provided
  12. that the entire resulting derived work is distributed under the terms
  13. of a permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that the sections entitled "GNU General Public
  17. License", "Conditions for Using Bison" and this permission notice may be
  18. included in translations approved by the Free Software Foundation
  19. instead of in the original English.
  20. File: bison.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  21.    This manual documents version 1.20 of Bison.
  22. * Menu:
  23. * Introduction::
  24. * Conditions::
  25. * Copying::           The GNU General Public License says
  26.                         how you can copy and share Bison
  27. Tutorial sections:
  28. * Concepts::          Basic concepts for understanding Bison.
  29. * Examples::          Three simple explained examples of using Bison.
  30. Reference sections:
  31. * Grammar File::      Writing Bison declarations and rules.
  32. * Interface::         C-language interface to the parser function `yyparse'.
  33. * Algorithm::         How the Bison parser works at run-time.
  34. * Error Recovery::    Writing rules for error recovery.
  35. * Context Dependency::  What to do if your language syntax is too
  36.                         messy for Bison to handle straightforwardly.
  37. * Debugging::         Debugging Bison parsers that parse wrong.
  38. * Invocation::        How to run Bison (to produce the parser source file).
  39. * Table of Symbols::  All the keywords of the Bison language are explained.
  40. * Glossary::          Basic concepts are explained.
  41. * Index::             Cross-references to the text.
  42.  -- The Detailed Node Listing --
  43. The Concepts of Bison
  44. * Language and Grammar::  Languages and context-free grammars,
  45.                             as mathematical ideas.
  46. * Grammar in Bison::  How we represent grammars for Bison's sake.
  47. * Semantic Values::   Each token or syntactic grouping can have
  48.                         a semantic value (the value of an integer,
  49.                         the name of an identifier, etc.).
  50. * Semantic Actions::  Each rule can have an action containing C code.
  51. * Bison Parser::      What are Bison's input and output,
  52.                         how is the output used?
  53. * Stages::            Stages in writing and running Bison grammars.
  54. * Grammar Layout::    Overall structure of a Bison grammar file.
  55. Examples
  56. * RPN Calc::          Reverse polish notation calculator;
  57.                         a first example with no operator precedence.
  58. * Infix Calc::        Infix (algebraic) notation calculator.
  59.                         Operator precedence is introduced.
  60. * Simple Error Recovery::  Continuing after syntax errors.
  61. * Multi-function Calc::    Calculator with memory and trig functions.
  62.                         It uses multiple data-types for semantic values.
  63. * Exercises::         Ideas for improving the multi-function calculator.
  64. Reverse Polish Notation Calculator
  65. * Decls: Rpcalc Decls.  Bison and C declarations for rpcalc.
  66. * Rules: Rpcalc Rules.  Grammar Rules for rpcalc, with explanation.
  67. * Lexer: Rpcalc Lexer.  The lexical analyzer.
  68. * Main: Rpcalc Main.    The controlling function.
  69. * Error: Rpcalc Error.  The error reporting function.
  70. * Gen: Rpcalc Gen.      Running Bison on the grammar file.
  71. * Comp: Rpcalc Compile. Run the C compiler on the output code.
  72. Grammar Rules for `rpcalc'
  73. * Rpcalc Input::
  74. * Rpcalc Line::
  75. * Rpcalc Expr::
  76. Multi-Function Calculator: `mfcalc'
  77. * Decl: Mfcalc Decl.      Bison declarations for multi-function calculator.
  78. * Rules: Mfcalc Rules.    Grammar rules for the calculator.
  79. * Symtab: Mfcalc Symtab.  Symbol table management subroutines.
  80. Bison Grammar Files
  81. * Grammar Outline::   Overall layout of the grammar file.
  82. * Symbols::           Terminal and nonterminal symbols.
  83. * Rules::             How to write grammar rules.
  84. * Recursion::         Writing recursive rules.
  85. * Semantics::         Semantic values and actions.
  86. * Declarations::      All kinds of Bison declarations are described here.
  87. * Multiple Parsers::  Putting more than one Bison parser in one program.
  88. Outline of a Bison Grammar
  89. * C Declarations::    Syntax and usage of the C declarations section.
  90. * Bison Declarations::  Syntax and usage of the Bison declarations section.
  91. * Grammar Rules::     Syntax and usage of the grammar rules section.
  92. * C Code::            Syntax and usage of the additional C code section.
  93. Defining Language Semantics
  94. * Value Type::        Specifying one data type for all semantic values.
  95. * Multiple Types::    Specifying several alternative data types.
  96. * Actions::           An action is the semantic definition of a grammar rule.
  97. * Action Types::      Specifying data types for actions to operate on.
  98. * Mid-Rule Actions::  Most actions go at the end of a rule.
  99.                       This says when, why and how to use the exceptional
  100.                         action in the middle of a rule.
  101. Bison Declarations
  102. * Token Decl::        Declaring terminal symbols.
  103. * Precedence Decl::   Declaring terminals with precedence and associativity.
  104. * Union Decl::        Declaring the set of all semantic value types.
  105. * Type Decl::         Declaring the choice of type for a nonterminal symbol.
  106. * Expect Decl::       Suppressing warnings about shift/reduce conflicts.
  107. * Start Decl::        Specifying the start symbol.
  108. * Pure Decl::         Requesting a reentrant parser.
  109. * Decl Summary::      Table of all Bison declarations.
  110. Parser C-Language Interface
  111. * Parser Function::   How to call `yyparse' and what it returns.
  112. * Lexical::           You must supply a function `yylex'
  113.                         which reads tokens.
  114. * Error Reporting::   You must supply a function `yyerror'.
  115. * Action Features::   Special features for use in actions.
  116. The Lexical Analyzer Function `yylex'
  117. * Calling Convention::  How `yyparse' calls `yylex'.
  118. * Token Values::      How `yylex' must return the semantic value
  119.                         of the token it has read.
  120. * Token Positions::   How `yylex' must return the text position
  121.                         (line number, etc.) of the token, if the
  122.                          actions want that.
  123. * Pure Calling::      How the calling convention differs
  124.                         in a pure parser (*note A Pure (Reentrant) Parser: Pure Decl.).
  125. The Bison Parser Algorithm
  126. * Look-Ahead::        Parser looks one token ahead when deciding what to do.
  127. * Shift/Reduce::      Conflicts: when either shifting or reduction is valid.
  128. * Precedence::        Operator precedence works by resolving conflicts.
  129. * Contextual Precedence::  When an operator's precedence depends on context.
  130. * Parser States::     The parser is a finite-state-machine with stack.
  131. * Reduce/Reduce::     When two rules are applicable in the same situation.
  132. * Mystery Conflicts::  Reduce/reduce conflicts that look unjustified.
  133. * Stack Overflow::    What happens when stack gets full.  How to avoid it.
  134. Operator Precedence
  135. * Why Precedence::    An example showing why precedence is needed.
  136. * Using Precedence::  How to specify precedence in Bison grammars.
  137. * Precedence Examples::  How these features are used in the previous example.
  138. * How Precedence::    How they work.
  139. Handling Context Dependencies
  140. * Semantic Tokens::   Token parsing can depend on the semantic context.
  141. * Lexical Tie-ins::   Token parsing can depend on the syntactic context.
  142. * Tie-in Recovery::   Lexical tie-ins have implications for how
  143.                         error recovery rules must be written.
  144. Invoking Bison
  145. * Bison Options::     All the opti