Commit Graph

40 Commits

Author SHA1 Message Date
Joel E. Denny
6721294104 Convert underscores to dashes in some %define variable names.
For now, just api.push-pull and lr.keep-unreachable-states.
Maintain old names for backward compatibility.
* NEWS (2.5): Document.
* data/c.m4 (b4_identification): Update comment.
* data/yacc.c: Update access.
* doc/bison.texinfo: Update.
* etc/bench.pl.in (bench_push_parser): Update use.
* src/files.c (tr): Move to...
* src/getargs.c, src/getargs.h (tr): ... here because I can't
think of a better place to expose it.  My logic is that, for all
uses of tr so far, command-line arguments can be involved, and
getargs.h is already included.
* src/main.c (main): Update access.
* src/muscle_tab.c (muscle_percent_define_insert): Convert old
variable names to new variable names before assigning value.
* src/reader.c (reader): Update setting default.
* tests/calc.at: Update uses.
* tests/conflicts.at (Unreachable States After Conflict
Resolution): Update use.
* tests/input.at (%define enum variables): Update use.
(%define backward compatibility): New test group.
* tests/push.at: Update uses.
* tests/reduce.at: Update uses.
* tests/torture.at: Update uses.
(cherry picked from commit 812775a039)

Conflicts:

	data/c.m4
	etc/bench.pl.in
	src/parse-gram.c
	src/parse-gram.h
	tests/conflicts.at
2009-04-30 03:43:58 -04:00
Akim Demaille
07a6e87d46 Style changes.
* etc/bench.pl.in (generate_grammar_list): Consitently use
	location_type, not yy::location.
2009-02-25 23:31:34 +01:00
Akim Demaille
932b0c960a Get rid of lalr1-split.cc.
It was no longer maintainer.

	* data/lalr1-split.cc: Remove.
	* etc/bench.pl.in (bench_fusion_parser): Remove.
	Adjust.
2008-11-26 09:48:24 +01:00
Akim Demaille
4fc55348e5 Simplify code for variants bench marks.
* etc/bench.pl.in (&generate_grammar_list): Define and use
	location_type.
	Factor the common code in yylex.
2008-11-15 14:17:15 +01:00
Akim Demaille
fe1b448ada Instead of using make_symbol<TOK_FOO>, generate make_FOO for each token type.
Using template buys us nothing, and makes it uselessly complex to
construct a symbol.  Besides, it could not be generalized to other
languages, while make_FOO would work in C/Java etc.

	* data/lalr1.cc (b4_symbol_): New.
	(b4_symbol): Use it.
	(b4_symbol_constructor_declaration_)
	(b4_symbol_constructor_definition_): Instead of generating
	specializations of an overloaded template function, just generate
	several functions whose names are forged from the token names
	without the token.prefix.
	(b4_symbol_constructor_declarations): Generate them for all the
	symbols, not just by class of symbol type, now that instead of
	specializing a function template by the token, we generate a
	function named after the token.
	(b4_symbol_constructor_specialization_)
	(b4_symbol_constructor_specializations): Remove.
	* etc/bench.pl.in: Adjust to this new API.
2008-11-15 10:20:02 +01:00
Akim Demaille
0927787504 Make it possible to return a symbol_type from yylex.
* data/lalr1.cc (b4_lex_symbol_if): New.
	(parse): When lex_symbol is defined, expected yylex to return the
	complete lookahead.
	* etc/bench.pl.in (generate_grammar_list): Extend to support this
	yylex interface.
	(bench_variant_parser): Exercise it.
2008-11-11 15:48:52 +01:00
Akim Demaille
64c1b92a4f Remove useless bench case.
* etc/bench.pl.in (bench_variant_parser): VARIANT_DESTROY is
	no longer used.
2008-11-11 15:45:45 +01:00
Akim Demaille
2722aa42bd Improve display of directives.
* etc/bench.pl.in (parse_term): Don't add useless eol.
2008-11-11 15:42:40 +01:00
Akim Demaille
918eb7c5ae Use string_cast in the bench.
* etc/bench.pl.in (generate_grammar_list): Define and use
	string_cast.
2008-11-11 15:39:28 +01:00
Akim Demaille
fce629c0ef Bench: syntactic sugar for %define/#define.
* etc/bench.pl.in (parse_dirs): Support %d and #d with arguments.
	(&bench_push_parser, bench_variant_parser): Use this feature.
	(&eat): New.
	Use it.
2008-11-11 15:23:13 +01:00
Akim Demaille
ce6719605b Less memory pressure on the "list" bench.
* etc/bench.pl.in (generate_grammar_list): Do not accumulate all
	the values, to limit memory pressure.
2008-11-11 15:20:03 +01:00
Akim Demaille
c17f9a4a62 Shortcuts in bench directives.
* etc/bench.pl.in (parse_dirs): New.
	Use it.
	(bench_variant_parser, bench_fusion_parser): Use %s and %d.
	Create the benches in "benches/".
2008-11-10 11:35:54 +01:00
Akim Demaille
6e0977873a Adjust verbose message to using emacs.
* etc/bench.pl.in: Inform compilation-mode when we change the
	directory.
	(generate_grammar_list): Recognize %define "variant" in addition
	to %define variant.
2008-11-10 11:29:06 +01:00
Akim Demaille
c85be41a07 Make benches in a sub dirs.
* etc/bench.pl.in ($dir): New.
	Use it.
	Check the use of constructors with an argument.
	(bench_variant_parser): Fix.
2008-11-09 20:57:06 +01:00
Akim Demaille
db65ca1f12 fix eof condition 2008-11-09 20:54:03 +01:00
Akim Demaille
9b0efa5bc2 Fix --help. 2008-11-09 20:50:39 +01:00
Akim Demaille
f10e19fd1a Enhance bench.pl.
* etc/bench.pl.in (parse, parse_expr, parse_term, parse_fact)
	(@token, $grammar, $bench): New.
	(generate_grammar_variant): Rename as...
	(generate_grammar_list): this.
	(generate_grammar): Adjust.
	(bench_grammar): Rename as...
	(bench): this.
	Use it in the various bench-marking routines.
	(-b, -g): New options.
2008-11-09 20:00:29 +01:00
Akim Demaille
757f8f98fc bench.pl -d, --directive.
* etc/bench.pl.in (@directive): New.
	(&bench_grammar): Use it.
	(&bench_list_grammar): New, to provide access to the "variant"
	grammar.
	Use it.
	(getopts): Support -d, --directive.
2008-11-09 19:54:29 +01:00
Akim Demaille
8901f32e4a The single-stack C++ parser is now the standard one.
* data/lalr1.cc: Rename as...
	* data/lalr1-split.cc: this.
	* data/lalr1-fusion.cc: Rename as...
	* data/lalr1.cc: this.
	* etc/bench.pl.in: Adjust.
2008-11-07 21:38:45 +01:00
Akim Demaille
2d32fc9fe2 Add "%define assert" to variants.
This is used to help the user catch cases where some value gets
ovewritten by a new one.  This should not happen, as this will
probably leak.

Unfortunately this uncovered a bug in the C++ parser itself: the
lookahead value was not destroyed between two calls to yylex.  For
instance if the previous lookahead was a std::string, and then an int,
then the value of the std::string was correctly taken (i.e., the
lookahead was now an empty string), but std::string structure itself
was not reclaimed.

This is now done in variant::build(other&) (which is used to take the
value of the lookahead): other is not only stolen from its value, it
is also destroyed.  This incurs a new performance penalty of a few
percent, and union becomes faster again.

	* data/lalr1-fusion.cc (variant::build(other&)): Destroy other.
	(b4_variant_if): New.
	(variant::built): New.
	Use it whereever the status of the variant changes.
	* etc/bench.pl.in: Check the penalty of %define assert.
2008-11-07 21:38:06 +01:00
Akim Demaille
f6038cb8c3 Use "%define variant" in bench.pl.
* etc/bench.pl.in: No longer use the pseudo directive %variants,
	just use %define variants.
2008-11-07 21:37:56 +01:00
Akim Demaille
3a2803df74 Use strict on bench.pl.
* etc/bench.pl.in (&run, &generate_grammar): New.
	Rename the grammar generating functions for consistency.
	Change the interface so that the list of benches to run is passed
	as (optionless) arguments.
	(&compile): Use &run.
2008-11-04 21:43:41 +01:00
Akim Demaille
cac9e09bbf Improve the display of sizes.
* etc/bench.p.in: Higher precision.
	Sort by decreasing size.
2008-11-04 21:43:32 +01:00
Akim Demaille
ef05c4d6f9 Better defaults for bench.pl.
* etc/bench.pl.in ($verbose, $cflags, $iterations): Change the
	default values.
	Adjust &verbose uses.
	(-q, --quiet): New.
2008-11-04 21:43:24 +01:00
Akim Demaille
a6df593dfe bench.pl --bench.
* etc/bench.pl.in (--bench, $bench): New.
2008-11-04 21:43:05 +01:00
Akim Demaille
429b4848d4 Bench the three-stack lalr1.cc.
* etc/bench.pl.in: Bench the three-stack lalr1.cc vs. the
	one-stack one.
2008-11-03 22:01:06 +01:00
Akim Demaille
0cc5bead40 bench: Improve output.
* etc/bench.pl.in (bench_grammar): Tune the printf format.
2008-11-03 22:00:53 +01:00
Akim Demaille
5b421a4e8e bench: check impact of %debug on variants.
* etc/bench.pl.in (variant_grammar): Fix the computation of
	$variant.
	Generate a grammar file that can work with or without %debug.
	Do use the @directive.
	(bench_variant_parser): Check impact of %debug.
	(@directives): Rename all the occurrences to...
	(@directive): this, for consistency.
2008-11-03 22:00:48 +01:00
Akim Demaille
d11ee647c3 bench: report the size too.
* etc/bench.pl.in ($iterations): Defaults to -3.
	(&bench_grammar): Require hireswallclock.
	Compute and display the size of the result.
	More comments.
2008-11-03 22:00:44 +01:00
Akim Demaille
e1b74b92a0 bench: More use of the verbosity level.
* etc/bench.pl.in ($verbose, &verbose): New.
	Use them.
	More POD documentation.
2008-11-03 22:00:39 +01:00
Akim Demaille
7e5f9c54c0 bench.pl: a command line interface
* etc/bench.pl.in: More doc.
	Some fixes in the documentation.
	($cflags, $iterations, &help, &getopt): New.
	Use them.
	(&variant_grammar): Let the number of stages be 10 times what is
	specified.
2008-11-03 22:00:34 +01:00
Akim Demaille
7109a18d18 Bench the use of Boost.Variants.
* etc/bench.pl.in ($cxx, &variant_grammar, &bench_variant_parser):
	New.
	(&compile): Be ready to compile C++ parsers.
	(&bench_push_parser): Move debug information to the outermost
	level.
	* THANKS: Add Michiel De Wilde.
2008-11-03 22:00:27 +01:00
Akim Demaille
922730fe36 bench.pl: Pass directives as a list instead of as a string.
* etc/bench.pl.in (&directives): New.
	(&triangular_grammar, &calc_grammar): Use it to format the Bison
	directives.
	(&triangular_grammar): Do use the directives (were ignored).
	(&bench_grammar, &bench_push_parser): Adjust to pass lists of
	directives.
2008-11-03 22:00:21 +01:00
Akim Demaille
7484f1d4f3 Improve genericity of bench.pl.
* etc/bench.pl.in (&bench_grammar): Take the set of benches as
	argument.
	(&bench_push_parser): New.
	Call it.
2008-11-03 22:00:17 +01:00
Akim Demaille
15129f2525 Add documentation to bench.pl.
* etc/bench.pl.in: Comment changes.
2008-11-03 22:00:12 +01:00
Akim Demaille
0925d5bfd4 Prefer "continue" for empty loop bodies.
* etc/bench.pl.in: Use "continue" instead of {}.
2008-10-28 17:11:11 +01:00
Joel E. Denny
9ca7f077a0 * data/Makefile.am (dist_pkgdata_DATA): Remove push.c.
* data/push.c: Rename to...
* data/yacc.c: ... this, overwriting it.
* etc/bench.pl.in (bench_grammar): `%pure-parser'-> `%define api.pure'.
`%push-pull-parser' -> `%define api.push_pull "both"'.
Remove old yacc.c tests, and update push.c tests to yacc.c.
2008-02-17 19:55:48 +00:00
Paul Eggert
f16b08196c Update to GPLv3.
* doc/gpl-3.0.texi: New file.
* doc/gpl.texi: Remove.
* COPYING, GNUmakefile, HACKING, Makefile.am, Makefile.cfg:
* Makefile.maint, NEWS, PACKAGING, README, README-alpha:
* README-hacking, TODO, bootstrap, bootstrap.conf:
* configure.ac, data/Makefile.am, data/README, data/bison.m4:
* data/c++-skel.m4, data/c++.m4, data/c-skel.m4, data/c.m4:
* data/glr.c, data/glr.cc, data/java-skel.m4, data/java.m4:
* data/lalr1.cc, data/lalr1.java, data/location.cc:
* data/push.c, data/yacc.c, data/m4sugar/m4sugar.m4:
* djgpp/Makefile.maint, djgpp/README.in, djgpp/config.bat:
* djgpp/config.sed, djgpp/config.site, djgpp/config_h.sed:
* djgpp/djunpack.bat, djgpp/subpipe.c, djgpp/subpipe.h:
* djgpp/testsuite.sed, doc/Makefile.am, doc/bison.texinfo:
* doc/fdl.texi, doc/refcard.tex, etc/Makefile.am, etc/README:
* etc/bench.pl.in, examples/Makefile.am, examples/extexi:
* examples/calc++/Makefile.am, lib/Makefile.am, lib/abitset.c:
* lib/abitset.h, lib/bbitset.h, lib/bitset.c, lib/bitset.h:
* lib/bitset_stats.c, lib/bitset_stats.h, lib/bitsetv-print.c:
* lib/bitsetv-print.h, lib/bitsetv.c, lib/bitsetv.h:
* lib/ebitset.c, lib/ebitset.h, lib/get-errno.c:
* lib/get-errno.h, lib/lbitset.c, lib/lbitset.h:
* lib/libiberty.h, lib/main.c, lib/subpipe.c, lib/subpipe.h:
* lib/timevar.c, lib/timevar.def, lib/timevar.h:
* lib/vbitset.c, lib/vbitset.h, lib/yyerror.c:
* m4/c-working.m4, m4/cxx.m4, m4/m4.m4, m4/subpipe.m4:
* m4/timevar.m4, src/LR0.c, src/LR0.h, src/Makefile.am:
* src/assoc.c, src/assoc.h, src/closure.c, src/closure.h:
* src/complain.c, src/complain.h, src/conflicts.c:
* src/conflicts.h, src/derives.c, src/derives.h, src/files.c:
* src/files.h, src/flex-scanner.h, src/getargs.c:
* src/getargs.h, src/gram.c, src/gram.h, src/graphviz.c:
* src/lalr.c, src/lalr.h, src/location.c, src/location.h:
* src/main.c, src/muscle_tab.c, src/muscle_tab.h:
* src/nullable.c, src/nullable.h, src/output.c, src/output.h:
* src/parse-gram.c, src/parse-gram.h, src/parse-gram.y:
* src/print.c, src/print.h, src/print_graph.c:
* src/print_graph.h, src/reader.c, src/reader.h, src/reduce.c:
* src/reduce.h, src/relation.c, src/relation.h:
* src/revision.h, src/scan-code.h, src/scan-code.l:
* src/scan-gram.h, src/scan-gram.l, src/scan-skel.h:
* src/scan-skel.l, src/state.c, src/state.h, src/symlist.c:
* src/symlist.h, src/symtab.c, src/symtab.h, src/system.h:
* src/tables.c, src/tables.h, src/uniqstr.c, src/uniqstr.h:
* tests/Makefile.am, tests/actions.at, tests/c++.at:
* tests/calc.at, tests/conflicts.at, tests/cxx-type.at:
* tests/existing.at, tests/glr-regression.at:
* tests/headers.at, tests/input.at, tests/java.at:
* tests/local.at, tests/output.at, tests/push.at:
* tests/reduce.at, tests/regression.at, tests/sets.at:
* tests/skeletons.at, tests/synclines.at, tests/testsuite.at:
* tests/torture.at:
Update to GPLv3.
2007-08-15 20:21:33 +00:00
Joel E. Denny
7172e23e8f For push mode, convert yyparse from a macro to a function, invoke yylex
instead of passing a yylexp argument to yypull_parse, and don't
generate yypull_parse or yyparse unless %push-pull-parser is declared.
Discussed starting at
<http://lists.gnu.org/archive/html/bison-patches/2006-12/msg00163.html>.
* data/bison.m4 (b4_pull_if): New.
* data/c.m4 (b4_identification): Define YYPULL similar to YYPUSH.
* data/push.c: Improve M4 quoting a little.
(b4_generate_macro_args, b4_parenthesize): Remove.
(yyparse): If there's a b4_prefix, #define this to b4_prefix[parse]
any time a pull parser is requested.
Don't #define this as a wrapper around yypull_parse.  Instead, when
both push and pull are requested, make it a function that does that
same thing.
(yypull_parse): If there's a b4_prefix, #define this to
b4_prefix[pull_parse] when both push and pull are requested.
Don't define this as a function unless both push and pull are
requested.
Remove the yylexp argument and hard-code yylex invocation instead.
* etc/bench.pl.in (bench_grammar): Use %push-pull-parser instead of
%push-parser.
* src/getargs.c (pull_parser): New global initialized to true.
* getargs.h (pull_parser): extern it.
* src/output.c (prepare): Insert pull_flag muscle.
* src/parse-gram.y (PERCENT_PUSH_PULL_PARSER): New token.
(prologue_declaration): Set both push_parser and pull_parser = true for
%push-pull-parser.  Set push_parser = true and pull_parser = false for
%push-parser.
* src/scan-gram.l: Don't accept %push_parser as an alternative to
%push-parser since there's no backward-compatibility concern here.
Scan %push-pull-parser.
* tests/calc.at (Simple LALR(1) Calculator): Use %push-pull-parser
instead of %push-parser.
* tests/headers.at (export YYLTYPE): Make yylex static, and don't
prototype it in the module that calls yyparse.
* tests/input.at (Torturing the Scanner): Likewise.
* tests/local.at (AT_PUSH_IF): Check for %push-pull-parser as well.
2006-12-31 20:29:48 +00:00
Joel E. Denny
2e7944cbb2 Update etc/bench.pl. Optimize push mode a little (the yyn change
deserves most of the credit).
* Makefile.am (SUBDIRS): Add etc subdirectory.
* configure.ac (AC_CONFIG_FILES): Add etc/bench.pl and etc/Makefile.
* data/push.c (b4_declare_parser_state_variables): Move yyn, yyresult,
yytoken, yyval, and yyloc declarations to...
(yyparse or yypush_parse): ... here to improve performance.  For
yypush_parse invocations after the first, be sure to assign yyn its old
value again.
(yypstate_new): Don't bother initializing the yyresult field since the
initial value isn't used.
(yyn, yyresult, yytoken, yyval, yyloc): For each NAME in this list,
remove the #define that, in push mode, set it to yyps->NAME.
* etc/Makefile.am: New.
* etc/bench.pl: Remove and build it instead from...
* etc/bench.pl.in: ... this new file.  Use @abs_top_builddir@ to invoke
"tests/bison" from the build directory by default rather than just
invoking "bison" from $PATH.
(calc_grammar): Update push parser code: don't declare yylval globally,
don't define yyparse_wrapper, and don't #define yyparse.
(bench_grammar): Update to check all working combinations of yacc.c,
push.c, impure, pure, pull, and push.
2006-12-26 18:09:53 +00:00