summaryrefslogtreecommitdiff
path: root/mkpfunc
diff options
context:
space:
mode:
Diffstat (limited to 'mkpfunc')
-rwxr-xr-xmkpfunc28
1 files changed, 28 insertions, 0 deletions
diff --git a/mkpfunc b/mkpfunc
new file mode 100755
index 0000000..810bc1f
--- /dev/null
+++ b/mkpfunc
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+
+($progname = $0) =~ s,.*/,,;
+
+print "/* This file is autogenerated by $progname */\n";
+
+print "typedef char*(*PFUNC)(PSTATE*, char *beg, char *end, U32 utf8, SV* self);\n";
+print "static PFUNC parsefunc[] = {\n";
+
+for my $c (0..255) {
+ local $_ = chr($c);
+ my $func = "null";
+ if (/^[A-Za-z]$/) {
+ $func = "start";
+ }
+ elsif ($_ eq "/") {
+ $func = "end";
+ }
+ elsif ($_ eq "!") {
+ $func = "decl";
+ }
+ elsif ($_ eq "?") {
+ $func = "process";
+ }
+ printf " %-15s /* %3d */\n", "parse_$func,", $c;
+}
+
+print "};\n";