/[bison]/bison/doc/bison.info-3
ViewVC logotype

Diff of /bison/doc/bison.info-3

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

revision 1.8.2.1 by akim, Wed Aug 29 12:16:04 2001 UTC revision 1.8.2.2 by akim, Sun Nov 4 16:26:59 2001 UTC
# Line 710  File: bison.info,  Node: Decl Summary, Line 710  File: bison.info,  Node: Decl Summary,
710  Bison Declaration Summary  Bison Declaration Summary
711  -------------------------  -------------------------
712    
713     Here is a summary of all Bison declarations:     Here is a summary of the declarations used to define a grammar:
714    
715  `%union'  `%union'
716       Declare the collection of data types that semantic values may have       Declare the collection of data types that semantic values may have
# Line 745  Bison Declaration Summary Line 745  Bison Declaration Summary
745       Declare the expected number of shift-reduce conflicts (*note       Declare the expected number of shift-reduce conflicts (*note
746       Suppressing Conflict Warnings: Expect Decl.).       Suppressing Conflict Warnings: Expect Decl.).
747    
748  `%yacc'  
749  `%fixed_output_files'  In order to change the behavior of `bison', use the following
750       Pretend the option `--yacc' was given, i.e., imitate Yacc,  directives:
751       including its naming conventions.  *Note Bison Options::, for more.  
752    `%debug'
753         Output a definition of the macro `YYDEBUG' into the parser file, so
754         that the debugging facilities are compiled.  *Note Debugging Your
755         Parser: Debugging.
756    
757    `%defines'
758         Write an extra output file containing macro definitions for the
759         token type names defined in the grammar and the semantic value type
760         `YYSTYPE', as well as a few `extern' variable declarations.
761    
762         If the parser output file is named `NAME.c' then this file is
763         named `NAME.h'.
764    
765         This output file is essential if you wish to put the definition of
766         `yylex' in a separate source file, because `yylex' needs to be
767         able to refer to token type codes and the variable `yylval'.
768         *Note Semantic Values of Tokens: Token Values.
769    
770    `%file-prefix="PREFIX"'
771         Specify a prefix to use for all Bison output file names.  The
772         names are chosen as if the input file were named `PREFIX.y'.
773    
774  `%locations'  `%locations'
775       Generate the code processing the locations (*note Special Features       Generate the code processing the locations (*note Special Features
# Line 757  Bison Declaration Summary Line 778  Bison Declaration Summary
778       grammar does not use it, using `%locations' allows for more       grammar does not use it, using `%locations' allows for more
779       accurate parse error messages.       accurate parse error messages.
780    
781  `%pure_parser'  `%name-prefix="PREFIX"'
782       Request a pure (reentrant) parser program (*note A Pure       Rename the external symbols used in the parser so that they start
783       (Reentrant) Parser: Pure Decl.).       with PREFIX instead of `yy'.  The precise list of symbols renamed
784         is `yyparse', `yylex', `yyerror', `yynerrs', `yylval', `yychar'
785         and `yydebug'.  For example, if you use `%name-prefix="c_"', the
786         names become `c_parse', `c_lex', and so on.  *Note Multiple
787         Parsers in the Same Program: Multiple Parsers.
788    
789  `%no_parser'  `%no-parser'
790       Do not include any C code in the parser file; generate tables       Do not include any C code in the parser file; generate tables
791       only.  The parser file contains just `#define' directives and       only.  The parser file contains just `#define' directives and
792       static variable declarations.       static variable declarations.
# Line 770  Bison Declaration Summary Line 795  Bison Declaration Summary
795       actions into a file named `FILENAME.act', in the form of a       actions into a file named `FILENAME.act', in the form of a
796       brace-surrounded body fit for a `switch' statement.       brace-surrounded body fit for a `switch' statement.
797    
798  `%no_lines'  `%no-lines'
799       Don't generate any `#line' preprocessor commands in the parser       Don't generate any `#line' preprocessor commands in the parser
800       file.  Ordinarily Bison writes these commands in the parser file       file.  Ordinarily Bison writes these commands in the parser file
801       so that the C compiler and debuggers will associate errors and       so that the C compiler and debuggers will associate errors and
# Line 778  Bison Declaration Summary Line 803  Bison Declaration Summary
803       directive causes them to associate errors with the parser file,       directive causes them to associate errors with the parser file,
804       treating it an independent source file in its own right.       treating it an independent source file in its own right.
805    
806  `%debug'  `%output="FILENAME"'
807       Output a definition of the macro `YYDEBUG' into the parser file, so       Specify the FILENAME for the parser file.
      that the debugging facilities are compiled.  *Note Debugging Your  
      Parser: Debugging.  
   
 `%defines'  
      Write an extra output file containing macro definitions for the  
      token type names defined in the grammar and the semantic value type  
      `YYSTYPE', as well as a few `extern' variable declarations.  
   
      If the parser output file is named `NAME.c' then this file is  
      named `NAME.h'.  
   
      This output file is essential if you wish to put the definition of  
      `yylex' in a separate source file, because `yylex' needs to be  
      able to refer to token type codes and the variable `yylval'.  
      *Note Semantic Values of Tokens: Token Values.  
   
 `%verbose'  
      Write an extra output file containing verbose descriptions of the  
      parser states and what is done for each type of look-ahead token in  
      that state.  
808    
809       This file also describes all the conflicts, both those resolved by  `%pure-parser'
810       operator precedence and the unresolved ones.       Request a pure (reentrant) parser program (*note A Pure
811         (Reentrant) Parser: Pure Decl.).
      The file's name is made by removing `.tab.c' or `.c' from the  
      parser output file name, and adding `.output' instead.  
   
      Therefore, if the input file is `foo.y', then the parser file is  
      called `foo.tab.c' by default.  As a consequence, the verbose  
      output file is called `foo.output'.  
812    
813  `%token_table'  `%token_table'
814       Generate an array of token names in the parser file.  The name of       Generate an array of token names in the parser file.  The name of
# Line 845  Bison Declaration Summary Line 844  Bison Declaration Summary
844      `YYNSTATES'      `YYNSTATES'
845            The number of parser states (*note Parser States::).            The number of parser states (*note Parser States::).
846    
847    `%verbose'
848         Write an extra output file containing verbose descriptions of the
849         parser states and what is done for each type of look-ahead token in
850         that state.
851    
852         This file also describes all the conflicts, both those resolved by
853         operator precedence and the unresolved ones.
854    
855         The file's name is made by removing `.tab.c' or `.c' from the
856         parser output file name, and adding `.output' instead.
857    
858         Therefore, if the input file is `foo.y', then the parser file is
859         called `foo.tab.c' by default.  As a consequence, the verbose
860         output file is called `foo.output'.
861    
862    `%yacc'
863    `%fixed-output-files'
864         Pretend the option `--yacc' was given, i.e., imitate Yacc,
865         including its naming conventions.  *Note Bison Options::, for more.
866    
867    
868  File: bison.info,  Node: Multiple Parsers,  Prev: Declarations,  Up: Grammar File  File: bison.info,  Node: Multiple Parsers,  Prev: Declarations,  Up: Grammar File
869    
# Line 1226  encountered so far.  Normally this varia Line 1245  encountered so far.  Normally this varia
1245  request a pure parser (*note A Pure (Reentrant) Parser: Pure Decl.)  request a pure parser (*note A Pure (Reentrant) Parser: Pure Decl.)
1246  then it is a local variable which only the actions can access.  then it is a local variable which only the actions can access.
1247    
   
 File: bison.info,  Node: Action Features,  Prev: Error Reporting,  Up: Interface  
   
 Special Features for Use in Actions  
 ===================================  
   
    Here is a table of Bison constructs, variables and macros that are  
 useful in actions.  
   
 `$$'  
      Acts like a variable that contains the semantic value for the  
      grouping made by the current rule.  *Note Actions::.  
   
 `$N'  
      Acts like a variable that contains the semantic value for the Nth  
      component of the current rule.  *Note Actions::.  
   
 `$<TYPEALT>$'  
      Like `$$' but specifies alternative TYPEALT in the union specified  
      by the `%union' declaration.  *Note Data Types of Values in  
      Actions: Action Types.  
   
 `$<TYPEALT>N'  
      Like `$N' but specifies alternative TYPEALT in the union specified  
      by the `%union' declaration.  *Note Data Types of Values in  
      Actions: Action Types.  
   
 `YYABORT;'  
      Return immediately from `yyparse', indicating failure.  *Note The  
      Parser Function `yyparse': Parser Function.  
   
 `YYACCEPT;'  
      Return immediately from `yyparse', indicating success.  *Note The  
      Parser Function `yyparse': Parser Function.  
   
 `YYBACKUP (TOKEN, VALUE);'  
      Unshift a token.  This macro is allowed only for rules that reduce  
      a single value, and only when there is no look-ahead token.  It  
      installs a look-ahead token with token type TOKEN and semantic  
      value VALUE; then it discards the value that was going to be  
      reduced by this rule.  
   
      If the macro is used when it is not valid, such as when there is a  
      look-ahead token already, then it reports a syntax error with a  
      message `cannot back up' and performs ordinary error recovery.  
   
      In either case, the rest of the action is not executed.  
   
 `YYEMPTY'  
      Value stored in `yychar' when there is no look-ahead token.  
   
 `YYERROR;'  
      Cause an immediate syntax error.  This statement initiates error  
      recovery just as if the parser itself had detected an error;  
      however, it does not call `yyerror', and does not print any  
      message.  If you want to print an error message, call `yyerror'  
      explicitly before the `YYERROR;' statement.  *Note Error  
      Recovery::.  
   
 `YYRECOVERING'  
      This macro stands for an expression that has the value 1 when the  
      parser is recovering from a syntax error, and 0 the rest of the  
      time.  *Note Error Recovery::.  
   
 `yychar'  
      Variable containing the current look-ahead token.  (In a pure  
      parser, this is actually a local variable within `yyparse'.)  When  
      there is no look-ahead token, the value `YYEMPTY' is stored in the  
      variable.  *Note Look-Ahead Tokens: Look-Ahead.  
   
 `yyclearin;'  
      Discard the current look-ahead token.  This is useful primarily in  
      error rules.  *Note Error Recovery::.  
   
 `yyerrok;'  
      Resume generating error messages immediately for subsequent syntax  
      errors.  This is useful primarily in error rules.  *Note Error  
      Recovery::.  
   
 `@$'  
      Acts like a structure variable containing information on the  
      textual position of the grouping made by the current rule.  *Note  
      Tracking Locations: Locations.  
   
 `@N'  
      Acts like a structure variable containing information on the  
      textual position of the Nth component of the current rule.  *Note  
      Tracking Locations: Locations.  
   

Legend:
Removed from v.1.8.2.1  
changed lines
  Added in v.1.8.2.2

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