summaryrefslogtreecommitdiff
path: root/mkpfunc
blob: 810bc1fb1c410566e9198ec0dfcebf65add1a75d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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";