Commit Graph

498 Commits

Author SHA1 Message Date
Akim Demaille
769b430fce * data/bison.c++: Catch up with bison.simple:
2002-05-24  Paul Hilfinger  <Hilfinger@CS.Berkeley.EDU>
and Paul Eggert  <eggert@twinsun.com>: `error' handing.
2002-05-26  Akim Demaille  <akim@epita.fr>: stos_, token_number_,
and popping traces.
2002-05-28 09:53:35 +00:00
Akim Demaille
5504898e82 * tests/calc.at (AT_CHECK_CALC): Adjust: there are now additional
`Error:' lines.
* data/bison.simple (yystos) [YYDEBUG]: New.
(yyparse) [YYDEBUG]: Display the symbols which are popped during
error recovery.
* tests/regression.at (Web2c Actions): Adjust: yystos is output now.
2002-05-26 18:38:41 +00:00
Paul Eggert
660bc8dd09 (yyparse): Correct error handling to conform to
POSIX and yacc.  Specifically, after syntax error is discovered,
do not reduce further before shifting the error token.
Clean up the code a bit by removing the labels yyerrdefault,
yyerrhandle, yyerrpop.
2002-05-24 12:37:12 +00:00
Paul Hilfinger
c0c9ea051b * data/bison.simple (yyr1): Don't use yy_token_number_type as element
type; it isn't always big enough, since it doesn't necessarily
include non-terminals.
(yytranslate): Expand definition of yy_token_number_type, so that
the latter can be removed.
(yy_token_number_type): Remove, only one use.
* data/bison.c++ (r1_): Parallel change to yyr1 in bison.simple---
don't use TokenNumberType as element type.

* tests/regression.at: Modify expected output to agree with change
to yyr1 and yytranslate.
2002-05-20 22:56:53 +00:00
Paul Hilfinger
fcc618005a * data/bison.simple (b4_sint_type, b4_uint_type): Correct to reflect
32-bit arithmetic.
* data/bison.c++ (b4_sint_type, b4_uint_type): Ditto.
2002-05-13 00:27:26 +00:00
Akim Demaille
5372019fab * src/output.c (GENERATE_OUTPUT_TABLE): Replace with...
(GENERATE_MUSCLE_INSERT_TABLE): this.
(output_int_table, output_unsigned_int_table, output_short_table)
(output_token_number_table, output_item_number_table): Replace with...
(muscle_insert_int_table, muscle_insert_unsigned_int_table)
(muscle_insert_short_table, muscle_insert_token_number_table)
(muscle_insert_item_number_table): these.
Adjust all callers.
(prepare_tokens): Don't free `translations', since...
* src/reader.h, src/reader.c (grammar_free): do it.
Move to...
* src/gram.h, src/gram.c (grammar_free): here.
* data/bison.simple, data/bison.c++: b4_token_number_max is now
b4_translate_max.
2002-05-05 11:56:27 +00:00
Akim Demaille
5df5f6d538 * src/output.c (output_unsigned_int_table): New.
(prepare_rules): `i' is unsigned.
`prhs', `rline', `r2' are unsigned int.
Rename muscle `rhs_number_max' as `rhs_max'.
Output muscles `prhs_max', `rline_max', and `r2_max'.
Free rline and r1.
* data/bison.simple, data/bison.c++: Adjust to use these muscles
to compute types instead of constant types.
* tests/regression.at (Web2c Actions): Adjust.
2002-05-05 11:56:06 +00:00
Paul Eggert
fba798c78e (b4_token_defines): Also define YYTOKENTYPE for K&R C. 2002-05-03 17:54:29 +00:00
Akim Demaille
53c71a12c8 * data/bison.simple (m4_if): Don't output empty enums.
And actually, output valid enum definitions :(.
2002-05-03 16:22:54 +00:00
Akim Demaille
83ccf991a6 * data/bison.simple (b4_token_enum): New.
(b4_token_defines): Use it to output tokens both as #define and
enums.
Suggested by Paul Eggert.
* src/output.c (token_definitions_output): Don't output spurious
white spaces.
2002-05-03 08:42:48 +00:00
Akim Demaille
1f41899519 * data/m4sugar/m4sugar.m4: Update from CVS Autoconf. 2002-05-03 08:26:55 +00:00
Robert Anisko
45119f0446 * data/bison.c++: Adapt expansion of $s and @s to the C++ parser.
Update the stack class, give a try to deque as the default container.
2002-05-02 16:43:00 +00:00
Akim Demaille
b2d52318fa * data/bison.simple (yyparse): Do not implement @$ = @1.
(YYLLOC_DEFAULT): Adjust to do it.
* doc/bison.texinfo (Location Default Action): Fix.
2002-05-02 16:40:54 +00:00
Akim Demaille
fdbcd8e289 Remove the so called hairy (semantic) parsers.
* src/system.h (EXT_GUARD_C, EXT_STYPE_H): Remove.
* src/gram.h, src/gram.c (semantic_parser): Remove.
(rule_t): Remove the guard and guard_line members.
* src/lex.h (token_t): remove tok_guard.
* src/options.c (option_table): Remove %guard and %semantic_parser
support.
* src/output.c, src/output.h (guards_output): Remove.
(prepare): Adjust.
(token_definitions_output): Don't output the `T'
tokens (???).
(output_skeleton): Don't output the guards.
* src/files.c, src/files.c (attrsfile): Remove.
* src/reader.c (symbol_list): Remove the guard and guard_line
members.
Adjust dependencies.
(parse_guard): Remove.
* data/bison.hairy: Remove.
* doc/bison.texinfo (Environment Variables): Remove occurrences of
BISON_HAIRY.
2002-05-02 15:06:46 +00:00
Akim Demaille
82b6cb3fb2 * src/reader.c (copy_at, copy_dollarm parse_braces, parse_action)
(parse_guard): Rename the formal argument `stack_offset' as
`rule_length', which is more readable.
Adjust callers.
(copy_at, copy_dollar): Instead of outputting the hard coded
values of $$, $n and so forth, output invocation to b4_lhs_value,
b4_lhs_location, b4_rhs_value, and b4_rhs_location.
* data/bison.simple, data/bison.c++ (b4_lhs_value)
(b4_lhs_location, b4_rhs_value, and b4_rhs_location: New.
2002-05-02 14:33:48 +00:00
Paul Eggert
0c76a0c911 (YYCOPY): Fix [] quoting problem in the non-GCC case. 2002-04-27 01:20:51 +00:00
Paul Eggert
71cd15d49b (YYSTYPE_IS_TRIVIAL, YYLTYPE_IS_TRIVIAL):
Define if we define YYSTYPE and YYLTYPE, respectively.
2002-04-27 01:10:59 +00:00
Robert Anisko
0dd1580afc * tests/calc.at: Exercise prologue splitting.
* data/bison.simple, data/bison.c++: Use `b4_pre_prologue' and
`b4_post_prologue' instead of `b4_prologue'.
* src/output.c (prepare): Add the `pre_prologue' and `post_prologue'
muscles.
(output): Free pre_prologue_obstack and post_prologue_obstack.
* src/files.h, src/files.c (attrs_obstack): Remove.
(pre_prologue_obstack, post_prologue_obstack): New.
* src/reader.c (copy_definition): Add a parameter to specify the
obstack to fill, instead of using attrs_obstack unconditionally.
(read_declarations): Pass pre_prologue_obstack to copy_definition if
`%union' has not yet been seen, pass post_prologue_obstack otherwise.
2002-04-24 16:22:57 +00:00
Paul Eggert
cf44a9aea7 Remove unnecessary commentary and white space differences from
1_29-branch.  Depend on YYERROR_VERBOSE, not defined (YYERROR_VERBOSE).

(union yyalloc, YYSTACK_GAP_MAX, YYSTACK_BYTES, YYCOPY,
YYSTACK_RELOCATE): Do not define if yyoverflow is defined, or
if this is a C++ parser and YYSTYPE or YYLTYPE has nontrivial
constructors or destructors.

(yyparse) [! defined YYSTACK_RELOCATE]: Do not relocate the stack.
2002-04-24 05:55:48 +00:00
Akim Demaille
9515e8a7f8 * data/bison.simple (yyr1): Its type is that of a token number.
* data/bison.c++ (r1_): Likewise.
* tests/regression.at (Web2c Actions): Adjust.
2002-04-22 08:22:22 +00:00
Akim Demaille
007a50a493 * src/gram.h, src/gram.c (error_token_number): Remove, use
errtoken->number.
* src/reader.c (reader): Don't specify the user token number (2)
for $undefined, as it uselessly prevents using it.
* src/gram.h (token_number_t): Move to...
* src/symtab.h: here.
(state_t.number): Is a token_number_t.
* src/print.c, src/reader.c: Use undeftoken->number instead of
hard coded 2.
(Even though this 2 is not the same as above: the number of the
undeftoken remains being 2, it is its user token number which
might not be 2).
* src/output.c (prepare_tokens): Rename the `maxtok' muscle with
`user_token_number_max'.
Output `undef_token_number'.
* data/bison.simple, data/bison.c++: Use them.
Be sure to map invalid yylex return values to
`undef_token_number'.  This saves us from gratuitous SEGV.
* tests/conflicts.at (Solved SR Conflicts)
(Unresolved SR Conflicts): Adjust.
* tests/regression.at (Web2c Actions): Adjust.
2002-04-09 19:19:59 +00:00
Akim Demaille
06446ccf94 * data/bison.c++: s/b4_item_number_max/b4_rhs_number_max/.
Adding #line.
Remove the duplicate `typedefs'.
(RhsNumberType): Fix the declaration and various other typos.
Use __ofile__.
* data/bison.simple: Use __ofile__.
* src/scan-skel.l: Handle __ofile__.
2002-04-08 12:31:15 +00:00
Akim Demaille
62a3e4f0c5 * src/gram.h (item_number_t): New, the type of item numbers in
RITEM.  Note that it must be able to code symbol numbers as
positive number, and the negation of rule numbers as negative
numbers.
Adjust all dependencies (pretty many).
* src/reduce.c (rule): Remove this `short *' pointer: use
item_number_t.
* src/system.h (MINSHORT, MAXSHORT): Remove.
Include `limits.h'.
Adjust dependencies to using SHRT_MAX and SHRT_MIN.
(shortcpy): Remove.
(MAXTABLE): Move to...
* src/output.c (MAXTABLE): here.
(prepare_rules): Use output_int_table to output rhs.
* data/bison.simple, data/bison.c++: Adjust.
* tests/torture.at (Big triangle): Move the limit from 254 to
500.
* tests/regression.at (Web2c Actions): Ajust.
Trying with bigger grammars shows various phenomena: at 3000 (28Mb
of grammar file) bison is killed by my system, at 2000 (12Mb) bison
passes, but produces negative #line number, once fixed, GCC is
killed while compiling 14Mb, at 1500 (6.7 Mb of grammar, 8.2Mb of
C), it passes.
* src/state.h (state_h): Code input lines on ints, not shorts.
2002-04-08 11:46:26 +00:00
Akim Demaille
680e8701b5 * src/muscle_tab.h (MUSCLE_INSERT_LONG_INT): New.
* src/output.c (output_table_data): Return the longest number.
(prepare_tokens): Output `token_number_max').
* data/bison.simple, data/bison.c++ (b4_sint_type, b4_uint_type):
New.
Use them to define yy_token_number_type/TokenNumberType.
Use this type for yytranslate.
* tests/torture.at (Big triangle): Push the limit from 124 to
253.
* tests/regression.at (Web2c Actions): Adjust.
2002-04-07 17:44:59 +00:00
Akim Demaille
26b23c1a49 * data/bison.c++, data/bison.simple: Don't output the current file
name in #line, to avoid useless diffs between two identical
outputs under different names.
2002-04-07 15:30:31 +00:00
Akim Demaille
e53c632297 * src/conflicts.c (log_resolution): Argument `resolution' is const. 2002-03-20 09:35:27 +00:00
Paul Eggert
5b041382df (YYCOPY): New macro.
(YYSTACK_RELOCATE): Use it.
Remove Type arg; no longer needed.  All callers changed.
(yymemcpy): Remove; no longer needed.
2002-03-20 07:28:52 +00:00
Akim Demaille
642cb8f829 Test and fix the #line outputs.
* tests/atlocal.at (GCC): New.
* tests/synclines.at (AT_TEST_SYNCLINE): New macro.
(Prologue synch line, ,%union synch line, Postprologue synch line)
(Action synch line, Epilogue synch line): New tests.
* src/reader.c (parse_union_decl): Define the muscle stype_line.
* data/bison.simple, data/bison.c++: Use it.
2002-03-19 08:16:25 +00:00
Akim Demaille
0d8bed5636 * data/m4sugar/m4sugar.m4: Update from CVS Autoconf.
* data/bison.simple, data/bison.c++: Handle the `#define' part, so
that we can move to enums for instance.
* src/output.c (token_definitions_output): Output a list of
`token-name, token-number' instead of the #define.
(output_skeleton): Name this list `b4_tokens', not `b4_tokendefs'.
2002-03-19 07:48:47 +00:00
Robert Anisko
af27eacb6a * data/bison.c++: Make the user able to add members to the generated
parser by subclassing.
2002-03-09 14:31:16 +00:00
Robert Anisko
64dba31e7f * data/bison.c++: Remove a debug line. 2002-03-04 16:48:33 +00:00
Robert Anisko
374f5a14de * data/bison.c++: Unmerge value as yylval and value as yyval. Unmerge
location as yylloc and location as yyloc.  Use YYLLOC_DEFAULT, and
provide a default implementation.
2002-03-04 16:37:52 +00:00
Robert Anisko
98254360e3 * data/bison.c++: Merge the two generated headers. Insert a copyright
notice in each output file.
2002-02-28 14:56:33 +00:00
Akim Demaille
a75c057f10 * data/bison.c++: Copy the prologue of bison.simple to fetch
useful M4 definitions, such as b4_header_guard.
2002-02-28 11:41:00 +00:00
Akim Demaille
2794679661 New. 2002-02-25 14:27:12 +00:00
Paul Eggert
45119af166 (YYSTD): Remove.
(YYSIZE_T, YYFPRINTF, YYPARSE_PARAM_ARG, YYPARSE_PARAM_DECL):
Treat C++ just like Standard C instead of trying to support
namespace cleanliness.
2002-02-14 20:27:45 +00:00
Robert Anisko
4162fa07ae * data/bison.c++ (YYDEBUG, YYERROR_VERBOSE): After the prologue.
(Copyright notice): Update.
2002-02-11 14:15:51 +00:00
Robert Anisko
8d69a1a3ae * data/bison.c++: Correct error recovery. Make the user able to
initialize the starting location.
2002-02-08 14:07:10 +00:00
Robert Anisko
69e2658bf6 * data/bison.c++: Replace some direct m4 expansions by constants. Be
more consistent when naming methods and variables.  Put preprocessor
directives around tables only needed for debugging.
2002-02-07 16:41:23 +00:00
Robert Anisko
4aacc3a71d * data/bison.c++ (yy::b4_name::print_): New method, replaces yyprint in
C++ parsers.
(yy::b4_name::parse): Use print_.
2002-02-07 14:41:46 +00:00
Robert Anisko
762a801e00 * data/bison.c++ (yy::b4_name::parse): Error recovery is back. 2002-02-07 13:02:40 +00:00
Robert Anisko
4bb2bc3f61 * data/bison.c++ (yy::b4_name::error_): New method, replaces yyerror in
C++ parsers.
(yy::b4_name::parse): Build verbose error messages, and use error_.
2002-02-07 11:35:40 +00:00
Robert Anisko
6b45a3ca82 * data/bison.c++: Fix m4 quoting in comments. 2002-02-06 15:17:57 +00:00
Robert Anisko
50997c6eeb * data/bison.c++: Adjust the parser code. Fix some muscles that were
not expanded by m4.
2002-02-06 14:22:44 +00:00
Akim Demaille
ea6cfe9ebd Really add m4sugar to the repo. 2002-02-05 10:13:16 +00:00
Akim Demaille
3f3eed2770 * data/bison.c++: Adjust to the M4 back end.
More is certainly needed.
2002-02-05 10:09:49 +00:00
Akim Demaille
be2a1a68ef Give a try to M4 as a back end.
* lib/readpipe.c: New, from wdiff.
* src/Makefile.am (DEFS): Define PKGDATADIR, not BISON_SIMPLE and
BISON_HAIRY.
* src/system.h (BISON_HAIRY, BISON_SIMPLE): Remove the DOS and VMS
specific values.  Now it is m4 that performs the lookup.
* src/parse-skel.y: Remove.
* src/muscle_tab.c, src/muscle_tab.h (muscles_m4_output): New.
* src/output.c (actions_output, guards_output)
(token_definitions_output): No longer keeps track of the output
line number, hence remove the second argument.
(guards_output): Check against the guard member of a rule, not the
action member.
Adjust callers.
(output_skeleton): Don't look for the skeleton location, let m4 do
that.
Create `/tmp/muscles.m4'.  This is temporary, a proper temporary
file will be used.
Invoke `m4' on m4sugar.m4, muscles.m4, and the skeleton.
(prepare): Given that for the time being changesyntax is not
usable in M4, rename the muscles using `-' to `_'.
Define `defines_flag', `output_parser_name' and `output_header_name'.
* src/output.h (actions_output, guards_output)
(token_definitions_output): Adjust prototypes.
* src/scan-skel.l: Instead of scanning the skeletons, it now
processes the output of m4: `__oline__' and `#output'.
* data/bison.simple: Adjust to be used by M4(sugar).
* tests/Makefile.am: Use check_SCRIPTS to make sure `bison' is up
to date.
* tests/bison.in: Use the secrete envvar `BISON_PKGDATADIR'
instead of the dead `BISON_SIMPLE' and `BISON_HAIRY'.
* data/m4sugar/m4sugar.m4, data/m4sugar/version.m4: New,
shamelessly stolen from CVS Autoconf.
2002-02-05 10:08:59 +00:00
Akim Demaille
5bb18f9a19 * src/bison.simple, src/bison.hairy, src/bison.c++: Move to...
* data/: here.
2002-02-05 09:57:52 +00:00