Commit Graph

212 Commits

Author SHA1 Message Date
Paul Eggert
383e69dc79 Output yylloc macro defn in glr.c even if locations are not being generated. 2004-05-21 22:23:04 +00:00
Paul Eggert
45d5982f04 (Parser::stos_) [! YYDEBUG]: Define even in this
case, as stos_ is now used by destructors due to the 2004-02-09
change.
2004-04-28 05:48:39 +00:00
Paul Eggert
779e7ceb93 Use 'short int' rather than 'short', and similarly for 'long', 'unsigned', etc. 2004-03-31 00:37:21 +00:00
Alexandre Duret-Lutz
c2729758f2 Support %destructor and merge error locations in lalr1.cc.
* data/lalr1.cc (b4_cxx_destruct_def): New macro.
(Parser::stos_): Define unconditionally.
(Parser::destruct_): New method.  Generate its body with
b4_yydestruct_generate.
(Parser::error_start_): New attribute.
(Parser::parse) <yyerrlab, yyerrlab1>: Call destruct_ on erroneous
token which are discarded.
(Parser::parse) <yyerrlab, yyerrorlab, yyerrlab1>: Update
error_start_ when erroneous token are discarded.
(Parser::parse) <yyerrlab1>: Compute the location of the error
token so that it covers all the discarded tokens.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Adjust so
it can be called with `%skeleton "lalr1.cc"', and do that.
2004-02-09 21:31:42 +00:00
Paul Eggert
d0d5aa6425 (yytokenName): Bullet-proof against YYEMPTY token.
(yyreportSyntaxError): Handle case where lookahead token is
YYEMPTY.
2004-02-02 22:35:53 +00:00
Paul Hilfinger
be16239bf7 data/glr.c: Put casts on uses of YYREALLOC and YYMALLOC so that
resulting parsers are compilable with C++.
2004-01-14 01:40:12 +00:00
Paul Eggert
0cc3da3a4e In GLR grammars, $N and @N now yield non-modifiable lvalues. 2003-10-05 06:46:53 +00:00
Akim Demaille
62b6aef925 * data/lalr1.cc (yyparse) [__GNUC__]: "Use" yyerrorlab to pacify
GCC warnings.
2003-08-27 07:00:10 +00:00
Akim Demaille
a08460b08c * data/lalr1.cc (Parser::report_syntax_error_): New, extracted from
(Parser::parse): here.
Adjust: nerrs and errstatus is now replaced by...
(Parser::nerrs_, Parser::errstatus_): New.
2003-08-26 05:21:41 +00:00
Akim Demaille
cd3684cfa8 When reducing initial empty rules, Bison parser read an initial
location that is not defined.  This results in garbage, and that
affects Bison's own parser.  Therefore we need (i) to extend Bison
to support a means to initialize this location, and (ii) to use
this CVS Bison to fix CVS Bison's parser.
* src/reader.h, reader.c (epilogue_augment): Remove, replace
with...
* src/muscle_tab.h, src/muscle_tab.c (muscle_code_grow): this.
* src/parse-gram.y: Adjust.
(%initial-action): New.
(%error-verbose): Since we require CVS Bison, there is no reason
not to use it.
* src/scan-gram.l: Adjust.
* src/Makefile.am (YACC): New, to make sure we use our own parser.
* data/yacc.c (yyparse): Use b4_initial_action.
2003-08-25 15:16:25 +00:00
Akim Demaille
8c182d0592 * data/lalr1.cc (Parser::reduce_print_): Remove unused yyi.
From Alexandre Duret-Lutz.
2003-08-25 09:54:57 +00:00
Akim Demaille
25f66e1a6a * data/lalr1.cc (Parser::stack_print_, YY_STACK_PRINT): New.
Use them.
2003-08-25 08:39:34 +00:00
Akim Demaille
5348bfbe29 * data/lalr1.cc (Parser::reduce_print_): New.
Use it.
2003-08-25 08:29:27 +00:00
Akim Demaille
473013144d Have lalr1.cc catch with Paul Eggert's patch to fix the infinite
error recovery loops.  This patch is based on
<http://mail.gnu.org/archive/html/bison-patches/2003-06/msg00000.html>.
Also, augment the similarity between lalr1.cc and yacc.c.
Note: the locations of error recovery rules are not correct yet.
* data/lalr1.cc: Comment changes to augment the similarity between
lalr1.cc and yacc.c.
(YYERROR): Goto to yyerrorlab, not yyerrlab1.
(yyerrlab1): Remove, but where it used to be (now the bottom part of
yyerrlab), when hitting EOF, pop the whole stack here instead of
merely falling thru the default error handling mechanism.
(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 (required by POSIX).
* tests/calc.at (AT_CHECK_CALC_LALR1_CC): No longer expected to
fail.
2003-08-25 08:06:17 +00:00
Paul Eggert
7b98f503de (yyuserMerge): Return void, not YYSTYPE.
The returned value is now stored in *YY0.  All callers changed.
2003-08-04 19:09:15 +00:00
Paul Eggert
64c4fd521a (YYASSERT): New macro.
(yyfillin, yydoAction, yyglrReduce, yysplitStack,
yyresolveStates, yyprocessOneStack):
Use `YYASSERT (FOO);' rather than `if (! (FOO)) abort ();'.
2003-07-26 14:12:28 +00:00
Paul Eggert
dfc8a22010 (yyglrReduce): Don't use C89 string concatenation. 2003-07-25 07:42:25 +00:00
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 Benoît 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