* NEWS: Document when yyparse started to return 2.

* doc/bison.texinfo (Parser Function): Document when yyparse
returns 2.

* data/lalr1.cc: Revert part of previous change, as it's incompatible.
(b4_filename_type): Renamed back from b4_file_name_type.  All uses
changed.
(class position): file_name -> filename (reverting).  All uses changed.
This commit is contained in:
Paul Eggert
2005-09-15 14:06:52 +00:00
parent 94306d5282
commit b47dbebee5
4 changed files with 36 additions and 14 deletions

View File

@@ -1,3 +1,20 @@
2005-09-15 Paul Eggert <eggert@cs.ucla.edu>
* NEWS: Document when yyparse started to return 2.
* doc/bison.texinfo (Parser Function): Document when yyparse
returns 2.
* data/lalr1.cc: Revert part of previous change, as it's incompatible.
(b4_filename_type): Renamed back from b4_file_name_type. All uses
changed.
(class position): file_name -> filename (reverting). All uses changed.
2005-09-14 Paul Eggert <eggert@cs.ucla.edu>
* examples/calc++/Makefile.am ($(calc_sources_generated)): Don't
do anything if $@ exists. This reverts part of the 2005-07-07
patch.
2005-09-11 Paul Eggert <eggert@cs.ucla.edu> 2005-09-11 Paul Eggert <eggert@cs.ucla.edu>
* Makefile.am (EXTRA_DIST): Do not distribute REFERENCES; it * Makefile.am (EXTRA_DIST): Do not distribute REFERENCES; it

2
NEWS
View File

@@ -428,6 +428,8 @@ Changes in version 1.31, 2002-01-14:
alloca is used only when compiled with GCC, to avoid portability alloca is used only when compiled with GCC, to avoid portability
problems as on AIX. problems as on AIX.
* yyparse now returns 2 if memory is exhausted; formerly it dumped core.
* When the generated parser lacks debugging code, YYDEBUG is now 0 * When the generated parser lacks debugging code, YYDEBUG is now 0
(as POSIX requires) instead of being undefined. (as POSIX requires) instead of being undefined.

View File

@@ -48,7 +48,7 @@ m4_define([b4_rhs_value],
[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))]) [(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))])
m4_define_default([b4_location_type], [location]) m4_define_default([b4_location_type], [location])
m4_define_default([b4_file_name_type], [std::string]) m4_define_default([b4_filename_type], [std::string])
# b4_lhs_location() # b4_lhs_location()
# ----------------- # -----------------
@@ -1256,7 +1256,7 @@ namespace yy
public: public:
/// Construct a position. /// Construct a position.
position () : position () :
file_name (0), filename (0),
line (initial_line), line (initial_line),
column (initial_column) column (initial_column)
{ {
@@ -1288,7 +1288,7 @@ namespace yy
public: public:
/// File name to which this position refers. /// File name to which this position refers.
]b4_file_name_type[* file_name; ]b4_filename_type[* filename;
/// Current line number. /// Current line number.
unsigned int line; unsigned int line;
/// Current column number. /// Current column number.
@@ -1332,8 +1332,8 @@ namespace yy
inline std::ostream& inline std::ostream&
operator<< (std::ostream& ostr, const position& pos) operator<< (std::ostream& ostr, const position& pos)
{ {
if (pos.file_name) if (pos.filename)
ostr << *pos.file_name << ':'; ostr << *pos.filename << ':';
return ostr << pos.line << '.' << pos.column; return ostr << pos.line << '.' << pos.column;
} }
@@ -1435,9 +1435,9 @@ namespace yy
{ {
position last = loc.end - 1; position last = loc.end - 1;
ostr << loc.begin; ostr << loc.begin;
if (last.file_name if (last.filename
&& (!loc.begin.file_name && (!loc.begin.filename
|| *loc.begin.file_name != *last.file_name)) || *loc.begin.filename != *last.filename))
ostr << '-' << last; ostr << '-' << last;
else if (loc.begin.line != last.line) else if (loc.begin.line != last.line)
ostr << '-' << last.line << '.' << last.column; ostr << '-' << last.line << '.' << last.column;

View File

@@ -3782,8 +3782,7 @@ For instance, if your locations use a file name, you may use
%parse-param @{ char const *file_name @}; %parse-param @{ char const *file_name @};
%initial-action %initial-action
@{ @{
@@$.begin.file_name = @@$.end.file_name = file_name; @@$.begin.filename = @@$.end.filename = file_name;
@@$.begin.file_name = @@$.end.file_name = file_name;
@}; @};
@end example @end example
@@ -4272,7 +4271,11 @@ without reading further.
The value returned by @code{yyparse} is 0 if parsing was successful (return The value returned by @code{yyparse} is 0 if parsing was successful (return
is due to end-of-input). is due to end-of-input).
The value is 1 if parsing failed (return is due to a syntax error). The value is 1 if parsing failed because of invalid input, i.e., input
that contains a syntax error or that causes @code{YYABORT} to be
invoked.
The value is 2 if parsing failed due to memory exhaustion.
@end deftypefun @end deftypefun
In an action, you can cause immediate return from @code{yyparse} by using In an action, you can cause immediate return from @code{yyparse} by using
@@ -6951,7 +6954,7 @@ Symbols}.
@c - %locations @c - %locations
@c - class Position @c - class Position
@c - class Location @c - class Location
@c - %define "file_name_type" "const symbol::Symbol" @c - %define "filename_type" "const symbol::Symbol"
When the directive @code{%locations} is used, the C++ parser supports When the directive @code{%locations} is used, the C++ parser supports
location tracking, see @ref{Locations, , Locations Overview}. Two location tracking, see @ref{Locations, , Locations Overview}. Two
@@ -6963,7 +6966,7 @@ and a @code{location}, a range composed of a pair of
The name of the file. It will always be handled as a pointer, the The name of the file. It will always be handled as a pointer, the
parser will never duplicate nor deallocate it. As an experimental parser will never duplicate nor deallocate it. As an experimental
feature you may change it to @samp{@var{type}*} using @samp{%define feature you may change it to @samp{@var{type}*} using @samp{%define
"file_name_type" "@var{type}"}. "filename_type" "@var{type}"}.
@end deftypemethod @end deftypemethod
@deftypemethod {position} {unsigned int} line @deftypemethod {position} {unsigned int} line
@@ -7323,7 +7326,7 @@ automatically propagated.
%initial-action %initial-action
@{ @{
// Initialize the initial location. // Initialize the initial location.
@@$.begin.file_name = @@$.end.file_name = &driver.file; @@$.begin.filename = @@$.end.filename = &driver.file;
@}; @};
@end example @end example