public void SplitWS(NodeWS origWS, NodeTok insertNode, int ci_post) { if (ci_post == 0) { throw new Exception(); // CPos invariant } if (origWS.len < ci_post) { throw new Exception(); } int len_R = origWS.len - ci_post; if (len_R == 0) { InsertTokAfterNode(origWS, insertNode); return; } NodeWS WS_L = new NodeWS { _len = ci_post }; NodeWS WS_R = new NodeWS { _len = len_R }; NodeBase L = origWS.left; NodeBase R = origWS.right; NodeTok Nu = insertNode; connect(L, WS_L); connect(WS_L, Nu); connect(Nu, WS_R); connect(WS_R, R); origWS.is_valid = false; }
/* * some of these guys invalidate CPos, ( SplitWS unlinks+invalidates the token CPos sits on ) */ public void InsertTokAfterNode(NodeBase N, NodeTok nodeTok) { if (N == End) { throw new Exception(); } var R = N.right; var Nu = nodeTok; connect(N, Nu); connect(Nu, R); }
public void ReplaceTok(Tok origTok, Tok newTok) { var N = findTok(origTok); N.is_valid = false; var L = N.left; var R = N.right; var Nu = new NodeTok { _tok = newTok }; connect(L, Nu); connect(Nu, R); }
public CPosC SplitWS(CPosC CP_at, Tok tok) // returned new CPos is a the end of the inserted node { if (!CP_at.isValid(this)) { throw new Exception(); } if (!CP_at.LAdj_isWS) { throw new Exception(); } var nu_node = new NodeTok { _tok = tok }; SplitWS((NodeWS)CP_at.N, nu_node, CP_at.ci_post); return(new CPosC(this) { N = nu_node, ci_post = nu_node.len }); // todo wird wahrscheinlich nicht gebraucht }