Commit Graph

319 Commits

Author SHA1 Message Date
Akim Demaille
68e11668e4 * data/lalr1.cc (Parser:print_): Remove, use %printer instead.
* tests/regression.at (_AT_DATA_DANCER_Y): Adjust.
* tests/calc.at (_AT_DATA_CALC_Y): Ditto.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Likewise.
2004-11-17 14:19:37 +00:00
Akim Demaille
e342c3beaf * data/glr.c (YYRHSLOC): Move its definition next to its uses.
Introduce another definition to address simple location arrays.
(yyGLRStack): New member: yyerror_range.
(yyrecoverSyntaxError, yyparse): Update it.
(yyrecoverSyntaxError): Use it when shifting the error token to
have an accurate range, equivalent to the one computed by both
yacc.c and lalr1.cc.
* tests/cxx-type.at (_AT_TEST_GLR_CXXTYPES): Change its yylex so
that column numbers start at column 0, as per GNU Coding
Standards, the others tests, and the doc.
(_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_AMBIG_GLR_OUTPUT_WITH_LOC):
Adjust to the above change (first column is 0).
And adjust the location of the "<error>", now covering the whole
line.
2004-10-25 10:37:35 +00:00
Akim Demaille
df09ef2e8f * src/symtab.c (symbol_check_alias_consistency): Also check
type names, destructors, and printers.
Reported by Alexandre Duret-Lutz.
Recode the handling of associativity and precedence in terms
of symbol_precedence_set.
Accept no redeclaration at all, not even equal to the previous
value.
(redeclaration): New.
Use it to factor redeclaration complaints.
(symbol_make_alias): Don't set the type of the alias, let
symbol_check_alias_consistency do it as for other features.
* src/symtab.h (symbol): Add new member prec_location, and
type_location.
* src/symtab.c (symbol_precedence_set, symbol_type_set): Set them.
* tests/input.at (Incompatible Aliases): New.
2004-10-11 09:03:55 +00:00
Akim Demaille
2c0ddf03ab Word changes. 2004-10-05 09:58:58 +00:00
Akim Demaille
b4a2033855 In Bison 1.875's yacc.c, YYLLOC_DEFAULT was called regardless
whether the reducion was empty or not.  This leaves room to
improve the use of YYLLOC_DEFAULT in such a case.
lalr1.cc is still experimental, so changing this is acceptable.
And finally, there are probably not many users who changed the
handling of locations in GLR, so changing is admissible too.
* data/glr.c, data/lalr1.cc, data/yacc.c (YYLLOC_DEFAULT): On an
empty reduction, set @$ to an empty location ending the previously
stacked symbol.
Adjust uses to make sure the code is triggered on empty
reductions.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Adjust the
expected output: empty reductions have empty locations.
2004-10-05 08:39:17 +00:00
Akim Demaille
451364edb1 Let the initial-action act on the look-ahead, and use it for the
"initial push" (corresponding to an hypothetical beginning-of-file).
And let lalr1.cc honor %initial-action.
* doc/bison.texinfo (Initial Action Decl): Clarify, and add an
example.
* data/lalr1.cc (Parser::initlocation_): Remove, bad experiment.
(Parser::Parser): Remove the ctor that used to initialize it.
(Parser::parse): Like in the other skeletons, issue the "starting
parse" message before any action.
Honor %initial-action.
Initialize the stacks with the lookahead.
* data/yacc.c: Let $$ and @$ in %initial-action designate the
look-ahead.
Push them in the stacks.
* tests/actions.at, tests/calc.at: Adjust the C++ ctor invocations.
2004-09-20 15:25:25 +00:00
Akim Demaille
3fc16193d9 * data/yacc.c (YY_LOCATION_PRINT): New.
Define when we know YYLTYPE's structure, i.e., when the default
YYLLOC_DEFAULT is used.
* data/c.m4 (b4_yysymprint_generate): Use it.
* data/lalr1.cc (YYLLOC_DEFAULT): Stop relying on the initial
value of the result.
(error_start_): Replace with...
(error_range_): this location array.
This allows to replace code relying on the implementation of
locations by portable code.
* data/yacc.c (yylerrsp): Replace with...
(yyerror_range): this.
Every time a token is popped, update yyerror_range[0], to have an
accurate location for the error token.
* data/glr.c (YY_LOCATION_PRINT): New.
(yyprocessOneStack): Fix an invocation of YY_SYMBOL_PRINT:
deference a pointer.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): No longer
report the location in %printers.
* src/scan-skel.l: Instead of abort, report error messages to ease
understanding skeleton scanning failures.
2004-09-20 09:32:55 +00:00
Akim Demaille
1576d44dce Have more complete shift traces.
* data/yacc.c, data/lalr1.c, data/glr.c: Use YY_SYMBOL_PRINT
to report Shifts instead of ad hoc YYDPRINTF invocations,
including for the error token.
* data/lalr1.cc (symprint_): Output the location.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): In C++, don't
output the location within the %printer.
Activate GLR tests, at least to make sure they compile properly.
They still don't pass though.
* tests/calc.at: Adjust expect verbose output, since now "Entering
state..." is on a different line than the "Shifting" message.
2004-09-16 14:14:27 +00:00
Akim Demaille
9c66f418c4 * tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Move the
Bison directive from the Bison file to the invocation of this
macro, so that these directives are passed to
AT_BISON_OPTION_PUSHDEFS to get correct help macros.
Use these helping macros (e.g., AT_LOC, AT_VAL and so forth).
Move the AT_SETUP/AT_CLEANUP outside, to report as test title
the extra Bison directives instead of the whole series.
Change the grammar so that there are recoverable errors, and
unrecoverable errors.  Now we can have the parser give up before
consuming the whole input.  As a result we now can observe that
the lookahead is freed when needed.
Change the parser source to parse argv[1] instead of a hard coded
string.
Simplify yylex, and give a value and location to EOF.
Simplify some invocations of AT_CHECK_PRINTER_AND_DESTRUCTOR that
passed directives already coded in the file.
Add some tests to check the location of "error".
For some tests, the C++ parser is correct, and not yacc.c.
For other tests, they provide different, but unsatisfying, values,
so keep the C++ value so that at least one parser is "correct"
according to the test suite.
(Actions after errors): Remove, this is subsumed by the
AT_CHECK_PRINTER_AND_DESTRUCTOR series.
2004-09-08 14:36:25 +00:00
Akim Demaille
e757bb10bc * data/glr.c, data/lalr1.cc, data/yacc.c: When YYABORT was
invoked, yydestruct the lookahead.
* tests/calc.at (Calculator $1): Update the expected lengths of
traces: there is an added line for the discarded lookahead.
* doc/bison.texinfo (Destructor Decl): Some rewording.
Define "discarded" symbols.
2004-09-06 07:48:20 +00:00
Akim Demaille
a5eb1ed262 * tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Adjust
%printer calls to use cdebug_ when using lalr1.cc.
* data/lalr1.cc (b4_yysymprint_generate): New.
2004-09-02 13:04:11 +00:00
Paul Eggert
ac700aa646 (_AT_CHECK_PRINTER_AND_DESTRUCTOR,
AT_CHECK_PRINTER_AND_DESTRUCTOR): New argument
UNION-FLAG.  All callers changed.
(_AT_CHECK_PRINTER_AND_DESTRUCTOR): Don't assume %union.
Use type char, not unsigned int, when declaring an array of char;
this lets us remove a cast.
(Printers and Destructors): Add non-%union test cases.
2004-07-22 14:40:21 +00:00
Paul Eggert
8dd162d3ff Use "look-ahead" instead of "lookahead", consistently. 2004-06-21 20:20:31 +00:00
Paul Eggert
8ed3234a14 Don't assume the C++ compiler takes the same arguments as the C compiler. 2004-05-30 18:58:00 +00:00
Paul Eggert
0797198341 Fix some "make check" problems with Tru64 C++. 2004-05-30 00:56:57 +00:00
Paul Eggert
2905865228 Workaround for SGI C++ compiler. 2004-05-29 07:16:29 +00:00
Paul Eggert
209ea708c4 Ensure that the C++ compiler used for testing actually works on a
simple test program; if not, skip the C++-related tests.
2004-05-24 06:58:02 +00:00
Paul Eggert
6e26ca8c27 Remove more K&R C support. 2004-04-28 06:52:51 +00:00
Paul Eggert
ca6f187f64 (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Don't
declare yyerror when using lalr.cc, as GCC 3.4.0 warns about the
unused declaration.
2004-04-28 06:06:31 +00:00
Paul Eggert
0f53f2226d (%union synch line): Put a dummy member in
the union, because empty unions aren't allowed in C.
Caught by GCC 3.4.0.
2004-04-28 06:03:54 +00:00
Paul Eggert
1f916a78e6 Update copyright to 2004. 2004-04-13 17:43:15 +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
Paul Eggert
006d217ddd (AT_COMPILE, AT_COMPILE_CXX): Ignore stdout from compilers. 2004-02-25 21:13:00 +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
dc8a217381 ($(TESTSUITE)): Remove warning about ignoring
multiple inclusion warnings.
2003-12-24 08:30:45 +00:00
Paul Eggert
ce05140d9d Require Autoconf 2.59, and don't include local.at twice since
Autoconf 2.59 yells about it for some reason.
2003-12-24 08:26:02 +00:00
Paul Eggert
3dc4c5faa9 (Torturing the Scanner): Don't use \x0 or \0 in
Bison tokens, as this runs afoul of the 2003-10-07 change that
disallowed NUL bytes in character constants or string literals.
2003-12-24 08:17:05 +00:00
Paul Eggert
6a5ecb38fc Don't run 'testsuite --clean' if testsuite doesn't exist. 2003-10-07 23:34:20 +00:00
Paul Eggert
22fccf958f Use "%no-default-prec" instead of "%default-prec 0". 2003-10-01 21:33:24 +00:00
Paul Eggert
39a06c251a Add %default-prec. 2003-09-30 20:11:29 +00:00
Paul Eggert
7f41b88821 Include local.at, not input.at, fixing a typo in the 2003-08-25 patch. 2003-09-30 16:45:13 +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
Akim Demaille
1f7a61ff99 Tune local.at so that people can "autom4te -l autotest calc.at -o
calc" for instance, to extract a sub test suite.
* tests/testsuite.at: Move the initialization, Autotest version
requirement, and AT_TESTED invocation into...
* tests/local.at: here.
* tests/testsuite.at: Include it for compatibility with Autoconf
2.57.
* tests/Makefile.am ($(TESTSUITE)): Report that the warning should
be ignore.
2003-08-25 07:15:49 +00:00
Paul Eggert
671881d12d Minor white space issues, e.g. trailing white space at end of line. 2003-06-16 19:17:38 +00:00
Paul Eggert
907e3bc851 (AT_CHECK_CALC): New option EXPECTED-TO-FAIL.
(AT_CHECK_CALC_LALR1_CC): Use it, since the C++ LALR parser fails
the tests right now.
2003-06-16 18:42:49 +00:00
Paul Eggert
b8a204c09b (_AT_TEST_GLR_CXXTYPES): Ensure yylex and
yyerror are declared before use; C99 requires this.
2003-06-16 18:37:55 +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
848dc439cb (_AT_DATA_DANCER_Y): Declare yylex to take
(void) as arg when not pure, since we now assume C89 when building
Bison.  Pacify GCC by using parameter.
2003-06-04 05:54:16 +00:00
Paul Eggert
f56f6d78b0 (Improper handling of embedded actions and $-N in GLR parsers): Remove
unused local variable from yylex.
2003-06-04 05:53:44 +00:00
Paul Eggert
57f5199797 (AT_COMPILE_CXX): Use it instead of CFLAGS. 2003-06-02 07:26:17 +00:00
Paul Eggert
713535c232 (CXXFLAGS): New var. 2003-06-02 07:25:54 +00:00
Paul Eggert
82c53be476 (_AT_DATA_CALC_Y): Include unistd.h if available.
Define 'alarm' to do nothing if unistd.h is not available.
Add a new rule "exp: '-' error;" to test the above change to
data/yacc.c.  Use 'alarm' to abort any test taking longer than
10 seconds, as it's probably looping.
(AT_CHECK_CALC): Test recovery from error in new grammar rule.
Also, the new yacc.c generates two fewer diagnostics for an
existing test.
2003-06-02 03:58:34 +00:00
Paul Eggert
087b9fdf03 (Torturing the Scanner): Add tests for ";|" in a grammar. 2003-05-14 19:26:52 +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
Akim Demaille
211074caca * tests/calc.at: Also test yacc.c and glr.c (but not lalr1.cc yet)
with %pure-parser and %locations to exercise the patch from Yakov
Markovitch below.
2003-04-29 08:41:13 +00:00
Paul Eggert
47e7600a21 (Invalid inputs): Remove cascaded diagnostic that is no longer emitted. 2003-04-18 07:26:46 +00:00
Paul Eggert
2740f1691f (GNU pic Grammar): New test case, taken from
<http://mail.gnu.org/archive/html/bug-bison/2003-04/msg00026.html>.
2003-04-18 05:10:58 +00:00
Paul Eggert
0eadf43ccc Add testsuite.log 2003-03-14 01:31:24 +00:00
Paul Eggert
4a99c66490 Update copyright. 2003-03-13 07:05:44 +00:00
Paul Eggert
0baf7c50ed (Torturing the Scanner): Test the scanner on
an empty input file, which was Tim Van Holder's test case.
2003-03-13 07:03:17 +00:00