public void visit(ConcatenationV concatenationV) { int position = -1; for (int i = 0; i < concatenationV.Children.Count; i++) { GrammarNodeV child = concatenationV.Children[i]; if (child.getReference() == target) { position = i; break; } child.accept(this); } if (position >= 0) { int theLevel = (concatenationV.Children[position] as SymbolV).Level; concatenationV.Children[position].Dispose(); concatenationV.Children.RemoveAt(position); if (concatenationV.Children.Count == 0) { // we add the undefined that should have been added by the Model.Function.Delete method UndefinedD undefinedD = concatenationV.Reference.Children[0] as UndefinedD; concatenationV.appendChildV(new UndefinedV(undefinedD, theLevel)); } } }
public void visit(ConcatenationV concatenationV) { int position = -1; for (int i = 0; i < concatenationV.Children.Count; i++) { GrammarNodeV child = concatenationV.Children[i]; if (child.getReference() == target) position = i; child.accept(this); } if (position >= 0) { int theLevel = (concatenationV.Children[position] as SymbolV).Level; ChoiceV choiceV = concatenationV.getParent() as ChoiceV; if (choiceV == null) throw new Exception("The concatV parent was not of type choiceV"); // assert that a new choice has been added to the concatD ChoiceD choiceD = concatenationV.Reference.Parent as ChoiceD; if (choiceD == null) throw new Exception("The concatV.Ref.Parent is not of type choiceD"); if (choiceD.Children.Count < 2) throw new Exception("A new choice has not been added to the choiceD grammar."); // assuming that the last choice to be added is the new one. ConcatenationD concatDadded = choiceD.Children[choiceD.Children.Count - 1] as ConcatenationD; if (concatDadded == null) throw new Exception("The choiceD children are not of type concatD"); // assert that the new concatD has one child of type UndefinedD if (concatDadded.Children.Count > 1) throw new Exception("ConcatD is new and does not have one child of type UndefinedD"); UndefinedD undefinedD = concatDadded.Children[0] as UndefinedD; if (undefinedD == null) throw new Exception("ConcatD is new and does not have one child of type UndefinedD"); ConcatenationV newConcat = new ConcatenationV(concatDadded); UndefinedV newUndefinedV = new UndefinedV(undefinedD, theLevel); newConcat.appendChildV(newUndefinedV); choiceV.appendChildV(newConcat); } }