/usr/share/doc/bison-doc/html/index.html is in bison-doc 1:2.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | <html lang="en">
<head>
<title>Bison 2.5</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Bison 2.5">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="#Top">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual (14 May 2011) is for GNU Bison (version
2.5), the GNU parser generator.
Copyright (C) 1988-1993, 1995, 1998-2011 Free Software
Foundation, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, with the Front-Cover texts
being "A GNU Manual," and with the Back-Cover Texts 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 the freedom to copy and
modify this GNU manual. Buying copies from the FSF supports it in
developing GNU and promoting software freedom."
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<h1 class="settitle">Bison 2.5</h1>
<div class="contents">
<h2>Table of Contents</h2>
<ul>
<li><a name="toc_Top" href="index.html#Top">Bison</a>
<li><a name="toc_Introduction" href="Introduction.html#Introduction">Introduction</a>
<li><a name="toc_Conditions" href="Conditions.html#Conditions">Conditions for Using Bison</a>
<li><a name="toc_Copying" href="Copying.html#Copying">GNU GENERAL PUBLIC LICENSE</a>
<li><a name="toc_Concepts" href="Concepts.html#Concepts">1 The Concepts of Bison</a>
<ul>
<li><a href="Language-and-Grammar.html#Language-and-Grammar">1.1 Languages and Context-Free Grammars</a>
<li><a href="Grammar-in-Bison.html#Grammar-in-Bison">1.2 From Formal Rules to Bison Input</a>
<li><a href="Semantic-Values.html#Semantic-Values">1.3 Semantic Values</a>
<li><a href="Semantic-Actions.html#Semantic-Actions">1.4 Semantic Actions</a>
<li><a href="GLR-Parsers.html#GLR-Parsers">1.5 Writing GLR Parsers</a>
<ul>
<li><a href="Simple-GLR-Parsers.html#Simple-GLR-Parsers">1.5.1 Using GLR on Unambiguous Grammars</a>
<li><a href="Merging-GLR-Parses.html#Merging-GLR-Parses">1.5.2 Using GLR to Resolve Ambiguities</a>
<li><a href="GLR-Semantic-Actions.html#GLR-Semantic-Actions">1.5.3 GLR Semantic Actions</a>
<li><a href="Compiler-Requirements.html#Compiler-Requirements">1.5.4 Considerations when Compiling GLR Parsers</a>
</li></ul>
<li><a href="Locations-Overview.html#Locations-Overview">1.6 Locations</a>
<li><a href="Bison-Parser.html#Bison-Parser">1.7 Bison Output: the Parser Implementation File</a>
<li><a href="Stages.html#Stages">1.8 Stages in Using Bison</a>
<li><a href="Grammar-Layout.html#Grammar-Layout">1.9 The Overall Layout of a Bison Grammar</a>
</li></ul>
<li><a name="toc_Examples" href="Examples.html#Examples">2 Examples</a>
<ul>
<li><a href="RPN-Calc.html#RPN-Calc">2.1 Reverse Polish Notation Calculator</a>
<ul>
<li><a href="Rpcalc-Declarations.html#Rpcalc-Declarations">2.1.1 Declarations for <code>rpcalc</code></a>
<li><a href="Rpcalc-Rules.html#Rpcalc-Rules">2.1.2 Grammar Rules for <code>rpcalc</code></a>
<ul>
<li><a href="Rpcalc-Input.html#Rpcalc-Input">2.1.2.1 Explanation of <code>input</code></a>
<li><a href="Rpcalc-Line.html#Rpcalc-Line">2.1.2.2 Explanation of <code>line</code></a>
<li><a href="Rpcalc-Expr.html#Rpcalc-Expr">2.1.2.3 Explanation of <code>expr</code></a>
</li></ul>
<li><a href="Rpcalc-Lexer.html#Rpcalc-Lexer">2.1.3 The <code>rpcalc</code> Lexical Analyzer</a>
<li><a href="Rpcalc-Main.html#Rpcalc-Main">2.1.4 The Controlling Function</a>
<li><a href="Rpcalc-Error.html#Rpcalc-Error">2.1.5 The Error Reporting Routine</a>
<li><a href="Rpcalc-Generate.html#Rpcalc-Generate">2.1.6 Running Bison to Make the Parser</a>
<li><a href="Rpcalc-Compile.html#Rpcalc-Compile">2.1.7 Compiling the Parser Implementation File</a>
</li></ul>
<li><a href="Infix-Calc.html#Infix-Calc">2.2 Infix Notation Calculator: <code>calc</code></a>
<li><a href="Simple-Error-Recovery.html#Simple-Error-Recovery">2.3 Simple Error Recovery</a>
<li><a href="Location-Tracking-Calc.html#Location-Tracking-Calc">2.4 Location Tracking Calculator: <code>ltcalc</code></a>
<ul>
<li><a href="Ltcalc-Declarations.html#Ltcalc-Declarations">2.4.1 Declarations for <code>ltcalc</code></a>
<li><a href="Ltcalc-Rules.html#Ltcalc-Rules">2.4.2 Grammar Rules for <code>ltcalc</code></a>
<li><a href="Ltcalc-Lexer.html#Ltcalc-Lexer">2.4.3 The <code>ltcalc</code> Lexical Analyzer.</a>
</li></ul>
<li><a href="Multi_002dfunction-Calc.html#Multi_002dfunction-Calc">2.5 Multi-Function Calculator: <code>mfcalc</code></a>
<ul>
<li><a href="Mfcalc-Declarations.html#Mfcalc-Declarations">2.5.1 Declarations for <code>mfcalc</code></a>
<li><a href="Mfcalc-Rules.html#Mfcalc-Rules">2.5.2 Grammar Rules for <code>mfcalc</code></a>
<li><a href="Mfcalc-Symbol-Table.html#Mfcalc-Symbol-Table">2.5.3 The <code>mfcalc</code> Symbol Table</a>
</li></ul>
<li><a href="Exercises.html#Exercises">2.6 Exercises</a>
</li></ul>
<li><a name="toc_Grammar-File" href="Grammar-File.html#Grammar-File">3 Bison Grammar Files</a>
<ul>
<li><a href="Grammar-Outline.html#Grammar-Outline">3.1 Outline of a Bison Grammar</a>
<ul>
<li><a href="Prologue.html#Prologue">3.1.1 The prologue</a>
<li><a href="Prologue-Alternatives.html#Prologue-Alternatives">3.1.2 Prologue Alternatives</a>
<li><a href="Bison-Declarations.html#Bison-Declarations">3.1.3 The Bison Declarations Section</a>
<li><a href="Grammar-Rules.html#Grammar-Rules">3.1.4 The Grammar Rules Section</a>
<li><a href="Epilogue.html#Epilogue">3.1.5 The epilogue</a>
</li></ul>
<li><a href="Symbols.html#Symbols">3.2 Symbols, Terminal and Nonterminal</a>
<li><a href="Rules.html#Rules">3.3 Syntax of Grammar Rules</a>
<li><a href="Recursion.html#Recursion">3.4 Recursive Rules</a>
<li><a href="Semantics.html#Semantics">3.5 Defining Language Semantics</a>
<ul>
<li><a href="Value-Type.html#Value-Type">3.5.1 Data Types of Semantic Values</a>
<li><a href="Multiple-Types.html#Multiple-Types">3.5.2 More Than One Value Type</a>
<li><a href="Actions.html#Actions">3.5.3 Actions</a>
<li><a href="Action-Types.html#Action-Types">3.5.4 Data Types of Values in Actions</a>
<li><a href="Mid_002dRule-Actions.html#Mid_002dRule-Actions">3.5.5 Actions in Mid-Rule</a>
<li><a href="Named-References.html#Named-References">3.5.6 Using Named References</a>
</li></ul>
<li><a href="Locations.html#Locations">3.6 Tracking Locations</a>
<ul>
<li><a href="Location-Type.html#Location-Type">3.6.1 Data Type of Locations</a>
<li><a href="Actions-and-Locations.html#Actions-and-Locations">3.6.2 Actions and Locations</a>
<li><a href="Location-Default-Action.html#Location-Default-Action">3.6.3 Default Action for Locations</a>
</li></ul>
<li><a href="Declarations.html#Declarations">3.7 Bison Declarations</a>
<ul>
<li><a href="Require-Decl.html#Require-Decl">3.7.1 Require a Version of Bison</a>
<li><a href="Token-Decl.html#Token-Decl">3.7.2 Token Type Names</a>
<li><a href="Precedence-Decl.html#Precedence-Decl">3.7.3 Operator Precedence</a>
<li><a href="Union-Decl.html#Union-Decl">3.7.4 The Collection of Value Types</a>
<li><a href="Type-Decl.html#Type-Decl">3.7.5 Nonterminal Symbols</a>
<li><a href="Initial-Action-Decl.html#Initial-Action-Decl">3.7.6 Performing Actions before Parsing</a>
<li><a href="Destructor-Decl.html#Destructor-Decl">3.7.7 Freeing Discarded Symbols</a>
<li><a href="Expect-Decl.html#Expect-Decl">3.7.8 Suppressing Conflict Warnings</a>
<li><a href="Start-Decl.html#Start-Decl">3.7.9 The Start-Symbol</a>
<li><a href="Pure-Decl.html#Pure-Decl">3.7.10 A Pure (Reentrant) Parser</a>
<li><a href="Push-Decl.html#Push-Decl">3.7.11 A Push Parser</a>
<li><a href="Decl-Summary.html#Decl-Summary">3.7.12 Bison Declaration Summary</a>
<li><a href="_0025define-Summary.html#_0025define-Summary">3.7.13 %define Summary</a>
<li><a href="_0025code-Summary.html#_0025code-Summary">3.7.14 %code Summary</a>
</li></ul>
<li><a href="Multiple-Parsers.html#Multiple-Parsers">3.8 Multiple Parsers in the Same Program</a>
</li></ul>
<li><a name="toc_Interface" href="Interface.html#Interface">4 Parser C-Language Interface</a>
<ul>
<li><a href="Parser-Function.html#Parser-Function">4.1 The Parser Function <code>yyparse</code></a>
<li><a href="Push-Parser-Function.html#Push-Parser-Function">4.2 The Push Parser Function <code>yypush_parse</code></a>
<li><a href="Pull-Parser-Function.html#Pull-Parser-Function">4.3 The Pull Parser Function <code>yypull_parse</code></a>
<li><a href="Parser-Create-Function.html#Parser-Create-Function">4.4 The Parser Create Function <code>yystate_new</code></a>
<li><a href="Parser-Delete-Function.html#Parser-Delete-Function">4.5 The Parser Delete Function <code>yystate_delete</code></a>
<li><a href="Lexical.html#Lexical">4.6 The Lexical Analyzer Function <code>yylex</code></a>
<ul>
<li><a href="Calling-Convention.html#Calling-Convention">4.6.1 Calling Convention for <code>yylex</code></a>
<li><a href="Token-Values.html#Token-Values">4.6.2 Semantic Values of Tokens</a>
<li><a href="Token-Locations.html#Token-Locations">4.6.3 Textual Locations of Tokens</a>
<li><a href="Pure-Calling.html#Pure-Calling">4.6.4 Calling Conventions for Pure Parsers</a>
</li></ul>
<li><a href="Error-Reporting.html#Error-Reporting">4.7 The Error Reporting Function <code>yyerror</code></a>
<li><a href="Action-Features.html#Action-Features">4.8 Special Features for Use in Actions</a>
<li><a href="Internationalization.html#Internationalization">4.9 Parser Internationalization</a>
</li></ul>
<li><a name="toc_Algorithm" href="Algorithm.html#Algorithm">5 The Bison Parser Algorithm</a>
<ul>
<li><a href="Lookahead.html#Lookahead">5.1 Lookahead Tokens</a>
<li><a href="Shift_002fReduce.html#Shift_002fReduce">5.2 Shift/Reduce Conflicts</a>
<li><a href="Precedence.html#Precedence">5.3 Operator Precedence</a>
<ul>
<li><a href="Why-Precedence.html#Why-Precedence">5.3.1 When Precedence is Needed</a>
<li><a href="Using-Precedence.html#Using-Precedence">5.3.2 Specifying Operator Precedence</a>
<li><a href="Precedence-Examples.html#Precedence-Examples">5.3.3 Precedence Examples</a>
<li><a href="How-Precedence.html#How-Precedence">5.3.4 How Precedence Works</a>
</li></ul>
<li><a href="Contextual-Precedence.html#Contextual-Precedence">5.4 Context-Dependent Precedence</a>
<li><a href="Parser-States.html#Parser-States">5.5 Parser States</a>
<li><a href="Reduce_002fReduce.html#Reduce_002fReduce">5.6 Reduce/Reduce Conflicts</a>
<li><a href="Mysterious-Conflicts.html#Mysterious-Conflicts">5.7 Mysterious Conflicts</a>
<li><a href="Tuning-LR.html#Tuning-LR">5.8 Tuning LR</a>
<ul>
<li><a href="LR-Table-Construction.html#LR-Table-Construction">5.8.1 LR Table Construction</a>
<li><a href="Default-Reductions.html#Default-Reductions">5.8.2 Default Reductions</a>
<li><a href="LAC.html#LAC">5.8.3 LAC</a>
<li><a href="Unreachable-States.html#Unreachable-States">5.8.4 Unreachable States</a>
</li></ul>
<li><a href="Generalized-LR-Parsing.html#Generalized-LR-Parsing">5.9 Generalized LR (GLR) Parsing</a>
<li><a href="Memory-Management.html#Memory-Management">5.10 Memory Management, and How to Avoid Memory Exhaustion</a>
</li></ul>
<li><a name="toc_Error-Recovery" href="Error-Recovery.html#Error-Recovery">6 Error Recovery</a>
<li><a name="toc_Context-Dependency" href="Context-Dependency.html#Context-Dependency">7 Handling Context Dependencies</a>
<ul>
<li><a href="Semantic-Tokens.html#Semantic-Tokens">7.1 Semantic Info in Token Types</a>
<li><a href="Lexical-Tie_002dins.html#Lexical-Tie_002dins">7.2 Lexical Tie-ins</a>
<li><a href="Tie_002din-Recovery.html#Tie_002din-Recovery">7.3 Lexical Tie-ins and Error Recovery</a>
</li></ul>
<li><a name="toc_Debugging" href="Debugging.html#Debugging">8 Debugging Your Parser</a>
<ul>
<li><a href="Understanding.html#Understanding">8.1 Understanding Your Parser</a>
<li><a href="Tracing.html#Tracing">8.2 Tracing Your Parser</a>
</li></ul>
<li><a name="toc_Invocation" href="Invocation.html#Invocation">9 Invoking Bison</a>
<ul>
<li><a href="Bison-Options.html#Bison-Options">9.1 Bison Options</a>
<li><a href="Option-Cross-Key.html#Option-Cross-Key">9.2 Option Cross Key</a>
<li><a href="Yacc-Library.html#Yacc-Library">9.3 Yacc Library</a>
</li></ul>
<li><a name="toc_Other-Languages" href="Other-Languages.html#Other-Languages">10 Parsers Written In Other Languages</a>
<ul>
<li><a href="C_002b_002b-Parsers.html#C_002b_002b-Parsers">10.1 C++ Parsers</a>
<ul>
<li><a href="C_002b_002b-Bison-Interface.html#C_002b_002b-Bison-Interface">10.1.1 C++ Bison Interface</a>
<li><a href="C_002b_002b-Semantic-Values.html#C_002b_002b-Semantic-Values">10.1.2 C++ Semantic Values</a>
<li><a href="C_002b_002b-Location-Values.html#C_002b_002b-Location-Values">10.1.3 C++ Location Values</a>
<li><a href="C_002b_002b-Parser-Interface.html#C_002b_002b-Parser-Interface">10.1.4 C++ Parser Interface</a>
<li><a href="C_002b_002b-Scanner-Interface.html#C_002b_002b-Scanner-Interface">10.1.5 C++ Scanner Interface</a>
<li><a href="A-Complete-C_002b_002b-Example.html#A-Complete-C_002b_002b-Example">10.1.6 A Complete C++ Example</a>
<ul>
<li><a href="Calc_002b_002b-_002d_002d_002d-C_002b_002b-Calculator.html#Calc_002b_002b-_002d_002d_002d-C_002b_002b-Calculator">10.1.6.1 Calc++ — C++ Calculator</a>
<li><a href="Calc_002b_002b-Parsing-Driver.html#Calc_002b_002b-Parsing-Driver">10.1.6.2 Calc++ Parsing Driver</a>
<li><a href="Calc_002b_002b-Parser.html#Calc_002b_002b-Parser">10.1.6.3 Calc++ Parser</a>
<li><a href="Calc_002b_002b-Scanner.html#Calc_002b_002b-Scanner">10.1.6.4 Calc++ Scanner</a>
<li><a href="Calc_002b_002b-Top-Level.html#Calc_002b_002b-Top-Level">10.1.6.5 Calc++ Top Level</a>
</li></ul>
</li></ul>
<li><a href="Java-Parsers.html#Java-Parsers">10.2 Java Parsers</a>
<ul>
<li><a href="Java-Bison-Interface.html#Java-Bison-Interface">10.2.1 Java Bison Interface</a>
<li><a href="Java-Semantic-Values.html#Java-Semantic-Values">10.2.2 Java Semantic Values</a>
<li><a href="Java-Location-Values.html#Java-Location-Values">10.2.3 Java Location Values</a>
<li><a href="Java-Parser-Interface.html#Java-Parser-Interface">10.2.4 Java Parser Interface</a>
<li><a href="Java-Scanner-Interface.html#Java-Scanner-Interface">10.2.5 Java Scanner Interface</a>
<li><a href="Java-Action-Features.html#Java-Action-Features">10.2.6 Special Features for Use in Java Actions</a>
<li><a href="Java-Differences.html#Java-Differences">10.2.7 Differences between C/C++ and Java Grammars</a>
<li><a href="Java-Declarations-Summary.html#Java-Declarations-Summary">10.2.8 Java Declarations Summary</a>
</li></ul>
</li></ul>
<li><a name="toc_FAQ" href="FAQ.html#FAQ">11 Frequently Asked Questions</a>
<ul>
<li><a href="Memory-Exhausted.html#Memory-Exhausted">11.1 Memory Exhausted</a>
<li><a href="How-Can-I-Reset-the-Parser.html#How-Can-I-Reset-the-Parser">11.2 How Can I Reset the Parser</a>
<li><a href="Strings-are-Destroyed.html#Strings-are-Destroyed">11.3 Strings are Destroyed</a>
<li><a href="Implementing-Gotos_002fLoops.html#Implementing-Gotos_002fLoops">11.4 Implementing Gotos/Loops</a>
<li><a href="Multiple-start_002dsymbols.html#Multiple-start_002dsymbols">11.5 Multiple start-symbols</a>
<li><a href="Secure_003f-Conform_003f.html#Secure_003f-Conform_003f">11.6 Secure? Conform?</a>
<li><a href="I-can_0027t-build-Bison.html#I-can_0027t-build-Bison">11.7 I can't build Bison</a>
<li><a href="Where-can-I-find-help_003f.html#Where-can-I-find-help_003f">11.8 Where can I find help?</a>
<li><a href="Bug-Reports.html#Bug-Reports">11.9 Bug Reports</a>
<li><a href="More-Languages.html#More-Languages">11.10 More Languages</a>
<li><a href="Beta-Testing.html#Beta-Testing">11.11 Beta Testing</a>
<li><a href="Mailing-Lists.html#Mailing-Lists">11.12 Mailing Lists</a>
</li></ul>
<li><a name="toc_Table-of-Symbols" href="Table-of-Symbols.html#Table-of-Symbols">Appendix A Bison Symbols</a>
<li><a name="toc_Glossary" href="Glossary.html#Glossary">Appendix B Glossary</a>
<li><a name="toc_Copying-This-Manual" href="Copying-This-Manual.html#Copying-This-Manual">Appendix C Copying This Manual</a>
<li><a name="toc_Bibliography" href="Bibliography.html#Bibliography">Bibliography</a>
<li><a name="toc_Index" href="Index.html#Index">Index</a>
</li></ul>
</div>
<div class="node">
<a name="Top"></a>
<p>
Next: <a rel="next" accesskey="n" href="Introduction.html#Introduction">Introduction</a>,
Up: <a rel="up" accesskey="u" href="../index.html#dir">(dir)</a>
<hr>
</div>
<h2 class="unnumbered">Bison</h2>
<p>This manual (14 May 2011) is for GNU Bison (version
2.5), the GNU parser generator.
<p>Copyright © 1988-1993, 1995, 1998-2011 Free Software
Foundation, Inc.
<blockquote>
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, with the Front-Cover texts
being “A GNU Manual,” and with the Back-Cover Texts as in
(a) below. A copy of the license is included in the section entitled
“GNU Free Documentation License.”
<p>(a) The FSF's Back-Cover Text is: “You have the freedom to copy and
modify this GNU manual. Buying copies from the FSF
supports it in developing GNU and promoting software
freedom.”
</blockquote>
<ul class="menu">
<li><a accesskey="1" href="Introduction.html#Introduction">Introduction</a>
<li><a accesskey="2" href="Conditions.html#Conditions">Conditions</a>
<li><a accesskey="3" href="Copying.html#Copying">Copying</a>: The GNU General Public License says
how you can copy and share Bison.
</li></ul>
<p>Tutorial sections:
</p>
<ul class="menu">
<li><a accesskey="4" href="Concepts.html#Concepts">Concepts</a>: Basic concepts for understanding Bison.
<li><a accesskey="5" href="Examples.html#Examples">Examples</a>: Three simple explained examples of using Bison.
</li></ul>
<p>Reference sections:
</p>
<ul class="menu">
<li><a accesskey="6" href="Grammar-File.html#Grammar-File">Grammar File</a>: Writing Bison declarations and rules.
<li><a accesskey="7" href="Interface.html#Interface">Interface</a>: C-language interface to the parser function <code>yyparse</code>.
<li><a accesskey="8" href="Algorithm.html#Algorithm">Algorithm</a>: How the Bison parser works at run-time.
<li><a accesskey="9" href="Error-Recovery.html#Error-Recovery">Error Recovery</a>: Writing rules for error recovery.
<li><a href="Context-Dependency.html#Context-Dependency">Context Dependency</a>: What to do if your language syntax is too
messy for Bison to handle straightforwardly.
<li><a href="Debugging.html#Debugging">Debugging</a>: Understanding or debugging Bison parsers.
<li><a href="Invocation.html#Invocation">Invocation</a>: How to run Bison (to produce the parser implementation).
<li><a href="Other-Languages.html#Other-Languages">Other Languages</a>: Creating C++ and Java parsers.
<li><a href="FAQ.html#FAQ">FAQ</a>: Frequently Asked Questions
<li><a href="Table-of-Symbols.html#Table-of-Symbols">Table of Symbols</a>: All the keywords of the Bison language are explained.
<li><a href="Glossary.html#Glossary">Glossary</a>: Basic concepts are explained.
<li><a href="Copying-This-Manual.html#Copying-This-Manual">Copying This Manual</a>: License for copying this manual.
<li><a href="Bibliography.html#Bibliography">Bibliography</a>: Publications cited in this manual.
<li><a href="Index.html#Index">Index</a>: Cross-references to the text.
</li></ul>
<p>--- The Detailed Node Listing ---
<p>The Concepts of Bison
</p>
<ul class="menu">
<li><a href="Language-and-Grammar.html#Language-and-Grammar">Language and Grammar</a>: Languages and context-free grammars,
as mathematical ideas.
<li><a href="Grammar-in-Bison.html#Grammar-in-Bison">Grammar in Bison</a>: How we represent grammars for Bison's sake.
<li><a href="Semantic-Values.html#Semantic-Values">Semantic Values</a>: Each token or syntactic grouping can have
a semantic value (the value of an integer,
the name of an identifier, etc.).
<li><a href="Semantic-Actions.html#Semantic-Actions">Semantic Actions</a>: Each rule can have an action containing C code.
<li><a href="GLR-Parsers.html#GLR-Parsers">GLR Parsers</a>: Writing parsers for general context-free languages.
<li><a href="Locations-Overview.html#Locations-Overview">Locations Overview</a>: Tracking Locations.
<li><a href="Bison-Parser.html#Bison-Parser">Bison Parser</a>: What are Bison's input and output,
how is the output used?
<li><a href="Stages.html#Stages">Stages</a>: Stages in writing and running Bison grammars.
<li><a href="Grammar-Layout.html#Grammar-Layout">Grammar Layout</a>: Overall structure of a Bison grammar file.
</li></ul>
<p>Writing GLR Parsers
</p>
<ul class="menu">
<li><a href="Simple-GLR-Parsers.html#Simple-GLR-Parsers">Simple GLR Parsers</a>: Using GLR parsers on unambiguous grammars.
<li><a href="Merging-GLR-Parses.html#Merging-GLR-Parses">Merging GLR Parses</a>: Using GLR parsers to resolve ambiguities.
<li><a href="GLR-Semantic-Actions.html#GLR-Semantic-Actions">GLR Semantic Actions</a>: Deferred semantic actions have special concerns.
<li><a href="Compiler-Requirements.html#Compiler-Requirements">Compiler Requirements</a>: GLR parsers require a modern C compiler.
</li></ul>
<p>Examples
</p>
<ul class="menu">
<li><a href="RPN-Calc.html#RPN-Calc">RPN Calc</a>: Reverse polish notation calculator;
a first example with no operator precedence.
<li><a href="Infix-Calc.html#Infix-Calc">Infix Calc</a>: Infix (algebraic) notation calculator.
Operator precedence is introduced.
<li><a href="Simple-Error-Recovery.html#Simple-Error-Recovery">Simple Error Recovery</a>: Continuing after syntax errors.
<li><a href="Location-Tracking-Calc.html#Location-Tracking-Calc">Location Tracking Calc</a>: Demonstrating the use of @<var>n</var> and @$.
<li><a href="Multi_002dfunction-Calc.html#Multi_002dfunction-Calc">Multi-function Calc</a>: Calculator with memory and trig functions.
It uses multiple data-types for semantic values.
<li><a href="Exercises.html#Exercises">Exercises</a>: Ideas for improving the multi-function calculator.
</li></ul>
<p>Reverse Polish Notation Calculator
</p>
<ul class="menu">
<li><a href="Rpcalc-Declarations.html#Rpcalc-Declarations">Rpcalc Declarations</a>: Prologue (declarations) for rpcalc.
<li><a href="Rpcalc-Rules.html#Rpcalc-Rules">Rpcalc Rules</a>: Grammar Rules for rpcalc, with explanation.
<li><a href="Rpcalc-Lexer.html#Rpcalc-Lexer">Rpcalc Lexer</a>: The lexical analyzer.
<li><a href="Rpcalc-Main.html#Rpcalc-Main">Rpcalc Main</a>: The controlling function.
<li><a href="Rpcalc-Error.html#Rpcalc-Error">Rpcalc Error</a>: The error reporting function.
<li><a href="Rpcalc-Generate.html#Rpcalc-Generate">Rpcalc Generate</a>: Running Bison on the grammar file.
<li><a href="Rpcalc-Compile.html#Rpcalc-Compile">Rpcalc Compile</a>: Run the C compiler on the output code.
</li></ul>
<p>Grammar Rules for <code>rpcalc</code>
</p>
<ul class="menu">
<li><a href="Rpcalc-Input.html#Rpcalc-Input">Rpcalc Input</a>
<li><a href="Rpcalc-Line.html#Rpcalc-Line">Rpcalc Line</a>
<li><a href="Rpcalc-Expr.html#Rpcalc-Expr">Rpcalc Expr</a>
</li></ul>
<p>Location Tracking Calculator: <code>ltcalc</code>
</p>
<ul class="menu">
<li><a href="Ltcalc-Declarations.html#Ltcalc-Declarations">Ltcalc Declarations</a>: Bison and C declarations for ltcalc.
<li><a href="Ltcalc-Rules.html#Ltcalc-Rules">Ltcalc Rules</a>: Grammar rules for ltcalc, with explanations.
<li><a href="Ltcalc-Lexer.html#Ltcalc-Lexer">Ltcalc Lexer</a>: The lexical analyzer.
</li></ul>
<p>Multi-Function Calculator: <code>mfcalc</code>
</p>
<ul class="menu">
<li><a href="Mfcalc-Declarations.html#Mfcalc-Declarations">Mfcalc Declarations</a>: Bison declarations for multi-function calculator.
<li><a href="Mfcalc-Rules.html#Mfcalc-Rules">Mfcalc Rules</a>: Grammar rules for the calculator.
<li><a href="Mfcalc-Symbol-Table.html#Mfcalc-Symbol-Table">Mfcalc Symbol Table</a>: Symbol table management subroutines.
</li></ul>
<p>Bison Grammar Files
</p>
<ul class="menu">
<li><a href="Grammar-Outline.html#Grammar-Outline">Grammar Outline</a>: Overall layout of the grammar file.
<li><a href="Symbols.html#Symbols">Symbols</a>: Terminal and nonterminal symbols.
<li><a href="Rules.html#Rules">Rules</a>: How to write grammar rules.
<li><a href="Recursion.html#Recursion">Recursion</a>: Writing recursive rules.
<li><a href="Semantics.html#Semantics">Semantics</a>: Semantic values and actions.
<li><a href="Locations.html#Locations">Locations</a>: Locations and actions.
<li><a href="Declarations.html#Declarations">Declarations</a>: All kinds of Bison declarations are described here.
<li><a href="Multiple-Parsers.html#Multiple-Parsers">Multiple Parsers</a>: Putting more than one Bison parser in one program.
</li></ul>
<p>Outline of a Bison Grammar
</p>
<ul class="menu">
<li><a href="Prologue.html#Prologue">Prologue</a>: Syntax and usage of the prologue.
<li><a href="Prologue-Alternatives.html#Prologue-Alternatives">Prologue Alternatives</a>: Syntax and usage of alternatives to the prologue.
<li><a href="Bison-Declarations.html#Bison-Declarations">Bison Declarations</a>: Syntax and usage of the Bison declarations section.
<li><a href="Grammar-Rules.html#Grammar-Rules">Grammar Rules</a>: Syntax and usage of the grammar rules section.
<li><a href="Epilogue.html#Epilogue">Epilogue</a>: Syntax and usage of the epilogue.
</li></ul>
<p>Defining Language Semantics
</p>
<ul class="menu">
<li><a href="Value-Type.html#Value-Type">Value Type</a>: Specifying one data type for all semantic values.
<li><a href="Multiple-Types.html#Multiple-Types">Multiple Types</a>: Specifying several alternative data types.
<li><a href="Actions.html#Actions">Actions</a>: An action is the semantic definition of a grammar rule.
<li><a href="Action-Types.html#Action-Types">Action Types</a>: Specifying data types for actions to operate on.
<li><a href="Mid_002dRule-Actions.html#Mid_002dRule-Actions">Mid-Rule Actions</a>: Most actions go at the end of a rule.
This says when, why and how to use the exceptional
action in the middle of a rule.
<li><a href="Named-References.html#Named-References">Named References</a>: Using named references in actions.
</li></ul>
<p>Tracking Locations
</p>
<ul class="menu">
<li><a href="Location-Type.html#Location-Type">Location Type</a>: Specifying a data type for locations.
<li><a href="Actions-and-Locations.html#Actions-and-Locations">Actions and Locations</a>: Using locations in actions.
<li><a href="Location-Default-Action.html#Location-Default-Action">Location Default Action</a>: Defining a general way to compute locations.
</li></ul>
<p>Bison Declarations
</p>
<ul class="menu">
<li><a href="Require-Decl.html#Require-Decl">Require Decl</a>: Requiring a Bison version.
<li><a href="Token-Decl.html#Token-Decl">Token Decl</a>: Declaring terminal symbols.
<li><a href="Precedence-Decl.html#Precedence-Decl">Precedence Decl</a>: Declaring terminals with precedence and associativity.
<li><a href="Union-Decl.html#Union-Decl">Union Decl</a>: Declaring the set of all semantic value types.
<li><a href="Type-Decl.html#Type-Decl">Type Decl</a>: Declaring the choice of type for a nonterminal symbol.
<li><a href="Initial-Action-Decl.html#Initial-Action-Decl">Initial Action Decl</a>: Code run before parsing starts.
<li><a href="Destructor-Decl.html#Destructor-Decl">Destructor Decl</a>: Declaring how symbols are freed.
<li><a href="Expect-Decl.html#Expect-Decl">Expect Decl</a>: Suppressing warnings about parsing conflicts.
<li><a href="Start-Decl.html#Start-Decl">Start Decl</a>: Specifying the start symbol.
<li><a href="Pure-Decl.html#Pure-Decl">Pure Decl</a>: Requesting a reentrant parser.
<li><a href="Push-Decl.html#Push-Decl">Push Decl</a>: Requesting a push parser.
<li><a href="Decl-Summary.html#Decl-Summary">Decl Summary</a>: Table of all Bison declarations.
<li><a href="_0025define-Summary.html#g_t_0025define-Summary">%define Summary</a>: Defining variables to adjust Bison's behavior.
<li><a href="_0025code-Summary.html#g_t_0025code-Summary">%code Summary</a>: Inserting code into the parser source.
</li></ul>
<p>Parser C-Language Interface
</p>
<ul class="menu">
<li><a href="Parser-Function.html#Parser-Function">Parser Function</a>: How to call <code>yyparse</code> and what it returns.
<li><a href="Push-Parser-Function.html#Push-Parser-Function">Push Parser Function</a>: How to call <code>yypush_parse</code> and what it returns.
<li><a href="Pull-Parser-Function.html#Pull-Parser-Function">Pull Parser Function</a>: How to call <code>yypull_parse</code> and what it returns.
<li><a href="Parser-Create-Function.html#Parser-Create-Function">Parser Create Function</a>: How to call <code>yypstate_new</code> and what it returns.
<li><a href="Parser-Delete-Function.html#Parser-Delete-Function">Parser Delete Function</a>: How to call <code>yypstate_delete</code> and what it returns.
<li><a href="Lexical.html#Lexical">Lexical</a>: You must supply a function <code>yylex</code>
which reads tokens.
<li><a href="Error-Reporting.html#Error-Reporting">Error Reporting</a>: You must supply a function <code>yyerror</code>.
<li><a href="Action-Features.html#Action-Features">Action Features</a>: Special features for use in actions.
<li><a href="Internationalization.html#Internationalization">Internationalization</a>: How to let the parser speak in the user's
native language.
</li></ul>
<p>The Lexical Analyzer Function <code>yylex</code>
</p>
<ul class="menu">
<li><a href="Calling-Convention.html#Calling-Convention">Calling Convention</a>: How <code>yyparse</code> calls <code>yylex</code>.
<li><a href="Token-Values.html#Token-Values">Token Values</a>: How <code>yylex</code> must return the semantic value
of the token it has read.
<li><a href="Token-Locations.html#Token-Locations">Token Locations</a>: How <code>yylex</code> must return the text location
(line number, etc.) of the token, if the
actions want that.
<li><a href="Pure-Calling.html#Pure-Calling">Pure Calling</a>: How the calling convention differs in a pure parser
(see <a href="Pure-Decl.html#Pure-Decl">A Pure (Reentrant) Parser</a>).
</li></ul>
<p>The Bison Parser Algorithm
</p>
<ul class="menu">
<li><a href="Lookahead.html#Lookahead">Lookahead</a>: Parser looks one token ahead when deciding what to do.
<li><a href="Shift_002fReduce.html#Shift_002fReduce">Shift/Reduce</a>: Conflicts: when either shifting or reduction is valid.
<li><a href="Precedence.html#Precedence">Precedence</a>: Operator precedence works by resolving conflicts.
<li><a href="Contextual-Precedence.html#Contextual-Precedence">Contextual Precedence</a>: When an operator's precedence depends on context.
<li><a href="Parser-States.html#Parser-States">Parser States</a>: The parser is a finite-state-machine with stack.
<li><a href="Reduce_002fReduce.html#Reduce_002fReduce">Reduce/Reduce</a>: When two rules are applicable in the same situation.
<li><a href="Mysterious-Conflicts.html#Mysterious-Conflicts">Mysterious Conflicts</a>: Conflicts that look unjustified.
<li><a href="Tuning-LR.html#Tuning-LR">Tuning LR</a>: How to tune fundamental aspects of LR-based parsing.
<li><a href="Generalized-LR-Parsing.html#Generalized-LR-Parsing">Generalized LR Parsing</a>: Parsing arbitrary context-free grammars.
<li><a href="Memory-Management.html#Memory-Management">Memory Management</a>: What happens when memory is exhausted. How to avoid it.
</li></ul>
<p>Operator Precedence
</p>
<ul class="menu">
<li><a href="Why-Precedence.html#Why-Precedence">Why Precedence</a>: An example showing why precedence is needed.
<li><a href="Using-Precedence.html#Using-Precedence">Using Precedence</a>: How to specify precedence in Bison grammars.
<li><a href="Precedence-Examples.html#Precedence-Examples">Precedence Examples</a>: How these features are used in the previous example.
<li><a href="How-Precedence.html#How-Precedence">How Precedence</a>: How they work.
</li></ul>
<p>Tuning LR
</p>
<ul class="menu">
<li><a href="LR-Table-Construction.html#LR-Table-Construction">LR Table Construction</a>: Choose a different construction algorithm.
<li><a href="Default-Reductions.html#Default-Reductions">Default Reductions</a>: Disable default reductions.
<li><a href="LAC.html#LAC">LAC</a>: Correct lookahead sets in the parser states.
<li><a href="Unreachable-States.html#Unreachable-States">Unreachable States</a>: Keep unreachable parser states for debugging.
</li></ul>
<p>Handling Context Dependencies
</p>
<ul class="menu">
<li><a href="Semantic-Tokens.html#Semantic-Tokens">Semantic Tokens</a>: Token parsing can depend on the semantic context.
<li><a href="Lexical-Tie_002dins.html#Lexical-Tie_002dins">Lexical Tie-ins</a>: Token parsing can depend on the syntactic context.
<li><a href="Tie_002din-Recovery.html#Tie_002din-Recovery">Tie-in Recovery</a>: Lexical tie-ins have implications for how
error recovery rules must be written.
</li></ul>
<p>Debugging Your Parser
</p>
<ul class="menu">
<li><a href="Understanding.html#Understanding">Understanding</a>: Understanding the structure of your parser.
<li><a href="Tracing.html#Tracing">Tracing</a>: Tracing the execution of your parser.
</li></ul>
<p>Invoking Bison
</p>
<ul class="menu">
<li><a href="Bison-Options.html#Bison-Options">Bison Options</a>: All the options described in detail,
in alphabetical order by short options.
<li><a href="Option-Cross-Key.html#Option-Cross-Key">Option Cross Key</a>: Alphabetical list of long options.
<li><a href="Yacc-Library.html#Yacc-Library">Yacc Library</a>: Yacc-compatible <code>yylex</code> and <code>main</code>.
</li></ul>
<p>Parsers Written In Other Languages
</p>
<ul class="menu">
<li><a href="C_002b_002b-Parsers.html#C_002b_002b-Parsers">C++ Parsers</a>: The interface to generate C++ parser classes
<li><a href="Java-Parsers.html#Java-Parsers">Java Parsers</a>: The interface to generate Java parser classes
</li></ul>
<p>C++ Parsers
</p>
<ul class="menu">
<li><a href="C_002b_002b-Bison-Interface.html#C_002b_002b-Bison-Interface">C++ Bison Interface</a>: Asking for C++ parser generation
<li><a href="C_002b_002b-Semantic-Values.html#C_002b_002b-Semantic-Values">C++ Semantic Values</a>: %union vs. C++
<li><a href="C_002b_002b-Location-Values.html#C_002b_002b-Location-Values">C++ Location Values</a>: The position and location classes
<li><a href="C_002b_002b-Parser-Interface.html#C_002b_002b-Parser-Interface">C++ Parser Interface</a>: Instantiating and running the parser
<li><a href="C_002b_002b-Scanner-Interface.html#C_002b_002b-Scanner-Interface">C++ Scanner Interface</a>: Exchanges between yylex and parse
<li><a href="A-Complete-C_002b_002b-Example.html#A-Complete-C_002b_002b-Example">A Complete C++ Example</a>: Demonstrating their use
</li></ul>
<p>A Complete C++ Example
</p>
<ul class="menu">
<li><a href="Calc_002b_002b-_002d_002d_002d-C_002b_002b-Calculator.html#Calc_002b_002b-_002d_002d_002d-C_002b_002b-Calculator">Calc++ --- C++ Calculator</a>: The specifications
<li><a href="Calc_002b_002b-Parsing-Driver.html#Calc_002b_002b-Parsing-Driver">Calc++ Parsing Driver</a>: An active parsing context
<li><a href="Calc_002b_002b-Parser.html#Calc_002b_002b-Parser">Calc++ Parser</a>: A parser class
<li><a href="Calc_002b_002b-Scanner.html#Calc_002b_002b-Scanner">Calc++ Scanner</a>: A pure C++ Flex scanner
<li><a href="Calc_002b_002b-Top-Level.html#Calc_002b_002b-Top-Level">Calc++ Top Level</a>: Conducting the band
</li></ul>
<p>Java Parsers
</p>
<ul class="menu">
<li><a href="Java-Bison-Interface.html#Java-Bison-Interface">Java Bison Interface</a>: Asking for Java parser generation
<li><a href="Java-Semantic-Values.html#Java-Semantic-Values">Java Semantic Values</a>: %type and %token vs. Java
<li><a href="Java-Location-Values.html#Java-Location-Values">Java Location Values</a>: The position and location classes
<li><a href="Java-Parser-Interface.html#Java-Parser-Interface">Java Parser Interface</a>: Instantiating and running the parser
<li><a href="Java-Scanner-Interface.html#Java-Scanner-Interface">Java Scanner Interface</a>: Specifying the scanner for the parser
<li><a href="Java-Action-Features.html#Java-Action-Features">Java Action Features</a>: Special features for use in actions
<li><a href="Java-Differences.html#Java-Differences">Java Differences</a>: Differences between C/C++ and Java Grammars
<li><a href="Java-Declarations-Summary.html#Java-Declarations-Summary">Java Declarations Summary</a>: List of Bison declarations used with Java
</li></ul>
<p>Frequently Asked Questions
</p>
<ul class="menu">
<li><a href="Memory-Exhausted.html#Memory-Exhausted">Memory Exhausted</a>: Breaking the Stack Limits
<li><a href="How-Can-I-Reset-the-Parser.html#How-Can-I-Reset-the-Parser">How Can I Reset the Parser</a>: <code>yyparse</code> Keeps some State
<li><a href="Strings-are-Destroyed.html#Strings-are-Destroyed">Strings are Destroyed</a>: <code>yylval</code> Loses Track of Strings
<li><a href="Implementing-Gotos_002fLoops.html#Implementing-Gotos_002fLoops">Implementing Gotos/Loops</a>: Control Flow in the Calculator
<li><a href="Multiple-start_002dsymbols.html#Multiple-start_002dsymbols">Multiple start-symbols</a>: Factoring closely related grammars
<li><a href="Secure_003f-Conform_003f.html#Secure_003f-Conform_003f">Secure? Conform?</a>: Is Bison POSIX safe?
<li><a href="I-can_0027t-build-Bison.html#I-can_0027t-build-Bison">I can't build Bison</a>: Troubleshooting
<li><a href="Where-can-I-find-help_003f.html#Where-can-I-find-help_003f">Where can I find help?</a>: Troubleshouting
<li><a href="Bug-Reports.html#Bug-Reports">Bug Reports</a>: Troublereporting
<li><a href="More-Languages.html#More-Languages">More Languages</a>: Parsers in C++, Java, and so on
<li><a href="Beta-Testing.html#Beta-Testing">Beta Testing</a>: Experimenting development versions
<li><a href="Mailing-Lists.html#Mailing-Lists">Mailing Lists</a>: Meeting other Bison users
</li></ul>
<p>Copying This Manual
</p>
<ul class="menu">
<li><a href="Copying-This-Manual.html#Copying-This-Manual">Copying This Manual</a>: License for copying this manual.
</ul>
</body></html>
|