]> git.saurik.com Git - bison.git/commitdiff
Since we now use obstacks, more % directives can be enabled.
authorAkim Demaille <akim@epita.fr>
Thu, 18 Jan 2001 14:47:09 +0000 (14:47 +0000)
committerAkim Demaille <akim@epita.fr>
Thu, 18 Jan 2001 14:47:09 +0000 (14:47 +0000)
* src/lex.c (percent_table): Also accept `%yacc',
`%fixed_output_files', `%defines', `%no_parser', `%verbose', and
`%debug'.
Handle the actions for `%semantic_parser' and `%pure_parser' here,
instead of returning a token.
* src/lex.h (SEMANTIC_PARSER, PURE_PARSER): Remove, unused.
* src/reader.c (read_declarations): Adjust.
* src/files.c (open_files): Don't call `compute_base_names', don't
compute `attrsfile' since they depend upon data which might be
*in* the input file now.
(output_files): Do it here.
* src/output.c (output_headers): Document the fact that this patch
introduces a guaranteed SEGV for semantic parsers.
* doc/bison.texinfo: Document them.
* tests/suite.at: Exercise these %options.

14 files changed:
ChangeLog
NEWS
doc/bison.info
doc/bison.info-3
doc/bison.info-4
doc/bison.info-5
doc/bison.texinfo
doc/stamp-vti
src/files.c
src/lex.c
src/lex.h
src/output.c
src/reader.c
tests/suite.at

index 77a1e8a6f2ed3753d352ae02bbd48956ef5751e5..c4380a93d04c51006817d3eb7abb5cc132579465 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2001-01-18  Akim Demaille  <akim@epita.fr>
+
+       Since we now use obstacks, more % directives can be enabled.
+
+       * src/lex.c (percent_table): Also accept `%yacc',
+       `%fixed_output_files', `%defines', `%no_parser', `%verbose', and
+       `%debug'.
+       Handle the actions for `%semantic_parser' and `%pure_parser' here,
+       instead of returning a token.
+       * src/lex.h (SEMANTIC_PARSER, PURE_PARSER): Remove, unused.
+       * src/reader.c (read_declarations): Adjust.
+       * src/files.c (open_files): Don't call `compute_base_names', don't
+       compute `attrsfile' since they depend upon data which might be
+       *in* the input file now.
+       (output_files): Do it here.
+       * src/output.c (output_headers): Document the fact that this patch
+       introduces a guaranteed SEGV for semantic parsers.
+       * doc/bison.texinfo: Document them.
+       * tests/suite.at: Exercise these %options.
+
 2000-12-20  Akim Demaille  <akim@epita.fr>
 
        Also handle the output file (--verbose) with obstacks.
diff --git a/NEWS b/NEWS
index 89304e06f749a81ae38641f1609e17344a220d99..8fbadf4e1178d3f3d8fd88f8b0433c348dacbbed 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ Changes in version 1.28a:
 * Added the old Bison reference card.
 
 * Added `--locations' and `%locations'.
+
+* New directives.
+  `%yacc', `%fixed_output_files', `%defines', `%no_parser', `%verbose', and
+  `%debug'.
 \f
 Changes in version 1.28:
 
@@ -84,4 +88,3 @@ Changes in version 1.22:
 Changes in version 1.20:
 
 Output file does not redefine const for C++.
-
index edc4e14eec6a070898cb64ee8039ae08384fdecd..763b5eb2a9619446498d39d4e92c2f65fbc3f043 100644 (file)
@@ -33,8 +33,8 @@ Indirect:
 bison.info-1: 1306
 bison.info-2: 50276
 bison.info-3: 98079
-bison.info-4: 147374
-bison.info-5: 197192
+bison.info-4: 147596
+bison.info-5: 191991
 \1f
 Tag Table:
 (Indirect)
@@ -93,42 +93,42 @@ Node: Expect Decl\7f110281
 Node: Start Decl\7f111827
 Node: Pure Decl\7f112205
 Node: Decl Summary\7f113882
-Node: Multiple Parsers\7f117718
-Node: Interface\7f119212
-Node: Parser Function\7f120084
-Node: Lexical\7f120919
-Node: Calling Convention\7f122325
-Node: Token Values\7f125096
-Node: Token Positions\7f126245
-Node: Pure Calling\7f127137
-Node: Error Reporting\7f130069
-Node: Action Features\7f132191
-Node: Algorithm\7f135852
-Node: Look-Ahead\7f138145
-Node: Shift/Reduce\7f140277
-Node: Precedence\7f143189
-Node: Why Precedence\7f143840
-Node: Using Precedence\7f145705
-Node: Precedence Examples\7f146673
-Node: How Precedence\7f147374
-Node: Contextual Precedence\7f148523
-Node: Parser States\7f150314
-Node: Reduce/Reduce\7f151557
-Node: Mystery Conflicts\7f155118
-Node: Stack Overflow\7f158504
-Node: Error Recovery\7f159877
-Node: Context Dependency\7f165013
-Node: Semantic Tokens\7f165861
-Node: Lexical Tie-ins\7f168878
-Node: Tie-in Recovery\7f170426
-Node: Debugging\7f172598
-Node: Invocation\7f175899
-Node: Bison Options\7f176629
-Node: Environment Variables\7f180983
-Node: Option Cross Key\7f181831
-Node: VMS Invocation\7f182721
-Node: Table of Symbols\7f183505
-Node: Glossary\7f190902
-Node: Index\7f197192
+Node: Multiple Parsers\7f119609
+Node: Interface\7f121103
+Node: Parser Function\7f121975
+Node: Lexical\7f122810
+Node: Calling Convention\7f124216
+Node: Token Values\7f126987
+Node: Token Positions\7f128136
+Node: Pure Calling\7f129028
+Node: Error Reporting\7f131960
+Node: Action Features\7f134082
+Node: Algorithm\7f137743
+Node: Look-Ahead\7f140036
+Node: Shift/Reduce\7f142168
+Node: Precedence\7f145080
+Node: Why Precedence\7f145731
+Node: Using Precedence\7f147596
+Node: Precedence Examples\7f148564
+Node: How Precedence\7f149265
+Node: Contextual Precedence\7f150414
+Node: Parser States\7f152205
+Node: Reduce/Reduce\7f153448
+Node: Mystery Conflicts\7f157009
+Node: Stack Overflow\7f160395
+Node: Error Recovery\7f161768
+Node: Context Dependency\7f166904
+Node: Semantic Tokens\7f167752
+Node: Lexical Tie-ins\7f170769
+Node: Tie-in Recovery\7f172317
+Node: Debugging\7f174489
+Node: Invocation\7f177790
+Node: Bison Options\7f178520
+Node: Environment Variables\7f181893
+Node: Option Cross Key\7f182741
+Node: VMS Invocation\7f183631
+Node: Table of Symbols\7f184415
+Node: Glossary\7f191991
+Node: Index\7f198281
 \1f
 End Tag Table
index 28cbcc370fa22495729f038f04ca647577d38c6a..66b519a75ee8906ea028b8a2125c4ba30d76e0f8 100644 (file)
@@ -465,6 +465,11 @@ Bison Declaration Summary
      Declare the expected number of shift-reduce conflicts (*note
      Suppressing Conflict Warnings: Expect Decl.).
 
+`%yacc'
+`%fixed_output_files'
+     Pretend the option `--yacc' was given, i.e., imitate Yacc,
+     including its naming conventions.  *Note Bison Options::, for more.
+
 `%locations'
      Generate the code processing the locations (*note Special Features
      for Use in Actions: Action Features.).  This mode is enabled as
@@ -476,6 +481,15 @@ Bison Declaration Summary
      Request a pure (reentrant) parser program (*note A Pure
      (Reentrant) Parser: Pure Decl.).
 
+`%no_parser'
+     Do not include any C code in the parser file; generate tables
+     only.  The parser file contains just `#define' directives and
+     static variable declarations.
+
+     This option also tells Bison to write the C code for the grammar
+     actions into a file named `FILENAME.act', in the form of a
+     brace-surrounded body fit for a `switch' statement.
+
 `%no_lines'
      Don't generate any `#line' preprocessor commands in the parser
      file.  Ordinarily Bison writes these commands in the parser file
@@ -484,6 +498,39 @@ Bison Declaration Summary
      directive causes them to associate errors with the parser file,
      treating it an independent source file in its own right.
 
+`%debug'
+     Output a definition of the macro `YYDEBUG' into the parser file, so
+     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.
+
+     This file also describes all the conflicts, both those resolved by
+     operator precedence and the unresolved ones.
+
+     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'.
+
 `%raw'
      The output file `NAME.h' normally defines the tokens with
      Yacc-compatible token numbers.  If this option is specified, the
@@ -1248,48 +1295,3 @@ of left or right association is a matter of whether the parser chooses
 to shift or reduce when the stack contains `1 - 2' and the look-ahead
 token is `-': shifting makes right-associativity.
 
-\1f
-File: bison.info,  Node: Using Precedence,  Next: Precedence Examples,  Prev: Why Precedence,  Up: Precedence
-
-Specifying Operator Precedence
-------------------------------
-
-   Bison allows you to specify these choices with the operator
-precedence declarations `%left' and `%right'.  Each such declaration
-contains a list of tokens, which are operators whose precedence and
-associativity is being declared.  The `%left' declaration makes all
-those operators left-associative and the `%right' declaration makes
-them right-associative.  A third alternative is `%nonassoc', which
-declares that it is a syntax error to find the same operator twice "in a
-row".
-
-   The relative precedence of different operators is controlled by the
-order in which they are declared.  The first `%left' or `%right'
-declaration in the file declares the operators whose precedence is
-lowest, the next such declaration declares the operators whose
-precedence is a little higher, and so on.
-
-\1f
-File: bison.info,  Node: Precedence Examples,  Next: How Precedence,  Prev: Using Precedence,  Up: Precedence
-
-Precedence Examples
--------------------
-
-   In our example, we would want the following declarations:
-
-     %left '<'
-     %left '-'
-     %left '*'
-
-   In a more complete example, which supports other operators as well,
-we would declare them in groups of equal precedence.  For example,
-`'+'' is declared with `'-'':
-
-     %left '<' '>' '=' NE LE GE
-     %left '+' '-'
-     %left '*' '/'
-
-(Here `NE' and so on stand for the operators for "not equal" and so on.
-We assume that these tokens are more than one character long and
-therefore are represented by names, not character literals.)
-
index 323fed0025aabf9341927be444799c03bf7e1527..ae2509a431ec939ec96e7acf1342b2654a12e46b 100644 (file)
@@ -28,6 +28,51 @@ License", "Conditions for Using Bison" and this permission notice may be
 included in translations approved by the Free Software Foundation
 instead of in the original English.
 
+\1f
+File: bison.info,  Node: Using Precedence,  Next: Precedence Examples,  Prev: Why Precedence,  Up: Precedence
+
+Specifying Operator Precedence
+------------------------------
+
+   Bison allows you to specify these choices with the operator
+precedence declarations `%left' and `%right'.  Each such declaration
+contains a list of tokens, which are operators whose precedence and
+associativity is being declared.  The `%left' declaration makes all
+those operators left-associative and the `%right' declaration makes
+them right-associative.  A third alternative is `%nonassoc', which
+declares that it is a syntax error to find the same operator twice "in a
+row".
+
+   The relative precedence of different operators is controlled by the
+order in which they are declared.  The first `%left' or `%right'
+declaration in the file declares the operators whose precedence is
+lowest, the next such declaration declares the operators whose
+precedence is a little higher, and so on.
+
+\1f
+File: bison.info,  Node: Precedence Examples,  Next: How Precedence,  Prev: Using Precedence,  Up: Precedence
+
+Precedence Examples
+-------------------
+
+   In our example, we would want the following declarations:
+
+     %left '<'
+     %left '-'
+     %left '*'
+
+   In a more complete example, which supports other operators as well,
+we would declare them in groups of equal precedence.  For example,
+`'+'' is declared with `'-'':
+
+     %left '<' '>' '=' NE LE GE
+     %left '+' '-'
+     %left '*' '/'
+
+(Here `NE' and so on stand for the operators for "not equal" and so on.
+We assume that these tokens are more than one character long and
+therefore are represented by names, not character literals.)
+
 \1f
 File: bison.info,  Node: How Precedence,  Prev: Precedence Examples,  Up: Precedence
 
@@ -803,9 +848,9 @@ Tuning the parser:
 
 `-t'
 `--debug'
-     Output a definition of the macro `YYDEBUG' into the parser file,
-     so that the debugging facilities are compiled.  *Note Debugging
-     Your Parser: Debugging.
+     Output a definition of the macro `YYDEBUG' into the parser file, so
+     that the debugging facilities are compiled.  *Note Debugging Your
+     Parser: Debugging.
 
 `--locations'
      Pretend that `%locactions' was specified.  *Note Decl Summary::.
@@ -833,13 +878,7 @@ Tuning the parser:
 
 `-n'
 `--no-parser'
-     Do not include any C code in the parser file; generate tables
-     only.  The parser file contains just `#define' directives and
-     static variable declarations.
-
-     This option also tells Bison to write the C code for the grammar
-     actions into a file named `FILENAME.act', in the form of a
-     brace-surrounded body fit for a `switch' statement.
+     Pretend that `%no_parser' was specified.  *Note Decl Summary::.
 
 `-r'
 `--raw'
@@ -853,17 +892,10 @@ Adjust the output:
 
 `-d'
 `--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.
+     Pretend that `%verbose' was specified, i.e., 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.  *Note Decl Summary::.
 
 `-b FILE-PREFIX'
 `--file-prefix=PREFIX'
@@ -872,19 +904,9 @@ Adjust the output:
 
 `-v'
 `--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.
-
-     This file also describes all the conflicts, both those resolved by
-     operator precedence and the unresolved ones.
-
-     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'.
+     Pretend that `%verbose' was specified, i.e, write an extra output
+     file containing verbose descriptions of the grammar and parser.
+     *Note Decl Summary::, for more.
 
 `-o OUTFILE'
 `--output-file=OUTFILE'
@@ -1093,6 +1115,13 @@ Bison Symbols
      The parser function produced by Bison; call this function to start
      parsing.  *Note The Parser Function `yyparse': Parser Function.
 
+`%debug'
+     Equip the parser for debugging.  *Note Decl Summary::.
+
+`%defines'
+     Bison declaration to create a header file meant for the scanner.
+     *Note Decl Summary::.
+
 `%left'
      Bison declaration to assign left associativity to token(s).  *Note
      Operator Precedence: Precedence Decl.
@@ -1169,169 +1198,3 @@ Bison Symbols
      Separates alternate rules for the same result nonterminal.  *Note
      Syntax of Grammar Rules: Rules.
 
-\1f
-File: bison.info,  Node: Glossary,  Next: Index,  Prev: Table of Symbols,  Up: Top
-
-Glossary
-********
-
-Backus-Naur Form (BNF)
-     Formal method of specifying context-free grammars.  BNF was first
-     used in the `ALGOL-60' report, 1963.  *Note Languages and
-     Context-Free Grammars: Language and Grammar.
-
-Context-free grammars
-     Grammars specified as rules that can be applied regardless of
-     context.  Thus, if there is a rule which says that an integer can
-     be used as an expression, integers are allowed _anywhere_ an
-     expression is permitted.  *Note Languages and Context-Free
-     Grammars: Language and Grammar.
-
-Dynamic allocation
-     Allocation of memory that occurs during execution, rather than at
-     compile time or on entry to a function.
-
-Empty string
-     Analogous to the empty set in set theory, the empty string is a
-     character string of length zero.
-
-Finite-state stack machine
-     A "machine" that has discrete states in which it is said to exist
-     at each instant in time.  As input to the machine is processed, the
-     machine moves from state to state as specified by the logic of the
-     machine.  In the case of the parser, the input is the language
-     being parsed, and the states correspond to various stages in the
-     grammar rules.  *Note The Bison Parser Algorithm: Algorithm.
-
-Grouping
-     A language construct that is (in general) grammatically divisible;
-     for example, `expression' or `declaration' in C.  *Note Languages
-     and Context-Free Grammars: Language and Grammar.
-
-Infix operator
-     An arithmetic operator that is placed between the operands on
-     which it performs some operation.
-
-Input stream
-     A continuous flow of data between devices or programs.
-
-Language construct
-     One of the typical usage schemas of the language.  For example,
-     one of the constructs of the C language is the `if' statement.
-     *Note Languages and Context-Free Grammars: Language and Grammar.
-
-Left associativity
-     Operators having left associativity are analyzed from left to
-     right: `a+b+c' first computes `a+b' and then combines with `c'.
-     *Note Operator Precedence: Precedence.
-
-Left recursion
-     A rule whose result symbol is also its first component symbol; for
-     example, `expseq1 : expseq1 ',' exp;'.  *Note Recursive Rules:
-     Recursion.
-
-Left-to-right parsing
-     Parsing a sentence of a language by analyzing it token by token
-     from left to right.  *Note The Bison Parser Algorithm: Algorithm.
-
-Lexical analyzer (scanner)
-     A function that reads an input stream and returns tokens one by
-     one.  *Note The Lexical Analyzer Function `yylex': Lexical.
-
-Lexical tie-in
-     A flag, set by actions in the grammar rules, which alters the way
-     tokens are parsed.  *Note Lexical Tie-ins::.
-
-Literal string token
-     A token which consists of two or more fixed characters.  *Note
-     Symbols::.
-
-Look-ahead token
-     A token already read but not yet shifted.  *Note Look-Ahead
-     Tokens: Look-Ahead.
-
-LALR(1)
-     The class of context-free grammars that Bison (like most other
-     parser generators) can handle; a subset of LR(1).  *Note
-     Mysterious Reduce/Reduce Conflicts: Mystery Conflicts.
-
-LR(1)
-     The class of context-free grammars in which at most one token of
-     look-ahead is needed to disambiguate the parsing of any piece of
-     input.
-
-Nonterminal symbol
-     A grammar symbol standing for a grammatical construct that can be
-     expressed through rules in terms of smaller constructs; in other
-     words, a construct that is not a token.  *Note Symbols::.
-
-Parse error
-     An error encountered during parsing of an input stream due to
-     invalid syntax.  *Note Error Recovery::.
-
-Parser
-     A function that recognizes valid sentences of a language by
-     analyzing the syntax structure of a set of tokens passed to it
-     from a lexical analyzer.
-
-Postfix operator
-     An arithmetic operator that is placed after the operands upon
-     which it performs some operation.
-
-Reduction
-     Replacing a string of nonterminals and/or terminals with a single
-     nonterminal, according to a grammar rule.  *Note The Bison Parser
-     Algorithm: Algorithm.
-
-Reentrant
-     A reentrant subprogram is a subprogram which can be in invoked any
-     number of times in parallel, without interference between the
-     various invocations.  *Note A Pure (Reentrant) Parser: Pure Decl.
-
-Reverse polish notation
-     A language in which all operators are postfix operators.
-
-Right recursion
-     A rule whose result symbol is also its last component symbol; for
-     example, `expseq1: exp ',' expseq1;'.  *Note Recursive Rules:
-     Recursion.
-
-Semantics
-     In computer languages, the semantics are specified by the actions
-     taken for each instance of the language, i.e., the meaning of each
-     statement.  *Note Defining Language Semantics: Semantics.
-
-Shift
-     A parser is said to shift when it makes the choice of analyzing
-     further input from the stream rather than reducing immediately some
-     already-recognized rule.  *Note The Bison Parser Algorithm:
-     Algorithm.
-
-Single-character literal
-     A single character that is recognized and interpreted as is.
-     *Note From Formal Rules to Bison Input: Grammar in Bison.
-
-Start symbol
-     The nonterminal symbol that stands for a complete valid utterance
-     in the language being parsed.  The start symbol is usually listed
-     as the first nonterminal symbol in a language specification.
-     *Note The Start-Symbol: Start Decl.
-
-Symbol table
-     A data structure where symbol names and associated data are stored
-     during parsing to allow for recognition and use of existing
-     information in repeated uses of a symbol.  *Note Multi-function
-     Calc::.
-
-Token
-     A basic, grammatically indivisible unit of a language.  The symbol
-     that describes a token in the grammar is a terminal symbol.  The
-     input of the Bison parser is a stream of tokens which comes from
-     the lexical analyzer.  *Note Symbols::.
-
-Terminal symbol
-     A grammar symbol that has no rules in the grammar and therefore is
-     grammatically indivisible.  The piece of text it represents is a
-     token.  *Note Languages and Context-Free Grammars: Language and
-     Grammar.
-
index a1dfa4d00547aecb951baf3d734a2b67f7e1fb2c..a917e95cb84129cec175674b58f9abf0caf2fb13 100644 (file)
@@ -28,6 +28,172 @@ License", "Conditions for Using Bison" and this permission notice may be
 included in translations approved by the Free Software Foundation
 instead of in the original English.
 
+\1f
+File: bison.info,  Node: Glossary,  Next: Index,  Prev: Table of Symbols,  Up: Top
+
+Glossary
+********
+
+Backus-Naur Form (BNF)
+     Formal method of specifying context-free grammars.  BNF was first
+     used in the `ALGOL-60' report, 1963.  *Note Languages and
+     Context-Free Grammars: Language and Grammar.
+
+Context-free grammars
+     Grammars specified as rules that can be applied regardless of
+     context.  Thus, if there is a rule which says that an integer can
+     be used as an expression, integers are allowed _anywhere_ an
+     expression is permitted.  *Note Languages and Context-Free
+     Grammars: Language and Grammar.
+
+Dynamic allocation
+     Allocation of memory that occurs during execution, rather than at
+     compile time or on entry to a function.
+
+Empty string
+     Analogous to the empty set in set theory, the empty string is a
+     character string of length zero.
+
+Finite-state stack machine
+     A "machine" that has discrete states in which it is said to exist
+     at each instant in time.  As input to the machine is processed, the
+     machine moves from state to state as specified by the logic of the
+     machine.  In the case of the parser, the input is the language
+     being parsed, and the states correspond to various stages in the
+     grammar rules.  *Note The Bison Parser Algorithm: Algorithm.
+
+Grouping
+     A language construct that is (in general) grammatically divisible;
+     for example, `expression' or `declaration' in C.  *Note Languages
+     and Context-Free Grammars: Language and Grammar.
+
+Infix operator
+     An arithmetic operator that is placed between the operands on
+     which it performs some operation.
+
+Input stream
+     A continuous flow of data between devices or programs.
+
+Language construct
+     One of the typical usage schemas of the language.  For example,
+     one of the constructs of the C language is the `if' statement.
+     *Note Languages and Context-Free Grammars: Language and Grammar.
+
+Left associativity
+     Operators having left associativity are analyzed from left to
+     right: `a+b+c' first computes `a+b' and then combines with `c'.
+     *Note Operator Precedence: Precedence.
+
+Left recursion
+     A rule whose result symbol is also its first component symbol; for
+     example, `expseq1 : expseq1 ',' exp;'.  *Note Recursive Rules:
+     Recursion.
+
+Left-to-right parsing
+     Parsing a sentence of a language by analyzing it token by token
+     from left to right.  *Note The Bison Parser Algorithm: Algorithm.
+
+Lexical analyzer (scanner)
+     A function that reads an input stream and returns tokens one by
+     one.  *Note The Lexical Analyzer Function `yylex': Lexical.
+
+Lexical tie-in
+     A flag, set by actions in the grammar rules, which alters the way
+     tokens are parsed.  *Note Lexical Tie-ins::.
+
+Literal string token
+     A token which consists of two or more fixed characters.  *Note
+     Symbols::.
+
+Look-ahead token
+     A token already read but not yet shifted.  *Note Look-Ahead
+     Tokens: Look-Ahead.
+
+LALR(1)
+     The class of context-free grammars that Bison (like most other
+     parser generators) can handle; a subset of LR(1).  *Note
+     Mysterious Reduce/Reduce Conflicts: Mystery Conflicts.
+
+LR(1)
+     The class of context-free grammars in which at most one token of
+     look-ahead is needed to disambiguate the parsing of any piece of
+     input.
+
+Nonterminal symbol
+     A grammar symbol standing for a grammatical construct that can be
+     expressed through rules in terms of smaller constructs; in other
+     words, a construct that is not a token.  *Note Symbols::.
+
+Parse error
+     An error encountered during parsing of an input stream due to
+     invalid syntax.  *Note Error Recovery::.
+
+Parser
+     A function that recognizes valid sentences of a language by
+     analyzing the syntax structure of a set of tokens passed to it
+     from a lexical analyzer.
+
+Postfix operator
+     An arithmetic operator that is placed after the operands upon
+     which it performs some operation.
+
+Reduction
+     Replacing a string of nonterminals and/or terminals with a single
+     nonterminal, according to a grammar rule.  *Note The Bison Parser
+     Algorithm: Algorithm.
+
+Reentrant
+     A reentrant subprogram is a subprogram which can be in invoked any
+     number of times in parallel, without interference between the
+     various invocations.  *Note A Pure (Reentrant) Parser: Pure Decl.
+
+Reverse polish notation
+     A language in which all operators are postfix operators.
+
+Right recursion
+     A rule whose result symbol is also its last component symbol; for
+     example, `expseq1: exp ',' expseq1;'.  *Note Recursive Rules:
+     Recursion.
+
+Semantics
+     In computer languages, the semantics are specified by the actions
+     taken for each instance of the language, i.e., the meaning of each
+     statement.  *Note Defining Language Semantics: Semantics.
+
+Shift
+     A parser is said to shift when it makes the choice of analyzing
+     further input from the stream rather than reducing immediately some
+     already-recognized rule.  *Note The Bison Parser Algorithm:
+     Algorithm.
+
+Single-character literal
+     A single character that is recognized and interpreted as is.
+     *Note From Formal Rules to Bison Input: Grammar in Bison.
+
+Start symbol
+     The nonterminal symbol that stands for a complete valid utterance
+     in the language being parsed.  The start symbol is usually listed
+     as the first nonterminal symbol in a language specification.
+     *Note The Start-Symbol: Start Decl.
+
+Symbol table
+     A data structure where symbol names and associated data are stored
+     during parsing to allow for recognition and use of existing
+     information in repeated uses of a symbol.  *Note Multi-function
+     Calc::.
+
+Token
+     A basic, grammatically indivisible unit of a language.  The symbol
+     that describes a token in the grammar is a terminal symbol.  The
+     input of the Bison parser is a stream of tokens which comes from
+     the lexical analyzer.  *Note Symbols::.
+
+Terminal symbol
+     A grammar symbol that has no rules in the grammar and therefore is
+     grammatically indivisible.  The piece of text it represents is a
+     token.  *Note Languages and Context-Free Grammars: Language and
+     Grammar.
+
 \1f
 File: bison.info,  Node: Index,  Prev: Glossary,  Up: Top
 
index da8508211a64dc52a3eab90c19767b85710ab054..be291754d6e31657ecae55dd8f991297fb36b01b 100644 (file)
@@ -3189,6 +3189,11 @@ Start-Symbol}).
 Declare the expected number of shift-reduce conflicts
 (@pxref{Expect Decl, ,Suppressing Conflict Warnings}).
 
+@item %yacc
+@itemx %fixed_output_files
+Pretend the option @option{--yacc} was given, i.e., imitate Yacc,
+including its naming conventions.  @xref{Bison Options}, for more.
+
 @item %locations
 Generate the code processing the locations (@pxref{Action Features,
 ,Special Features for Use in Actions}).  This mode is enabled as soon as
@@ -3200,6 +3205,15 @@ accurate parse error messages.
 Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure
 (Reentrant) Parser}).
 
+@item %no_parser
+Do not include any C code in the parser file; generate tables only.  The
+parser file contains just @code{#define} directives and static variable
+declarations.
+
+This option also tells Bison to write the C code for the grammar actions
+into a file named @file{@var{filename}.act}, in the form of a
+brace-surrounded body fit for a @code{switch} statement.
+
 @item %no_lines
 Don't generate any @code{#line} preprocessor commands in the parser
 file.  Ordinarily Bison writes these commands in the parser file so that
@@ -3208,6 +3222,39 @@ your source file (the grammar file).  This directive causes them to
 associate errors with the parser file, treating it an independent source
 file in its own right.
 
+@item %debug
+Output a definition of the macro @code{YYDEBUG} into the parser file, so
+that the debugging facilities are compiled.  @xref{Debugging, ,Debugging
+Your Parser}.
+
+@item %defines
+Write an extra output file containing macro definitions for the token
+type names defined in the grammar and the semantic value type
+@code{YYSTYPE}, as well as a few @code{extern} variable declarations.
+
+If the parser output file is named @file{@var{name}.c} then this file
+is named @file{@var{name}.h}.@refill
+
+This output file is essential if you wish to put the definition of
+@code{yylex} in a separate source file, because @code{yylex} needs to
+be able to refer to token type codes and the variable
+@code{yylval}.  @xref{Token Values, ,Semantic Values of Tokens}.@refill
+
+@item %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.
+
+This file also describes all the conflicts, both those resolved by
+operator precedence and the unresolved ones.
+
+The file's name is made by removing @samp{.tab.c} or @samp{.c} from
+the parser output file name, and adding @samp{.output} instead.@refill
+
+Therefore, if the input file is @file{foo.y}, then the parser file is
+called @file{foo.tab.c} by default.  As a consequence, the verbose
+output file is called @file{foo.output}.@refill
+
 @item %raw
 The output file @file{@var{name}.h} normally defines the tokens with
 Yacc-compatible token numbers.  If this option is specified, the
@@ -4939,8 +4986,9 @@ Tuning the parser:
 @table @option
 @item -t
 @itemx --debug
-Output a definition of the macro @code{YYDEBUG} into the parser file,
-so that the debugging facilities are compiled.  @xref{Debugging, ,Debugging Your Parser}.
+Output a definition of the macro @code{YYDEBUG} into the parser file, so
+that the debugging facilities are compiled.  @xref{Debugging, ,Debugging
+Your Parser}.
 
 @item --locations
 Pretend that @code{%locactions} was specified.  @xref{Decl Summary}.
@@ -4967,13 +5015,7 @@ parser file, treating it as an independent source file in its own right.
 
 @item -n
 @itemx --no-parser
-Do not include any C code in the parser file; generate tables only.  The
-parser file contains just @code{#define} directives and static variable
-declarations.
-
-This option also tells Bison to write the C code for the grammar actions
-into a file named @file{@var{filename}.act}, in the form of a
-brace-surrounded body fit for a @code{switch} statement.
+Pretend that @code{%no_parser} was specified.  @xref{Decl Summary}.
 
 @item -r
 @itemx --raw
@@ -4990,17 +5032,10 @@ Adjust the output:
 @table @option
 @item -d
 @itemx --defines
-Write an extra output file containing macro definitions for the token
-type names defined in the grammar and the semantic value type
-@code{YYSTYPE}, as well as a few @code{extern} variable declarations.
-
-If the parser output file is named @file{@var{name}.c} then this file
-is named @file{@var{name}.h}.@refill
-
-This output file is essential if you wish to put the definition of
-@code{yylex} in a separate source file, because @code{yylex} needs to
-be able to refer to token type codes and the variable
-@code{yylval}.  @xref{Token Values, ,Semantic Values of Tokens}.@refill
+Pretend that @code{%verbose} was specified, i.e., write an extra output
+file containing macro definitions for the token type names defined in
+the grammar and the semantic value type @code{YYSTYPE}, as well as a few
+@code{extern} variable declarations.  @xref{Decl Summary}.
 
 @item -b @var{file-prefix}
 @itemx --file-prefix=@var{prefix}
@@ -5009,19 +5044,9 @@ chosen as if the input file were named @file{@var{prefix}.c}.
 
 @item -v
 @itemx --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.
-
-This file also describes all the conflicts, both those resolved by
-operator precedence and the unresolved ones.
-
-The file's name is made by removing @samp{.tab.c} or @samp{.c} from
-the parser output file name, and adding @samp{.output} instead.@refill
-
-Therefore, if the input file is @file{foo.y}, then the parser file is
-called @file{foo.tab.c} by default.  As a consequence, the verbose
-output file is called @file{foo.output}.@refill
+Pretend that @code{%verbose} was specified, i.e, write an extra output
+file containing verbose descriptions of the grammar and
+parser. @xref{Decl Summary}, for more.
 
 @item -o @var{outfile}
 @itemx --output-file=@var{outfile}
@@ -5255,6 +5280,13 @@ Global variable which Bison increments each time there is a parse error.
 The parser function produced by Bison; call this function to start
 parsing.  @xref{Parser Function, ,The Parser Function @code{yyparse}}.
 
+@item %debug
+Equip the parser for debugging.  @xref{Decl Summary}.
+
+@item %defines
+Bison declaration to create a header file meant for the scanner.
+@xref{Decl Summary}.
+
 @item %left
 Bison declaration to assign left associativity to token(s).
 @xref{Precedence Decl, ,Operator Precedence}.
index aafe601c06c3053eedc37f9e574821d5fae78185..5fb7ec0579bbeb33ad63eeb8c0c6fb309fea656a 100644 (file)
@@ -1,3 +1,3 @@
-@set UPDATED 15 January 2001
+@set UPDATED 18 January 2001
 @set EDITION 1.28a
 @set VERSION 1.28a
index 7433076a1f81e8afe07f30a9b73366e484791b41..eefa188d11cf72140eeb210e04f084acc4d504d1 100644 (file)
@@ -245,12 +245,8 @@ compute_base_names (void)
 void
 open_files (void)
 {
-  compute_base_names ();
-
   finput = xfopen (infile, "r");
 
-  attrsfile = stringappend (short_base_name, EXT_STYPE_H);
-
   /* Initialize the obstacks. */
   obstack_init (&action_obstack);
   obstack_init (&attrs_obstack);
@@ -271,6 +267,9 @@ output_files (void)
 {
   xfclose (finput);
 
+  compute_base_names ();
+  attrsfile = stringappend (short_base_name, EXT_STYPE_H);
+
   /* Output the main file.  */
   if (spec_outfile)
     obstack_save (&table_obstack, spec_outfile);
index 4d6fdb6a5d08bdb103f23f84a52202ecf2e05b14..6e54712443f03f9810d7f6ae02b97c14a001af54 100644 (file)
--- a/src/lex.c
+++ b/src/lex.c
@@ -538,48 +538,47 @@ struct percent_table_struct
   const char *name;
   void *set_flag;
   int retval;
-}
-percent_table[] =
+};
+
+struct percent_table_struct percent_table[] =
 {
-  { "token", NULL, TOKEN },
-  { "term", NULL, TOKEN },
-  { "nterm", NULL, NTERM },
-  { "type", NULL, TYPE },
-  { "guard", NULL, GUARD },
-  { "union", NULL, UNION },
-  { "expect", NULL, EXPECT },
-  { "thong", NULL, THONG },
-  { "start", NULL, START },
-  { "left", NULL, LEFT },
-  { "right", NULL, RIGHT },
-  { "nonassoc", NULL, NONASSOC },
-  { "binary", NULL, NONASSOC },
-  { "semantic_parser", NULL, SEMANTIC_PARSER },
-  { "pure_parser", NULL, PURE_PARSER },
-  { "prec", NULL, PREC },
-  { "locations", &locations_flag, NOOP},       /* -l */
-  { "no_lines", &no_lines_flag, NOOP}, /* -l */
-  { "raw", &raw_flag, NOOP },  /* -r */
-  { "token_table", &token_table_flag, NOOP},   /* -k */
+  { "token",           NULL,                   TOKEN },
+  { "term",            NULL,                   TOKEN },
+  { "nterm",           NULL,                   NTERM },
+  { "type",            NULL,                   TYPE },
+  { "guard",           NULL,                   GUARD },
+  { "union",           NULL,                   UNION },
+  { "expect",          NULL,                   EXPECT },
+  { "thong",           NULL,                   THONG },
+  { "start",           NULL,                   START },
+  { "left",            NULL,                   LEFT },
+  { "right",           NULL,                   RIGHT },
+  { "nonassoc",                NULL,                   NONASSOC },
+  { "binary",          NULL,                   NONASSOC },
+  { "prec",            NULL,                   PREC },
+  { "locations",       &locations_flag,        NOOP },         /* -l */
+  { "no_lines",                &no_lines_flag,         NOOP },         /* -l */
+  { "raw",             &raw_flag,              NOOP },         /* -r */
+  { "token_table",     &token_table_flag,      NOOP },         /* -k */
+  { "yacc",            &yacc_flag,             NOOP },         /* -y */
+  { "fixed_output_files",&yacc_flag,           NOOP },         /* -y */
+  { "defines",         &defines_flag,          NOOP },         /* -d */
+  { "no_parser",       &no_parser_flag,        NOOP },         /* -n */
 #if 0
-    /* These can be utilized after main is reoganized so
-       open_files() is deferred 'til after read_declarations().
-       But %{ and %union both put information into files
-       that have to be opened before read_declarations().
-     */
-  { "yacc", &yacc_flag, NOOP},                         /* -y */
-  { "fixed_output_files", &yacc_flag, NOOP},           /* -y */
-  { "defines", &defines_flag, NOOP},                   /* -d */
-  { "no_parser", &no_parser_flag, NOOP},               /* -n */
-  { "output_file", &spec_outfile, SETOPT},             /* -o */
-  { "file_prefix", &spec_file_prefix, SETOPT},         /* -b */
-  { "name_prefix", &spec_name_prefix, SETOPT},         /* -p */
-    /* These would be acceptable, but they do not affect processing */
-  { "verbose", &verbose_flag, NOOP},                   /* -v */
-  { "debug", &debug_flag, NOOP},                       /* -t */
+  /* For the time being, this is not enabled yet, while it's possible
+     though, since we use obstacks.  The only risk is with semantic
+     parsers which will output an `include' of an output file: be sure
+     that the naem included is indeed the name of the output file.  */
+  { "output_file",     &spec_outfile,          SETOPT },       /* -o */
+  { "file_prefix",     &spec_file_prefix,      SETOPT },       /* -b */
+  { "name_prefix",     &spec_name_prefix,      SETOPT },       /* -p */
+#endif
+  { "verbose",         &verbose_flag,          NOOP },         /* -v */
+  { "debug",           &debug_flag,            NOOP },         /* -t */
+  { "semantic_parser", &semantic_parser,       NOOP },
+  { "pure_parser",     &pure_parser,           NOOP },
 /*    {"help", <print usage stmt>, NOOP}, *//* -h */
 /*    {"version", <print version number> ,  NOOP}, *//* -V */
-#endif
   { NULL, NULL, ILLEGAL}
 };
 
@@ -646,6 +645,7 @@ parse_percent_token (void)
   for (tx = percent_table; tx->name; tx++)
     if (strcmp (token_buffer + 1, tx->name) == 0)
       break;
+
   if (tx->retval == SETOPT)
     {
       *((char **) (tx->set_flag)) = optarg;
index aa267eecdf2ee8ed4c9cf8ff6046dae214623f80..3e4560f50c568bf25f00c1861228220e66705a2e 100644 (file)
--- a/src/lex.h
+++ b/src/lex.h
@@ -41,8 +41,6 @@
 # define RIGHT         16
 # define NONASSOC      17
 # define PREC                  18
-# define SEMANTIC_PARSER 19
-# define PURE_PARSER           20
 # define TYPENAME      21
 # define NUMBER                22
 # define EXPECT                23
index f4b3c3fd7f8fd8600d01c4c0f428f6f27388fe5f..914e0a7d87d660a8120693135c851d4bf44c7a22 100644 (file)
@@ -223,10 +223,18 @@ register YYLTYPE *yylsp;\n\
 void
 output_headers (void)
 {
-  char *attrsfile_quoted = quotearg_style (c_quoting_style, attrsfile);
+  char *attrsfile_quoted = 0;
 
   if (semantic_parser)
-    obstack_fgrow1 (&guard_obstack, GUARDSTR, attrsfile_quoted);
+    {
+      /* FIXME: This is *buggy*.  ATTRSFILE is not computed yet, since
+        we are waiting for the full input file to have been read to
+        be sure of the output file name.  So basically, here, a SEGV
+        is guaranteed.  OTOH, currently semantic parsers are not
+        supported.  */
+      attrsfile_quoted = quotearg_style (c_quoting_style, attrsfile);
+      obstack_fgrow1 (&guard_obstack, GUARDSTR, attrsfile_quoted);
+    }
 
   if (no_parser_flag)
     return;
index 4f62e759a8e731c6af7f26311881c3c6988e6d58..9ae0238e41d4cd5862ac6d932647f0ee985f9e20 100644 (file)
@@ -931,6 +931,7 @@ read_declarations (void)
            case EXPECT:
              parse_expect_decl ();
              break;
+
            case THONG:
              parse_thong_decl ();
              break;
@@ -947,14 +948,6 @@ read_declarations (void)
              parse_assoc_decl (non_assoc);
              break;
 
-           case SEMANTIC_PARSER:
-             semantic_parser = 1;
-             break;
-
-           case PURE_PARSER:
-             pure_parser = 1;
-             break;
-
            case NOOP:
              break;
 
index e2283513953a49aa9618ce7215d22d47349b1b91..ce72011561eb430a9dbc70c418e76a7a04edff05 100644 (file)
@@ -9,29 +9,53 @@ AT_INIT([bison])
 ## Checking output file names.  ##
 ## ---------------------------- ##
 
-AT_SETUP([Checking output file names.])
-
+# AT_CHECK_BISON_FLAGS(FLAGS, EXPECTED-FILES-SORTED)
+# --------------------------------------------------
+AT_DEFINE([AT_CHECK_BISON_FLAGS],
+[AT_SETUP([Output files: $1.])
 AT_DATA([foo.y],
 [[%%
 foo: {}
 ]])
-
-# AT_CHECK_BISON_OUTPUT(FLAGS, EXPECTED-FILES-SORTED)
-# ---------------------------------------------------
-AT_DEFINE([AT_CHECK_BISON_OUTPUT],
-[rm -rf $2
+rm -rf $2
 AT_CHECK([bison -dv foo.y $1], 0, ignore, ignore)
 AT_CHECK([ls $2 | sort | tr '\n' ' ' | sed 's/.$//g'], 0, [$2])
-rm -f $2])
+rm -f $2
+AT_CLEANUP
+])
+
+AT_CHECK_BISON_FLAGS([],             [foo.output foo.tab.c foo.tab.h])
+AT_CHECK_BISON_FLAGS([-o foo.c],     [foo.c foo.h foo.output])
+AT_CHECK_BISON_FLAGS([-o foo.tab.c], [foo.output foo.tab.c foo.tab.h])
+AT_CHECK_BISON_FLAGS([-y],           [y.output y.tab.c y.tab.h])
+AT_CHECK_BISON_FLAGS([-b bar],       [bar.output bar.tab.c bar.tab.h])
 
-AT_CHECK_BISON_OUTPUT([],             [foo.output foo.tab.c foo.tab.h])
-AT_CHECK_BISON_OUTPUT([-o foo.c],     [foo.c foo.h foo.output])
-AT_CHECK_BISON_OUTPUT([-o foo.tab.c], [foo.output foo.tab.c foo.tab.h])
-AT_CHECK_BISON_OUTPUT([-y],           [y.output y.tab.c y.tab.h])
-AT_CHECK_BISON_OUTPUT([-b bar],       [bar.output bar.tab.c bar.tab.h])
 
-AT_CLEANUP
 
+# AT_CHECK_BISON_PERCENT(GRAMMAR-OPTIONS, EXPECTED-FILES-SORTED)
+# --------------------------------------------------------------
+AT_DEFINE([AT_CHECK_BISON_PERCENT],
+[AT_SETUP([Output files: $1.])
+AT_DATA([foo.y],
+[[$1
+%defines
+%verbose
+%%
+foo: {}
+]])
+rm -rf $2
+AT_CHECK([bison foo.y], 0, ignore, ignore)
+AT_CHECK([ls $2 | sort | tr '\n' ' ' | sed 's/.$//g'], 0, [$2])
+rm -f $2
+AT_CLEANUP
+])
+
+# The sames, but using the % directives.
+AT_CHECK_BISON_PERCENT([],                  [foo.output foo.tab.c foo.tab.h])
+# AT_CHECK_BISON_PERCENT([%output foo.c],     [foo.c foo.h foo.output])
+# AT_CHECK_BISON_PERCENT([%output foo.tab.c], [foo.output foo.tab.c foo.tab.h])
+AT_CHECK_BISON_PERCENT([%yacc],             [y.output y.tab.c y.tab.h])
+# AT_CHECK_BISON_PERCENT([%file_prefix bar],  [bar.output bar.tab.c bar.tab.h])
 
 AT_INCLUDE([calc.at])
 AT_INCLUDE([regression.at])