Commit Graph

1750 Commits

Author SHA1 Message Date
Akim Demaille
617a8f1227 Move lalr1.cc internals into yy*.
* data/lalr1.cc (semantic_stack_, location_stack_, state_stack_)
(semantic_stack_, location_stack_, pact_, pact_ninf_, defact_)
(pgoto_, defgoto_, table_, table_ninf_, check_, stos_, r1_, r2_)
(name_, rhs_, prhs_, rline_, token_number_, eof_, last_, nnts_)
(empty_, final_, terror_, errcode_, ntokens_)
(user_token_number_max_, undef_token_, n_, len_, state_, nerrs_)
(looka_, ilooka_, error_range_, nerrs_):
Rename as...
(yysemantic_stack_, yylocation_stack_, yystate_stack_)
(yysemantic_stack_, yylocation_stack_, yypact_, yypact_ninf_)
(yydefact_, yypgoto_, yydefgoto_, yytable_, yytable_ninf_)
(yycheck_, yystos_, yyr1_, yyr2_, yyname_, yyrhs_, yyprhs_)
(yyrline_, yytoken_number_, yyeof_, yylast_, yynnts_, yyempty_)
(yyfinal_, yyterror_, yyerrcode_, yyntokens_)
(yyuser_token_number_max_, yyundef_token_, yyn_, yylen_, yystate_)
(yynerrs_, yylooka_, yyilooka_, yyerror_range_, yynerrs_):
these.
2004-12-16 08:48:54 +00:00
Akim Demaille
f69a414266 * data/lalr1.cc (lex_): Rename as...
(yylex_): this.
Move the trace here.
Take the %name-prefix into account.
Reported by Alexandre Duret-Lutz.
2004-12-15 17:38:37 +00:00
Akim Demaille
2e1f5829ee * data/lalr1.cc (lex_): Rename as...
(yylex_): this.
Move the trace here.
Take the %name-prefix into account.
Reported by Alexandre Duret-Lutz.
2004-12-15 16:30:15 +00:00
Akim Demaille
a3cb624893 Simplify the C++ parser constructor.
* data/lalr1.cc (debug_): Rename as...
(yydebug_): so that the parser's internals are always in the yy*
pseudo namespace.
Adjust uses.
(b4_parse_param_decl): Remove the leading comma as it is now only
called as unique argument list.
(Parser::Parser): Remove the constructor accepting a location and
an initial debugging level.
Remove from the other ctor the argument for the debugging level.
(debug_level_type, debug_level, set_debug_level): New.
* tests/actions.at, tests/calc.at, tests/regression.at: Adjust
constructor calls.
2004-12-15 16:18:12 +00:00
Akim Demaille
07fed89197 Remove b4_root related material: failure experiment
(which goal was to allow to derive from an class).
* data/lalr1.cc (b4_root, b4_param, b4_constructor): Remove
definitions and uses.
2004-12-15 15:35:17 +00:00
Paul Eggert
63d72da75b (struct yyGLRStack): yyerror_range now has 3 items,
not 2, since it's not portable to subtract 1 from the start of an
array.  The new item 0 is never set or used.  All uses changed.

(yyrecoverSyntaxError): Use YYLLOC_DEFAULT instead of assuming
the default definition of YYLLOC_DEFAULT.  Problem reported
by Frank Heckenbach.
2004-12-14 18:48:42 +00:00
Paul Eggert
9fafc4ddfd (YYRHSLOC): Don't have two definitions, one for
the normal case and one for the error case.  Just use the
first one uniformly.  Problem reported by Frank Heckenbach.
(YYLLOC_DEFAULT): Use the conventions of yacc.c, so we can
use exactly the same macro in both places.
(yyerror_range): Now of type yyGLRStackItem, not YYLTYPE,
so that the normal-case YYRHSLOC works for the error case too.
All uses changed.
2004-12-12 09:25:45 +00:00
Paul Eggert
24e0cbd0e1 (YYRHSLOC): New macro, taken from glr.c.
(YYLLOC_DEFAULT): Use the same macro as glr.c.
2004-12-12 09:25:24 +00:00
Paul Eggert
80a183578b (yyuserAction, yyrecoverSyntaxError): Mark args
with ATTRIBUTE_UNUSED if they're not used, to avoid GCC warning.
(yyparse): Remove unused local introduced in 2004-10-25 patch.
2004-12-11 06:07:11 +00:00
Akim Demaille
be3d9d4219 2004-11-23 Akim Demaille <akim@epita.fr>
* data/lalr1.cc (YYSTYPE): Define it as is done for C, instead
	of #defining from yystype.
	Don't typedef yystype, C++ does not need it.
	This lets it possible to forward declare it as union.
2004-11-23 19:56:12 +00:00
Akim Demaille
c1f8f16a9b * data/lalr1.cc (symprint_): Use cdebug_ to avoid warnings. 2004-11-17 16:48:45 +00:00
Akim Demaille
9a1e998918 Alexandre Duret-Lutz <adl@gnu.org>
* data/lalr1.cc (Parser::yycdebug_): New, a pointer, to allow
changes.
(YYCDEBUG): Adjust.
Use it instead of cdebug_.
(Parser::debug_stream, Parser::set_debug_stream): New.
(Parser::symprint_): Define cdebug_ for temporary backward
compatibility.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Use
debug_stream ().
2004-11-17 16:17:50 +00:00
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
Paul Eggert
b9b51bf05a Fix wording problem in comment. 2004-10-27 22:22:51 +00:00
Paul Eggert
288006a259 (yyloc_default): Remove; not used. 2004-10-27 22:19:44 +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
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
f85a5e6f4b * data/lalr1.cc: Move towards a more standard C++ coding style
for templates: Class < T > -> Class<T>.
2004-09-29 12:49:50 +00:00
Akim Demaille
b203fc2c07 * data/lalr1.cc: Reinstall the former ctor, for sake of
compatibility, but warn it will be removed.
Move towards a more standard C++ coding style (i.e., type *var ->
type* var).
2004-09-29 12:41:58 +00:00
Akim Demaille
0dcca5c22f * data/yacc.c (YY_LOCATION_PRINT): Fix its default declaration. 2004-09-27 07:47:47 +00:00
Akim Demaille
6dde1c82cd * data/lalr1.cc (b4_parse_param_decl_1): New.
(b4_parse_param_decl): Use it to have different names bw attribute
and argument names.
(b4_cc_constructor_call): Likewise.
2004-09-27 07:45:09 +00:00
Akim Demaille
619404e3fd * data/c.m4 (b4_yysymprint_generate): Move the YYINPUT invocation
after the location.
2004-09-24 14:14:58 +00:00
Akim Demaille
0092f063af * data/yacc.c, data/glr.c (b4_at_dollar, b4_dollar_dollar): Remove
the useless parentheses.
Suggested by Paul Eggert.
2004-09-21 06:59:19 +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
b8458aa5cc * data/yacc.c (YY_LOCATION_PRINT): Use YYLTYPE_IS_TRIVIAL as a
clearer criterion to define it.
(parse): Initialize the initial location when YYLTYPE_IS_TRIVIAL.
When reducing on an empty RHS, use the latest stacked location as
location.
yylloc is not always available.
* data/glr.c: Likewise.
Also, honor initial-actions.
2004-09-20 12:24:45 +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
ecfe33e799 * data/lalr1.cc (Stack::Iterator, Stack::ConstIterator): Rename as...
(iterator, const_iterator): these, to be more in the C++ spirit.
Also, return reverse iterators so that when displaying the stack
we display its bottom first.
(Parser::stack_print_, Parser::reduce_print_): Match the messages
from yacc.c.
We should probably use vector here though.
2004-09-16 14:41:18 +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
52d5733ff0 * data/lalr1.cc: Adjust the indentation of the labels.
Use it.
2004-09-06 14:32:05 +00:00
Akim Demaille
a0e68930d8 * data/yacc.cc, data/glr.cc (yydestruct): Accept an additional
argument, an informative message.
Call YY_SYMBOL_PRINT.
Adjust all callers: integrate the associated YY_SYMBOL_PRINT.
* data/lalr1.cc (destruct_): Likewise.
In addition, no longer depend on b4_yysymprint_generate and
b4_yydestruct_generate to generate these functions, do it "by
hand".
2004-09-06 10:29:52 +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
0fe1f06d36 * data/lalr1.cc (translate_, destruct_): No reason to be static. 2004-09-02 14:30:55 +00:00
Akim Demaille
284acc8ba7 * data/glr.c, yacc.c (YYDSYMPRINT): Remove, not used.
(YYDSYMPRINTF): Rename as...
(YY_SYMBOL_PRINT): this.
* data/lalr1.cc (YY_SYMBOL_PRINT): New, modeled after the previous
two.
Use it instead of direct symprint_ calls.
(yybackup): Tweak the "Now at end of input" case to match yacc.c's
one.
2004-09-02 14:27:02 +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
Akim Demaille
417141dd61 * data/glr.c: Guard the declarations of yypstack and yypdumpstack
with #ifdef YYDEBUG.
2004-08-30 07:50:08 +00:00
Paul Eggert
c0659069d0 (yystype) [defined YYSTYPE]: Define to YYSTYPE, not to our own type. 2004-07-22 14:39:34 +00:00
Paul Eggert
60c8294801 (b4_symbol_actions): Don't assume %union was used. 2004-07-22 14:39:03 +00:00
Paul Eggert
8dd162d3ff Use "look-ahead" instead of "lookahead", consistently. 2004-06-21 20:20:31 +00:00
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