From b47dbebee51e9d093e140e78b6bedaf065a01c8c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 15 Sep 2005 14:06:52 +0000 Subject: [PATCH] * 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. --- ChangeLog | 17 +++++++++++++++++ NEWS | 2 ++ data/lalr1.cc | 16 ++++++++-------- doc/bison.texinfo | 15 +++++++++------ 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 606837d6..76152369 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-09-15 Paul Eggert + + * 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 + + * 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 * Makefile.am (EXTRA_DIST): Do not distribute REFERENCES; it diff --git a/NEWS b/NEWS index 8593f27f..fa198bbe 100644 --- a/NEWS +++ b/NEWS @@ -428,6 +428,8 @@ Changes in version 1.31, 2002-01-14: 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. diff --git a/data/lalr1.cc b/data/lalr1.cc index 837f7df8..0b6ca5d9 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -48,7 +48,7 @@ m4_define([b4_rhs_value], [(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() # ----------------- @@ -1256,7 +1256,7 @@ namespace yy public: /// Construct a position. position () : - file_name (0), + filename (0), line (initial_line), column (initial_column) { @@ -1288,7 +1288,7 @@ namespace yy 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. @@ -1332,8 +1332,8 @@ namespace yy 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; } @@ -1435,9 +1435,9 @@ namespace yy { 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; diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 8babb6f8..50f1f42a 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -3782,8 +3782,7 @@ For instance, if your locations use a file name, you may use %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 @@ -4272,7 +4271,11 @@ without reading further. 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 @@ -6951,7 +6954,7 @@ Symbols}. @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 @@ -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 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 @@ -7323,7 +7326,7 @@ automatically propagated. %initial-action @{ // Initialize the initial location. - @@$.begin.file_name = @@$.end.file_name = &driver.file; + @@$.begin.filename = @@$.end.filename = &driver.file; @}; @end example -- 2.45.2