3 namespace Mercury.Syntax
10 internal enum DerivationType
23 internal class EdgeDerivation : IEquatable<EdgeDerivation>, IComparable<EdgeDerivation>
31 private EdgeDerivation()
39 public static EdgeDerivation
Initial()
40 {
return new EdgeDerivation() { Derivation = DerivationType.Initial }; }
43 {
return new EdgeDerivation() { Derivation = DerivationType.Prediction }; }
45 public static EdgeDerivation
Scanning(Edge source)
47 return new EdgeDerivation() { Derivation = DerivationType.Scanning, Source = source };
50 public static EdgeDerivation
Fundamental(Edge source, Edge additional)
52 return new EdgeDerivation()
53 { Derivation = DerivationType.Fundamental, Source = source, Additional = additional };
60 public DerivationType Derivation {
get;
private set; }
63 public Edge Source {
get;
private set; }
66 public Edge Additional {
get;
private set; }
72 public override bool Equals(
object obj)
74 EdgeDerivation ed = obj as EdgeDerivation;
75 return ed == null ?
false : Equals(ed);
78 public override int GetHashCode()
80 if (!memHash.HasValue)
82 memHash = 3 * (int) Derivation;
83 memHash += 7 * (Source == null ? 0 : Source.GetHashCode());
84 memHash += 23 * (Additional == null ? 0 : Additional.GetHashCode());
94 #region [ IEquatable ]
96 public bool Equals(EdgeDerivation other)
98 return (other != null)
99 && (Derivation == other.Derivation) && (GetHashCode() == other.GetHashCode())
100 && (Source == null ? other.Source == null : Source.Equals(other.Source))
101 && (Additional == null ? other.Additional == null : Additional.Equals(other.Additional));
106 #region [ IComparable ]
108 public int CompareTo(EdgeDerivation other)
110 int temp = Derivation.CompareTo(other.Derivation);
112 if ((temp == 0) && (Source != null)) temp = Source.CompareTo(other.Source);
113 if ((temp == 0) && (Additional != null)) temp = Additional.CompareTo(other.Additional);
Edge created by input scanning
Edge created by fundamental A or B rule
Edge created by prediction