Permalink
Browse files

Implement usage of pseudo-properties like :Letter for all gc/sc aliases

  • Loading branch information...
1 parent 525ca24 commit 45f825d3e903f33012b65a8e08b8fcad4dbec35d @sorear committed Dec 23, 2011
Showing with 26 additions and 0 deletions.
  1. +25 −0 lib/UCD.cs
  2. +1 −0 t/spectest.data
View
@@ -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;
@@ -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;
@@ -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]) {
@@ -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();
}
}
@@ -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;
View
@@ -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

0 comments on commit 45f825d

Please sign in to comment.