X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/ab7f29f8f9a7ad89b6a3163f913e1ee2b7889223..118d4978839515efa4d6bb4815a774c5c3f947e7:/doc/bison.texinfo diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 72d027ac..da10c6bb 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -4023,7 +4023,7 @@ associativity and precedence. @xref{Precedence Decl, ,Operator Precedence}. You can explicitly specify the numeric code for a token type by appending -a decimal or hexadecimal integer value in the field immediately +a nonnegative decimal or hexadecimal integer value in the field immediately following the token name: @example @@ -4076,6 +4076,16 @@ Once you equate the literal string and the token name, you can use them interchangeably in further declarations or the grammar rules. The @code{yylex} function can use the token name or the literal string to obtain the token type code number (@pxref{Calling Convention}). +Syntax error messages passed to @code{yyerror} from the parser will reference +the literal string instead of the token name. + +The token numbered as 0 corresponds to end of file; the following line +allows for nicer error messages referring to ``end of file'' instead +of ``$end'': + +@example +%token END 0 "end of file" +@end example @node Precedence Decl @subsection Operator Precedence @@ -4543,6 +4553,9 @@ valid grammar. @cindex push parser @findex %define api.push_pull +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) + A pull parser is called once and it takes control until all its input is completely parsed. A push parser, on the other hand, is called each time a new token is made available. @@ -4872,6 +4885,8 @@ Some of the accepted @var{variable}s are: @item Purpose: Requests a pull parser, a push parser, or both. @xref{Push Decl, ,A Push Parser}. +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) @item Accepted Values: @code{"pull"}, @code{"push"}, @code{"both"} @@ -5032,7 +5047,7 @@ chosen as if the input file were named @file{@var{prefix}.y}. @deffn {Directive} %language "@var{language}" Specify the programming language for the generated parser. Currently -supported languages include C and C++. +supported languages include C, C++, and Java. @var{language} is case-insensitive. @end deffn @@ -5294,6 +5309,9 @@ exp: @dots{} @{ @dots{}; *randomness += 1; @dots{} @} @section The Push Parser Function @code{yypush_parse} @findex yypush_parse +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) + You call the function @code{yypush_parse} to parse a single token. This function is available if either the @code{%define api.push_pull "push"} or @code{%define api.push_pull "both"} declaration is used. @@ -5309,6 +5327,9 @@ is required to finish parsing the grammar. @section The Pull Parser Function @code{yypull_parse} @findex yypull_parse +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) + You call the function @code{yypull_parse} to parse the rest of the input stream. This function is available if the @code{%define api.push_pull "both"} declaration is used. @@ -5322,6 +5343,9 @@ The value returned by @code{yypull_parse} is the same as for @code{yyparse}. @section The Parser Create Function @code{yystate_new} @findex yypstate_new +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) + You call the function @code{yypstate_new} to create a new parser instance. This function is available if either the @code{%define api.push_pull "push"} or @code{%define api.push_pull "both"} declaration is used. @@ -5329,13 +5353,18 @@ This function is available if either the @code{%define api.push_pull "push"} or @deftypefun yypstate *yypstate_new (void) The fuction will return a valid parser instance if there was memory available -or NULL if no memory was available. +or 0 if no memory was available. +In impure mode, it will also return 0 if a parser instance is currently +allocated. @end deftypefun @node Parser Delete Function @section The Parser Delete Function @code{yystate_delete} @findex yypstate_delete +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) + You call the function @code{yypstate_delete} to delete a parser instance. function is available if either the @code{%define api.push_pull "push"} or @code{%define api.push_pull "both"} declaration is used. @@ -7747,6 +7776,46 @@ traditional Yacc grammars. If your grammar uses a Bison extension like @samp{%glr-parser}, Bison might not be Yacc-compatible even if this option is specified. +@item -W +@itemx --warnings +Output warnings falling in @var{category}. @var{category} can be one +of: +@table @code +@item midrule-values +Warn about about mid-rule values that are set but not used within any of +the actions of the parent rule. For example, Bison warns about unused +@code{$2} in: + +@example +exp: '1' @{ $$ = 1; @} '+' exp @{ $$ = $1 + $4; @}; +@end example + +It also warns about mid-rule values that are used but not set. For +example, Bison warns about unset @code{$$} in the mid-rule action in: + +@example + exp: '1' @{ $1 = 1; @} '+' exp @{ $$ = $2 + $4; @}; +@end example + +These warnings are not enabled by default since they sometimes prove to +be false alarms in existing grammars employing the Yacc constructs +@code{$0} or @code{$-@var{b}} (where @var{n} is some positive integer). + + +@item yacc +Incompatibilities with @acronym{POSIX} Yacc. + +@item all +all the warnings +@item none +turn off all the warnings +@item error +treat warnings as errors +@end table + +A category can be turned off by prefixing its name with @samp{no-}. For +instance, @option{-Wno-syntax} will hide the warnings about unused +variables. @end table @noindent @@ -7763,7 +7832,7 @@ already defined, so that the debugging facilities are compiled. @itemx --language=@var{language} Specify the programming language for the generated parser, as if @code{%language} was specified (@pxref{Decl Summary, , Bison Declaration -Summary}). Currently supported languages include C and C++. +Summary}). Currently supported languages include C, C++, and Java. @var{language} is case-insensitive. @item --locations @@ -7864,9 +7933,18 @@ If the grammar file is @file{foo.y}, the output file will be @file{foo.dot}. @item --graph=@var{graph-file} -The behavior of @var{--graph} is the same than @samp{-g}. The only +The behavior of @var{--graph} is the same as @samp{-g}. The only difference is that it has an optional argument which is the name of the output graph file. + +@item -x +@itemx --xml=@var{file} +Output an XML report of the @acronym{LALR}(1) automaton computed by Bison. +@code{=@var{file}} is optional. +If omitted and the grammar file is @file{foo.y}, the output file will be +@file{foo.xml}. +(The current XML schema is experimental and may evolve. +More user feedback will help to stabilize it.) @end table @node Option Cross Key @@ -8657,6 +8735,9 @@ main (int argc, char *argv[]) @c - %language "Java" @c - initial action +(The current Java interface is experimental and may evolve. +More user feedback will help to stabilize it.) + The Java parser skeletons are selected using a language directive, @samp{%language "Java"}, or the synonymous command-line option @option{--language=java}. @@ -9769,6 +9850,8 @@ The function to delete a parser instance, produced by Bison in push mode; call this function to delete the memory associated with a parser. @xref{Parser Delete Function, ,The Parser Delete Function @code{yypstate_delete}}. +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) @end deffn @deffn {Function} yypstate_new @@ -9776,6 +9859,8 @@ The function to create a parser instance, produced by Bison in push mode; call this function to create a new parser. @xref{Parser Create Function, ,The Parser Create Function @code{yypstate_new}}. +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) @end deffn @deffn {Function} yypull_parse @@ -9783,12 +9868,16 @@ The parser function produced by Bison in push mode; call this function to parse the rest of the input stream. @xref{Pull Parser Function, ,The Pull Parser Function @code{yypull_parse}}. +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) @end deffn @deffn {Function} yypush_parse The parser function produced by Bison in push mode; call this function to parse a single token. @xref{Push Parser Function, ,The Push Parser Function @code{yypush_parse}}. +(The current push parsing interface is experimental and may evolve. +More user feedback will help to stabilize it.) @end deffn @deffn {Macro} YYPARSE_PARAM