Пример #1
0
 public int CompactCollection(CollectionVariable collection, string name, bool sequential)
 {
     int addcount=0;
     if (collection!=null && collection.Count>0) {
     List<_IndexVariablePair> pairs=new List<_IndexVariablePair>();
     bool matched; //, namematched, varmatched;
     int mc=0;
     int mmax=(_iden!=null) ? _iden.Length : 0;
     mmax=(((_layout!=null) ? _layout.Length : 0)>mmax) ? _layout.Length : mmax;
     //Console.WriteLine("(Template.CompactCollection) mmax:{0}", mmax);
     ValueVariable val=null;
     bool repeatmatch=false;
     int i=0;
     Variable[] array=collection.Children.ToArray();
     while (i<array.Length) {
         //Console.WriteLine("(Template.CompactCollection) [{0}] repeatmatch:{0}", mc, repeatmatch);
         if (repeatmatch) {
             repeatmatch=false;
         } else {
             val=(array[i] is ValueVariable) ? (ValueVariable)array[i] : null;
             i++;
         }
         if (val!=null) {
             //namematched=__matchname(mc, _iden, value.Name, _casesens, _infinitism);
             //varmatched=__matchvariable(mc, _layout, _infinitism, value);
             //matched=namematched && varmatched;
             matched=__matchname(mc, _iden, val.Name, _casesens, _infinitism) && __matchvariable(mc, _layout, _infinitism, val);
             //Console.WriteLine("(Template.CompactCollection) [{0}] type:{1}, name:{2}, namematched:{3}, varmatched:{4}, (mc<mmax):{5}, (_layout && mc<_layout.Length):{6}",
             //	mc, value.TypeName, "" /*value.Name*/, namematched, varmatched, (mc<mmax), (_layout && mc<_layout.Length));
             if (matched) {
                 //Console.WriteLine("(Template.CompactCollection) match at mc:{0}", mc);
                 pairs.Add(new _IndexVariablePair(i, val));
                 mc++;
             } else if (mc>0 && mc!=mmax) {
                 //Console.WriteLine("(Template.CompactCollection) unmatched before total; mc:{0}", mc);
                 if (mmax==0 || mc>mmax) {
                     //Console.WriteLine("(Template.CompactCollection) creating from left over");
                     __add(collection, pairs, name, ref addcount);
                 }
                 __reset(out mc, out repeatmatch, true, pairs);
             }
             if (mmax>0 && ((mc==mmax && (_infinitism==VariableType.NONE)) || (mc>0 && !(i!=array.Length)))) {
                 //Console.WriteLine("(Template.CompactCollection) unmatched total mc:{0}, creating identifier", mc);
                 __add(collection, pairs, name, ref addcount);
                 __reset(out mc, out repeatmatch, matched, pairs);
             }
         } else if (mc>0 && sequential) {
             //Console.WriteLine("(Template.CompactCollection) non-value inbetween match series mc:{0}", mc);
             if (mmax==0 || mc>mmax) {
                 //Console.WriteLine("(Template.CompactCollection) creating from left over");
                 __add(collection, pairs, name, ref addcount);
             }
             __reset(out mc, out repeatmatch, false, pairs);
         }
     }
     }
     return addcount;
 }
Пример #2
0
 public IntVariable(int val, CollectionVariable parent)
     : this(val, String.Empty, parent)
 {
 }
Пример #3
0
 public IntVariable(int val, string name, CollectionVariable parent)
 {
     _value=val;
     _name=name;
     _parent=parent;
 }
Пример #4
0
 public Identifier(CollectionVariable parent)
     : this("", parent)
 {
 }
Пример #5
0
 public Identifier(string name, CollectionVariable parent)
 {
     _name=name;
     _parent=parent;
 }
Пример #6
0
 public FloatVariable(float val, CollectionVariable parent)
     : this(val, String.Empty, parent)
 {
 }
Пример #7
0
 public Identifier GetMatchingIdentifier(CollectionVariable collection)
 {
     if (collection!=null) {
     foreach (Variable v in collection.Children) {
         Identifier identifier=v as Identifier;
         if (ValidateIdentifier(identifier))
             return identifier;
     }
     }
     return null;
 }
Пример #8
0
 public StringVariable(string val, string name, CollectionVariable parent)
 {
     _value=val;
     _name=name;
     _parent=parent;
 }
Пример #9
0
 public BoolVariable(bool val, string name, CollectionVariable parent)
 {
     _value=val;
     _name=name;
     _parent=parent;
 }
Пример #10
0
 void __add(CollectionVariable collection, List<_IndexVariablePair> pairs, string name, ref int addcount)
 {
     if (pairs.Count>0) {
     bool first=true;
     Identifier iden=new Identifier(name, collection);
     foreach (_IndexVariablePair pair in pairs) {
         collection.Children.RemoveAt(pair.i);
         if (first) {
             collection.Children.Insert(pair.i, iden);
             first=false;
         }
         iden.Add(pair.variable); // re-own to the new identifier
     }
     addcount++;
     }
 }
Пример #11
0
 public int CompactCollection(CollectionVariable collection, string name)
 {
     return CompactCollection(collection, name, false);
 }
Пример #12
0
 public int RenameValues(CollectionVariable collection, string name)
 {
     int count=0;
     if (collection!=null) {
     foreach (Variable v in collection.Children) {
         ValueVariable val = v as ValueVariable;
         if (ValidateValue(val)) {
             val.Name=name;
             count++;
         }
     }
     }
     return count;
 }
Пример #13
0
 public int RenameIdentifiers(CollectionVariable collection, string name)
 {
     int count=0;
     if (collection!=null) {
     foreach (Variable v in collection.Children) {
         Identifier identifier=v as Identifier;
         if (ValidateIdentifier(identifier)) {
             identifier.Name=name;
             count++;
         }
     }
     }
     return count;
 }
Пример #14
0
 public ValueVariable GetMatchingValue(CollectionVariable collection)
 {
     if (collection!=null) {
     foreach (Variable v in collection.Children) {
         ValueVariable val = v as ValueVariable;
         if (ValidateValue(val))
             return val;
     }
     }
     return null;
 }
Пример #15
0
 public Node(string name, CollectionVariable parent)
 {
     _name=name;
     _parent=parent;
 }
Пример #16
0
 public BoolVariable(bool val, CollectionVariable parent)
     : this(val, String.Empty, parent)
 {
 }
Пример #17
0
 public Node(CollectionVariable parent)
     : this(String.Empty, parent)
 {
 }
Пример #18
0
 public FloatVariable(float val, string name, CollectionVariable parent)
 {
     _value=val;
     _name=name;
     _parent=parent;
 }
Пример #19
0
 public StringVariable(string val, CollectionVariable parent)
     : this(val, String.Empty, parent)
 {
 }
Пример #20
0
 void AddVariableAndReset(CollectionVariable collection, Variable variable, bool iden, bool val)
 {
     collection.Add(variable);
     Reset(iden, val);
 }