70 if ( !( $start >= 0x20 && $start < 0x7f ) && $end - $start >= 10 ) {
71 $ranges[$k][] = sprintf(
"c >= 0x%06x and c < 0x%06x", $start, $end );
73 for ( $i = $start; $i < $end; $i++ ) {
74 fprintf(
$fh,
"\t\t[0x%06x] = 1,\n", $i );
79fprintf(
$fh,
"-- This file is automatically generated by make-tables.php\n" );
80fprintf(
$fh,
"local pats = {\n" );
81foreach (
$pats as $k => $pp ) {
85 fprintf(
$fh,
"\t[0x%02x] = {},\n", ord( $k ) );
92 foreach ( str_split( $pp[1] ) as $p ) {
93 $re2[] =
$pats[$p][0];
95 $re2 = implode(
'|', $re2 );
98 fprintf(
$fh,
"\t[0x%02x] = {\n", ord( $k ) );
100 foreach (
$chars as $i => $c ) {
101 if ( preg_match(
"/^$re$/u", $c ) && !preg_match(
"/^$re2$/u", $c ) ) {
102 if ( $rstart ===
null ) {
106 if ( $rstart !==
null ) {
112 if ( $rstart !==
null ) {
115 fprintf(
$fh,
"\t},\n" );
117foreach (
$pats as $k => $pp ) {
118 $kk = strtoupper( $k );
119 fprintf(
$fh,
"\t[0x%02x] = {},\n", ord( $kk ) );
121fprintf(
$fh,
"}\n" );
122foreach (
$pats as $k => $pp ) {
126 foreach ( str_split( $pp[1] ) as $p ) {
127 $check[] = sprintf(
"pats[0x%02x][k]", ord( $p ) );
131 $body =
"\tlocal c = tonumber( k ) or 0/0;\n";
132 $check = array_merge( $check,
$ranges[$k] );
135 $body .=
"\treturn " . implode(
" or\n\t\t", $check );
136 fprintf(
$fh,
"setmetatable( pats[0x%02x], { __index = function ( t, k )\n%s\nend } )\n",
140foreach (
$pats as $k => $pp ) {
141 fprintf(
$fh,
"setmetatable( pats[0x%02x], { ", ord( strtoupper( $k ) ) );
142 fprintf(
$fh,
"__index = function ( t, k ) return k and not pats[0x%02x][k] end", ord( $k ) );
143 fprintf(
$fh,
" } )\n" );