Commit Graph

395 Commits

Author SHA1 Message Date
Paul Eggert
2779e38386 (YYFREE, YYMALLOC): New macros.
All uses of free, malloc changed to use these macros.
2003-07-25 07:11:42 +00:00
Paul Eggert
a525b5687d (YYFREE, YYMALLOC, YYREALLOC): New macros.
All uses of free, malloc, realloc changed to use these macros,
and unnecessary casts removed.
2003-07-25 07:10:14 +00:00
Paul Eggert
b81a6e01dc (operator<<(std::ostream&, const Position&)):
use s.empty() rather than s == "" to test for empty string; see
<http://mail.gnu.org/archive/html/bison-patches/2003-07/msg00003.html>
(trivial change)
2003-07-07 03:46:28 +00:00
Paul Eggert
0ae99356d5 * data/glr.c (YYLLOC_DEFAULT): Parenthesize arguments as needed,
and return properly parenthesized result.
* data/lalar1.cc (YYLLOC_DEFAULT): Likewise.
* data/yacc.c (YYLLOC_DEFAULT): Likewise.
Remove unnecessary parentheses from uses.
* doc/bison.texinfo (Location Default Action): Describe the
conventions for parentheses.
2003-06-20 22:52:12 +00:00
Paul Eggert
08fc98e544 (yyremoveDeletes, yy_reduce_print, yyglrReduce, yyreportTree): Do not
assume that size_t is the same width as int, when printing sizes.
Print sizes using an unsigned format.  Problem reported by Frank
Heckenbach in
<http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00035.html>.
2003-06-19 08:45:16 +00:00
Paul Eggert
5cc16ecc96 Port to Forte Developer 7 C compiler.
(struct YYLTYPE): If locations are not being used, declare a single
dummy member, as empty structs do not conform to the C standard.
(YYERROR, YYBACKUP): Do not use "do { ...; return foo; } while (0)";
the Forte Developer 7 C compiler complains that end-of-loop
code is not reached.
2003-06-19 07:38:39 +00:00
Paul Hilfinger
25005f6ab0 * data/glr.c (YYERROR): Update definition.
(yyrecoverSyntaxError): Correct yyerrState logic. Correct comment.
Allow states with only a default reduction.

Fixes to avoid problem that $-N rules in GLR parsers can cause
buffer overruns, corrupting state.

* src/output.c (prepare_rules): Output max_left_semantic_context.
* src/reader.h (max_left_semantic_context): New
* src/scan-gram.l (max_left_semantic_context): Define.
(handle_action_dollar): Update max_left_semantic_context.
* data/glr.c (YYMAXLEFT): New.
(yydoAction): Increase yyrhsVals size.
(yyresolveAction): Ditto.

Fixes to problems with location handling in GLR parsers reported by
Frank Heckenbach (2003/06/05).

* data/glr.c (YYLTYPE): Make trivial if locations not used.
(YYRHSLOC): Add parentheses, make depend on whether locations used.
(YYLLOC_DEFAULT): Ditto.
(yyuserAction): Use YYLLOC_DEFAULT.
(yydoAction): Remove redundant code.

* tests/cxx-type.at: Exercise location information.
(yylex): Track locations.
(stmtMerge): Return value rather than printing.
2003-06-10 02:44:58 +00:00
Paul Eggert
1d4055aa2b (yy::]b4_parser_class_name[::parse,
yy::]b4_parser_class_name[::translate_,
yy::Stack::operator[] (unsigned),
yy::Stack::operator[] (unsigned) const,
yy::Slice::operator[] (unsigned),
yy::Slice::operator[] (unsigned) const):
Rename local vars to avoid warnings.
2003-06-04 05:53:10 +00:00
Paul Eggert
2ffbee0e0b (yy::Position::lines, yy::Position::columns,
yy::Location::lines, yy::Location::columns): Rename arguments
to avoid shadowing; this removes a warning generated by GCC 3.3.
2003-06-02 08:19:08 +00:00
Paul Eggert
6a84279cb5 (yyfillin): Renamed from the old yyfill. Mark
as possibly unused.
(yyfill): New function.
(YYFILL): Use it.
(yyuserAction): Change type of yynormal to bool, so that it matches
the new yyfill signature.  Mark it as possibly unused.
2003-06-02 06:18:31 +00:00
Paul Eggert
a6b89bb2dc (YYERROR): Now just 'goto yyerrorlab', since the
macro's size was becoming unwieldy.
(yyerrlab): Do not discard an empty lookahead symbol, as this
might destroy garbage.
(yyerrorlab): New label, with the old contents of YYERROR,
plus the following change: pop the stack of rhs corresponding
to the production that invoked YYERROR.  That is how Yacc
behaves, and POSIX requires this behavior.
(yyerrlab1): Use YYPOPSTACK instead of its definiens.
2003-06-02 03:57:39 +00:00
Paul Eggert
d7aa6ec179 (union yyalloc): Do not evaluate
YYSTYPE_IS_TRIVIAL or YYSTYPE_IS_TRIVIAL unless they are defined.
This fixes a problem reported by John Bowman when the Compaq/HP
Alpha cxx compiler happy (e.g. using cxx -D__USE_STD_IOSTREAM
-ansi -Wall -gall).
(YYCOPY): Do not evaluate __GNUC__ unless it is defined.
2003-05-25 06:44:08 +00:00
Paul Eggert
f545262547 (YYSTACKEXPANDABLE): Do not evaluate
YYSTYPE_IS_TRIVIAL or YYSTYPE_IS_TRIVIAL unless they are defined.
This fixes a problem reported by John Bowman when the Compaq/HP
Alpha cxx compiler happy (e.g. using cxx -D__USE_STD_IOSTREAM
-ansi -Wall -gall).
2003-05-25 06:43:19 +00:00
Alexandre Duret-Lutz
caf37a3666 %parse-param support for lalr1.cc.
* data/lalr1.cc (b4_parse_param_decl, b4_parse_param_cons,
b4_cc_constructor_calls, b4_cc_constructor_call,
b4_parse_param_vars, b4_cc_var_decls, b4_cc_var_decl): New m4
definitions.
(yy::b4_parser_class_name::b4_parser_class_name): Take extra
parse-param arguments.
(yy::b4_parser_class_name): Declare instance variables to
hold parse-param arguments.
* tests/calc.at: s/value/semantic_value/ because value clashes
with a member of yy::b4_parser_class_name.  Adjust C++ code
to handle %parse-param.  Enable %parse-param test in C++.
2003-05-14 18:41:48 +00:00
Paul Eggert
68cdf74747 (b4_lex_param): Corrected for the case where %lex-param is provided
and %pure-parser isn't.

From Tim Van Holder in
<http://mail.gnu.org/archive/html/bug-bison/2003-04/msg00045.html>.
2003-04-29 06:04:04 +00:00
Paul Eggert
b929851a33 Avoid gcc -Wundef warnings reported by Gerald Pfeifer in
<http://mail.gnu.org/archive/html/bug-bison/2003-04/msg00044.html>.
(YYSTACK_ALLOC): Don't evaluate YYSTACK_USE_ALLOCA if it is not defined.
(YYMAXDEPTH): Don't evaluate YYMAXDEPTH if it is not defined.
2003-04-28 06:03:58 +00:00
Paul Eggert
0c3c1f98ec (yy::Parser::pact_ninf_, yy::Parser::table_ninf_):
Declare to be of type suitable for the ninf value itself, not of
type suitable for the corresponding table, since the latter might
be unsigned but the ninf value might be negative.  This fixes a
bug reported by Alexandre Duret-Lutz in
<http://mail.gnu.org/archive/html/bug-bison/2003-04/msg00017.html>.
2003-04-27 05:56:34 +00:00
Paul Eggert
1d2d7eddf7 (yyexpandGLRStack) [!YYSTACKEXPANDABLE]:
Fix obvious typo that results in uncompilable GLR parsers
when both %pure-parser and %locations are used.  (trivial change
from Yakov Markovitch <Markovitch@iso.ru>)
2003-04-21 19:37:09 +00:00
Akim Demaille
c47495657b * data/yacc.c, data/glr.c, data/lal1.cc: Use similar code to
generate verbose error messages.
Use the number of tokens as an upper bound in yytname, as it
cannot be a non terminal.
2003-03-02 13:39:44 +00:00
Paul Eggert
52f32190aa (yy_reduce_print): yylineno -> yylno. 2003-02-25 07:57:48 +00:00
Paul Eggert
9b76b7868e (yy::]b4_parser_class_name[::parse): yylineno -> yylno. 2003-02-25 07:57:09 +00:00
Paul Eggert
47ee29cf60 (yy_reduce_print): yylineno -> yylno,
to avoid collision with flex use of yylineno.
Problem reported by Bruce Lilly in
<http://mail.gnu.org/archive/html/bug-bison/2003-02/msg00016.html>.
2003-02-25 07:56:34 +00:00
Paul Eggert
ba1ecc079b Stick to ASCII for now. 2003-02-24 21:06:17 +00:00
Akim Demaille
f939fc12fe * data/lalr1.cc: Use temporary variables instead of casts to
change integer types.
Suggested by Paul Eggert.
2003-02-21 08:13:37 +00:00
Akim Demaille
2cdc240eeb * data/lalr1.cc (position.hh): Make sure "columns" never pushes
before initial_columns.
(location.hh): Use consistent variable names when defining the
operator<<.
Use "last" so that we subtract from Positions, not from unsigned.
2003-02-20 14:42:43 +00:00
Akim Demaille
5d00311619 * data/lalr1.cc (position.hh): New subfile, including the extended
and Doxygen'ed documentation of class Position.
(location.hh): Use it.
Document a` la Doxygen.
With the help of Benot Perrot.
2003-02-20 13:36:08 +00:00
Akim Demaille
0d1c3a04b7 * data/lalr1.cc: When displaying a line number, be sure to make it
an int.
2003-02-19 14:55:14 +00:00
Akim Demaille
60a777aa24 * data/lalr1.cc (b4_stack_depth_init, yy::Parser::initdepth_):
Remove, useless.
(YYABORT, YYACCEPT, YYERROR): New.
* tests/calc.at: Renable the lalr1.cc test.
2003-02-19 14:33:27 +00:00
Paul Eggert
93a0df697f (yyreportSyntaxError) [YYERROR_VERBOSE]:
Avoid subscript error in yycheck.  Bug reported by Andrew Suffield in
<http://mail.gnu.org/archive/html/bug-bison/2003-02/msg00003.html>.
Check for malloc failure, for consistency with yacc.c.
(yytname_size): Remove, for consistency with yacc.c.
2003-02-13 07:14:29 +00:00
Paul Eggert
3aa2f55d71 (yyerrlab) [YYERROR_VERBOSE]:
Avoid subscript error in yycheck.  Bug reported by Andrew Suffield in
<http://mail.gnu.org/archive/html/bug-bison/2003-02/msg00003.html>.
2003-02-13 07:13:57 +00:00
Akim Demaille
7548fed236 * configure.ac (GXX): Rename as...
(CXX): this, to keep the original Autoconf semantics.
Require 2.57.
* data/lalr1.cc: Fix b4_copyright invocations.
If YYDEBUG is not defined, don't depend upon name_ being defined.
(location.hh): Include string and iostream.
(Position::filename): New member.
(Position::Position ()): New.
(operator<< (Position)): New.
(operator- (Position, int)): New.
(Location::first, Location::last): Rename as...
(Location::begin, Location::end): these, to mock the conventional
iterator names.
(operator<< (Location)): New.
* tests/atlocal.in (CXX): New.
* tests/testsuite.at (AT_COMPILE_CXX): New.
* tests/calc.at (_AT_DATA_CALC_Y): Adjust yyerror to report the
locations in a more synthetic way.
(AT_CHECK_PUSHDEFS): AT_YYERROR_SEES_LOC_IF is positive if
lalr1.cc is used.
Adjust the C locations to match those from Emacs: first column is
column 0.
Change all the expected results.
Conform to the GCS: simplify the locations when applicable.
(LOC, VAL, YYLLOC_FORMAL, YYLLOC_ARG, USE_YYLLOC, LEX_FORMALS)
(LEX_ARGS, USE_LEX_ARGS, LEX_PRE_FORMALS, LEX_PRE_ARGS): Replace
these CPP macros with the m4 macros new defined by...
(AT_CHECK_PUSHDEFS): this, i.e.:
(AT_LALR1_CC_IF, AT_PURE_LEX_IF, AT_LOC, AT_VAL, AT_LEX_FORMALS)
(AT_LEX_ARGS, AT_USE_LEX_ARGS, AT_LEX_PRE_FORMALSm AT_LEX_PRE_ARGS)
New macros.
(AT_CHECK_POPDEFS): Undefine them.
(AT_CHECK_CALC_LALR1_CC): New.
Use it for the first lalr1.cc test.
2003-02-06 10:04:29 +00:00
Akim Demaille
43a176ef35 * data/lalr1.cc (YYLLOC_DEFAULT): Fix its definition: be based on
Location as is defined.
2003-02-04 21:05:03 +00:00
Akim Demaille
fc049e9caf * data/lalr1.cc: If YYDEBUG is not defined, don't depend upon
name_ being defined.
2003-02-04 20:57:46 +00:00
Paul Hilfinger
f868dc04e4 Changes in response to error report by S. Eken: GLR mode does not
handle negative $ indices or $ indices in embedded rules correctly.
See <http://mail.gnu.org/archive/html/bug-bison/2003-01/msg00076.html>.

(b4_rhs_value): Change to use YYFILL macro.
(b4_rhs_location): Ditto.
(yyfill): New function to copy from stack tree into array
incrementally.
(yyuserAction): Modify to allow incremental move of semantic values
to rhs array when in GLR mode.
Define YYFILL to use in user-defined actions to fill semantic array
as needed.
Remove dummy use of yystack, as there is now a guaranteed use.
(yydoAction): Modify to allow incremental move of semantic values
to rhs array when in GLR mode.
(yyresolveAction): Ditto.
(yyglrShiftDefer): Update comment.
(yyresolveStates): Use X == NULL for pointers, not !X.
(yyglrReduce): Ditto.
(yydoAction): Ditto
2003-01-29 23:37:15 +00:00
Paul Eggert
b61c697827 Do not use @output_header_name@ unless
b4_defines_flag is set.  This fixes two bugs reported by
Tim Van Holder in
<http://mail.gnu.org/archive/html/bug-bison/2003-01/msg00071.html>
and <http://mail.gnu.org/archive/html/bug-bison/2003-01/msg00073.html>.
2003-01-29 06:31:02 +00:00
Paul Eggert
8a3eb3c8ba (YYERROR): Move code from yyerrlab1 to here, so that
we don't need to worry about yyerrlab1 being reported as an
"unused label" by non-GCC C compilers.  The downside is that if
locations are used then a couple of statements are duplicated each
time YYERROR is invoked, but the upside is that the warnings
should vanish.
(yyerrlab1): Move code to YERROR.
(yyerrlab2): Remove.  Change uses back to yyerrlab1.
This reverts some of the 2002-12-27 change.
2003-01-22 06:38:32 +00:00
Akim Demaille
3ae831b413 Quoc Peyrot <chojin@lrde.epita.fr>,
Robert Anisko <anisko_r@lrde.epita.fr>
* data/lalr1.cc (parse::yyerrlab1): When popping the stack, stop
when the stacks contain one element, as the loop would otherwise
free the last state, and then use the top state (the one we just
popped).  This means that the initial elements will not be freed
explicitly, as is the case in yacc.c; it is not a problem, as
these elements have fake values.
2003-01-13 15:42:31 +00:00
Paul Eggert
49b6b48b99 (yyerrlab1): Omit attribute if __cplusplus is defined,
since GNU C++ (as of 3.2.1) does not allow attributes on labels.
Problem reported by Nelson H. F. Beebe.
2003-01-05 00:48:16 +00:00
Paul Eggert
c1a0d7e076 Update copyright. 2003-01-03 14:33:17 +00:00
Paul Eggert
f7c398aaff (yybool): Renamed from bool, to avoid collisions in C.
All uses changed.  Provide a definition in both C and C++.
(yytrue, yyfalse): Define even if defined (__cplusplus).
2003-01-03 14:22:53 +00:00
Paul Eggert
f96e75a64e (yyerrlab1): Append `;' after attribute, to
pacify the buggy "smart preprocessor" in MacOS 10.2.3.
Bug reported by Nelson H. F. Beebe.
2003-01-02 23:58:42 +00:00
Paul Eggert
d42f69cdf7 (yyparse): New local var yylerrsp, to record the
top of the location stack's error locations.
(yyerrlab): Set it.  When discarding a token, push its location
onto yylerrsp so that we don't lose track of the error's end.
(yyerrlab1): Now is only the target of YYERROR, so that we can
properly record the location of the action that failed.  For GCC
2.93 and later, insert an __attribute__ ((__unused__)) to avoid
GCC warning about yyerrlab1 being unused if YYERROR is unused.
(yyerrlab2): New label, which yyerrlab now falls through to.
Compute the error's location by applying YYLLOC_DEFAULT to
the locations of all the symbols that went into the error.
2002-12-28 08:36:02 +00:00
Paul Eggert
04877eec24 Remove this file, since we
can't use m4_include on relative file names.
2002-12-28 08:00:56 +00:00
Paul Eggert
5b66ea8b80 (dist_m4sugar_DATA): Remove m4sugar/version.m4. 2002-12-26 08:29:56 +00:00
Paul Eggert
70b4c070cc Don't include m4sugar/version.m4. 2002-12-26 08:28:09 +00:00
Paul Eggert
cce7a5f423 Don't include c.m4, as "include" doesn't do what we want. 2002-12-26 08:27:09 +00:00
Paul Eggert
f6abc26e38 Comment fix: don't mention obsolete bison.simple. 2002-12-26 06:58:35 +00:00
Paul Eggert
050c471b8e (b4_location_type): Remove.
(YYSTYPE): Renamed from yystype.
(YYSTYPE_IS_DECLARED): New macro, used to prevent double-typedef.
(struct YYLTYPE): Renamed from struct yyltype.
(YYLTYPE): Renamed from yyltype.
(yyltype, yystype): New (and obsolescent) macros,
for backward compatibility.

(YYSTYPE): Declare as union YYSTYPE if the user
does not specify a union tag.  This is for compatibility with
Solaris 9 yacc.
2002-12-24 07:41:47 +00:00
Paul Eggert
fa8c3ebca3 (b4_location_type): Remove.
(YYSTYPE): Renamed from yystype.
(YYSTYPE_IS_DECLARED): New macro, used to prevent double-typedef.
(struct YYLTYPE): Renamed from struct yyltype.
(YYLTYPE): Renamed from yyltype.
(yyltype, yystype): New (and obsolescent) macros,
for backward compatibility.
2002-12-24 07:40:58 +00:00
Paul Eggert
a20713a4af Undo most of the 2002-11-12 yychar -> yytoken patch, as it broke
GCC 3.2.1 (which depends on yychar == YYEMPTY when there is no
lookahead symbol, and which sets yychar in parser actions) and it
disagreed with the Bison documentation.  This should fix the bug
reported by Andrew Walrond in
<http://mail.gnu.org/pipermail/bug-bison/2002-December/001949.html>.

(YYTRANSLATE): Don't check for negative argument,
as the caller now does that.
(yyclearin, YYBACKUP, yyparse): Use yychar, not yytoken.
(YYEMPTY): Parenthesize right hand side, since others use it.
(yyparse): Don't assume that our generated code is the only code
that sets yychar.
2002-12-15 09:20:24 +00:00