Codebase list libhtml-parser-perl / R3_05 mkpfunc
R3_05

Tree @R3_05 (Download .tar.gz)

mkpfunc @R3_05raw · history · blame

#!/usr/bin/perl

($progname = $0) =~ s,.*/,,;

print "/* This file is autogenerated by $progname */\n";

print "typedef char*(*PFUNC)(PSTATE*, char *beg, char *end,
                             STRLEN offset, 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 "  %-20s /* %3d */\n", "parse_$func,", $c;
}

print "};\n";