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/".
This commit is contained in:
Akim Demaille
2008-08-16 09:40:34 +02:00
parent b9855ea55b
commit c17f9a4a62
2 changed files with 67 additions and 21 deletions

View File

@@ -1,3 +1,11 @@
2008-11-10 Akim Demaille <demaille@gostai.com>
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 Akim Demaille <demaille@gostai.com> 2008-11-10 Akim Demaille <demaille@gostai.com>
Formatting changes. Formatting changes.

View File

@@ -30,11 +30,14 @@ bench.pl - bench marks for Bison parsers.
Specify the set of benches to run. The following grammar defines the Specify the set of benches to run. The following grammar defines the
I<directives>: I<directives>:
I<directives> ::= I<directives> | I<directives> -- Alternation directives ::=
| I<directives> & I<directives> -- Concatenation directives | directives -- Alternation
| [ I<directives> ] -- Optional | directives & directives -- Concatenation
| ( I<directives> ) -- Parentheses | [ directives> ] -- Optional
| I<directive> | ( directives> ) -- Parentheses
| %s skeleton -- %skeleton "skeleton"
| #d definition -- %code { #define definition }
| directive
Parentheses only group to override precedence. For instance: Parentheses only group to override precedence. For instance:
@@ -887,17 +890,19 @@ Bench the C++ lalr1.cc parser using Boost.Variants or %union.
sub bench_variant_parser () sub bench_variant_parser ()
{ {
bench ('list', bench ('list',
('%skeleton "lalr1.cc"', qw(
'&', %s lalr1.cc
'[', '%debug', ']', &
'&', [ %debug ]
'[', '%define variant', &
'&', [ %define variant
'[', "%code {\n#define VARIANT_DESTROY\n}", ']', &
'&', [ #d VARIANT_DESTROY ]
'[', "%code {\n#define ONE_STAGE_BUILD\n}", ']', &
']' [ #d ONE_STAGE_BUILD ]
)); ]
)
);
} }
###################################################################### ######################################################################
@@ -911,9 +916,12 @@ Bench the C++ lalr1.cc parser using Boost.Variants or %union.
sub bench_fusion_parser () sub bench_fusion_parser ()
{ {
bench ('list', bench ('list',
('%skeleton "lalr1-split.cc"', qw(
'|', %s lalr1-split.cc
'%skeleton "lalr1.cc"')); |
%s lalr1.cc
)
);
} }
############################################################################ ############################################################################
@@ -938,6 +946,7 @@ my @token;
# expr: term (| term)* # expr: term (| term)*
# term: fact (& fact)* # term: fact (& fact)*
# fact: ( expr ) | [ expr ] | dirs # fact: ( expr ) | [ expr ] | dirs
# dirs: %s SKELETON | #d DEFINE | directive
sub parse (@) sub parse (@)
{ {
@token = @_; @token = @_;
@@ -1002,11 +1011,37 @@ sub parse_fact ()
unless $token[0] eq ']'; unless $token[0] eq ']';
shift @token; shift @token;
} }
else
{
@res = parse_dirs ();
}
return @res;
}
sub parse_dirs ()
{
my @res;
die "unexpected end of expression"
unless defined $token[0];
if ($token[0] eq '#d')
{
shift @token;
@res = ("%code {\n#define\n}");
shift @token;
}
elsif ($token[0] eq '%s')
{
shift @token;
@res = ("%skeleton \"$token[0]\"");
shift @token;
}
else else
{ {
@res = $token[0]; @res = $token[0];
shift @token; shift @token;
} }
return @res; return @res;
} }
@@ -1035,14 +1070,17 @@ sub getopt ()
getopt; getopt;
# Create the directory we work in. # Create the directory we work in.
mkdir "benches" or die "cannot create benches"
unless -d "benches";
my $count = 1; my $count = 1;
++$count ++$count
while -d "bench-$count"; while -d "benches/$count";
my $dir = "bench-$count"; my $dir = "benches/$count";
mkdir $dir mkdir $dir
or die "cannot create $dir"; or die "cannot create $dir";
chdir $dir chdir $dir
or die "cannot chdir $dir"; or die "cannot chdir $dir";
# The following message is tailored to please Emacs' compilation-mode. # The following message is tailored to please Emacs' compilation-mode.
verbose 1, "Entering directory `$dir'\n"; verbose 1, "Entering directory `$dir'\n";
verbose 1, "Using bison=$bison.\n"; verbose 1, "Using bison=$bison.\n";