summaryrefslogtreecommitdiff
path: root/regcomp.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-03-17 13:33:48 +0000
committerNicholas Clark <nick@ccl4.org>2010-05-27 10:30:01 +0100
commitf9ef50a71935a8e93b4030c12dcd1206ccab71ab (patch)
treeeb3fd930cc49176fa359201be519a6563a343321 /regcomp.pl
parentf8abb37e5b952f76a9e019137369e3f8ef5a58ae (diff)
downloadperl-f9ef50a71935a8e93b4030c12dcd1206ccab71ab.tar.gz
Generate PL_simple[] and PL_varies[] with regcomp.pl, rather than hard-coding.
Add a new flags column to regcomp.sym, with V if the node type is in PL_varies, S if it is in PL_simple, and . if a placeholder is needed because subsequent optional columns are present.
Diffstat (limited to 'regcomp.pl')
-rw-r--r--regcomp.pl41
1 files changed, 38 insertions, 3 deletions
diff --git a/regcomp.pl b/regcomp.pl
index 2fbe6c68f9..0c63b94380 100644
--- a/regcomp.pl
+++ b/regcomp.pl
@@ -24,7 +24,7 @@ use warnings;
open DESC, 'regcomp.sym';
my $ind = 0;
-my (@name,@rest,@type,@code,@args,@longj);
+my (@name,@rest,@type,@code,@args,@flags,@longj);
my ($desc,$lastregop);
while (<DESC>) {
s/#.*$//;
@@ -37,8 +37,8 @@ while (<DESC>) {
unless ($lastregop) {
$ind++;
($name[$ind], $desc, $rest[$ind]) = /^(\S+)\s+([^\t]+)\s*;\s*(.*)/;
- ($type[$ind], $code[$ind], $args[$ind], $longj[$ind])
- = split /[,\s]\s*/, $desc, 4;
+ ($type[$ind], $code[$ind], $args[$ind], $flags[$ind], $longj[$ind])
+ = split /[,\s]\s*/, $desc;
} else {
my ($type,@lists)=split /\s+/, $_;
die "No list? $type" if !@lists;
@@ -79,6 +79,29 @@ close DESC;
die "Too many regexp/state opcodes! Maximum is 256, but there are $lastregop in file!"
if $lastregop>256;
+sub process_flags {
+ my ($flag, $varname, $comment) = @_;
+ $comment = '' unless defined $comment;
+
+ $ind = 0;
+ my @selected;
+ while (++$ind <= $lastregop) {
+ push @selected, $name[$ind] if $flags[$ind] && $flags[$ind] eq $flag;
+ }
+ my $out_string = join ', ', @selected, 0;
+ $out_string =~ s/(.{1,70},) /$1\n /g;
+ return $comment . <<"EOP";
+#ifndef DOINIT
+EXTCONST U8 PL_${varname}[];
+#else
+EXTCONST U8 PL_${varname}[] = {
+ $out_string
+};
+#endif /* DOINIT */
+
+EOP
+}
+
my $tmp_h = 'regnodes.h-new';
unlink $tmp_h if -f $tmp_h;
@@ -236,6 +259,18 @@ print $out <<EOP;
};
#endif /* DOINIT */
+EOP
+
+print $out process_flags('V', 'varies', <<'EOC');
+/* The following have no fixed length. U8 so we can do strchr() on it. */
+EOC
+
+print $out process_flags('S', 'simple', <<'EOC');
+/* The following always have a length of 1. U8 we can do strchr() on it. */
+/* (Note that length 1 means "one character" under UTF8, not "one octet".) */
+EOC
+
+print $out <<EOP;
/* ex: set ro: */
EOP
safer_close($out);