[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
file_name; also, yyparse returning 2
From: |
Paul Eggert |
Subject: |
file_name; also, yyparse returning 2 |
Date: |
Thu, 15 Sep 2005 07:09:00 -0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Akim Demaille <address@hidden> writes:
> I think there will be many complaints about the change from filename
> to file_name in lalr1.cc. In particular, you provide no means to have
> a version that works both with 2.0 and 2.1. That's nasty.
>
> I do not think this patch is vital, so I would simply reverse it.
You're right. Sorry about the confusion. I installed this.
This also fixes an unrelated issue that I was already working on:
yyparse was not documented as returning 2 on memory allocation
failure.
2005-09-15 Paul Eggert <address@hidden>
* 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.
Index: NEWS
===================================================================
RCS file: /cvsroot/bison/bison/NEWS,v
retrieving revision 1.121
diff -p -u -r1.121 NEWS
--- NEWS 24 Jul 2005 07:24:22 -0000 1.121
+++ NEWS 15 Sep 2005 14:06:03 -0000
@@ -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.
Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.94
diff -p -u -r1.94 lalr1.cc
--- data/lalr1.cc 9 Sep 2005 22:42:15 -0000 1.94
+++ data/lalr1.cc 15 Sep 2005 14:06:04 -0000
@@ -48,7 +48,7 @@ m4_define([b4_rhs_value],
[(address@hidden([$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;
Index: doc/bison.texinfo
===================================================================
RCS file: /cvsroot/bison/bison/doc/bison.texinfo,v
retrieving revision 1.157
diff -p -u -r1.157 bison.texinfo
--- doc/bison.texinfo 9 Sep 2005 22:42:15 -0000 1.157
+++ doc/bison.texinfo 15 Sep 2005 14:06:04 -0000
@@ -3782,8 +3782,7 @@ For instance, if your locations use a fi
%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
address@hidden - %define "file_name_type" "const symbol::Symbol"
address@hidden - %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
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 @address@hidden 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
- file_name, Akim Demaille, 2005/09/15
- file_name; also, yyparse returning 2,
Paul Eggert <=