home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / bison / bison.info-4 < prev    next >
Encoding:
GNU Info File  |  1996-02-17  |  47.6 KB  |  1,277 lines

  1. This is Info file bison.info, produced by Makeinfo-1.64 from the input
  2. file ./bison.texinfo.
  3.  
  4.    This file documents the Bison parser generator.
  5.  
  6.    Copyright (C) 1988, 89, 90, 91, 92, 93, 1995 Free Software
  7. Foundation, Inc.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided also
  15. that the sections entitled "GNU General Public License" and "Conditions
  16. for Using Bison" are included exactly as in the original, and provided
  17. that the entire resulting derived work is distributed under the terms
  18. of a permission notice identical to this one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "GNU General Public
  23. License", "Conditions for Using Bison" and this permission notice may be
  24. included in translations approved by the Free Software Foundation
  25. instead of in the original English.
  26.  
  27. 
  28. File: bison.info,  Node: Contextual Precedence,  Next: Parser States,  Prev: Precedence,  Up: Algorithm
  29.  
  30. Context-Dependent Precedence
  31. ============================
  32.  
  33.    Often the precedence of an operator depends on the context.  This
  34. sounds outlandish at first, but it is really very common.  For example,
  35. a minus sign typically has a very high precedence as a unary operator,
  36. and a somewhat lower precedence (lower than multiplication) as a binary
  37. operator.
  38.  
  39.    The Bison precedence declarations, `%left', `%right' and
  40. `%nonassoc', can only be used once for a given token; so a token has
  41. only one precedence declared in this way.  For context-dependent
  42. precedence, you need to use an additional mechanism: the `%prec'
  43. modifier for rules.
  44.  
  45.    The `%prec' modifier declares the precedence of a particular rule by
  46. specifying a terminal symbol whose precedence should be used for that
  47. rule.  It's not necessary for that symbol to appear otherwise in the
  48. rule.  The modifier's syntax is:
  49.  
  50.      %prec TERMINAL-SYMBOL
  51.  
  52. and it is written after the components of the rule.  Its effect is to
  53. assign the rule the precedence of TERMINAL-SYMBOL, overriding the
  54. precedence that would be deduced for it in the ordinary way.  The
  55. altered rule precedence then affects how conflicts involving that rule
  56. are resolved (*note Operator Precedence: Precedence.).
  57.  
  58.    Here is how `%prec' solves the problem of unary minus.  First,
  59. declare a precedence for a fictitious terminal symbol named `UMINUS'.
  60. There are no tokens of this type, but the symbol serves to stand for its
  61. precedence:
  62.  
  63.      ...
  64.      %left '+' '-'
  65.      %left '*'
  66.      %left UMINUS
  67.  
  68.    Now the precedence of `UMINUS' can be used in specific rules:
  69.  
  70.      exp:    ...
  71.              | exp '-' exp
  72.              ...
  73.              | '-' exp %prec UMINUS
  74.  
  75. 
  76. File: bison.info,  Node: Parser States,  Next: Reduce/Reduce,  Prev: Contextual Precedence,  Up: Algorithm
  77.  
  78. Parser States
  79. =============
  80.  
  81.    The function `yyparse' is implemented using a finite-state machine.
  82. The values pushed on the parser stack are not simply token type codes;
  83. they represent the entire sequence of terminal and nonterminal symbols
  84. at or near the top of the stack.  The current state collects all the
  85. information about previous input which is relevant to deciding what to
  86. do next.
  87.  
  88.    Each time a look-ahead token is read, the current parser state
  89. together with the type of look-ahead token are looked up in a table.
  90. This table entry can say, "Shift the look-ahead token."  In this case,
  91. it also specifies the new parser state, which is pushed onto the top of
  92. the parser stack.  Or it can say, "Reduce using rule number N." This
  93. means that a certain number of tokens or groupings are taken off the
  94. top of the stack, and replaced by one grouping.  In other words, that
  95. number of states are popped from the stack, and one new state is pushed.
  96.  
  97.    There is one other alternative: the table can say that the
  98. look-ahead token is erroneous in the current state.  This causes error
  99. processing to begin (*note Error Recovery::.).
  100.  
  101. 
  102. File: bison.info,  Node: Reduce/Reduce,  Next: Mystery Conflicts,  Prev: Parser States,  Up: Algorithm
  103.  
  104. Reduce/Reduce Conflicts
  105. =======================
  106.  
  107.    A reduce/reduce conflict occurs if there are two or more rules that
  108. apply to the same sequence of input.  This usually indicates a serious
  109. error in the grammar.
  110.  
  111.    For example, here is an erroneous attempt to define a sequence of
  112. zero or more `word' groupings.
  113.  
  114.      sequence: /* empty */
  115.                      { printf ("empty sequence\n"); }
  116.              | maybeword
  117.              | sequence word
  118.                      { printf ("added word %s\n", $2); }
  119.              ;
  120.      
  121.      maybeword: /* empty */
  122.                      { printf ("empty maybeword\n"); }
  123.              | word
  124.                      { printf ("single word %s\n", $1); }
  125.              ;
  126.  
  127. The error is an ambiguity: there is more than one way to parse a single
  128. `word' into a `sequence'.  It could be reduced to a `maybeword' and
  129. then into a `sequence' via the second rule.  Alternatively,
  130. nothing-at-all could be reduced into a `sequence' via the first rule,
  131. and this could be combined with the `word' using the third rule for
  132. `sequence'.
  133.  
  134.    There is also more than one way to reduce nothing-at-all into a
  135. `sequence'.  This can be done directly via the first rule, or
  136. indirectly via `maybeword' and then the second rule.
  137.  
  138.    You might think that this is a distinction without a difference,
  139. because it does not change whether any particular input is valid or
  140. not.  But it does affect which actions are run.  One parsing order runs
  141. the second rule's action; the other runs the first rule's action and
  142. the third rule's action.  In this example, the output of the program
  143. changes.
  144.  
  145.    Bison resolves a reduce/reduce conflict by choosing to use the rule
  146. that appears first in the grammar, but it is very risky to rely on
  147. this.  Every reduce/reduce conflict must be studied and usually
  148. eliminated.  Here is the proper way to define `sequence':
  149.  
  150.      sequence: /* empty */
  151.                      { printf ("empty sequence\n"); }
  152.              | sequence word
  153.                      { printf ("added word %s\n", $2); }
  154.              ;
  155.  
  156.    Here is another common error that yields a reduce/reduce conflict:
  157.  
  158.      sequence: /* empty */
  159.              | sequence words
  160.              | sequence redirects
  161.              ;
  162.      
  163.      words:    /* empty */
  164.              | words word
  165.              ;
  166.      
  167.      redirects:/* empty */
  168.              | redirects redirect
  169.              ;
  170.  
  171. The intention here is to define a sequence which can contain either
  172. `word' or `redirect' groupings.  The individual definitions of
  173. `sequence', `words' and `redirects' are error-free, but the three
  174. together make a subtle ambiguity: even an empty input can be parsed in
  175. infinitely many ways!
  176.  
  177.    Consider: nothing-at-all could be a `words'.  Or it could be two
  178. `words' in a row, or three, or any number.  It could equally well be a
  179. `redirects', or two, or any number.  Or it could be a `words' followed
  180. by three `redirects' and another `words'.  And so on.
  181.  
  182.    Here are two ways to correct these rules.  First, to make it a
  183. single level of sequence:
  184.  
  185.      sequence: /* empty */
  186.              | sequence word
  187.              | sequence redirect
  188.              ;
  189.  
  190.    Second, to prevent either a `words' or a `redirects' from being
  191. empty:
  192.  
  193.      sequence: /* empty */
  194.              | sequence words
  195.              | sequence redirects
  196.              ;
  197.      
  198.      words:    word
  199.              | words word
  200.              ;
  201.      
  202.      redirects:redirect
  203.              | redirects redirect
  204.              ;
  205.  
  206. 
  207. File: bison.info,  Node: Mystery Conflicts,  Next: Stack Overflow,  Prev: Reduce/Reduce,  Up: Algorithm
  208.  
  209. Mysterious Reduce/Reduce Conflicts
  210. ==================================
  211.  
  212.    Sometimes reduce/reduce conflicts can occur that don't look
  213. warranted.  Here is an example:
  214.  
  215.      %token ID
  216.      
  217.      %%
  218.      def:    param_spec return_spec ','
  219.              ;
  220.      param_spec:
  221.                   type
  222.              |    name_list ':' type
  223.              ;
  224.      return_spec:
  225.                   type
  226.              |    name ':' type
  227.              ;
  228.      type:        ID
  229.              ;
  230.      name:        ID
  231.              ;
  232.      name_list:
  233.                   name
  234.              |    name ',' name_list
  235.              ;
  236.  
  237.    It would seem that this grammar can be parsed with only a single
  238. token of look-ahead: when a `param_spec' is being read, an `ID' is a
  239. `name' if a comma or colon follows, or a `type' if another `ID'
  240. follows.  In other words, this grammar is LR(1).
  241.  
  242.    However, Bison, like most parser generators, cannot actually handle
  243. all LR(1) grammars.  In this grammar, two contexts, that after an `ID'
  244. at the beginning of a `param_spec' and likewise at the beginning of a
  245. `return_spec', are similar enough that Bison assumes they are the same.
  246. They appear similar because the same set of rules would be active--the
  247. rule for reducing to a `name' and that for reducing to a `type'.  Bison
  248. is unable to determine at that stage of processing that the rules would
  249. require different look-ahead tokens in the two contexts, so it makes a
  250. single parser state for them both.  Combining the two contexts causes a
  251. conflict later.  In parser terminology, this occurrence means that the
  252. grammar is not LALR(1).
  253.  
  254.    In general, it is better to fix deficiencies than to document them.
  255. But this particular deficiency is intrinsically hard to fix; parser
  256. generators that can handle LR(1) grammars are hard to write and tend to
  257. produce parsers that are very large.  In practice, Bison is more useful
  258. as it is now.
  259.  
  260.    When the problem arises, you can often fix it by identifying the two
  261. parser states that are being confused, and adding something to make them
  262. look distinct.  In the above example, adding one rule to `return_spec'
  263. as follows makes the problem go away:
  264.  
  265.      %token BOGUS
  266.      ...
  267.      %%
  268.      ...
  269.      return_spec:
  270.                   type
  271.              |    name ':' type
  272.              /* This rule is never used.  */
  273.              |    ID BOGUS
  274.              ;
  275.  
  276.    This corrects the problem because it introduces the possibility of an
  277. additional active rule in the context after the `ID' at the beginning of
  278. `return_spec'.  This rule is not active in the corresponding context in
  279. a `param_spec', so the two contexts receive distinct parser states.  As
  280. long as the token `BOGUS' is never generated by `yylex', the added rule
  281. cannot alter the way actual input is parsed.
  282.  
  283.    In this particular example, there is another way to solve the
  284. problem: rewrite the rule for `return_spec' to use `ID' directly
  285. instead of via `name'.  This also causes the two confusing contexts to
  286. have different sets of active rules, because the one for `return_spec'
  287. activates the altered rule for `return_spec' rather than the one for
  288. `name'.
  289.  
  290.      param_spec:
  291.                   type
  292.              |    name_list ':' type
  293.              ;
  294.      return_spec:
  295.                   type
  296.              |    ID ':' type
  297.              ;
  298.  
  299. 
  300. File: bison.info,  Node: Stack Overflow,  Prev: Mystery Conflicts,  Up: Algorithm
  301.  
  302. Stack Overflow, and How to Avoid It
  303. ===================================
  304.  
  305.    The Bison parser stack can overflow if too many tokens are shifted
  306. and not reduced.  When this happens, the parser function `yyparse'
  307. returns a nonzero value, pausing only to call `yyerror' to report the
  308. overflow.
  309.  
  310.    By defining the macro `YYMAXDEPTH', you can control how deep the
  311. parser stack can become before a stack overflow occurs.  Define the
  312. macro with a value that is an integer.  This value is the maximum number
  313. of tokens that can be shifted (and not reduced) before overflow.  It
  314. must be a constant expression whose value is known at compile time.
  315.  
  316.    The stack space allowed is not necessarily allocated.  If you
  317. specify a large value for `YYMAXDEPTH', the parser actually allocates a
  318. small stack at first, and then makes it bigger by stages as needed.
  319. This increasing allocation happens automatically and silently.
  320. Therefore, you do not need to make `YYMAXDEPTH' painfully small merely
  321. to save space for ordinary inputs that do not need much stack.
  322.  
  323.    The default value of `YYMAXDEPTH', if you do not define it, is 10000.
  324.  
  325.    You can control how much stack is allocated initially by defining the
  326. macro `YYINITDEPTH'.  This value too must be a compile-time constant
  327. integer.  The default is 200.
  328.  
  329. 
  330. File: bison.info,  Node: Error Recovery,  Next: Context Dependency,  Prev: Algorithm,  Up: Top
  331.  
  332. Error Recovery
  333. **************
  334.  
  335.    It is not usually acceptable to have a program terminate on a parse
  336. error.  For example, a compiler should recover sufficiently to parse the
  337. rest of the input file and check it for errors; a calculator should
  338. accept another expression.
  339.  
  340.    In a simple interactive command parser where each input is one line,
  341. it may be sufficient to allow `yyparse' to return 1 on error and have
  342. the caller ignore the rest of the input line when that happens (and
  343. then call `yyparse' again).  But this is inadequate for a compiler,
  344. because it forgets all the syntactic context leading up to the error.
  345. A syntax error deep within a function in the compiler input should not
  346. cause the compiler to treat the following line like the beginning of a
  347. source file.
  348.  
  349.    You can define how to recover from a syntax error by writing rules to
  350. recognize the special token `error'.  This is a terminal symbol that is
  351. always defined (you need not declare it) and reserved for error
  352. handling.  The Bison parser generates an `error' token whenever a
  353. syntax error happens; if you have provided a rule to recognize this
  354. token in the current context, the parse can continue.
  355.  
  356.    For example:
  357.  
  358.      stmnts:  /* empty string */
  359.              | stmnts '\n'
  360.              | stmnts exp '\n'
  361.              | stmnts error '\n'
  362.  
  363.    The fourth rule in this example says that an error followed by a
  364. newline makes a valid addition to any `stmnts'.
  365.  
  366.    What happens if a syntax error occurs in the middle of an `exp'?  The
  367. error recovery rule, interpreted strictly, applies to the precise
  368. sequence of a `stmnts', an `error' and a newline.  If an error occurs in
  369. the middle of an `exp', there will probably be some additional tokens
  370. and subexpressions on the stack after the last `stmnts', and there will
  371. be tokens to read before the next newline.  So the rule is not
  372. applicable in the ordinary way.
  373.  
  374.    But Bison can force the situation to fit the rule, by discarding
  375. part of the semantic context and part of the input.  First it discards
  376. states and objects from the stack until it gets back to a state in
  377. which the `error' token is acceptable.  (This means that the
  378. subexpressions already parsed are discarded, back to the last complete
  379. `stmnts'.)  At this point the `error' token can be shifted.  Then, if
  380. the old look-ahead token is not acceptable to be shifted next, the
  381. parser reads tokens and discards them until it finds a token which is
  382. acceptable.  In this example, Bison reads and discards input until the
  383. next newline so that the fourth rule can apply.
  384.  
  385.    The choice of error rules in the grammar is a choice of strategies
  386. for error recovery.  A simple and useful strategy is simply to skip the
  387. rest of the current input line or current statement if an error is
  388. detected:
  389.  
  390.      stmnt: error ';'  /* on error, skip until ';' is read */
  391.  
  392.    It is also useful to recover to the matching close-delimiter of an
  393. opening-delimiter that has already been parsed.  Otherwise the
  394. close-delimiter will probably appear to be unmatched, and generate
  395. another, spurious error message:
  396.  
  397.      primary:  '(' expr ')'
  398.              | '(' error ')'
  399.              ...
  400.              ;
  401.  
  402.    Error recovery strategies are necessarily guesses.  When they guess
  403. wrong, one syntax error often leads to another.  In the above example,
  404. the error recovery rule guesses that an error is due to bad input
  405. within one `stmnt'.  Suppose that instead a spurious semicolon is
  406. inserted in the middle of a valid `stmnt'.  After the error recovery
  407. rule recovers from the first error, another syntax error will be found
  408. straightaway, since the text following the spurious semicolon is also
  409. an invalid `stmnt'.
  410.  
  411.    To prevent an outpouring of error messages, the parser will output
  412. no error message for another syntax error that happens shortly after
  413. the first; only after three consecutive input tokens have been
  414. successfully shifted will error messages resume.
  415.  
  416.    Note that rules which accept the `error' token may have actions, just
  417. as any other rules can.
  418.  
  419.    You can make error messages resume immediately by using the macro
  420. `yyerrok' in an action.  If you do this in the error rule's action, no
  421. error messages will be suppressed.  This macro requires no arguments;
  422. `yyerrok;' is a valid C statement.
  423.  
  424.    The previous look-ahead token is reanalyzed immediately after an
  425. error.  If this is unacceptable, then the macro `yyclearin' may be used
  426. to clear this token.  Write the statement `yyclearin;' in the error
  427. rule's action.
  428.  
  429.    For example, suppose that on a parse error, an error handling
  430. routine is called that advances the input stream to some point where
  431. parsing should once again commence.  The next symbol returned by the
  432. lexical scanner is probably correct.  The previous look-ahead token
  433. ought to be discarded with `yyclearin;'.
  434.  
  435.    The macro `YYRECOVERING' stands for an expression that has the value
  436. 1 when the parser is recovering from a syntax error, and 0 the rest of
  437. the time.  A value of 1 indicates that error messages are currently
  438. suppressed for new syntax errors.
  439.  
  440. 
  441. File: bison.info,  Node: Context Dependency,  Next: Debugging,  Prev: Error Recovery,  Up: Top
  442.  
  443. Handling Context Dependencies
  444. *****************************
  445.  
  446.    The Bison paradigm is to parse tokens first, then group them into
  447. larger syntactic units.  In many languages, the meaning of a token is
  448. affected by its context.  Although this violates the Bison paradigm,
  449. certain techniques (known as "kludges") may enable you to write Bison
  450. parsers for such languages.
  451.  
  452. * Menu:
  453.  
  454. * Semantic Tokens::   Token parsing can depend on the semantic context.
  455. * Lexical Tie-ins::   Token parsing can depend on the syntactic context.
  456. * Tie-in Recovery::   Lexical tie-ins have implications for how
  457.                         error recovery rules must be written.
  458.  
  459.    (Actually, "kludge" means any technique that gets its job done but is
  460. neither clean nor robust.)
  461.  
  462. 
  463. File: bison.info,  Node: Semantic Tokens,  Next: Lexical Tie-ins,  Up: Context Dependency
  464.  
  465. Semantic Info in Token Types
  466. ============================
  467.  
  468.    The C language has a context dependency: the way an identifier is
  469. used depends on what its current meaning is.  For example, consider
  470. this:
  471.  
  472.      foo (x);
  473.  
  474.    This looks like a function call statement, but if `foo' is a typedef
  475. name, then this is actually a declaration of `x'.  How can a Bison
  476. parser for C decide how to parse this input?
  477.  
  478.    The method used in GNU C is to have two different token types,
  479. `IDENTIFIER' and `TYPENAME'.  When `yylex' finds an identifier, it
  480. looks up the current declaration of the identifier in order to decide
  481. which token type to return: `TYPENAME' if the identifier is declared as
  482. a typedef, `IDENTIFIER' otherwise.
  483.  
  484.    The grammar rules can then express the context dependency by the
  485. choice of token type to recognize.  `IDENTIFIER' is accepted as an
  486. expression, but `TYPENAME' is not.  `TYPENAME' can start a declaration,
  487. but `IDENTIFIER' cannot.  In contexts where the meaning of the
  488. identifier is *not* significant, such as in declarations that can
  489. shadow a typedef name, either `TYPENAME' or `IDENTIFIER' is
  490. accepted--there is one rule for each of the two token types.
  491.  
  492.    This technique is simple to use if the decision of which kinds of
  493. identifiers to allow is made at a place close to where the identifier is
  494. parsed.  But in C this is not always so: C allows a declaration to
  495. redeclare a typedef name provided an explicit type has been specified
  496. earlier:
  497.  
  498.      typedef int foo, bar, lose;
  499.      static foo (bar);        /* redeclare `bar' as static variable */
  500.      static int foo (lose);   /* redeclare `foo' as function */
  501.  
  502.    Unfortunately, the name being declared is separated from the
  503. declaration construct itself by a complicated syntactic structure--the
  504. "declarator".
  505.  
  506.    As a result, the part of Bison parser for C needs to be duplicated,
  507. with all the nonterminal names changed: once for parsing a declaration
  508. in which a typedef name can be redefined, and once for parsing a
  509. declaration in which that can't be done.  Here is a part of the
  510. duplication, with actions omitted for brevity:
  511.  
  512.      initdcl:
  513.                declarator maybeasm '='
  514.                init
  515.              | declarator maybeasm
  516.              ;
  517.      
  518.      notype_initdcl:
  519.                notype_declarator maybeasm '='
  520.                init
  521.              | notype_declarator maybeasm
  522.              ;
  523.  
  524. Here `initdcl' can redeclare a typedef name, but `notype_initdcl'
  525. cannot.  The distinction between `declarator' and `notype_declarator'
  526. is the same sort of thing.
  527.  
  528.    There is some similarity between this technique and a lexical tie-in
  529. (described next), in that information which alters the lexical analysis
  530. is changed during parsing by other parts of the program.  The
  531. difference is here the information is global, and is used for other
  532. purposes in the program.  A true lexical tie-in has a special-purpose
  533. flag controlled by the syntactic context.
  534.  
  535. 
  536. File: bison.info,  Node: Lexical Tie-ins,  Next: Tie-in Recovery,  Prev: Semantic Tokens,  Up: Context Dependency
  537.  
  538. Lexical Tie-ins
  539. ===============
  540.  
  541.    One way to handle context-dependency is the "lexical tie-in": a flag
  542. which is set by Bison actions, whose purpose is to alter the way tokens
  543. are parsed.
  544.  
  545.    For example, suppose we have a language vaguely like C, but with a
  546. special construct `hex (HEX-EXPR)'.  After the keyword `hex' comes an
  547. expression in parentheses in which all integers are hexadecimal.  In
  548. particular, the token `a1b' must be treated as an integer rather than
  549. as an identifier if it appears in that context.  Here is how you can do
  550. it:
  551.  
  552.      %{
  553.      int hexflag;
  554.      %}
  555.      %%
  556.      ...
  557.      expr:   IDENTIFIER
  558.              | constant
  559.              | HEX '('
  560.                      { hexflag = 1; }
  561.                expr ')'
  562.                      { hexflag = 0;
  563.                         $$ = $4; }
  564.              | expr '+' expr
  565.                      { $$ = make_sum ($1, $3); }
  566.              ...
  567.              ;
  568.      
  569.      constant:
  570.                INTEGER
  571.              | STRING
  572.              ;
  573.  
  574. Here we assume that `yylex' looks at the value of `hexflag'; when it is
  575. nonzero, all integers are parsed in hexadecimal, and tokens starting
  576. with letters are parsed as integers if possible.
  577.  
  578.    The declaration of `hexflag' shown in the C declarations section of
  579. the parser file is needed to make it accessible to the actions (*note
  580. The C Declarations Section: C Declarations.).  You must also write the
  581. code in `yylex' to obey the flag.
  582.  
  583. 
  584. File: bison.info,  Node: Tie-in Recovery,  Prev: Lexical Tie-ins,  Up: Context Dependency
  585.  
  586. Lexical Tie-ins and Error Recovery
  587. ==================================
  588.  
  589.    Lexical tie-ins make strict demands on any error recovery rules you
  590. have.  *Note Error Recovery::.
  591.  
  592.    The reason for this is that the purpose of an error recovery rule is
  593. to abort the parsing of one construct and resume in some larger
  594. construct.  For example, in C-like languages, a typical error recovery
  595. rule is to skip tokens until the next semicolon, and then start a new
  596. statement, like this:
  597.  
  598.      stmt:   expr ';'
  599.              | IF '(' expr ')' stmt { ... }
  600.              ...
  601.              error ';'
  602.                      { hexflag = 0; }
  603.              ;
  604.  
  605.    If there is a syntax error in the middle of a `hex (EXPR)'
  606. construct, this error rule will apply, and then the action for the
  607. completed `hex (EXPR)' will never run.  So `hexflag' would remain set
  608. for the entire rest of the input, or until the next `hex' keyword,
  609. causing identifiers to be misinterpreted as integers.
  610.  
  611.    To avoid this problem the error recovery rule itself clears
  612. `hexflag'.
  613.  
  614.    There may also be an error recovery rule that works within
  615. expressions.  For example, there could be a rule which applies within
  616. parentheses and skips to the close-parenthesis:
  617.  
  618.      expr:   ...
  619.              | '(' expr ')'
  620.                      { $$ = $2; }
  621.              | '(' error ')'
  622.              ...
  623.  
  624.    If this rule acts within the `hex' construct, it is not going to
  625. abort that construct (since it applies to an inner level of parentheses
  626. within the construct).  Therefore, it should not clear the flag: the
  627. rest of the `hex' construct should be parsed with the flag still in
  628. effect.
  629.  
  630.    What if there is an error recovery rule which might abort out of the
  631. `hex' construct or might not, depending on circumstances?  There is no
  632. way you can write the action to determine whether a `hex' construct is
  633. being aborted or not.  So if you are using a lexical tie-in, you had
  634. better make sure your error recovery rules are not of this kind.  Each
  635. rule must be such that you can be sure that it always will, or always
  636. won't, have to clear the flag.
  637.  
  638. 
  639. File: bison.info,  Node: Debugging,  Next: Invocation,  Prev: Context Dependency,  Up: Top
  640.  
  641. Debugging Your Parser
  642. *********************
  643.  
  644.    If a Bison grammar compiles properly but doesn't do what you want
  645. when it runs, the `yydebug' parser-trace feature can help you figure
  646. out why.
  647.  
  648.    To enable compilation of trace facilities, you must define the macro
  649. `YYDEBUG' when you compile the parser.  You could use `-DYYDEBUG=1' as
  650. a compiler option or you could put `#define YYDEBUG 1' in the C
  651. declarations section of the grammar file (*note The C Declarations
  652. Section: C Declarations.).  Alternatively, use the `-t' option when you
  653. run Bison (*note Invoking Bison: Invocation.).  We always define
  654. `YYDEBUG' so that debugging is always possible.
  655.  
  656.    The trace facility uses `stderr', so you must add
  657. `#include <stdio.h>' to the C declarations section unless it is already
  658. there.
  659.  
  660.    Once you have compiled the program with trace facilities, the way to
  661. request a trace is to store a nonzero value in the variable `yydebug'.
  662. You can do this by making the C code do it (in `main', perhaps), or you
  663. can alter the value with a C debugger.
  664.  
  665.    Each step taken by the parser when `yydebug' is nonzero produces a
  666. line or two of trace information, written on `stderr'.  The trace
  667. messages tell you these things:
  668.  
  669.    * Each time the parser calls `yylex', what kind of token was read.
  670.  
  671.    * Each time a token is shifted, the depth and complete contents of
  672.      the state stack (*note Parser States::.).
  673.  
  674.    * Each time a rule is reduced, which rule it is, and the complete
  675.      contents of the state stack afterward.
  676.  
  677.    To make sense of this information, it helps to refer to the listing
  678. file produced by the Bison `-v' option (*note Invoking Bison:
  679. Invocation.).  This file shows the meaning of each state in terms of
  680. positions in various rules, and also what each state will do with each
  681. possible input token.  As you read the successive trace messages, you
  682. can see that the parser is functioning according to its specification
  683. in the listing file.  Eventually you will arrive at the place where
  684. something undesirable happens, and you will see which parts of the
  685. grammar are to blame.
  686.  
  687.    The parser file is a C program and you can use C debuggers on it,
  688. but it's not easy to interpret what it is doing.  The parser function
  689. is a finite-state machine interpreter, and aside from the actions it
  690. executes the same code over and over.  Only the values of variables
  691. show where in the grammar it is working.
  692.  
  693.    The debugging information normally gives the token type of each token
  694. read, but not its semantic value.  You can optionally define a macro
  695. named `YYPRINT' to provide a way to print the value.  If you define
  696. `YYPRINT', it should take three arguments.  The parser will pass a
  697. standard I/O stream, the numeric code for the token type, and the token
  698. value (from `yylval').
  699.  
  700.    Here is an example of `YYPRINT' suitable for the multi-function
  701. calculator (*note Declarations for `mfcalc': Mfcalc Decl.):
  702.  
  703.      #define YYPRINT(file, type, value)   yyprint (file, type, value)
  704.      
  705.      static void
  706.      yyprint (file, type, value)
  707.           FILE *file;
  708.           int type;
  709.           YYSTYPE value;
  710.      {
  711.        if (type == VAR)
  712.          fprintf (file, " %s", value.tptr->name);
  713.        else if (type == NUM)
  714.          fprintf (file, " %d", value.val);
  715.      }
  716.  
  717. 
  718. File: bison.info,  Node: Invocation,  Next: Table of Symbols,  Prev: Debugging,  Up: Top
  719.  
  720. Invoking Bison
  721. **************
  722.  
  723.    The usual way to invoke Bison is as follows:
  724.  
  725.      bison INFILE
  726.  
  727.    Here INFILE is the grammar file name, which usually ends in `.y'.
  728. The parser file's name is made by replacing the `.y' with `.tab.c'.
  729. Thus, the `bison foo.y' filename yields `foo.tab.c', and the `bison
  730. hack/foo.y' filename yields `hack/foo.tab.c'.
  731.  
  732. * Menu:
  733.  
  734. * Bison Options::     All the options described in detail,
  735.             in alphabetical order by short options.
  736. * Option Cross Key::  Alphabetical list of long options.
  737. * VMS Invocation::    Bison command syntax on VMS.
  738.  
  739. 
  740. File: bison.info,  Node: Bison Options,  Next: Option Cross Key,  Up: Invocation
  741.  
  742. Bison Options
  743. =============
  744.  
  745.    Bison supports both traditional single-letter options and mnemonic
  746. long option names.  Long option names are indicated with `--' instead of
  747. `-'.  Abbreviations for option names are allowed as long as they are
  748. unique.  When a long option takes an argument, like `--file-prefix',
  749. connect the option name and the argument with `='.
  750.  
  751.    Here is a list of options that can be used with Bison, alphabetized
  752. by short option.  It is followed by a cross key alphabetized by long
  753. option.
  754.  
  755. `-b FILE-PREFIX'
  756. `--file-prefix=PREFIX'
  757.      Specify a prefix to use for all Bison output file names.  The
  758.      names are chosen as if the input file were named `PREFIX.c'.
  759.  
  760. `-d'
  761. `--defines'
  762.      Write an extra output file containing macro definitions for the
  763.      token type names defined in the grammar and the semantic value type
  764.      `YYSTYPE', as well as a few `extern' variable declarations.
  765.  
  766.      If the parser output file is named `NAME.c' then this file is
  767.      named `NAME.h'.
  768.  
  769.      This output file is essential if you wish to put the definition of
  770.      `yylex' in a separate source file, because `yylex' needs to be
  771.      able to refer to token type codes and the variable `yylval'.
  772.      *Note Semantic Values of Tokens: Token Values.
  773.  
  774. `-l'
  775. `--no-lines'
  776.      Don't put any `#line' preprocessor commands in the parser file.
  777.      Ordinarily Bison puts them in the parser file so that the C
  778.      compiler and debuggers will associate errors with your source
  779.      file, the grammar file.  This option causes them to associate
  780.      errors with the parser file, treating it as an independent source
  781.      file in its own right.
  782.  
  783. `-n'
  784. `--no-parser'
  785.      Do not include any C code in the parser file; generate tables
  786.      only.  The parser file contains just `#define' directives and
  787.      static variable declarations.
  788.  
  789.      This option also tells Bison to write the C code for the grammar
  790.      actions into a file named `FILENAME.act', in the form of a
  791.      brace-surrounded body fit for a `switch' statement.
  792.  
  793. `-o OUTFILE'
  794. `--output-file=OUTFILE'
  795.      Specify the name OUTFILE for the parser file.
  796.  
  797.      The other output files' names are constructed from OUTFILE as
  798.      described under the `-v' and `-d' options.
  799.  
  800. `-p PREFIX'
  801. `--name-prefix=PREFIX'
  802.      Rename the external symbols used in the parser so that they start
  803.      with PREFIX instead of `yy'.  The precise list of symbols renamed
  804.      is `yyparse', `yylex', `yyerror', `yynerrs', `yylval', `yychar'
  805.      and `yydebug'.
  806.  
  807.      For example, if you use `-p c', the names become `cparse', `clex',
  808.      and so on.
  809.  
  810.      *Note Multiple Parsers in the Same Program: Multiple Parsers.
  811.  
  812. `-r'
  813. `--raw'
  814.      Pretend that `%raw' was specified.  *Note Decl Summary::.
  815.  
  816. `-t'
  817. `--debug'
  818.      Output a definition of the macro `YYDEBUG' into the parser file,
  819.      so that the debugging facilities are compiled.  *Note Debugging
  820.      Your Parser: Debugging.
  821.  
  822. `-v'
  823. `--verbose'
  824.      Write an extra output file containing verbose descriptions of the
  825.      parser states and what is done for each type of look-ahead token in
  826.      that state.
  827.  
  828.      This file also describes all the conflicts, both those resolved by
  829.      operator precedence and the unresolved ones.
  830.  
  831.      The file's name is made by removing `.tab.c' or `.c' from the
  832.      parser output file name, and adding `.output' instead.
  833.  
  834.      Therefore, if the input file is `foo.y', then the parser file is
  835.      called `foo.tab.c' by default.  As a consequence, the verbose
  836.      output file is called `foo.output'.
  837.  
  838. `-V'
  839. `--version'
  840.      Print the version number of Bison and exit.
  841.  
  842. `-h'
  843. `--help'
  844.      Print a summary of the command-line options to Bison and exit.
  845.  
  846. `-y'
  847. `--yacc'
  848. `--fixed-output-files'
  849.      Equivalent to `-o y.tab.c'; the parser output file is called
  850.      `y.tab.c', and the other outputs are called `y.output' and
  851.      `y.tab.h'.  The purpose of this option is to imitate Yacc's output
  852.      file name conventions.  Thus, the following shell script can
  853.      substitute for Yacc:
  854.  
  855.           bison -y $*
  856.  
  857. 
  858. File: bison.info,  Node: Option Cross Key,  Next: VMS Invocation,  Prev: Bison Options,  Up: Invocation
  859.  
  860. Option Cross Key
  861. ================
  862.  
  863.    Here is a list of options, alphabetized by long option, to help you
  864. find the corresponding short option.
  865.  
  866.      --debug                               -t
  867.      --defines                             -d
  868.      --file-prefix=PREFIX                  -b FILE-PREFIX
  869.      --fixed-output-files --yacc           -y
  870.      --help                                -h
  871.      --name-prefix=PREFIX                  -p NAME-PREFIX
  872.      --no-lines                            -l
  873.      --no-parser                           -n
  874.      --output-file=OUTFILE                 -o OUTFILE
  875.      --raw                                 -r
  876.      --token-table                         -k
  877.      --verbose                             -v
  878.      --version                             -V
  879.  
  880. 
  881. File: bison.info,  Node: VMS Invocation,  Prev: Option Cross Key,  Up: Invocation
  882.  
  883. Invoking Bison under VMS
  884. ========================
  885.  
  886.    The command line syntax for Bison on VMS is a variant of the usual
  887. Bison command syntax--adapted to fit VMS conventions.
  888.  
  889.    To find the VMS equivalent for any Bison option, start with the long
  890. option, and substitute a `/' for the leading `--', and substitute a `_'
  891. for each `-' in the name of the long option.  For example, the
  892. following invocation under VMS:
  893.  
  894.      bison /debug/name_prefix=bar foo.y
  895.  
  896. is equivalent to the following command under POSIX.
  897.  
  898.      bison --debug --name-prefix=bar foo.y
  899.  
  900.    The VMS file system does not permit filenames such as `foo.tab.c'.
  901. In the above example, the output file would instead be named
  902. `foo_tab.c'.
  903.  
  904. 
  905. File: bison.info,  Node: Table of Symbols,  Next: Glossary,  Prev: Invocation,  Up: Top
  906.  
  907. Bison Symbols
  908. *************
  909.  
  910. `error'
  911.      A token name reserved for error recovery.  This token may be used
  912.      in grammar rules so as to allow the Bison parser to recognize an
  913.      error in the grammar without halting the process.  In effect, a
  914.      sentence containing an error may be recognized as valid.  On a
  915.      parse error, the token `error' becomes the current look-ahead
  916.      token.  Actions corresponding to `error' are then executed, and
  917.      the look-ahead token is reset to the token that originally caused
  918.      the violation.  *Note Error Recovery::.
  919.  
  920. `YYABORT'
  921.      Macro to pretend that an unrecoverable syntax error has occurred,
  922.      by making `yyparse' return 1 immediately.  The error reporting
  923.      function `yyerror' is not called.  *Note The Parser Function
  924.      `yyparse': Parser Function.
  925.  
  926. `YYACCEPT'
  927.      Macro to pretend that a complete utterance of the language has been
  928.      read, by making `yyparse' return 0 immediately.  *Note The Parser
  929.      Function `yyparse': Parser Function.
  930.  
  931. `YYBACKUP'
  932.      Macro to discard a value from the parser stack and fake a
  933.      look-ahead token.  *Note Special Features for Use in Actions:
  934.      Action Features.
  935.  
  936. `YYERROR'
  937.      Macro to pretend that a syntax error has just been detected: call
  938.      `yyerror' and then perform normal error recovery if possible
  939.      (*note Error Recovery::.), or (if recovery is impossible) make
  940.      `yyparse' return 1.  *Note Error Recovery::.
  941.  
  942. `YYERROR_VERBOSE'
  943.      Macro that you define with `#define' in the Bison declarations
  944.      section to request verbose, specific error message strings when
  945.      `yyerror' is called.
  946.  
  947. `YYINITDEPTH'
  948.      Macro for specifying the initial size of the parser stack.  *Note
  949.      Stack Overflow::.
  950.  
  951. `YYLEX_PARAM'
  952.      Macro for specifying an extra argument (or list of extra
  953.      arguments) for `yyparse' to pass to `yylex'.  *Note Calling
  954.      Conventions for Pure Parsers: Pure Calling.
  955.  
  956. `YYLTYPE'
  957.      Macro for the data type of `yylloc'; a structure with four
  958.      members.  *Note Textual Positions of Tokens: Token Positions.
  959.  
  960. `yyltype'
  961.      Default value for YYLTYPE.
  962.  
  963. `YYMAXDEPTH'
  964.      Macro for specifying the maximum size of the parser stack.  *Note
  965.      Stack Overflow::.
  966.  
  967. `YYPARSE_PARAM'
  968.      Macro for specifying the name of a parameter that `yyparse' should
  969.      accept.  *Note Calling Conventions for Pure Parsers: Pure Calling.
  970.  
  971. `YYRECOVERING'
  972.      Macro whose value indicates whether the parser is recovering from a
  973.      syntax error.  *Note Special Features for Use in Actions: Action
  974.      Features.
  975.  
  976. `YYSTYPE'
  977.      Macro for the data type of semantic values; `int' by default.
  978.      *Note Data Types of Semantic Values: Value Type.
  979.  
  980. `yychar'
  981.      External integer variable that contains the integer value of the
  982.      current look-ahead token.  (In a pure parser, it is a local
  983.      variable within `yyparse'.)  Error-recovery rule actions may
  984.      examine this variable.  *Note Special Features for Use in Actions:
  985.      Action Features.
  986.  
  987. `yyclearin'
  988.      Macro used in error-recovery rule actions.  It clears the previous
  989.      look-ahead token.  *Note Error Recovery::.
  990.  
  991. `yydebug'
  992.      External integer variable set to zero by default.  If `yydebug' is
  993.      given a nonzero value, the parser will output information on input
  994.      symbols and parser action.  *Note Debugging Your Parser: Debugging.
  995.  
  996. `yyerrok'
  997.      Macro to cause parser to recover immediately to its normal mode
  998.      after a parse error.  *Note Error Recovery::.
  999.  
  1000. `yyerror'
  1001.      User-supplied function to be called by `yyparse' on error.  The
  1002.      function receives one argument, a pointer to a character string
  1003.      containing an error message.  *Note The Error Reporting Function
  1004.      `yyerror': Error Reporting.
  1005.  
  1006. `yylex'
  1007.      User-supplied lexical analyzer function, called with no arguments
  1008.      to get the next token.  *Note The Lexical Analyzer Function
  1009.      `yylex': Lexical.
  1010.  
  1011. `yylval'
  1012.      External variable in which `yylex' should place the semantic value
  1013.      associated with a token.  (In a pure parser, it is a local
  1014.      variable within `yyparse', and its address is passed to `yylex'.)
  1015.      *Note Semantic Values of Tokens: Token Values.
  1016.  
  1017. `yylloc'
  1018.      External variable in which `yylex' should place the line and
  1019.      column numbers associated with a token.  (In a pure parser, it is a
  1020.      local variable within `yyparse', and its address is passed to
  1021.      `yylex'.)  You can ignore this variable if you don't use the `@'
  1022.      feature in the grammar actions.  *Note Textual Positions of
  1023.      Tokens: Token Positions.
  1024.  
  1025. `yynerrs'
  1026.      Global variable which Bison increments each time there is a parse
  1027.      error.  (In a pure parser, it is a local variable within
  1028.      `yyparse'.)  *Note The Error Reporting Function `yyerror': Error
  1029.      Reporting.
  1030.  
  1031. `yyparse'
  1032.      The parser function produced by Bison; call this function to start
  1033.      parsing.  *Note The Parser Function `yyparse': Parser Function.
  1034.  
  1035. `%left'
  1036.      Bison declaration to assign left associativity to token(s).  *Note
  1037.      Operator Precedence: Precedence Decl.
  1038.  
  1039. `%no_lines'
  1040.      Bison declaration to avoid generating `#line' directives in the
  1041.      parser file.  *Note Decl Summary::.
  1042.  
  1043. `%nonassoc'
  1044.      Bison declaration to assign nonassociativity to token(s).  *Note
  1045.      Operator Precedence: Precedence Decl.
  1046.  
  1047. `%prec'
  1048.      Bison declaration to assign a precedence to a specific rule.
  1049.      *Note Context-Dependent Precedence: Contextual Precedence.
  1050.  
  1051. `%pure_parser'
  1052.      Bison declaration to request a pure (reentrant) parser.  *Note A
  1053.      Pure (Reentrant) Parser: Pure Decl.
  1054.  
  1055. `%raw'
  1056.      Bison declaration to use Bison internal token code numbers in token
  1057.      tables instead of the usual Yacc-compatible token code numbers.
  1058.      *Note Decl Summary::.
  1059.  
  1060. `%right'
  1061.      Bison declaration to assign right associativity to token(s).
  1062.      *Note Operator Precedence: Precedence Decl.
  1063.  
  1064. `%start'
  1065.      Bison declaration to specify the start symbol.  *Note The
  1066.      Start-Symbol: Start Decl.
  1067.  
  1068. `%token'
  1069.      Bison declaration to declare token(s) without specifying
  1070.      precedence.  *Note Token Type Names: Token Decl.
  1071.  
  1072. `%token_table'
  1073.      Bison declaration to include a token name table in the parser file.
  1074.      *Note Decl Summary::.
  1075.  
  1076. `%type'
  1077.      Bison declaration to declare nonterminals.  *Note Nonterminal
  1078.      Symbols: Type Decl.
  1079.  
  1080. `%union'
  1081.      Bison declaration to specify several possible data types for
  1082.      semantic values.  *Note The Collection of Value Types: Union Decl.
  1083.  
  1084.    These are the punctuation and delimiters used in Bison input:
  1085.  
  1086. `%%'
  1087.      Delimiter used to separate the grammar rule section from the Bison
  1088.      declarations section or the additional C code section.  *Note The
  1089.      Overall Layout of a Bison Grammar: Grammar Layout.
  1090.  
  1091. `%{ %}'
  1092.      All code listed between `%{' and `%}' is copied directly to the
  1093.      output file uninterpreted.  Such code forms the "C declarations"
  1094.      section of the input file.  *Note Outline of a Bison Grammar:
  1095.      Grammar Outline.
  1096.  
  1097. `/*...*/'
  1098.      Comment delimiters, as in C.
  1099.  
  1100. `:'
  1101.      Separates a rule's result from its components.  *Note Syntax of
  1102.      Grammar Rules: Rules.
  1103.  
  1104. `;'
  1105.      Terminates a rule.  *Note Syntax of Grammar Rules: Rules.
  1106.  
  1107. `|'
  1108.      Separates alternate rules for the same result nonterminal.  *Note
  1109.      Syntax of Grammar Rules: Rules.
  1110.  
  1111. 
  1112. File: bison.info,  Node: Glossary,  Next: Index,  Prev: Table of Symbols,  Up: Top
  1113.  
  1114. Glossary
  1115. ********
  1116.  
  1117. Backus-Naur Form (BNF)
  1118.      Formal method of specifying context-free grammars.  BNF was first
  1119.      used in the `ALGOL-60' report, 1963.  *Note Languages and
  1120.      Context-Free Grammars: Language and Grammar.
  1121.  
  1122. Context-free grammars
  1123.      Grammars specified as rules that can be applied regardless of
  1124.      context.  Thus, if there is a rule which says that an integer can
  1125.      be used as an expression, integers are allowed *anywhere* an
  1126.      expression is permitted.  *Note Languages and Context-Free
  1127.      Grammars: Language and Grammar.
  1128.  
  1129. Dynamic allocation
  1130.      Allocation of memory that occurs during execution, rather than at
  1131.      compile time or on entry to a function.
  1132.  
  1133. Empty string
  1134.      Analogous to the empty set in set theory, the empty string is a
  1135.      character string of length zero.
  1136.  
  1137. Finite-state stack machine
  1138.      A "machine" that has discrete states in which it is said to exist
  1139.      at each instant in time.  As input to the machine is processed, the
  1140.      machine moves from state to state as specified by the logic of the
  1141.      machine.  In the case of the parser, the input is the language
  1142.      being parsed, and the states correspond to various stages in the
  1143.      grammar rules.  *Note The Bison Parser Algorithm: Algorithm.
  1144.  
  1145. Grouping
  1146.      A language construct that is (in general) grammatically divisible;
  1147.      for example, `expression' or `declaration' in C.  *Note Languages
  1148.      and Context-Free Grammars: Language and Grammar.
  1149.  
  1150. Infix operator
  1151.      An arithmetic operator that is placed between the operands on
  1152.      which it performs some operation.
  1153.  
  1154. Input stream
  1155.      A continuous flow of data between devices or programs.
  1156.  
  1157. Language construct
  1158.      One of the typical usage schemas of the language.  For example,
  1159.      one of the constructs of the C language is the `if' statement.
  1160.      *Note Languages and Context-Free Grammars: Language and Grammar.
  1161.  
  1162. Left associativity
  1163.      Operators having left associativity are analyzed from left to
  1164.      right: `a+b+c' first computes `a+b' and then combines with `c'.
  1165.      *Note Operator Precedence: Precedence.
  1166.  
  1167. Left recursion
  1168.      A rule whose result symbol is also its first component symbol; for
  1169.      example, `expseq1 : expseq1 ',' exp;'.  *Note Recursive Rules:
  1170.      Recursion.
  1171.  
  1172. Left-to-right parsing
  1173.      Parsing a sentence of a language by analyzing it token by token
  1174.      from left to right.  *Note The Bison Parser Algorithm: Algorithm.
  1175.  
  1176. Lexical analyzer (scanner)
  1177.      A function that reads an input stream and returns tokens one by
  1178.      one.  *Note The Lexical Analyzer Function `yylex': Lexical.
  1179.  
  1180. Lexical tie-in
  1181.      A flag, set by actions in the grammar rules, which alters the way
  1182.      tokens are parsed.  *Note Lexical Tie-ins::.
  1183.  
  1184. Literal string token
  1185.      A token which constists of two or more fixed characters.  *Note
  1186.      Symbols::.
  1187.  
  1188. Look-ahead token
  1189.      A token already read but not yet shifted.  *Note Look-Ahead
  1190.      Tokens: Look-Ahead.
  1191.  
  1192. LALR(1)
  1193.      The class of context-free grammars that Bison (like most other
  1194.      parser generators) can handle; a subset of LR(1).  *Note
  1195.      Mysterious Reduce/Reduce Conflicts: Mystery Conflicts.
  1196.  
  1197. LR(1)
  1198.      The class of context-free grammars in which at most one token of
  1199.      look-ahead is needed to disambiguate the parsing of any piece of
  1200.      input.
  1201.  
  1202. Nonterminal symbol
  1203.      A grammar symbol standing for a grammatical construct that can be
  1204.      expressed through rules in terms of smaller constructs; in other
  1205.      words, a construct that is not a token.  *Note Symbols::.
  1206.  
  1207. Parse error
  1208.      An error encountered during parsing of an input stream due to
  1209.      invalid syntax.  *Note Error Recovery::.
  1210.  
  1211. Parser
  1212.      A function that recognizes valid sentences of a language by
  1213.      analyzing the syntax structure of a set of tokens passed to it
  1214.      from a lexical analyzer.
  1215.  
  1216. Postfix operator
  1217.      An arithmetic operator that is placed after the operands upon
  1218.      which it performs some operation.
  1219.  
  1220. Reduction
  1221.      Replacing a string of nonterminals and/or terminals with a single
  1222.      nonterminal, according to a grammar rule.  *Note The Bison Parser
  1223.      Algorithm: Algorithm.
  1224.  
  1225. Reentrant
  1226.      A reentrant subprogram is a subprogram which can be in invoked any
  1227.      number of times in parallel, without interference between the
  1228.      various invocations.  *Note A Pure (Reentrant) Parser: Pure Decl.
  1229.  
  1230. Reverse polish notation
  1231.      A language in which all operators are postfix operators.
  1232.  
  1233. Right recursion
  1234.      A rule whose result symbol is also its last component symbol; for
  1235.      example, `expseq1: exp ',' expseq1;'.  *Note Recursive Rules:
  1236.      Recursion.
  1237.  
  1238. Semantics
  1239.      In computer languages, the semantics are specified by the actions
  1240.      taken for each instance of the language, i.e., the meaning of each
  1241.      statement.  *Note Defining Language Semantics: Semantics.
  1242.  
  1243. Shift
  1244.      A parser is said to shift when it makes the choice of analyzing
  1245.      further input from the stream rather than reducing immediately some
  1246.      already-recognized rule.  *Note The Bison Parser Algorithm:
  1247.      Algorithm.
  1248.  
  1249. Single-character literal
  1250.      A single character that is recognized and interpreted as is.
  1251.      *Note From Formal Rules to Bison Input: Grammar in Bison.
  1252.  
  1253. Start symbol
  1254.      The nonterminal symbol that stands for a complete valid utterance
  1255.      in the language being parsed.  The start symbol is usually listed
  1256.      as the first nonterminal symbol in a language specification.
  1257.      *Note The Start-Symbol: Start Decl.
  1258.  
  1259. Symbol table
  1260.      A data structure where symbol names and associated data are stored
  1261.      during parsing to allow for recognition and use of existing
  1262.      information in repeated uses of a symbol.  *Note Multi-function
  1263.      Calc::.
  1264.  
  1265. Token
  1266.      A basic, grammatically indivisible unit of a language.  The symbol
  1267.      that describes a token in the grammar is a terminal symbol.  The
  1268.      input of the Bison parser is a stream of tokens which comes from
  1269.      the lexical analyzer.  *Note Symbols::.
  1270.  
  1271. Terminal symbol
  1272.      A grammar symbol that has no rules in the grammar and therefore is
  1273.      grammatically indivisible.  The piece of text it represents is a
  1274.      token.  *Note Languages and Context-Free Grammars: Language and
  1275.      Grammar.
  1276.  
  1277.