summaryrefslogtreecommitdiff
path: root/regcomp.pl
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>1998-06-21 12:38:21 -0400
committerGurusamy Sarathy <gsar@cpan.org>1998-06-22 01:53:59 +0000
commitd09b2d29781629d5f0436d3a59d2552621af768b (patch)
tree991d92776cb5a97bba1d0894f26fc0738df69d19 /regcomp.pl
parenta29cdaf07aa5601e42ae4955cc0f168e91a7c385 (diff)
downloadperl-d09b2d29781629d5f0436d3a59d2552621af768b.tar.gz
add patch that generates regnodes.h via regcomp.pl
Message-Id: <199806212038.QAA29797@monk.mps.ohio-state.edu> Subject: [PATCH 5.004_67] regcomp.h regnodes cleanup p4raw-id: //depot/perl@1188
Diffstat (limited to 'regcomp.pl')
-rw-r--r--regcomp.pl98
1 files changed, 98 insertions, 0 deletions
diff --git a/regcomp.pl b/regcomp.pl
new file mode 100644
index 0000000000..cfe59adc22
--- /dev/null
+++ b/regcomp.pl
@@ -0,0 +1,98 @@
+#use Fatal qw(open close rename chmod unlink);
+open DESC, 'regcomp.sym';
+$ind = 0;
+
+while (<DESC>) {
+ next if /^\s*($|\#)/;
+ $ind++;
+ chomp;
+ ($name[$ind], $desc, $rest[$ind]) = split /\t+/, $_, 3;
+ ($type[$ind], $code[$ind], $args[$ind], $longj[$ind])
+ = split /[,\s]\s*/, $desc, 4;
+}
+close DESC;
+$tot = $ind;
+
+$tmp_h = 'tmp_reg.h';
+
+unlink $tmp_h if -f $tmp_h;
+
+open OUT, ">$tmp_h";
+
+print OUT <<EOP;
+/* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
+ This file is built by regcomp.pl from regcomp.sym.
+ Any changes made here will be lost!
+*/
+
+EOP
+
+$ind = 0;
+while (++$ind <= $tot) {
+ $oind = $ind - 1;
+ $hind = sprintf "%#4x", $oind;
+ print OUT <<EOP;
+#define $name[$ind] $oind /* $hind $rest[$ind] */
+EOP
+}
+
+print OUT <<EOP;
+
+#ifndef DOINIT
+EXTCONST U8 regkind[];
+#else
+EXTCONST U8 regkind[] = {
+EOP
+
+$ind = 0;
+while (++$ind <= $tot) {
+ print OUT <<EOP;
+ $type[$ind], /* $name[$ind] */
+EOP
+}
+
+print OUT <<EOP;
+};
+#endif
+
+
+#ifdef REG_COMP_C
+const static U8 regarglen[] = {
+EOP
+
+$ind = 0;
+while (++$ind <= $tot) {
+ $size = 0;
+ $size = "EXTRA_SIZE(struct regnode_$args[$ind])" if $args[$ind];
+
+ print OUT <<EOP;
+ $size, /* $name[$ind] */
+EOP
+}
+
+print OUT <<EOP;
+};
+
+const static char reg_off_by_arg[] = {
+EOP
+
+$ind = 0;
+while (++$ind <= $tot) {
+ $size = $longj[$ind] || 0;
+
+ print OUT <<EOP;
+ $size, /* $name[$ind] */
+EOP
+}
+
+print OUT <<EOP;
+};
+#endif /* REG_COMP_C */
+
+EOP
+
+close OUT;
+
+chmod 0666, 'regnodes.h';
+unlink 'regnodes.h';
+rename $tmp_h, 'regnodes.h';