/[bison]/bison/doc/bison.texinfo
ViewVC logotype

Diff of /bison/doc/bison.texinfo

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.66 by akim, Fri Jul 26 06:24:11 2002 UTC revision 1.67 by akim, Mon Jul 29 17:30:33 2002 UTC
# Line 3553  Request a pure (reentrant) parser progra Line 3553  Request a pure (reentrant) parser progra
3553  Generate an array of token names in the parser file.  The name of the  Generate an array of token names in the parser file.  The name of the
3554  array is @code{yytname}; @code{yytname[@var{i}]} is the name of the  array is @code{yytname}; @code{yytname[@var{i}]} is the name of the
3555  token whose internal Bison token code number is @var{i}.  The first  token whose internal Bison token code number is @var{i}.  The first
3556  three elements of @code{yytname} are always @code{"$"}, @code{"error"},  three elements of @code{yytname} are always @code{"$end"},
3557  and @code{"$undefined."}; after these come the symbols defined in the  @code{"error"}, and @code{"$undefined"}; after these come the symbols
3558  grammar file.  defined in the grammar file.
3559    
3560  For single-character literal tokens and literal string tokens, the name  For single-character literal tokens and literal string tokens, the name
3561  in the table includes the single-quote or double-quote characters: for  in the table includes the single-quote or double-quote characters: for
# Line 5276  useless: STR; Line 5276  useless: STR;
5276  %%  %%
5277  @end example  @end example
5278    
5279  @command{bison} reports that @samp{calc.y contains 1 useless nonterminal  @command{bison} reports:
5280  and 1 useless rule} and that @samp{calc.y contains 7 shift/reduce  
5281  conflicts}.  When given @option{--report=state}, in addition to  @example
5282  @file{calc.tab.c}, it creates a file @file{calc.output} with contents  calc.y: warning: 1 useless nonterminal and 1 useless rule
5283  detailed below.  The order of the output and the exact presentation  calc.y:11.1-7: warning: useless nonterminal: useless
5284  might vary, but the interpretation is the same.  calc.y:11.8-12: warning: useless rule: useless: STR
5285    calc.y contains 7 shift/reduce conflicts.
5286    @end example
5287    
5288    When given @option{--report=state}, in addition to @file{calc.tab.c}, it
5289    creates a file @file{calc.output} with contents detailed below.  The
5290    order of the output and the exact presentation might vary, but the
5291    interpretation is the same.
5292    
5293  The first section includes details on conflicts that were solved thanks  The first section includes details on conflicts that were solved thanks
5294  to precedence and/or associativity:  to precedence and/or associativity:
# Line 5334  The next section reproduces the exact gr Line 5341  The next section reproduces the exact gr
5341  Grammar  Grammar
5342    
5343    Number, Line, Rule    Number, Line, Rule
5344      0   5 $axiom -> exp $      0   5 $accept -> exp $end
5345      1   5 exp -> exp '+' exp      1   5 exp -> exp '+' exp
5346      2   6 exp -> exp '-' exp      2   6 exp -> exp '-' exp
5347      3   7 exp -> exp '*' exp      3   7 exp -> exp '*' exp
# Line 5348  and reports the uses of the symbols: Line 5355  and reports the uses of the symbols:
5355  @example  @example
5356  Terminals, with rules where they appear  Terminals, with rules where they appear
5357    
5358  $ (0) 0  $end (0) 0
5359  '*' (42) 3  '*' (42) 3
5360  '+' (43) 1  '+' (43) 1
5361  '-' (45) 2  '-' (45) 2
# Line 5358  NUM (258) 5 Line 5365  NUM (258) 5
5365    
5366  Nonterminals, with rules where they appear  Nonterminals, with rules where they appear
5367    
5368  $axiom (8)  $accept (8)
5369      on left: 0      on left: 0
5370  exp (9)  exp (9)
5371      on left: 1 2 3 4 5, on right: 0 1 2 3 4      on left: 1 2 3 4 5, on right: 0 1 2 3 4
# Line 5376  that the input cursor. Line 5383  that the input cursor.
5383  @example  @example
5384  state 0  state 0
5385    
5386      $axiom  ->  . exp $   (rule 0)      $accept  ->  . exp $   (rule 0)
5387    
5388      NUM         shift, and go to state 1      NUM         shift, and go to state 1
5389    
# Line 5407  be derived: Line 5414  be derived:
5414  @example  @example
5415  state 0  state 0
5416    
5417      $axiom  ->  . exp $   (rule 0)      $accept  ->  . exp $   (rule 0)
5418      exp  ->  . exp '+' exp   (rule 1)      exp  ->  . exp '+' exp   (rule 1)
5419      exp  ->  . exp '-' exp   (rule 2)      exp  ->  . exp '-' exp   (rule 2)
5420      exp  ->  . exp '*' exp   (rule 3)      exp  ->  . exp '*' exp   (rule 3)
# Line 5439  jump to state 2 (@samp{exp: go to state Line 5446  jump to state 2 (@samp{exp: go to state
5446  @example  @example
5447  state 2  state 2
5448    
5449      $axiom  ->  exp . $   (rule 0)      $accept  ->  exp . $   (rule 0)
5450      exp  ->  exp . '+' exp   (rule 1)      exp  ->  exp . '+' exp   (rule 1)
5451      exp  ->  exp . '-' exp   (rule 2)      exp  ->  exp . '-' exp   (rule 2)
5452      exp  ->  exp . '*' exp   (rule 3)      exp  ->  exp . '*' exp   (rule 3)
# Line 5466  state}: Line 5473  state}:
5473  @example  @example
5474  state 3  state 3
5475    
5476      $axiom  ->  exp $ .   (rule 0)      $accept  ->  exp $ .   (rule 0)
5477    
5478      $default    accept      $default    accept
5479  @end example  @end example
# Line 6006  would instead be named @file{foo_tab.c}. Line 6013  would instead be named @file{foo_tab.c}.
6013  @table @code  @table @code
6014  @item @@$  @item @@$
6015  In an action, the location of the left-hand side of the rule.  In an action, the location of the left-hand side of the rule.
6016    @xref{Locations, , Locations Overview}.  @xref{Locations, , Locations Overview}.
6017    
6018  @item @@@var{n}  @item @@@var{n}
6019  In an action, the location of the @var{n}-th symbol of the right-hand  In an action, the location of the @var{n}-th symbol of the right-hand
# Line 6020  In an action, the semantic value of the Line 6027  In an action, the semantic value of the
6027  In an action, the semantic value of the @var{n}-th symbol of the  In an action, the semantic value of the @var{n}-th symbol of the
6028  right-hand side of the rule.  @xref{Actions}.  right-hand side of the rule.  @xref{Actions}.
6029    
6030    @item $accept
6031    The predefined nonterminal whose only rule is @samp{$accept: @var{start}
6032    $end}, where @var{start} is the start symbol.  @xref{Start Decl, , The
6033    Start-Symbol}.  It cannot be used in the grammar.
6034    
6035    @item $end
6036    The predefined token marking the end of the token stream.  It cannot be
6037    used in the grammar.
6038    
6039    @item $undefined
6040    The predefined token onto which all undefined values returned by
6041    @code{yylex} are mapped.  It cannot be used in the grammar, rather, use
6042    @code{error}.
6043    
6044  @item error  @item error
6045  A token name reserved for error recovery.  This token may be used in  A token name reserved for error recovery.  This token may be used in
6046  grammar rules so as to allow the Bison parser to recognize an error in  grammar rules so as to allow the Bison parser to recognize an error in

Legend:
Removed from v.1.66  
changed lines
  Added in v.1.67

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26