File: genprefixes.pl

package info (click to toggle)
hspell 1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,556 kB
  • sloc: ansic: 2,808; perl: 1,989; makefile: 209; sh: 109; awk: 15
file content (91 lines) | stat: -rwxr-xr-x 2,349 bytes parent folder | download | duplicates (8)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/perl -w

require "PrefixBits.pl";

sub find_prefixes {
	my $INQUISITIVE_HE=shift;

	my ($mask,$prefix);
	my %prefixes;

	foreach $W ('','�'){
	  foreach $S ('','�','�'){
	    foreach $K ('','��','��','���'){
	      foreach $k ('','�'){
		foreach $B ('','�','�','�','�','�','��'){
		  next if (!$INQUISITIVE_HE && $S eq '�');
		  next if ($k eq '�' && $B eq '�');
		  $prefix = "$W$S$K$k$B";
		  $mask = $PS_MISC;
		  $mask |= $PS_L if $B =~ m/[����]$/;
		  $mask |= $PS_B if $prefix =~ m/^�?�?�$/;
		  $mask |= $PS_VERB if ($k eq "" && $B eq "");
		  $mask |= $PS_NONDEF if $B !~ m/�$/;
		  $prefixes{$prefix} = 0 if !defined $prefixes{$prefix};
		  $prefixes{$prefix} |= $mask;
		}
	      }
	    }
	  }
	}
	foreach $W ('','�'){
	  foreach $S ('','�','�'){
	    foreach $K ('','��','��','���'){
	      foreach $B ('','�','�','�'){
	      	foreach $k ('','�'){
		  next if (!$INQUISITIVE_HE && $S eq '�');
		  $prefix = "$W$S$K$B$k";
		  $mask = $PS_MISC;
		  $mask |= $PS_L if $B =~ m/[����]$/;
		  $mask |= $PS_B if $prefix =~ m/^�?�?�$/;
		  $mask |= $PS_VERB if ($k eq "" && $B eq "");
		  $mask |= $PS_NONDEF if $B !~ m/�$/;
		  $prefixes{$prefix} = 0 if !defined $prefixes{$prefix};
		  $prefixes{$prefix} |= $mask;
		}
	      }
	    }
	  }
	}
	foreach $B ('�','�'){
		$prefix = "�$B";
		$mask = $PS_MISC;
		$mask |= $PS_L if $B =~ m/[����]$/;
		$mask |= $PS_B if $prefix =~ m/^�?�?�$/;
		$mask |= $PS_NONDEF if $B !~ m/�$/;
		$prefixes{$prefix} = 0 if !defined $prefixes{$prefix};
		$prefixes{$prefix} |= $mask;
	}

	$prefixes{""} |= $PS_IMPER;
	$prefixes{"�"} |= $PS_IMPER;

	return %prefixes;
}

print "/* This file is automatically generated by genprefixes.pl.\n";
print "   DO NOT EDIT THIS FILE DIRECTLY!\n */\n\n";

# Prefix list without He Ha-She'ela (but with He Ha-Yedi`a, of course)

my %prefixes = find_prefixes(0);

print "static char *prefixes_noH[]={";
foreach (sort keys %prefixes) {print "\"$_\",\n"}
print "0};\n";

print "static int masks_noH[]={";
foreach (sort keys %prefixes) {print "$prefixes{$_},\n"}
print "-1};\n";

# Output the same thing, but with He Ha-She'ela...

%prefixes = find_prefixes(1);

print "static char *prefixes_H[]={";
foreach (sort keys %prefixes) {print "\"$_\",\n"}
print "0};\n";

print "static int masks_H[]={";
foreach (sort keys %prefixes) {print "$prefixes{$_},\n"}
print "-1};\n";