Skip to content

Commit

Permalink
Implement usage of pseudo-properties like :Letter for all gc/sc aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Dec 23, 2011
1 parent 525ca24 commit 45f825d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/UCD.cs
Expand Up @@ -37,6 +37,20 @@ class LimitedProperty : Property {
this.values = values;
}

public Property Proxify(string prefix) {
var va0 = new string[] { "N", "No", "F", "False" };
var va1 = new string[] { "Y", "Yes", "T", "True" };

string[][] nvalues = new string[values.Length][];
for (int i = 0; i < nvalues.Length; i++) {
nvalues[i] =
values[i][0].Substring(0, prefix.Length) == prefix
? va1 : va0;
}

return new LimitedProperty(data, nvalues);
}

public override string GetValue(int cp) {
int lix = 0;
int hix = data.Length / 2;
Expand Down Expand Up @@ -267,6 +281,7 @@ static class DataSet {
static byte[] bits;
static Dictionary<string,int[]> directory;
static Dictionary<string,string> aliases;
static Dictionary<string,string> proxy_aliases;
static Dictionary<Prod<string,string>,string[]> val_aliases;
static string[] tokens;
static bool Trace;
Expand Down Expand Up @@ -339,6 +354,7 @@ static class DataSet {
int[] loc = directory["!PropertyAlias"];
aliases = new Dictionary<string, string>();
val_aliases = new Dictionary<Prod<string,string>,string[]>();
proxy_aliases = new Dictionary<string,string>();

int rpos = loc[2];
while (rpos < loc[3]) {
Expand All @@ -364,6 +380,12 @@ static class DataSet {
aset.Add(alias);
//if (Trace) Console.WriteLine("Alias {0},{1} -> {2}", tbl, canon, Kernel.JoinS(", ", aset));
val_aliases[Prod.C(tbl, canon)] = aset.ToArray();

if (tbl == "sc" || tbl == "gc") {
foreach (string a in aset)
aliases[a] = canon;
proxy_aliases[canon] = tbl;
}
aset.Clear();
}
}
Expand Down Expand Up @@ -502,6 +524,9 @@ static class DataSet {
if (cache.TryGetValue(name, out r))
return r;

if (proxy_aliases.TryGetValue(name, out a))
return cache[name] = ((LimitedProperty) GetTable(a)).Proxify(name);

if (name == "!inverse_name") {
var inv = (GetTable("na") as StringProperty).MakeInverseMap();
var na1 = GetTable("na1") as StringProperty;
Expand Down
1 change: 1 addition & 0 deletions t/spectest.data
Expand Up @@ -213,6 +213,7 @@ S05-grammar/protoregex.t
S05-grammar/signatures.t
S05-interpolation/lexicals.t
S05-mass/named-chars.t
S05-mass/properties-script.t
S05-mass/recursive.t
S05-mass/rx.t
S05-mass/stdrules.t
Expand Down

0 comments on commit 45f825d

Please sign in to comment.