/// <summary> /// Initializes this rule /// </summary> /// <param name='head'>The rule's head</param> /// <param name='headAction'>Whether this rule is generated</param> /// <param name='body'>The rule's body</param> /// <param name='context'>The lexical context pushed by this rule</param> public Rule(Variable head, TreeAction headAction, RuleBody body, int context) { this.head = head; this.headAction = headAction; this.body = body; this.context = context; }
/// <summary> /// Produces the concatenation of the left and right bodies /// </summary> /// <param name='left'>The left rule body</param> /// <param name='right'>The right rule body</param> public static RuleBody Concatenate(RuleBody left, RuleBody right) { RuleBody result = new RuleBody(); result.parts.AddRange(left.parts); result.parts.AddRange(right.parts); return(result); }
/// <summary> /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="Hime.SDK.Grammars.RuleBody"/>. /// </summary> /// <param name='obj'> /// The <see cref="System.Object"/> to compare with the current <see cref="Hime.SDK.Grammars.RuleBody"/>. /// </param> /// <returns> /// <c>true</c> if the specified <see cref="System.Object"/> is equal to the current /// <see cref="Hime.SDK.Grammars.RuleBody"/>; otherwise, <c>false</c>. /// </returns> public override bool Equals(object obj) { RuleBody temp = obj as RuleBody; if (temp == null) { return(false); } if (parts.Count != temp.parts.Count) { return(false); } for (int i = 0; i != parts.Count; i++) { if (!parts[i].Equals(temp.parts[i])) { return(false); } } return(true); }