+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>
* Makefile.am (EXTRA_DIST): Do not distribute REFERENCES; it
alloca is used only when compiled with GCC, to avoid portability
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
(as POSIX requires) instead of being undefined.
[(yysemantic_stack_@{m4_eval([$1 - $2])@}m4_ifval([$3], [.$3]))])
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()
# -----------------
public:
/// Construct a position.
position () :
- file_name (0),
+ filename (0),
line (initial_line),
column (initial_column)
{
public:
/// File name to which this position refers.
- ]b4_file_name_type[* file_name;
+ ]b4_filename_type[* filename;
/// Current line number.
unsigned int line;
/// Current column number.
inline std::ostream&
operator<< (std::ostream& ostr, const position& pos)
{
- if (pos.file_name)
- ostr << *pos.file_name << ':';
+ if (pos.filename)
+ ostr << *pos.filename << ':';
return ostr << pos.line << '.' << pos.column;
}
{
position last = loc.end - 1;
ostr << loc.begin;
- if (last.file_name
- && (!loc.begin.file_name
- || *loc.begin.file_name != *last.file_name))
+ if (last.filename
+ && (!loc.begin.filename
+ || *loc.begin.filename != *last.filename))
ostr << '-' << last;
else if (loc.begin.line != last.line)
ostr << '-' << last.line << '.' << last.column;
%parse-param @{ char const *file_name @};
%initial-action
@{
- @@$.begin.file_name = @@$.end.file_name = file_name;
- @@$.begin.file_name = @@$.end.file_name = file_name;
+ @@$.begin.filename = @@$.end.filename = file_name;
@};
@end example
The value returned by @code{yyparse} is 0 if parsing was successful (return
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
In an action, you can cause immediate return from @code{yyparse} by using
@c - %locations
@c - class Position
@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
location tracking, see @ref{Locations, , Locations Overview}. Two
The name of the file. It will always be handled as a pointer, the
parser will never duplicate nor deallocate it. As an experimental
feature you may change it to @samp{@var{type}*} using @samp{%define
-"file_name_type" "@var{type}"}.
+"filename_type" "@var{type}"}.
@end deftypemethod
@deftypemethod {position} {unsigned int} line
%initial-action
@{
// Initialize the initial location.
- @@$.begin.file_name = @@$.end.file_name = &driver.file;
+ @@$.begin.filename = @@$.end.filename = &driver.file;
@};
@end example