2 # Get function prototypes
3 require 'regen_lib.pl';
5 #use Fatal qw(open close rename chmod unlink);
9 open DESC, 'regcomp.sym';
12 my (@name,@rest,@type,@code,@args,@longj);
13 my ($desc,$lastregop);
24 ($name[$ind], $desc, $rest[$ind]) = split /\t+/, $_, 3;
25 ($type[$ind], $code[$ind], $args[$ind], $longj[$ind])
26 = split /[,\s]\s*/, $desc, 4;
28 my ($type,@lists)=split /\s*\t+\s*/, $_;
29 die "No list? $type" if !@lists;
30 foreach my $list (@lists) {
31 my ($names,$special)=split /:/, $list , 2;
33 foreach my $name (split /,/,$names) {
34 my $real= $name eq 'resume'
40 } elsif ($special=~/\d/) {
41 @suffix=(1..$special);
42 } elsif ($special eq 'FAIL') {
45 die "unknown :type ':$special'";
47 foreach my $suffix (@suffix) {
49 $name[$ind]="$real$suffix";
51 $rest[$ind]="Regmatch state for $type";
58 my ($width,$rwidth,$twidth)=(0,0,0);
60 $width=length($name[$_]) if $name[$_] and $width<length($name[$_]);
61 $twidth=length($type[$_]) if $type[$_] and $twidth<length($type[$_]);
62 $rwidth=$width if $_ == $lastregop;
67 die "Too many regexp/state opcodes! Maximum is 256, but there are $lastregop in file!"
70 my $tmp_h = 'tmp_reg.h';
72 unlink $tmp_h if -f $tmp_h;
79 /* -*- buffer-read-only: t -*-
80 !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
81 This file is built by regcomp.pl from regcomp.sym.
82 Any changes made here will be lost!
85 /* Regops and State definitions */
91 -$width, REGNODE_MAX => $lastregop - 1,
92 -$width, REGMATCH_STATE_MAX => $tot - 1
96 while (++$ind <= $tot) {
98 printf OUT "#define\t%*s\t%d\t/* %#04x %s */\n",
99 -$width, $name[$ind], $ind-1, $ind-1, $rest[$ind];
100 print OUT "\n\t/* ------------ States ------------- */\n\n"
101 if $ind == $lastregop and $lastregop != $tot;
106 /* PL_regkind[] What type of regop or state is this. */
109 EXTCONST U8 PL_regkind[];
111 EXTCONST U8 PL_regkind[] = {
115 while (++$ind <= $tot) {
116 printf OUT "\t%*s\t/* %*s */\n",
117 -1-$twidth, "$type[$ind],", -$width, $name[$ind];
118 print OUT "\t/* ------------ States ------------- */\n"
119 if $ind == $lastregop and $lastregop != $tot;
126 /* regarglen[] - How large is the argument part of the node (in regnodes) */
129 static const U8 regarglen[] = {
133 while (++$ind <= $lastregop) {
135 $size = "EXTRA_SIZE(struct regnode_$args[$ind])" if $args[$ind];
137 printf OUT "\t%*s\t/* %*s */\n",
138 -37, "$size,",-$rwidth,$name[$ind];
144 /* reg_off_by_arg[] - Which argument holds the offset to the next node */
146 static const char reg_off_by_arg[] = {
150 while (++$ind <= $lastregop) {
151 my $size = $longj[$ind] || 0;
153 printf OUT "\t%d,\t/* %*s */\n",
154 $size, -$rwidth, $name[$ind]
160 /* reg_name[] - Opcode/state names in string form, for debugging */
163 const char * reg_name[] = {
167 while (++$ind <= $tot) {
168 my $size = $longj[$ind] || 0;
170 printf OUT "\t%*s\t/* %#04x */\n",
171 -3-$width,qq("$name[$ind]",),$ind-1;
172 print OUT "\t/* ------------ States ------------- */\n"
173 if $ind == $lastregop and $lastregop != $tot;
178 #endif /* DEBUGGING */
181 extern const char * reg_name[];
183 #endif /* REG_COMP_C */
188 close OUT or die "close $tmp_h: $!";
190 safer_rename $tmp_h, 'regnodes.h';