public override bool Equals(object obj) { if (obj == null || !(obj is ARRAY)) { return(false); } ARRAY array = (ARRAY)obj; if (Limits.Count != array.Limits.Count) { return(false); } for (int l = 0; l < Limits.Count; l++) { if (!Limits[l].Equals(array.Limits[l])) { return(false); } } return(MemberType.Equals(array.MemberType)); }
public static DataType Parse(string str, out string left) { char[] ws = { ' ', '\t' }; left = str; str = str.TrimStart(); if (str.Length == 0) { return(null); } int i; for (i = 0; i < str.Length; i++) { char c = str[i]; if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) { break; } } if (i == 0) { return(UNKNOWN.Type); } DataType type; if (!keyword_lookup.TryGetValue(str.Substring(0, i).ToLowerInvariant(), out type)) { return(UNKNOWN.Type); } left = str.Substring(i); str = left; if (type is ARRAY) { ARRAY array_type = new ARRAY(); if (!MatchSymbol("[", str, out str)) { return(null); } while (true) { Constant low = ParseConstant(str, out str); if (low == null) { return(null); } if (!MatchSymbol("..", str, out str)) { return(null); } Constant high = ParseConstant(str, out str); if (low == null) { return(null); } array_type.Limits.Add(new ArrayLimits(low, high)); if (!MatchSymbol(",", str, out str)) { break; } } if (!MatchSymbol("]", str, out str)) { return(null); } if (!MatchSymbol("of", str, out str)) { return(null); } DataType item_type = Parse(str, out str); if (item_type == null) { return(null); } left = str; array_type.MemberType = item_type; return(array_type); } else if (type is STRING) { STRING string_type = new STRING(); if (!MatchSymbol("[", str, out str)) { return(null); } Constant capacity = ParseConstant(str, out str); if (capacity == null) { return(null); } if (!MatchSymbol("]", str, out str)) { return(null); } left = str; string_type.Capacity = capacity; return(string_type); } else if (type is STRUCT) { STRUCT struct_type = new STRUCT(); return(struct_type); } return(type); }