BEGIN { # Get function prototypes require 'regen_lib.pl'; } #use Fatal qw(open close rename chmod unlink); use strict; use warnings; open DESC, 'regcomp.sym'; my $ind = 0; my (@name,@rest,@type,@code,@args,@longj); my ($desc,$lastregop); while () { s/#.*$//; next if /^\s*$/; s/\s*\z//; if (/^-+\s*$/) { $lastregop= $ind; next; } unless ($lastregop) { $ind++; ($name[$ind], $desc, $rest[$ind]) = split /\t+/, $_, 3; ($type[$ind], $code[$ind], $args[$ind], $longj[$ind]) = split /[,\s]\s*/, $desc, 4; } else { my ($type,@lists)=split /\s*\t+\s*/, $_; die "No list? $type" if !@lists; foreach my $list (@lists) { my ($names,$special)=split /:/, $list , 2; $special ||= ""; foreach my $name (split /,/,$names) { my $real= $name eq 'resume' ? "resume_$type" : "${type}_$name"; my @suffix; if (!$special) { @suffix=(""); } elsif ($special=~/\d/) { @suffix=(1..$special); } elsif ($special eq 'FAIL') { @suffix=("","_fail"); } else { die "unknown :type ':$special'"; } foreach my $suffix (@suffix) { $ind++; $name[$ind]="$real$suffix"; $type[$ind]=$type; $rest[$ind]="Regmatch state for $type"; } } } } } my ($width,$rwidth,$twidth)=(0,0,0); for (1..@name) { $width=length($name[$_]) if $name[$_] and $width256; my $tmp_h = 'tmp_reg.h'; unlink $tmp_h if -f $tmp_h; open OUT, ">$tmp_h"; #*OUT=\*STDOUT; binmode OUT; printf OUT < $lastregop - 1, -$width, REGMATCH_STATE_MAX => $tot - 1 ; $ind = 0; while (++$ind <= $tot) { my $oind = $ind - 1; printf OUT "#define\t%*s\t%d\t/* %#04x %s */\n", -$width, $name[$ind], $ind-1, $ind-1, $rest[$ind]; print OUT "\n\t/* ------------ States ------------- */\n\n" if $ind == $lastregop and $lastregop != $tot; } print OUT <