tokhash: allow a bit smarter pattern matching
Allow constants to match only part of the token string.
This commit is contained in:
parent
fc565dd362
commit
0c3e395cc1
1 changed files with 12 additions and 0 deletions
12
tokhash.pl
12
tokhash.pl
|
@ -101,6 +101,18 @@ while (defined($line = <TD>)) {
|
|||
$tokens{$token} = scalar @tokendata;
|
||||
|
||||
$data = $pattern;
|
||||
if ($data =~ /^(.*)\{(.*)\}(.*)$/) {
|
||||
my $head = $1, $tail = $3;
|
||||
my $px = $2;
|
||||
|
||||
$px =~ s/\*/(.*)/g;
|
||||
if ($token =~ /$px/i) {
|
||||
$data = $head."\U$1".$tail;
|
||||
} else {
|
||||
die "$0: token $token doesn't match $px\n";
|
||||
}
|
||||
}
|
||||
|
||||
$data =~ s/\*/\U$token/g;
|
||||
|
||||
push(@tokendata, "\"$token\", $data");
|
||||
|
|
Loading…
Reference in a new issue