/*
 * SDK Pullenti Lingvo, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software.
 * This class is generated using the converter Unisharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

package com.pullenti.ner.decree.internal;

public class DecreeChangeToken extends com.pullenti.ner.MetaToken {

    public static java.util.ArrayList<com.pullenti.ner.ReferentToken> attachReferents(com.pullenti.ner.Referent dpr, DecreeChangeToken tok0) {
        if (dpr == null || tok0 == null) 
            return null;
        com.pullenti.ner.Token tt0 = tok0.getEndToken().getNext();
        if (tt0 != null && tt0.isCommaAnd() && tok0.actKind == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
            tt0 = tt0.getNext();
        if (tt0 != null && tt0.isChar(':')) 
            tt0 = tt0.getNext();
        java.util.ArrayList<DecreeChangeToken> toks = null;
        if (tt0 == null) {
        }
        else if (tt0.getPrevious() != null && tt0.getPrevious().isChar(':')) {
            if (tok0.actKind2 == com.pullenti.ner.decree.DecreeChangeKind.APPEND || tok0.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND) 
                toks = tryAttachList(tt0, true, tok0.getIndentRegime());
        }
        else {
            if (tt0.isComma() && tok0.decree != null) 
                tt0 = tt0.getNext();
            toks = tryAttachList(tt0, false, tok0.getIndentRegime());
        }
        if (toks == null) 
            toks = new java.util.ArrayList<DecreeChangeToken>();
        toks.add(0, tok0);
        if ((toks.size() == 2 && toks.get(0).actKind == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED && toks.get(0).changeVal != null) && toks.get(1).actKind == com.pullenti.ner.decree.DecreeChangeKind.NEW && toks.get(1).changeVal != null) 
            toks.get(1).actKind = com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE;
        if ((((toks.size() == 4 && toks.get(0).changeVal == null && toks.get(1).changeVal == null) && toks.get(1).actKind == com.pullenti.ner.decree.DecreeChangeKind.NEW && toks.get(2).typ == DecreeChangeTokenTyp.VALUE) && toks.get(3).typ == DecreeChangeTokenTyp.VALUE && toks.get(3).parts == null) && toks.get(3).newParts == null) {
            toks.get(1).actKind = com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE;
            toks.get(0).actKind = com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE;
        }
        java.util.ArrayList<com.pullenti.ner.decree.DecreeChangeKind> kinds = new java.util.ArrayList<com.pullenti.ner.decree.DecreeChangeKind>();
        for (DecreeChangeToken tok : toks) {
            if (tok.actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED && !kinds.contains(tok.actKind)) 
                kinds.add(tok.actKind);
        }
        if ((((kinds.size() == 1 && kinds.get(0) == com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE && toks.size() == 5) && toks.get(0).changeVal != null && toks.get(2).changeVal != null) && toks.get(4).changeVal != null && toks.get(2).changeVal.getStringValues("BEGIN").size() == 2) && toks.get(4).changeVal.getStringValues("BEGIN").size() == 1) {
            com.pullenti.ner.decree.DecreeChangeValueReferent cv = toks.get(2).changeVal;
            toks.get(2).setEndToken(toks.get(4).getEndToken());
            for (int jj = cv.getSlots().size() - 3; jj < cv.getSlots().size(); jj++) {
                toks.get(0).changeVal.getSlots().add(cv.getSlots().get(jj));
            }
            for(int jjj = cv.getSlots().size() - 3 + 3 - 1, mmm = cv.getSlots().size() - 3; jjj >= mmm; jjj--) cv.getSlots().remove(jjj);
            com.pullenti.unisharp.Utils.addToArrayList(toks.get(2).changeVal.getSlots(), toks.get(4).changeVal.getSlots());
            for(int jjj = 3 + 2 - 1, mmm = 3; jjj >= mmm; jjj--) toks.remove(jjj);
        }
        java.util.ArrayList<com.pullenti.ner.ReferentToken> res = new java.util.ArrayList<com.pullenti.ner.ReferentToken>();
        com.pullenti.ner.decree.DecreeChangeReferent dcr = new com.pullenti.ner.decree.DecreeChangeReferent();
        if (tok0.realPart != null && !(dpr instanceof com.pullenti.ner.decree.DecreePartReferent)) 
            dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_OWNER, tok0.realPart, false, 0);
        else {
            dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_OWNER, dpr, false, 0);
            if (((dpr instanceof com.pullenti.ner.decree.DecreePartReferent) && ((com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(dpr, com.pullenti.ner.decree.DecreePartReferent.class)).getOwner() != null && tok0.decree != null) && !((com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(dpr, com.pullenti.ner.decree.DecreePartReferent.class)).getOwner().canBeEquals(tok0.decree, com.pullenti.ner.core.ReferentsEqualType.WITHINONETEXT)) 
                dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_OWNER, tok0.decree, false, 0);
        }
        if (tok0.addDecrees != null) {
            for (com.pullenti.ner.decree.DecreeReferent dd : tok0.addDecrees) {
                com.pullenti.ner.decree.DecreePartReferent pp = (com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(dpr, com.pullenti.ner.decree.DecreePartReferent.class);
                if (pp != null && pp.getPreamble() != null && pp.getSlots().size() == 2) {
                    com.pullenti.ner.decree.DecreePartReferent pp2 = new com.pullenti.ner.decree.DecreePartReferent();
                    pp2.setOwner(dd);
                    pp2.setPreamble(pp.getPreamble());
                    dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_OWNER, pp2, false, 0);
                    res.add(new com.pullenti.ner.ReferentToken(pp2, null, null, null));
                    continue;
                }
                dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_OWNER, dd, false, 0);
            }
        }
        com.pullenti.ner.ReferentToken rt = new com.pullenti.ner.ReferentToken(dcr, tok0.getBeginToken(), tok0.getEndToken(), null);
        res.add(rt);
        java.util.ArrayList<String> newItems = null;
        boolean _inTheEnd = false;
        while (true) {
            for (int i = 0; i < toks.size(); i++) {
                DecreeChangeToken tok = toks.get(i);
                if (tok.inTheEnd) 
                    _inTheEnd = true;
                if (i > 0 && tok.getBeginToken().getPrevious() != null && tok.getBeginToken().getPrevious().isChar(';')) 
                    break;
                if ((i > 0 && tok.actKind == com.pullenti.ner.decree.DecreeChangeKind.EXPIRE && tok.changeVal == null) && tok.parts == null) {
                    if (dcr.getKind() != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                        break;
                }
                if (tok.typ == DecreeChangeTokenTyp.AFTERVALUE) {
                    if (tok.changeVal != null) {
                        if (tok.changeVal.isContent) 
                            dcr.setLocValue(tok.changeVal);
                        else {
                            if (dcr.getParam() != null && dcr.getKind() == com.pullenti.ner.decree.DecreeChangeKind.APPEND && dcr.getValue() != null) {
                                dcr = (com.pullenti.ner.decree.DecreeChangeReferent)com.pullenti.unisharp.Utils.cast(dcr.clone(), com.pullenti.ner.decree.DecreeChangeReferent.class);
                                dcr.setParam(null);
                                dcr.setValue(null);
                                dcr.setLocValue(null);
                                rt = new com.pullenti.ner.ReferentToken(dcr, tok.getBeginToken(), tok.getEndToken(), null);
                                res.add(rt);
                            }
                            dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_PARAM, tok.changeVal, false, 0);
                        }
                        if (tok.getEndChar() > rt.getEndChar()) 
                            rt.setEndToken(tok.getEndToken());
                        res.add(res.size() - 1, new com.pullenti.ner.ReferentToken(tok.changeVal, tok.getBeginToken(), tok.getEndToken(), null));
                    }
                    continue;
                }
                rt.setEndToken(tok.getEndToken());
                if (tok.actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) {
                    if (dcr.getKind() != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED && dcr.getKind() != tok.actKind) {
                        if (i > 0) 
                            rt.setEndToken(toks.get(i - 1).getEndToken());
                        break;
                    }
                    dcr.setKind(tok.actKind);
                    if (tok.actKind == com.pullenti.ner.decree.DecreeChangeKind.EXPIRE || tok.actKind == com.pullenti.ner.decree.DecreeChangeKind.EXPIRECHANGES || tok.actKind == com.pullenti.ner.decree.DecreeChangeKind.CONFIDENTIAL) 
                        break;
                    if (((tok.actKind == com.pullenti.ner.decree.DecreeChangeKind.REMOVE && tok.parts != null && tok.parts.get(0).typ == PartToken.ItemType.SENTENCE) && (i + 1) == toks.size() && tok0.realPart != null) && tok0.realPart.getSentence() == null) 
                        tok0.realPart.setSentence(tok.parts.get(0).values.get(0).toString());
                }
                if (tok.changeVal == null && tok.appExtChanges != null) {
                    tok.changeVal = new com.pullenti.ner.decree.DecreeChangeValueReferent();
                    tok.changeVal.setKind(com.pullenti.ner.decree.DecreeChangeValueKind.EXTAPPENDIX);
                    tok.changeVal.setValue((tok.appExtChanges.values.size() == 0 ? "" : tok.appExtChanges.values.get(0).toString()));
                    res.add(res.size() - 1, new com.pullenti.ner.ReferentToken(tok.changeVal, tok.appExtChanges.getBeginToken(), tok.appExtChanges.getEndToken(), null));
                    rt.setEndToken(tok.getEndToken());
                }
                if (tok.changeVal != null) {
                    if (((i + 2) < toks.size()) && ((toks.get(i + 1).actKind == com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE || toks.get(i + 1).actKind == com.pullenti.ner.decree.DecreeChangeKind.NEW)) && toks.get(i + 2).changeVal != null) {
                        dcr.setParam(tok.changeVal);
                        com.pullenti.ner.ReferentToken rt11 = new com.pullenti.ner.ReferentToken(tok.changeVal, tok.getBeginToken(), tok.getEndToken(), null);
                        if (tok.parts != null && tok.parts.size() > 0) 
                            rt11.setBeginToken(tok.parts.get(tok.parts.size() - 1).getEndToken().getNext());
                        res.add(res.size() - 1, rt11);
                        dcr.setValue(toks.get(i + 2).changeVal);
                        dcr.setKind(toks.get(i + 1).actKind);
                        i += 2;
                        tok = toks.get(i);
                    }
                    else if ((((i + 3) < toks.size()) && tok.changeVal.isContent && toks.get(i + 1).changeVal != null) && ((toks.get(i + 2).actKind == com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE || toks.get(i + 2).actKind == com.pullenti.ner.decree.DecreeChangeKind.NEW)) && toks.get(i + 3).changeVal != null) {
                        dcr.setLocValue(tok.changeVal);
                        dcr.setParam(toks.get(i + 1).changeVal);
                        com.pullenti.ner.ReferentToken rt11 = new com.pullenti.ner.ReferentToken(tok.changeVal, tok.getBeginToken(), tok.getEndToken(), null);
                        if (tok.parts != null && tok.parts.size() > 0) 
                            rt11.setBeginToken(tok.parts.get(tok.parts.size() - 1).getEndToken().getNext());
                        res.add(res.size() - 1, rt11);
                        rt11 = new com.pullenti.ner.ReferentToken(toks.get(i + 1).changeVal, toks.get(i + 1).getBeginToken(), toks.get(i + 1).getEndToken(), null);
                        res.add(res.size() - 1, rt11);
                        dcr.setValue(toks.get(i + 3).changeVal);
                        dcr.setKind(toks.get(i + 2).actKind);
                        i += 3;
                        tok = toks.get(i);
                    }
                    else if ((((i + 1) < toks.size()) && toks.get(i + 1).changeVal != null && kinds.size() == 1) && kinds.get(0) == com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE) {
                        dcr.setParam(tok.changeVal);
                        dcr.setKind(com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE);
                        res.add(res.size() - 1, new com.pullenti.ner.ReferentToken(tok.changeVal, tok.getBeginToken(), tok.getEndToken(), null));
                        dcr.setValue(toks.get(i + 1).changeVal);
                        i += 1;
                        tok = toks.get(i);
                    }
                    else if (tok.changeVal.isContent && dcr.getLocValue() == null) 
                        dcr.setLocValue(tok.changeVal);
                    else if (dcr.getValue() == null) {
                        dcr.setValue(tok.changeVal);
                        if (dcr.getKind() == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED && ((i == (toks.size() - 1) || ((i == (toks.size() - 2) && toks.get(i + 1).typ == DecreeChangeTokenTyp.VALUE))))) {
                            java.util.ArrayList<DecreeChangeToken> _next = new java.util.ArrayList<DecreeChangeToken>();
                            for (com.pullenti.ner.Token ttt = toks.get(toks.size() - 1).getEndToken().getNext(); ttt != null; ttt = ttt.getNext()) {
                                if (ttt.isCommaAnd()) 
                                    continue;
                                DecreeChangeToken ne = tryAttach(ttt, null, false, null, false, false, null, false);
                                if (ne == null) 
                                    break;
                                if (ne.typ == DecreeChangeTokenTyp.VALUE && ne.changeVal != null) {
                                    _next.add(ne);
                                    ttt = ne.getEndToken();
                                    continue;
                                }
                                if (ne.typ == DecreeChangeTokenTyp.ACTION && ne.actKind == com.pullenti.ner.decree.DecreeChangeKind.REMOVE) 
                                    _next.add(ne);
                                break;
                            }
                            if (_next.size() > 0 && _next.get(_next.size() - 1).typ == DecreeChangeTokenTyp.ACTION) {
                                dcr.setKind(com.pullenti.ner.decree.DecreeChangeKind.REMOVE);
                                res.add(res.size() - 1, new com.pullenti.ner.ReferentToken(tok.changeVal, tok.getBeginToken(), tok.getEndToken(), null));
                                if (i < (toks.size() - 1)) 
                                    _next.add(0, toks.get(i + 1));
                                for (int k = 0; k < (_next.size() - 1); k++) {
                                    DecreeChangeToken ne = _next.get(k);
                                    res.add(new com.pullenti.ner.ReferentToken(ne.changeVal, ne.getBeginToken(), ne.getEndToken(), null));
                                    dcr = new com.pullenti.ner.decree.DecreeChangeReferent();
                                    dcr.setKind(com.pullenti.ner.decree.DecreeChangeKind.REMOVE);
                                    dcr.setValue(ne.changeVal);
                                    dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_OWNER, dpr, false, 0);
                                    rt = new com.pullenti.ner.ReferentToken(dcr, ne.getBeginToken(), ne.getEndToken(), null);
                                    if (k == (_next.size() - 2)) 
                                        rt.setEndToken(_next.get(_next.size() - 1).getEndToken());
                                    res.add(rt);
                                }
                                break;
                            }
                        }
                        if (dcr.getKind() == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED && toks.size() == 1) {
                            if (tok.changeVal.getValue() != null && tok.changeVal.getValue().endsWith(" исключить")) {
                                dcr.setKind(com.pullenti.ner.decree.DecreeChangeKind.REMOVE);
                                tok.changeVal.setValue(tok.changeVal.getValue().substring(0, 0 + tok.changeVal.getValue().length() - 10));
                                tok.changeVal.setEndChar(tok.changeVal.getEndChar() - 10);
                            }
                        }
                    }
                    else if ((dcr.getValue().getKind() != com.pullenti.ner.decree.DecreeChangeValueKind.TEXT && tok.changeVal.getKind() == com.pullenti.ner.decree.DecreeChangeValueKind.TEXT && tok.changeVal.getValue() != null) && dcr.getValue().getValue() == null) 
                        dcr.getValue().setValue(tok.changeVal.getValue());
                    else if (kinds.size() == 1 && kinds.get(0) == com.pullenti.ner.decree.DecreeChangeKind.REMOVE) 
                        dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_VALUE, tok.changeVal, false, 0);
                    else if ((kinds.size() == 1 && kinds.get(0) == com.pullenti.ner.decree.DecreeChangeKind.APPEND && dcr.getParam() == null) && tok.actKind == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) {
                        dcr.setParam(dcr.getValue());
                        dcr.setValue(tok.changeVal);
                    }
                    else if (kinds.size() == 0 && dcr.getParam() == null) 
                        dcr.setParam(tok.changeVal);
                    else if (dcr.getValue() != null && i == (toks.size() - 1)) {
                        if (i > 1 && ((tok.isNewlineBefore() || tok.numBefore != null))) {
                            rt.setEndToken(toks.get(i - 1).getEndToken());
                            break;
                        }
                        else 
                            dcr.setKind(com.pullenti.ner.decree.DecreeChangeKind.ERROR);
                    }
                    else 
                        dcr.setValue(tok.changeVal);
                    if (tok.getEndChar() > rt.getEndChar()) 
                        rt.setEndToken(tok.getEndToken());
                    res.add(res.size() - 1, new com.pullenti.ner.ReferentToken(tok.changeVal, tok.getBeginToken(), tok.getEndToken(), null));
                    if (dcr.getKind() == com.pullenti.ner.decree.DecreeChangeKind.NEW) 
                        break;
                    if (dcr.getKind() == com.pullenti.ner.decree.DecreeChangeKind.CONSIDER) {
                        if ((i + 2) < toks.size()) {
                            if (toks.get(i + 2).actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED || toks.get(i + 1).actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                                break;
                            dcr = new com.pullenti.ner.decree.DecreeChangeReferent();
                            dcr.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_OWNER, dpr, false, 0);
                            rt = new com.pullenti.ner.ReferentToken(dcr, toks.get(i + 1).getBeginToken(), toks.get(i + 1).getEndToken(), null);
                            res.add(rt);
                            continue;
                        }
                        break;
                    }
                }
                if (dcr.getKind() == com.pullenti.ner.decree.DecreeChangeKind.APPEND && tok.newParts != null) {
                    for (PartToken np : tok.newParts) {
                        int rank = PartToken._getRank(np.typ);
                        if (rank == 0) 
                            continue;
                        String eqLevVal = null;
                        if (dpr instanceof com.pullenti.ner.decree.DecreePartReferent) {
                            if (!((com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(dpr, com.pullenti.ner.decree.DecreePartReferent.class)).isAllItemsOverThisLevel(np.typ)) {
                                eqLevVal = dpr.getStringValue(PartToken._getAttrNameByTyp(np.typ));
                                if (eqLevVal == null) 
                                    continue;
                            }
                        }
                        dcr.setKind(com.pullenti.ner.decree.DecreeChangeKind.APPEND);
                        if (newItems == null) 
                            newItems = new java.util.ArrayList<String>();
                        String nam = PartToken._getAttrNameByTyp(np.typ);
                        if (nam == null) 
                            continue;
                        if (np.values.size() == 0) {
                            if (eqLevVal == null) 
                                newItems.add(nam);
                            else {
                                int n;
                                com.pullenti.unisharp.Outargwrapper<Integer> wrapn1046 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                                boolean inoutres1047 = com.pullenti.unisharp.Utils.parseInteger(eqLevVal, 0, null, wrapn1046);
                                n = (wrapn1046.value != null ? wrapn1046.value : 0);
                                if (inoutres1047) 
                                    newItems.add((nam + " " + (n + 1)));
                                else 
                                    newItems.add(nam);
                            }
                        }
                        else if (np.values.size() == 2 && np.values.get(0).getEndToken().getNext().isHiphen()) {
                            java.util.ArrayList<String> vv = com.pullenti.ner.instrument.internal.NumberingHelper.createDiap(np.values.get(0).value, np.values.get(1).value);
                            if (vv != null) {
                                for (String v : vv) {
                                    newItems.add((nam + " " + v));
                                }
                            }
                        }
                        if (newItems.size() == 0) {
                            for (PartToken.PartValue v : np.values) {
                                newItems.add((nam + " " + v.value + "///" + v.getSourceValue()));
                            }
                        }
                    }
                }
            }
            if (dcr.getParam() != null && dcr.getValue() != null && dcr.getKind() == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                dcr.setKind(com.pullenti.ner.decree.DecreeChangeKind.ERROR);
            if (!dcr.checkCorrect()) 
                return null;
            if (newItems != null && dcr.getValue() != null && dcr.getKind() == com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                for (String v : newItems) {
                    String vvv = v;
                    String src = null;
                    int ii = vvv.indexOf("///");
                    if (ii > 0) {
                        vvv = vvv.substring(0, 0 + ii);
                        src = v.substring(ii + 3);
                    }
                    dcr.getValue().addSlot(com.pullenti.ner.decree.DecreeChangeValueReferent.ATTR_NEWITEM, vvv, false, 0).setTag(src);
                }
            }
            newItems = null;
            if (rt.getEndToken().getNext() == null) 
                break;
            if (!rt.getEndToken().getNext().isCommaAnd()) 
                break;
            com.pullenti.ner.Token tt2 = rt.getEndToken().getNext().getNext();
            if (tt2 == null) 
                break;
            if (tt2.isValue("А", null)) 
                tt2 = tt2.getNext();
            toks = tryAttachList(tt2, false, false);
            if (toks == null) 
                break;
            com.pullenti.ner.decree.DecreeChangeReferent dts1 = new com.pullenti.ner.decree.DecreeChangeReferent();
            for (com.pullenti.ner.Referent o : dcr.getOwners()) {
                dts1.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_OWNER, o, false, 0);
            }
            rt = new com.pullenti.ner.ReferentToken(dts1, toks.get(0).getBeginToken(), toks.get(0).getEndToken(), null);
            res.add(rt);
            dcr = dts1;
        }
        return res;
    }

    public static java.util.ArrayList<com.pullenti.ner.ReferentToken> splitValue(com.pullenti.ner.ReferentToken rtVal, com.pullenti.ner.Referent own) {
        java.util.ArrayList<com.pullenti.ner.ReferentToken> res = new java.util.ArrayList<com.pullenti.ner.ReferentToken>();
        for (com.pullenti.ner.Token t = rtVal.getBeginToken(); t != null && (t.getEndChar() < rtVal.getEndChar()); t = t.getNext()) {
            if (rtVal.getBeginToken() == t && com.pullenti.ner.core.BracketHelper.isBracket(t, true)) 
                t = t.getNext();
            com.pullenti.ner.instrument.internal.InstrToken1 line = com.pullenti.ner.instrument.internal.InstrToken1.parse(t, true, null, 0, null, false, 0, false, false);
            if (line == null) 
                break;
            com.pullenti.ner.Token t1 = line.getEndToken();
            if ((t1.getEndChar() + 1) >= rtVal.getEndChar()) {
                line.setEndToken(rtVal.getEndToken());
                for (; t1 != null; t1 = t1.getPrevious()) {
                    if (t1.isCharOf(".;")) {
                    }
                    else if (com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(t1, false, null, false)) {
                        t1 = t1.getPrevious();
                        break;
                    }
                    else 
                        break;
                }
            }
            com.pullenti.ner.decree.DecreeChangeValueReferent v = new com.pullenti.ner.decree.DecreeChangeValueReferent();
            v.setKind(com.pullenti.ner.decree.DecreeChangeValueKind.TEXT);
            v.setValue(com.pullenti.ner.core.MiscHelper.getTextValue(t, t1, com.pullenti.ner.core.GetTextAttr.of((com.pullenti.ner.core.GetTextAttr.KEEPQUOTES.value()) | (com.pullenti.ner.core.GetTextAttr.KEEPREGISTER.value()))));
            v.setBeginChar(((com.pullenti.ner.decree.DecreeChangeValueReferent)com.pullenti.unisharp.Utils.cast(rtVal.referent, com.pullenti.ner.decree.DecreeChangeValueReferent.class)).getBeginChar());
            v.setEndChar(((com.pullenti.ner.decree.DecreeChangeValueReferent)com.pullenti.unisharp.Utils.cast(rtVal.referent, com.pullenti.ner.decree.DecreeChangeValueReferent.class)).getEndChar());
            com.pullenti.ner.ReferentToken rr = new com.pullenti.ner.ReferentToken(v, t, line.getEndToken(), null);
            res.add(rr);
            t = line.getEndToken();
        }
        if (res.size() > 0) {
            com.pullenti.ner.ReferentToken rr = res.get(res.size() - 1);
            if (rr.getEndToken().isCharOf(";.,")) 
                rr.setEndToken(rr.getEndToken().getPrevious());
        }
        return res;
    }

    public static DecreeChangeToken _tryParseText(com.pullenti.ner.Token xx1, boolean abzacRegime, boolean wordRegime, PartToken defPart) {
        DecreeChangeToken res = _new1048(xx1, xx1, DecreeChangeTokenTyp.VALUE);
        res.changeVal = com.pullenti.ner.decree.DecreeChangeValueReferent._new1049(com.pullenti.ner.decree.DecreeChangeValueKind.TEXT);
        com.pullenti.ner.Token t0 = xx1;
        res.changeVal.setBeginChar(xx1.getBeginChar());
        if (com.pullenti.ner.core.BracketHelper.isBracket(xx1, true)) {
            res.changeVal.setBeginChar(xx1.getEndChar() + 1);
            t0 = xx1.getNext();
            if (xx1.isChar('<') && t0 != null && t0.isChar('<')) {
                res.changeVal.setBeginChar(t0.getEndChar() + 1);
                t0 = t0.getNext();
            }
        }
        else if (xx1.isTableControlChar() && com.pullenti.ner.core.BracketHelper.isBracket(xx1.getNext(), true) && xx1.getNext().getNext() != null) {
            res.changeVal.setBeginChar(xx1.getNext().getEndChar() + 1);
            t0 = xx1.getNext().getNext();
        }
        com.pullenti.ner.instrument.internal.InstrToken1 clauseLast = null;
        java.util.HashMap<PartToken.ItemType, String> pstack = new java.util.HashMap<PartToken.ItemType, String>();
        int nls = 0;
        java.util.HashMap<String, com.pullenti.ner.core.ComplexNumToken> lastNums = new java.util.HashMap<String, com.pullenti.ner.core.ComplexNumToken>();
        com.pullenti.ner.core.ComplexNumToken ln = com.pullenti.ner.core.ComplexNumToken.tryParse(xx1.getNext(), null, false, false);
        if (ln != null) 
            lastNums.put(ln.getSignature(), ln);
        for (com.pullenti.ner.Token tt = t0; tt != null; tt = tt.getNext()) {
            boolean stop = false;
            boolean isDoubt = false;
            int seqNum = -1;
            if (tt.tag instanceof com.pullenti.ner.NumberToken) {
                if (((com.pullenti.ner.NumberToken)com.pullenti.unisharp.Utils.cast(tt.tag, com.pullenti.ner.NumberToken.class)).getBeginChar() < res.getBeginChar()) 
                    stop = true;
            }
            if (!tt.isNewlineAfter() && !tt.getNext().isChar((char)0x1E)) {
                if (tt == t0) {
                    PartToken part0 = _tryParsePart(tt, false);
                    if (part0 != null && part0.values.size() == 1) {
                        pstack.put(part0.typ, part0.values.get(0).value);
                        tt = part0.getEndToken();
                        continue;
                    }
                }
                if (tt != null && tt.isChar((char)0x1E)) {
                    java.util.ArrayList<com.pullenti.ner.core.TableRowToken> rows = com.pullenti.ner.core.TableHelper.tryParseRows(tt, 0, true, false);
                    if (rows != null && rows.size() >= 1) {
                        for (com.pullenti.ner.Token tt33 = tt.getNext(); tt33 != null && tt33.getEndChar() <= rows.get(rows.size() - 1).getEndChar(); tt33 = tt33.getNext()) {
                            if (tt33.tag instanceof com.pullenti.ner.NumberToken) {
                                if (((com.pullenti.ner.NumberToken)com.pullenti.unisharp.Utils.cast(tt33.tag, com.pullenti.ner.NumberToken.class)).getBeginChar() < res.getBeginChar()) {
                                    stop = true;
                                    tt = tt33;
                                    break;
                                }
                            }
                        }
                        if (!stop) {
                            tt = rows.get(rows.size() - 1).getEndToken().getPrevious();
                            continue;
                        }
                    }
                }
                if (tt.isCharOf(";.") || ((tt.isValue("ИСКЛЮЧИТЬ", null) && wordRegime))) {
                    if (_checkEndBracket(tt.getPrevious())) {
                        if (!tt.isNewlineAfter() && tt.getNext() != null && tt.getNext().isChar('<')) 
                            continue;
                        isDoubt = true;
                        if (((tt.getNext() instanceof com.pullenti.ner.TextToken) && tt.getNext().getLengthChar() == 1 && tt.getNext().getNext() != null) && tt.getNext().getNext().isChar(')')) 
                            stop = true;
                        else if ((tt.getNext() instanceof com.pullenti.ner.NumberToken) && tt.getNext().getNext() != null && tt.getNext().getNext().isCharOf(").")) 
                            stop = true;
                        else {
                            PartToken part0 = _tryParsePart(tt.getNext(), false);
                            if (part0 != null && part0.values.size() == 1) {
                                if (part0.isNewlineAfter() && part0.getMorph().getCase().isNominative() && !tt.getNext().chars.isAllLower()) 
                                    stop = true;
                                else {
                                    com.pullenti.ner.core.TerminToken tok1 = M_TERMS.tryParse(part0.getEndToken().getNext(), com.pullenti.ner.core.TerminParseAttr.NO);
                                    if (tok1 != null) 
                                        stop = true;
                                }
                            }
                        }
                        if (tt.isValue("ИСКЛЮЧИТЬ", null)) {
                            tt = tt.getPrevious();
                            stop = true;
                        }
                        if (!stop) {
                            if (_canBeChangeToken(tt.getNext(), 0, false, false)) 
                                stop = true;
                        }
                        if (!stop) 
                            continue;
                    }
                    else if (_canBeChangeToken(tt.getNext(), 0, true, false)) 
                        stop = true;
                    else 
                        continue;
                }
                else if ((tt.isCommaAnd() && com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(tt.getPrevious(), true, null, false) && !xx1.isNewlineBefore()) && nls == 0) {
                    DecreeChangeToken nn = tryAttach(tt.getNext(), null, true, null, false, false, null, false);
                    if (nn != null || M_TERMS.tryParse(tt.getNext(), com.pullenti.ner.core.TerminParseAttr.NO) != null) {
                        stop = true;
                        tt = tt.getPrevious();
                    }
                    else if (tt.getNext() != null) {
                        boolean ok = false;
                        if (tt.getNext().isValue("ПОСЛЕДНИЙ", null) || tt.getNext().isValue("ПРЕДПОСЛЕДНИЙ", null) || (((tt.getNext() instanceof com.pullenti.ner.NumberToken) && tt.getNext().getMorph()._getClass().isAdjective()))) 
                            ok = true;
                        if (ok) {
                            stop = true;
                            tt = tt.getPrevious();
                        }
                    }
                }
                else if (com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(tt, true, null, false)) {
                    if (tt.isWhitespaceAfter()) {{
                                if (_canBeChangeToken(tt.getNext(), 0, false, true)) 
                                    stop = true;
                                else 
                                    continue;
                            }
                    }
                    else if (tt.getNext().isCharOf(";.") && ((tt.getPrevious().isTableControlChar() || _canBeChangeToken(tt.getNext(), 0, false, false)))) 
                        stop = true;
                    else 
                        continue;
                }
                else if (tt.isComma() && tt.isNewlineAfter() && _canBeChangeToken(tt.getNext(), 0, true, false)) 
                    stop = true;
                else {
                    if (tt == t0) {
                        com.pullenti.ner.core.ComplexNumToken nnn = com.pullenti.ner.core.ComplexNumToken.tryParse(tt, null, false, false);
                        if (nnn != null && !lastNums.containsKey(nnn.getSignature())) 
                            lastNums.put(nnn.getSignature(), nnn);
                    }
                    continue;
                }
            }
            else {
                if (tt.getNext() != null && tt.getNext().isValue2("АДМИНИСТРАТИВНАЯ", "ПРОЦЕДУРА")) {
                }
                if (tt.getNext() instanceof com.pullenti.ner.ReferentToken) {
                }
                if (tt.getNext() != null && tt.getNext().isChar((char)0x1E)) {
                    java.util.ArrayList<com.pullenti.ner.core.TableRowToken> rows = com.pullenti.ner.core.TableHelper.tryParseRows(tt.getNext(), 0, true, false);
                    if (rows != null && rows.size() > 1) {
                        for (com.pullenti.ner.Token tt33 = tt.getNext(); tt33 != null && tt33.getEndChar() <= rows.get(rows.size() - 1).getEndChar(); tt33 = tt33.getNext()) {
                            if (tt33.tag instanceof com.pullenti.ner.NumberToken) {
                                if (((com.pullenti.ner.NumberToken)com.pullenti.unisharp.Utils.cast(tt33.tag, com.pullenti.ner.NumberToken.class)).getBeginChar() < res.getBeginChar()) {
                                    stop = true;
                                    tt = tt33.getPrevious();
                                    break;
                                }
                            }
                        }
                        if (!stop) {
                            tt = rows.get(rows.size() - 1).getEndToken().getPrevious();
                            continue;
                        }
                    }
                    com.pullenti.ner.Token tt2 = tt.getNext();
                    for (; tt2 != null; tt2 = tt2.getNext()) {
                        if (!tt2.isTableControlChar()) 
                            break;
                    }
                    if (tt2 != null) {
                        if (tt2.getReferent() != null && com.pullenti.unisharp.Utils.stringsEq(tt2.getReferent().getTypeName(), "PERSON")) {
                            if (tt2.isNewlineAfter() || tt2.getNext().isTableControlChar()) 
                                stop = true;
                        }
                    }
                }
                if (tt.getNext() != null && tt.getNext().isTableControlChar() && !stop) 
                    continue;
                boolean strict = true;
                if (_checkEndBracket(tt)) 
                    strict = false;
                else if (tt.isCharOf(";.") && _checkEndBracket(tt.getPrevious())) 
                    strict = false;
                if (_canBeChangeToken(tt.getNext(), 0, strict, true)) 
                    stop = true;
                nls++;
                com.pullenti.ner.core.ComplexNumToken nnn = com.pullenti.ner.core.ComplexNumToken.tryParse(tt.getNext(), null, true, false);
                if (nnn == null && com.pullenti.ner.core.BracketHelper.isBracket(tt.getNext(), false) && (tt.getNext().getNext() instanceof com.pullenti.ner.NumberToken)) 
                    nnn = com.pullenti.ner.core.ComplexNumToken.tryParse(tt.getNext().getNext(), null, true, false);
                if ((nnn != null && nnn.getBeginToken() == nnn.getEndToken() && nnn.nums.get(0).vals.get(0).typ == com.pullenti.ner.core.SingleNumValueType.LETTER) && nnn.getSuffix() == null) 
                    nnn = null;
                if (nnn != null) {
                    if (com.pullenti.unisharp.Utils.stringsEq(nnn.getSourceText(), "27<5>.")) {
                    }
                    seqNum = 0;
                    com.pullenti.ner.core.ComplexNumToken nnn0;
                    com.pullenti.unisharp.Outargwrapper<com.pullenti.ner.core.ComplexNumToken> wrapnnn01050 = new com.pullenti.unisharp.Outargwrapper<com.pullenti.ner.core.ComplexNumToken>();
                    boolean inoutres1051 = com.pullenti.unisharp.Utils.tryGetValue(lastNums, nnn.getSignature(), wrapnnn01050);
                    nnn0 = wrapnnn01050.value;
                    if (inoutres1051) {
                        com.pullenti.ner.core.ComplexNumComparer cmp = new com.pullenti.ner.core.ComplexNumComparer();
                        cmp.process(nnn0, nnn);
                        if (cmp.typ == com.pullenti.ner.core.ComplexNumCompareType.LESS && ((cmp.delta == 1 || cmp.delta == 2))) 
                            seqNum = 1;
                        lastNums.put(nnn.getSignature(), nnn);
                        if (seqNum == 1) {
                            if (_canBeChangeToken(nnn.getBeginToken(), 0, true, false)) 
                                stop = true;
                            else {
                                DecreeChangeToken tok2 = tryAttach(tt.getNext(), null, false, null, false, false, null, false);
                                if (tok2 == null) 
                                    continue;
                            }
                        }
                    }
                    else 
                        lastNums.put(nnn.getSignature(), nnn);
                    if (tt.isCharOf(".;") && tt.getNext() != null && seqNum != 1) {
                        DecreeChangeToken next1 = tryAttach(tt.getNext(), null, false, null, false, false, null, false);
                        if (next1 != null) {
                            if (next1.actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                                stop = true;
                            else if (next1.typ != DecreeChangeTokenTyp.UNDEFINED && next1.parts != null && seqNum != 1) 
                                stop = true;
                            else if (next1.decree != null && next1.getEndToken().isChar(':')) 
                                stop = true;
                            else {
                                DecreeChangeToken next2 = tryAttach(next1.getEndToken().getNext(), null, false, null, false, false, null, false);
                                if (next2 != null && next2.actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                                    stop = true;
                            }
                        }
                        else if (seqNum != 1) {
                            com.pullenti.ner.Token tt2 = nnn.getEndToken().getNext();
                            if (tt2 != null && tt2.isValue("В", null) && DecreeToken.isKeyword(tt2.getNext(), false) != null) 
                                stop = true;
                        }
                    }
                    else if ((tt.isComma() && tt.getNext() != null && seqNum != 1) && com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(tt.getPrevious(), true, null, false)) {
                        DecreeChangeToken next1 = tryAttach(tt.getNext(), null, false, null, false, false, null, false);
                        if (next1 != null) {
                            if (next1.actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                                stop = true;
                            else if (next1.typ != DecreeChangeTokenTyp.UNDEFINED && next1.parts != null && seqNum != 1) 
                                stop = true;
                            else if (next1.decree != null && next1.getEndToken().isChar(':')) 
                                stop = true;
                        }
                    }
                    if (tt.isComma() && _canBeChangeToken(tt.getNext(), 0, true, false)) 
                        stop = true;
                }
                if (tt.getNext() == null) {
                }
                else {
                    com.pullenti.ner.Referent r = tt.getNext().getReferent();
                    if (r != null && tt.getNext().isNewlineAfter()) {
                        if (com.pullenti.unisharp.Utils.stringsEq(r.getTypeName(), "PERSON")) 
                            stop = true;
                    }
                }
            }
            if (stop) {
            }
            PartToken part = _tryParsePart(tt.getNext(), false);
            if ((part != null && part.values.size() == 1 && tt.isNewlineAfter()) && part.getMorph().getCase().isNominative() && !tt.getNext().chars.isAllLower()) {
                if (defPart != null && com.pullenti.unisharp.Utils.stringsEq(defPart.toString(), part.toString())) {
                    tt = part.getEndToken();
                    continue;
                }
                if (defPart != null && defPart.values.size() == 2 && (defPart.values.get(0).getIntValue() < defPart.values.get(1).getIntValue())) {
                    if (part.values.get(0).getIntValue() >= defPart.values.get(0).getIntValue() && part.values.get(0).getIntValue() <= defPart.values.get(1).getIntValue()) {
                        tt = part.getEndToken();
                        continue;
                    }
                }
                if (tt != tt.getNext() && pstack.size() == 0) 
                    stop = true;
                else if (!pstack.containsKey(part.typ)) 
                    pstack.put(part.typ, part.values.get(0).value);
                else {
                    int n0;
                    int n1;
                    pstack.put(part.typ, part.values.get(0).value);
                }
            }
            com.pullenti.ner.instrument.internal.InstrToken1 instr = com.pullenti.ner.instrument.internal.InstrToken1.parse(tt.getNext(), true, null, 0, null, false, 0, false, false);
            if (instr != null && instr.typ == com.pullenti.ner.instrument.internal.InstrToken1.Types.APPENDIX) {
            }
            if (tt.getNext() == null) {
                if (pstack.size() > 0) 
                    stop = true;
                else if (_checkEndBracket(tt) || tt.isCharOf(";.")) 
                    stop = true;
            }
            else if (instr != null && instr.numbers.size() > 0 && !stop) {
                if (isDoubt) 
                    stop = true;
                else if (abzacRegime && !com.pullenti.ner.core.BracketHelper.isBracket(xx1, true)) 
                    stop = true;
                else if (!tt.isCharOf(":")) {
                    DecreeChangeToken nn = tryAttach(tt.getNext(), null, false, null, false, false, null, false);
                    if (nn != null && nn.parts != null) {
                        if (nn.getEndToken().isNewlineAfter() || nn.actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                            stop = true;
                        else {
                            DecreeChangeToken nnn = tryAttach(nn.getEndToken().getNext(), null, false, null, false, false, null, false);
                            if (nnn != null) {
                                if (nnn.changeVal != null || nnn.actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                                    stop = true;
                            }
                        }
                    }
                }
            }
            boolean hasNext = false;
            if (tt.getNext() == null) {
            }
            else if (tt.getNext().isValue("ПОСЛЕ", null)) {
            }
            else {
                isDoubt = true;
                PartToken pt = _tryParsePart(tt.getNext(), false);
                if (pt != null && pt.typ == PartToken.ItemType.CLAUSE && ((pt.isNewlineAfter() || ((pt.getEndToken().getNext() != null && pt.getEndToken().getNext().isChar('.')))))) {
                    isDoubt = false;
                    if (clauseLast != null && instr != null && com.pullenti.ner.instrument.internal.NumberingHelper.calcDelta(clauseLast, instr, true) == 1) 
                        isDoubt = true;
                }
            }
            if (instr != null && instr.typ == com.pullenti.ner.instrument.internal.InstrToken1.Types.CLAUSE) 
                clauseLast = instr;
            if (isDoubt && instr != null && !stop) {
                for (com.pullenti.ner.Token ttt = tt; ttt != null && ttt.getEndChar() <= instr.getEndChar(); ttt = ttt.getNext()) {
                    if (ttt.isValue("УТРАТИТЬ", "ВТРАТИТИ") && ttt.getNext() != null && ttt.getNext().isValue("СИЛА", "ЧИННІСТЬ")) {
                        isDoubt = false;
                        break;
                    }
                }
                if ((instr.numEndToken != null && instr.numEndToken.getNext() != null && instr.numEndToken.getNext().isValue("В", null)) && instr.getEndToken().isChar(':')) {
                    if (_canBeChangeToken(instr.getBeginToken(), 0, false, false)) 
                        isDoubt = false;
                    else 
                        continue;
                }
            }
            if (com.pullenti.ner.core.BracketHelper.isBracket(tt.getNext(), true)) {
                if (tt.getNext().isNewlineAfter()) {
                    tt = tt.getNext();
                    stop = true;
                }
                else if (tt.getNext().getNext() != null && tt.getNext().getNext().isCharOf(":.;") && tt.getNext().getNext().isNewlineAfter()) {
                    tt = tt.getNext().getNext();
                    stop = true;
                }
            }
            res.setEndToken(tt);
            com.pullenti.ner.Token tt1 = tt;
            int hcou = 0;
            com.pullenti.ner.Token tt3;
            for (tt3 = tt.getNext(); tt3 != null; tt3 = tt3.getNext()) {
                if (tt3.isHiphen() || tt3.isChar('_')) 
                    hcou++;
                else 
                    break;
            }
            if (hcou > 4) {
                if (tt3 == null) 
                    stop = true;
                else if (DecreeToken.isKeyword(tt3, false) != null) 
                    stop = true;
                else if (tt3.getReferent() != null && ((com.pullenti.unisharp.Utils.stringsEq(tt3.getReferent().getTypeName(), "PERSON") || com.pullenti.unisharp.Utils.stringsEq(tt3.getReferent().getTypeName(), "PERSONPROPERTY")))) 
                    stop = true;
            }
            if (tt1.getNext() != null && tt1.getNext().isValue("СТАТЬЯ", null) && !tt1.getNext().chars.isAllLower()) {
                PartToken pt = _tryParsePart(tt1.getNext(), false);
                if (pt != null && pt.isNewlineAfter()) {
                    DecreeChangeToken chr = DecreeChangeToken.tryAttach(pt.getEndToken().getNext(), null, false, null, false, false, null, false);
                    if (chr != null && ((chr.typ == DecreeChangeTokenTyp.STARTMULTU || chr.typ == DecreeChangeTokenTyp.STARTSINGLE))) 
                        stop = true;
                }
            }
            com.pullenti.ner.core.TerminToken tok = M_TERMS.tryParse(tt1.getNext(), com.pullenti.ner.core.TerminParseAttr.NO);
            if (tok != null) {
                if (tok.getEndToken() == tt1.getNext() && tt1.getNext().getMorph().containsAttr("к.ф.", null)) {
                }
                else if ((tok.termin.tag instanceof com.pullenti.ner.decree.DecreeChangeKind) && !tt1.getNext().getMorphClassInDictionary().isAdjective()) 
                    stop = true;
            }
            else {
            }
            if (tt1.getNext() != null) {
                if (tt1.getNext().getReferent() != null && ((com.pullenti.unisharp.Utils.stringsEq(tt1.getNext().getReferent().getTypeName(), "PERSON") || com.pullenti.unisharp.Utils.stringsEq(tt1.getNext().getReferent().getTypeName(), "PERSONPROPERTY")))) {
                    if (((com.pullenti.ner.ReferentToken)com.pullenti.unisharp.Utils.cast(tt1.getNext(), com.pullenti.ner.ReferentToken.class)).getBeginToken().chars.isAllLower()) {
                    }
                    else if (tt1.getNext().getLengthChar() < 10) {
                    }
                    else 
                        stop = true;
                }
            }
            if (tt1.isCharOf(";.") && tt1.isNewlineAfter() && seqNum == 0) {
                if (_checkEndBracket(tt1.getPrevious())) 
                    stop = true;
            }
            if (stop) {
                boolean brClose = false;
                for (com.pullenti.ner.Token ttt = tt1; ttt != null; ttt = ttt.getPrevious()) {
                    if (!ttt.isTableControlChar()) {
                        if (ttt.isCharOf(";.") && com.pullenti.ner.core.BracketHelper.isBracket(ttt.getPrevious(), true)) 
                            tt1 = ttt;
                        break;
                    }
                }
                if (tt1.isCharOf(";.") && com.pullenti.ner.core.BracketHelper.isBracket(tt1.getPrevious(), true)) {
                    if (_findPrevBracket(tt1.getPrevious(), t0.getNext()) != null) {
                    }
                    else {
                        res.setEndToken(tt1.getPrevious());
                        tt1 = tt1.getPrevious().getPrevious();
                        brClose = true;
                        if (tt1.isChar('>') && tt1.getNext().isChar('>')) 
                            tt1 = tt1.getPrevious();
                    }
                }
                else if (tt1.isCharOf(";")) {
                    if (tt1.getPrevious().isChar('.')) 
                        res.setEndToken((tt1 = tt1.getPrevious()));
                }
                if (!brClose && com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(tt1, true, null, false)) {
                    if (_findPrevBracket(tt1, t0.getNext()) != null) {
                        if (tt1.getNext() != null && tt1.getNext().isChar('.') && !tt1.isNewlineAfter()) {
                            if (tt1.getNext().getNext() != null && tt1.getNext().getNext().isChar(';')) 
                                tt1 = tt1.getNext();
                        }
                    }
                    else {
                        tt1 = tt1.getPrevious();
                        brClose = true;
                        if (tt1.isChar('>') && tt1.getNext().isChar('>')) 
                            tt1 = tt1.getPrevious();
                    }
                }
                if (tt1 == null || t0.getBeginChar() > tt1.getBeginChar()) 
                    return null;
                res.changeVal.setValue((new com.pullenti.ner.MetaToken(t0, tt1, null)).getSourceText());
                if (tt1.getNext() == null) 
                    res.changeVal.setEndChar(tt1.getEndChar());
                else 
                    res.changeVal.setEndChar(tt1.getNext().getBeginChar() - 1);
                return res;
            }
            if (tt.isChar(')')) {
                for (com.pullenti.ner.Token tt2 = tt.getPrevious(); tt2 != null; tt2 = tt2.getPrevious()) {
                    if (tt2.isChar('(') && tt2.getPrevious() != null && tt2.getPrevious().getEndChar() > res.getBeginChar()) {
                        tt1 = tt2.getPrevious();
                        break;
                    }
                    else if (tt2.isNewlineAfter()) 
                        break;
                }
            }
            boolean closePoint = false;
            if (tt1.isCharOf(";.")) {
                closePoint = true;
                tt1 = res.setEndToken(tt1.getPrevious());
            }
            if (tt1.isCharOf(";.")) {
                closePoint = true;
                tt1 = res.setEndToken(tt1.getPrevious());
            }
            boolean closeBr = false;
            if (com.pullenti.ner.core.BracketHelper.isBracket(tt1, true) && !tt1.isCharOf("]>") && _findPrevBracket(tt1, t0.getNext()) == null) {
                closeBr = true;
                tt1 = tt1.getPrevious();
            }
            else if (_checkEndBracket(tt1)) {
            }
            else if (tt1.getNext() == null) {
            }
            else if (hasNext && tt1.isTableControlChar()) {
            }
            else 
                continue;
            if (isDoubt) {
                if (tt.isCharOf("<>[]")) 
                    continue;
                if (!closePoint || !closeBr) 
                    continue;
                if (!com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(t0.getPrevious(), true, false)) 
                    continue;
                java.util.ArrayList<com.pullenti.ner.Token> brs = new java.util.ArrayList<com.pullenti.ner.Token>();
                brs.add(t0.getPrevious());
                for (com.pullenti.ner.Token ttt = t0; ttt != null && ttt.getEndChar() <= tt1.getNext().getEndChar(); ttt = ttt.getNext()) {
                    if (!com.pullenti.ner.core.BracketHelper.isBracket(ttt, false)) 
                        continue;
                    if (brs.size() > 0 && com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(ttt, false, brs.get(0), false)) 
                        brs.remove(0);
                    else 
                        brs.add(0, ttt);
                }
                if (brs.size() > 0) {
                    if ((instr != null && instr.typ == com.pullenti.ner.instrument.internal.InstrToken1.Types.APPENDIX && closeBr) && closePoint) {
                    }
                    else 
                        continue;
                }
            }
            if (tt1.getBeginChar() > xx1.getEndChar()) {
                for (; tt1.getNext() != null; tt1 = tt1.getNext()) {
                    if (!tt1.getNext().isTableControlChar()) 
                        break;
                }
                res.changeVal.setValue((new com.pullenti.ner.MetaToken(t0, tt1, null)).getSourceText());
                if (tt1.getNext() == null) 
                    res.changeVal.setEndChar(tt1.getEndChar());
                else 
                    res.changeVal.setEndChar(tt1.getNext().getBeginChar() - 1);
                if (res.getEndChar() < tt1.getEndChar()) 
                    res.setEndToken(tt1);
                if (tt1.getNext() != null && com.pullenti.ner.core.BracketHelper.isBracket(tt1.getNext(), true)) {
                    if (tt1.getNext().getNext() != null && tt1.getNext().getNext().isCharOf(";.")) 
                        res.setEndToken(tt1.getNext().getNext());
                    else if (tt1.getNext().isNewlineAfter()) 
                        res.setEndToken(tt1.getNext());
                }
                return res;
            }
            break;
        }
        return null;
    }

    public static boolean _checkEndBracket(com.pullenti.ner.Token t) {
        if (com.pullenti.ner.core.BracketHelper.isBracket(t, true)) {
            if (t.isChar('>') && t.getPrevious() != null && t.getPrevious().isChar('>')) 
                return true;
            return !t.isCharOf(">]");
        }
        if (t instanceof com.pullenti.ner.MetaToken) {
            if (com.pullenti.ner.core.BracketHelper.isBracket(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(t, com.pullenti.ner.MetaToken.class)).getEndToken(), true)) 
                return !((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(t, com.pullenti.ner.MetaToken.class)).getEndToken().isCharOf(">]");
            if (((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(t, com.pullenti.ner.MetaToken.class)).getEndToken() instanceof com.pullenti.ner.MetaToken) {
                if (com.pullenti.ner.core.BracketHelper.isBracket(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(t, com.pullenti.ner.MetaToken.class)).getEndToken(), com.pullenti.ner.MetaToken.class)).getEndToken(), true)) 
                    return !((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(t, com.pullenti.ner.MetaToken.class)).getEndToken(), com.pullenti.ner.MetaToken.class)).getEndToken().isCharOf(">]");
            }
        }
        return false;
    }

    public static com.pullenti.ner.Token _findPrevBracket(com.pullenti.ner.Token t, com.pullenti.ner.Token minT) {
        if (t == null || !t.isCharOf("»\"") || t.getPrevious() == null) 
            return null;
        if (t.isChar('"') && t.getPrevious().isCharOf(";.\"")) 
            return null;
        int cou = 30;
        for (com.pullenti.ner.Token tt = t.getPrevious(); tt != null && cou > 0 && ((minT == null || tt.getBeginChar() > minT.getEndChar())); tt = tt.getPrevious(),cou--) {
            if (tt.isTableControlChar()) 
                break;
            if (tt.isChar('»')) 
                break;
            if (tt.isChar('«')) 
                return tt;
            if (tt.isChar('"') && t.isChar('"')) {
                if (tt.getNext().isCharOf(".;,-") || tt.isWhitespaceAfter()) 
                    return null;
                return tt;
            }
        }
        return null;
    }

    public static PartToken _tryParsePart(com.pullenti.ner.Token t, boolean onlyTyp) {
        if (t == null) 
            return null;
        if (t.isValue("УКАЗАННЫЙ", null)) 
            t = t.getNext();
        PartToken pt = PartToken.tryAttach(t, null, false, false);
        if (pt != null && pt.typ == PartToken.ItemType.PREFIX) 
            return null;
        if (pt == null && onlyTyp) 
            pt = PartToken.tryAttach(t, null, false, true);
        if ((pt != null && pt.typ == PartToken.ItemType.TABLECOLUMN && pt.getBeginToken() == pt.getEndToken()) && !onlyTyp) {
            PartToken pt1 = _tryParseSpecialPart0(t, onlyTyp);
            if (pt1 != null) 
                return pt1;
        }
        if (pt == null) 
            pt = _tryParseSpecialPart0(t, onlyTyp);
        return pt;
    }

    public static java.util.ArrayList<PartToken> _tryParsePartList(com.pullenti.ner.Token t) {
        if (t == null) 
            return null;
        com.pullenti.ner.Token t0 = t;
        if (t.isValue("УКАЗАННЫЙ", null)) 
            t = t.getNext();
        java.util.ArrayList<PartToken> res = PartToken.tryAttachList(t, false, 40);
        if ((res != null && res.size() == 1 && res.get(0).typ == PartToken.ItemType.TABLECOLUMN) && res.get(0).getBeginToken() == res.get(0).getEndToken()) {
            PartToken pt0 = _tryParseSpecialPart0(res.get(res.size() - 1).getEndToken().getNext(), false);
            if (pt0 != null) 
                res = null;
        }
        if (res != null) {
            com.pullenti.ner.Token tt2 = res.get(res.size() - 1).getEndToken().getNext();
            if (tt2 != null && tt2.isChar('.')) 
                tt2 = tt2.getNext();
            PartToken pt0 = _tryParseSpecialPart0(tt2, false);
            if (pt0 != null) {
                res.add(pt0);
                java.util.ArrayList<PartToken> res1 = PartToken.tryAttachList(pt0.getEndToken().getNext(), false, 40);
                if (res1 != null) {
                    if (pt0.typ == PartToken.ItemType.PREFIX) 
                        res.remove(res.size() - 1);
                    com.pullenti.unisharp.Utils.addToArrayList(res, res1);
                }
            }
            if (res.size() >= 1 && res.get(res.size() - 1).typ == PartToken.ItemType.SENTENCE && res.get(res.size() - 1).values.size() == 0) {
                if (res.size() == 1) 
                    return null;
                res.remove(res.size() - 1);
            }
            return res;
        }
        PartToken pt = _tryParsePart(t, false);
        if (pt == null && t0 != t && (t0 instanceof com.pullenti.ner.TextToken)) {
            pt = PartToken.tryAttach(t, null, false, true);
            if (pt != null) 
                pt.setBeginToken(t);
        }
        else if ((pt != null && !t.chars.isAllLower() && ((pt.isNewlineBefore() || ((pt.getBeginToken().getPrevious() != null && pt.getBeginToken().getPrevious().isTableControlChar()))))) && pt.getEndToken().getNext() != null && pt.getEndToken().getNext().isChar('.')) 
            return null;
        if (pt == null) 
            return res;
        res = new java.util.ArrayList<PartToken>();
        res.add(pt);
        if (pt.getWhitespacesAfterCount() < 3) {
            java.util.ArrayList<PartToken> res1 = PartToken.tryAttachList(pt.getEndToken().getNext(), false, 40);
            if (res1 != null && !res1.get(0).getMorph().getCase().isInstrumental()) 
                com.pullenti.unisharp.Utils.addToArrayList(res, res1);
        }
        return res;
    }

    public static PartToken _tryParseSpecialPart0(com.pullenti.ner.Token t, boolean onlyTyp) {
        if (t == null) 
            return null;
        if (t.isValue("СЛЕДУЮЩИЙ", null) || t.isValue("НОВЫЙ", null) || t.isValue("К", null)) {
            if (t.getNext() != null) 
                t = t.getNext();
        }
        com.pullenti.ner.Token t0 = t;
        if (t.isValue2("ГРИФ", "УТВЕРЖДЕНИЯ")) {
            PartToken res = PartToken._new1052(t0, t.getNext(), PartToken.ItemType.FREETEXT, t);
            res.values.add(PartToken.PartValue._new1053(t0, t.getNext(), "гриф утверждения"));
            return res;
        }
        if (t.isValue2("ПОДСТРОЧНЫЙ", "ТЕКСТ")) {
            PartToken res = PartToken._new1052(t0, t.getNext(), PartToken.ItemType.FREETEXT, t);
            res.values.add(PartToken.PartValue._new1053(t0, t.getNext(), "подстрочный текст"));
            return res;
        }
        if (t.isValue2("НУМЕРАЦИОННЫЙ", "ЗАГОЛОВОК")) {
            PartToken res = PartToken._new1056(t0, t.getNext(), PartToken.ItemType.FREETEXT, t.getNext().getMorph(), t);
            res.values.add(PartToken.PartValue._new1053(t0, t.getNext(), "нумерационный заголовок"));
            return res;
        }
        if (t.isValue2("ТИПОВОЙ", "ДОГОВОР") || t.isValue3("УСЛОВИЕ", "ТИПОВОЙ", "ДОГОВОР")) {
            for (com.pullenti.ner.Token tt = t.getNext().getNext(); tt != null; tt = tt.getNext()) {
                if (com.pullenti.ner.core.MiscHelper.canBeStartOfSentence(tt) || tt.isNewlineBefore() || tt.isChar(';')) 
                    break;
                if (tt.isValue("УТВЕРЖДЕННЫЙ", null)) {
                    com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt.getNext(), com.pullenti.ner.core.NounPhraseParseAttr.NO, 0, null);
                    if (npt != null && npt.getMorph().getCase().isInstrumental()) {
                        PartToken pp = PartToken.tryAttach(tt.getNext(), null, false, false);
                        if (pp != null && pp.typ == PartToken.ItemType.APPENDIX && pp.values.size() > 0) 
                            return PartToken._new1058(t0, tt, PartToken.ItemType.PREFIX);
                        tt = npt.getEndToken();
                        if (tt.getNext() != null && tt.getNext().isValue("К", null)) {
                            npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt.getNext().getNext(), com.pullenti.ner.core.NounPhraseParseAttr.NO, 0, null);
                            if (npt != null) 
                                tt = npt.getEndToken();
                        }
                        if (tt.getNext() != null && tt.getNext().isComma()) 
                            tt = tt.getNext();
                        return PartToken._new1058(t0, tt, PartToken.ItemType.PREFIX);
                    }
                }
            }
            return null;
        }
        if (t.getNext() == null) 
            return null;
        PartToken.ItemType _typ = PartToken.ItemType.FREETEXT;
        if (t.isValue("ПОЗИЦИЯ", null)) {
            if ((t.getNext() != null && t.getNext().isComma() && t.getNext().getNext() != null) && ((t.getNext().getNext().isValue("КЛАССИФИЦИРУЕМЫЙ", null) || t.getNext().getNext().isValue("КАСАЮЩИЙСЯ", null)))) 
                t = t.getNext().getNext();
            else if (t.getNext() != null && t.getNext().isValue("ПАСПОРТ", null)) 
                t = t.getNext();
            else if (onlyTyp) 
                return PartToken._new1060(t, t, PartToken.ItemType.FREETEXT, t.getMorph());
            else 
                return null;
        }
        else if (t.isValue("ГРАФИК", null) && t.chars.isCapitalUpper()) 
            t = t.getNext();
        else if (t.isValue("ГРУППА", null)) 
            t = t.getNext();
        else if (t.isValue3("ПРИОРИТЕТЫ", "И", "ЦЕЛИ")) {
            t = t.getNext().getNext().getNext().getNext();
            _typ = PartToken.ItemType.CHAPTER;
        }
        else if (t.isValue("СТОЛБЕЦ", null)) {
            if ((t.getNext() != null && t.getNext().isComma() && t.getNext().getNext() != null) && ((t.getNext().getNext().isValue("КЛАССИФИЦИРУЕМЫЙ", null) || t.getNext().getNext().isValue("КАСАЮЩИЙСЯ", null)))) 
                t = t.getNext().getNext();
            else 
                return null;
        }
        else if (t.isValue2("УЧЕБНЫЙ", "ПРЕДМЕТ")) 
            t = t.getNext().getNext();
        else 
            return null;
        com.pullenti.ner.Token t1 = t.getPrevious();
        int cr = 0;
        boolean ok = false;
        com.pullenti.ner.Token t11 = t1;
        if (t11.kit.miscData.containsKey("specpart")) {
        }
        else {
            t11.kit.miscData.put("specpart", null);
            for (; t != null && (cr < 4); t = t.getNext()) {
                if (t.isNewlineBefore()) 
                    cr++;
                if (t.isChar(':') && t.isNewlineAfter()) {
                    ok = true;
                    break;
                }
                if (t.isValue("КОД", null)) {
                }
                else if (_canBeChangeToken(t, 0, true, false)) {
                    ok = true;
                    break;
                }
                if (t.isValue("В", null)) 
                    continue;
                com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(t, com.pullenti.ner.core.BracketParseAttr.NO, 100);
                if (br != null) {
                    t1 = (t = br.getEndToken());
                    continue;
                }
                if ((t instanceof com.pullenti.ner.TextToken) && t.getLengthChar() == 1) 
                    continue;
                t1 = t;
            }
            t11.kit.miscData.remove("specpart");
        }
        if (ok) {
            if (t1 == t11 && !onlyTyp && !(t1 instanceof com.pullenti.ner.ReferentToken)) 
                return null;
            PartToken res = PartToken._new1060(t0, t1, _typ, t0.getMorph());
            res.values.add(PartToken.PartValue._new1053(t0, t1, com.pullenti.ner.core.MiscHelper.getTextValue(t0, t1, com.pullenti.ner.core.GetTextAttr.of((com.pullenti.ner.core.GetTextAttr.KEEPREGISTER.value()) | (com.pullenti.ner.core.GetTextAttr.KEEPQUOTES.value()) | (com.pullenti.ner.core.GetTextAttr.FIRSTNOUNGROUPTONOMINATIVE.value())))));
            return res;
        }
        return null;
    }

    public DecreeChangeToken(com.pullenti.ner.Token b, com.pullenti.ner.Token e) {
        super(b, e, null);
    }

    public DecreeChangeTokenTyp typ = DecreeChangeTokenTyp.UNDEFINED;

    public com.pullenti.ner.decree.DecreeReferent decree;

    public java.util.ArrayList<com.pullenti.ner.decree.DecreeReferent> addDecrees;

    public DecreeToken decreeTok;

    public java.util.ArrayList<PartToken> parts;

    public java.util.ArrayList<java.util.ArrayList<PartToken>> addParts;

    public java.util.ArrayList<PartToken> newParts;

    public PartToken appExtChanges;

    public com.pullenti.ner.decree.DecreePartReferent realPart;

    public java.util.ArrayList<com.pullenti.ner.decree.DecreePartReferent> addRealParts;

    public com.pullenti.ner.Token inPart;

    public com.pullenti.ner.decree.DecreeChangeValueReferent changeVal;

    public boolean hasText;

    public boolean ignorable;

    public boolean inTheEnd;

    public boolean hasAnafor;

    public boolean hasChangeKeyword;

    public com.pullenti.ner.decree.DecreeChangeKind actKind = com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED;

    public com.pullenti.ner.decree.DecreeChangeKind actKind2 = com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED;

    public PartToken.ItemType partTyp = PartToken.ItemType.UNDEFINED;

    public com.pullenti.ner.MetaToken alias;

    public com.pullenti.ner.core.ComplexNumToken numBefore;

    public boolean getIndentRegime() {
        if (newParts != null) {
            if (newParts.size() == 1 && PartToken._getRank(newParts.get(0).typ) >= PartToken._getRank(PartToken.ItemType.ITEM)) {
                if (newParts.get(0).values.size() > 1) 
                    return false;
                return true;
            }
            return false;
        }
        if (((actKind != com.pullenti.ner.decree.DecreeChangeKind.APPEND && parts != null && parts.size() > 0) && !parts.get(0).delimAfter && parts.get(0).values.size() <= 1) && PartToken._getRank(parts.get(0).typ) >= PartToken._getRank(PartToken.ItemType.ITEM)) 
            return true;
        return false;
    }


    @Override
    public String toString() {
        StringBuilder tmp = new StringBuilder();
        if (numBefore != null) 
            tmp.append(numBefore).append(" ");
        tmp.append(typ.toString());
        if (actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
            tmp.append(" Kind=").append(actKind.toString());
        if (actKind2 != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
            tmp.append(" Kind2=").append(actKind2.toString());
        if (hasText) 
            tmp.append(" HasText");
        if (ignorable) 
            tmp.append(" Ignorable");
        if (inTheEnd) 
            tmp.append(" InTheEnd");
        if (hasAnafor) 
            tmp.append(" HasAnafor");
        if (inPart != null) 
            tmp.append(" InPart");
        if (hasChangeKeyword) 
            tmp.append(" HasChangeKeyword");
        if (appExtChanges != null) 
            tmp.append(" ExtChanges=").append(appExtChanges);
        if (parts != null) {
            for (PartToken p : parts) {
                tmp.append(" ").append(p);
            }
        }
        if (realPart != null) 
            tmp.append(" RealPart=").append(realPart.toString());
        if (newParts != null) {
            for (PartToken p : newParts) {
                tmp.append(" New=").append(p);
            }
        }
        if (partTyp != PartToken.ItemType.UNDEFINED) 
            tmp.append(" PTyp=").append(partTyp.toString());
        if (decreeTok != null) 
            tmp.append(" DecTok=").append(decreeTok.toString());
        if (decree != null) 
            tmp.append(" Ref=").append(decree.toStringEx(true, null, 0));
        if (changeVal != null) 
            tmp.append(" ChangeVal=").append(changeVal.toStringEx(true, null, 0));
        if (getIndentRegime()) 
            tmp.append(" IndentRegime!");
        return tmp.toString();
    }

    public boolean isStart() {
        return typ == DecreeChangeTokenTyp.STARTSINGLE || typ == DecreeChangeTokenTyp.STARTMULTU || typ == DecreeChangeTokenTyp.SINGLE;
    }


    private void _skipDecreeDummy() {
        boolean ignoreDecree = false;
        int errs = 0;
        for (com.pullenti.ner.Token tt = getEndToken().getNext(); tt != null; tt = tt.getNext()) {
            if (tt.isCommaAnd()) 
                continue;
            if (parts != null) 
                break;
            if (tt.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) 
                continue;
            if (tt.isChar('(') && tt.getNext() != null) {
                com.pullenti.ner.decree.DecreeReferent dr = (com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(tt.getNext().getReferent(), com.pullenti.ner.decree.DecreeReferent.class);
                if (dr != null && dr.getKind() == com.pullenti.ner.decree.DecreeKind.PUBLISHER) 
                    setEndToken(tt.getPrevious());
                else {
                    com.pullenti.ner.decree.DecreePartReferent pp = (com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(tt.getNext().getReferent(), com.pullenti.ner.decree.DecreePartReferent.class);
                    if (pp != null && pp.getOwner() != null && pp.getOwner().getKind() == com.pullenti.ner.decree.DecreeKind.PUBLISHER) 
                        setEndToken(tt.getPrevious());
                }
            }
            break;
        }
        for (com.pullenti.ner.Token tt = getEndToken().getNext(); tt != null && (errs < 4); tt = tt.getNext()) {
            if (tt.isCommaAnd() || tt.isTableControlChar()) 
                continue;
            com.pullenti.ner.Token tt2 = com.pullenti.ner.core.MiscHelper.checkImage(tt);
            if (tt2 != null) {
                tt = tt2;
                continue;
            }
            if (tt.isValue2("С", "ИЗМЕНЕНИЕ")) {
                errs = 0;
                tt = tt.getNext().getNext();
                if (tt == null) 
                    break;
                if (tt.isComma()) 
                    tt = tt.getNext();
                if (tt != null && tt.isValue("ВНЕСЕННЫЙ", null)) {
                    tt = tt.getNext();
                    ignoreDecree = true;
                }
                if (tt == null) 
                    break;
                continue;
            }
            if (tt.isValue("СОГЛАСНО", null)) 
                break;
            if (com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt, true, false)) {
                com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(tt, com.pullenti.ner.core.BracketParseAttr.NO, 100);
                if (br != null && br.getEndToken().getNext() != null) {
                    com.pullenti.ner.MetaToken ali = com.pullenti.ner.decree.DecreeAnalyzer._checkAliasAfter(br.getEndToken().getNext());
                    if (ali != null) {
                        alias = ali;
                        setEndToken(ali.getEndToken());
                        return;
                    }
                }
            }
            java.util.ArrayList<PartToken> li = _tryParsePartList(tt);
            if (li != null && li.size() > 0) {
                if (!ignoreDecree) 
                    break;
                if (li.get(0).getMorph().getCase().isInstrumental()) 
                    break;
                setEndToken((tt = li.get(li.size() - 1).getEndToken()));
                errs = 0;
                continue;
            }
            if (tt.isChar('(')) {
                errs = 0;
                com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(tt, com.pullenti.ner.core.BracketParseAttr.CANBEMANYLINES, 3000);
                if (br != null) {
                    setEndToken((tt = br.getEndToken()));
                    continue;
                }
                int cou = 5000;
                for (com.pullenti.ner.Token ttt = tt.getNext(); ttt != null && cou > 0; ttt = ttt.getNext(),cou--) {
                    if (ttt.isChar(')')) {
                        setEndToken((tt = ttt));
                        break;
                    }
                    tt2 = com.pullenti.ner.core.MiscHelper.checkImage(ttt);
                    if (tt2 != null) {
                        ttt = tt2;
                        continue;
                    }
                    if (_canBeChangeToken(ttt, 0, false, false)) {
                        setEndToken((tt = ttt.getPrevious()));
                        break;
                    }
                    com.pullenti.ner.Token ttt2 = com.pullenti.ner.core.MiscHelper.checkImage(ttt);
                    if (ttt2 != null) {
                        ttt = ttt2;
                        continue;
                    }
                    com.pullenti.ner.decree.DecreeReferent dr = (com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(ttt.getReferent(), com.pullenti.ner.decree.DecreeReferent.class);
                    if (dr != null) {
                        if (dr.getKind() == com.pullenti.ner.decree.DecreeKind.PUBLISHER) 
                            continue;
                    }
                    if (ttt instanceof com.pullenti.ner.ReferentToken) 
                        continue;
                    if ((ttt instanceof com.pullenti.ner.NumberToken) || (ttt.getLengthChar() < 5)) 
                        continue;
                    DecreeToken pt = DecreeToken.tryAttach(ttt, null, false);
                    if (pt != null) {
                        ttt = pt.getEndToken();
                        continue;
                    }
                    break;
                }
            }
            if (tt.isChar(')')) {
                setEndToken(tt);
                errs = 0;
                continue;
            }
            if (tt.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) {
                errs = 0;
                if (!ignoreDecree) {
                    if (tt.getPrevious().isAnd() && tt.getNext() != null && tt.getNext().isChar('(')) {
                        if (addDecrees == null) 
                            addDecrees = new java.util.ArrayList<com.pullenti.ner.decree.DecreeReferent>();
                        addDecrees.add((com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreeReferent.class));
                    }
                    else 
                        break;
                }
                setEndToken(tt);
                continue;
            }
            if (tt.isNewlineBefore()) 
                break;
            if (tt.isCharOf(":;,")) 
                break;
            if (_canBeChangeToken(tt, 0, false, false)) 
                break;
            if (tt.getLengthChar() > 1) 
                errs++;
        }
    }

    public static DecreeChangeToken tryAttach(com.pullenti.ner.Token t, com.pullenti.ner.decree.DecreeChangeReferent main, boolean ignoreNewlines, java.util.ArrayList<com.pullenti.ner.decree.DecreePartReferent> changeStack, boolean isInEdition, boolean abzacRegime, PartToken defPart, boolean nlBefore) {
        if (t == null) 
            return null;
        com.pullenti.ner.Token tt = t;
        com.pullenti.ner.core.ComplexNumToken _numBefore = null;
        boolean _isNewlineBefore = t.isNewlineBefore();
        if ((!_isNewlineBefore && t.getPrevious() != null && t.getPrevious().isChar(':')) && t.getWhitespacesBeforeCount() > 0) 
            _isNewlineBefore = true;
        if ((t.getPrevious() != null && ((t.getPrevious().isCharOf(";.") || t.getPrevious().isCommaAnd())) && t.getPrevious().getPrevious() != null) && (t.getPrevious().getPrevious().getReferent() instanceof com.pullenti.ner.decree.DecreeChangeReferent)) 
            _isNewlineBefore = true;
        else if (t.getPrevious() != null && (t.getPrevious().getReferent() instanceof com.pullenti.ner.decree.DecreeChangeReferent)) 
            _isNewlineBefore = true;
        if ((!_isNewlineBefore && t.getPrevious() != null && t.getPrevious().isTableControlChar()) && ((t.getPrevious().isNewlineBefore() || main != null))) 
            _isNewlineBefore = true;
        if ((_isNewlineBefore && t.getPrevious() != null && t.getPrevious().isValue("РЕДАКЦИЯ", null)) && ((com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(t, true, false) || t.isNewlineBefore()))) 
            _isNewlineBefore = false;
        if (nlBefore) 
            _isNewlineBefore = true;
        if (_isNewlineBefore && !ignoreNewlines) {
            for (tt = t; tt != null; tt = tt.getNext()) {
                if (tt.isChar('[')) {
                    com.pullenti.ner.Token ii = com.pullenti.ner.core.MiscHelper.checkImage(tt);
                    if (ii != null && !ii.isNewlineAfter() && ii.getNext() != null) {
                        tt = ii;
                        continue;
                    }
                }
                if (t == tt) {
                    _numBefore = com.pullenti.ner.core.ComplexNumToken.tryParse(t, null, false, false);
                    if (_numBefore != null) {
                        PartToken pp = PartToken.tryAttach(t, null, false, false);
                        if (pp != null) 
                            _numBefore = null;
                        else if (_numBefore.getEndToken().getNext() != null && _numBefore.getEndToken().getNext().isHiphen()) {
                        }
                        else {
                            tt = _numBefore.getEndToken();
                            continue;
                        }
                    }
                }
                if ((tt == t && (tt instanceof com.pullenti.ner.TextToken) && ((com.pullenti.unisharp.Utils.stringsEq(((com.pullenti.ner.TextToken)com.pullenti.unisharp.Utils.cast(tt, com.pullenti.ner.TextToken.class)).term, "СТАТЬЯ") || com.pullenti.unisharp.Utils.stringsEq(((com.pullenti.ner.TextToken)com.pullenti.unisharp.Utils.cast(tt, com.pullenti.ner.TextToken.class)).term, "СТАТТЯ")))) && (tt.getNext() instanceof com.pullenti.ner.NumberToken)) {
                    com.pullenti.ner.Token tt1 = tt.getNext().getNext();
                    if (tt1 != null && tt1.isChar('.')) {
                        tt1 = tt1.getNext();
                        if (tt1 != null && !tt1.isNewlineBefore() && tt1.isValue("ВНЕСТИ", "УНЕСТИ")) 
                            continue;
                        if (tt1 != null && tt1.isNewlineBefore()) 
                            return null;
                        tt = tt1;
                    }
                    break;
                }
                else if (tt == t && _tryParsePart(tt, false) != null) {
                    if ((tt instanceof com.pullenti.ner.NumberToken) && tt.getNext() != null && tt.getNext().isChar(')')) 
                        tt = tt.getNext().getNext();
                    break;
                }
                else if ((tt instanceof com.pullenti.ner.NumberToken) && ((com.pullenti.ner.NumberToken)com.pullenti.unisharp.Utils.cast(tt, com.pullenti.ner.NumberToken.class)).typ == com.pullenti.ner.NumberSpellingType.DIGIT) {
                }
                else if (tt.isHiphen() || tt.isChar(')')) {
                }
                else if ((tt instanceof com.pullenti.ner.TextToken) && !tt.chars.isLetter() && !tt.isWhitespaceBefore()) {
                }
                else if (((tt instanceof com.pullenti.ner.TextToken) && tt.getLengthChar() == 1 && (tt.getNext() instanceof com.pullenti.ner.TextToken)) && !tt.getNext().chars.isLetter()) {
                    if (com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt, true, false) && tt.getPrevious() != null && tt.getPrevious().isValue("ДОПОЛНИТЬ", null)) {
                        ignoreNewlines = true;
                        break;
                    }
                }
                else 
                    break;
            }
        }
        if (tt == null) 
            return null;
        DecreeChangeToken res = null;
        com.pullenti.ner.Token te1 = null;
        boolean hasChange = false;
        if ((tt instanceof com.pullenti.ner.TextToken) && t.isNewlineBefore() && !ignoreNewlines) {
            if (tt.isValue("ИЗЛОЖИТЬ", null)) {
            }
            boolean enter = false;
            if (tt.isValue("ВНЕСТИ", "УНЕСТИ") && ((((tt.getNext() != null && tt.getNext().isValue("В", "ДО"))) || com.pullenti.unisharp.Utils.stringsEq(((com.pullenti.ner.TextToken)com.pullenti.unisharp.Utils.cast(tt, com.pullenti.ner.TextToken.class)).term, "ВНЕСТИ") || com.pullenti.unisharp.Utils.stringsEq(((com.pullenti.ner.TextToken)com.pullenti.unisharp.Utils.cast(tt, com.pullenti.ner.TextToken.class)).term, "УНЕСТИ")))) {
                te1 = tt;
                if (tt.getNext() != null && tt.getNext().isValue("В", "ДО")) 
                    te1 = tt.getNext();
                enter = true;
            }
            else if (tt.isValue("ИЗМЕНЕНИЕ", null) && tt.getNext() != null && tt.getNext().isComma()) {
                hasChange = true;
                for (com.pullenti.ner.Token ttt = tt.getNext().getNext(); ttt != null; ttt = ttt.getNext()) {
                    if (ttt.isValue("КОТОРЫЙ", null)) 
                        continue;
                    if (ttt.isValue("ВНОСИТЬСЯ", null) || ttt.isValue("ВНОСИМЫЙ", null)) 
                        continue;
                    if (ttt.isValue("В", "ДО")) {
                        te1 = ttt;
                        break;
                    }
                    break;
                }
            }
        }
        if (te1 != null) {
            res = _new1063(tt, te1, DecreeChangeTokenTyp.STARTMULTU, true, _numBefore);
            for (tt = te1.getNext(); tt != null; tt = tt.getNext()) {
                if (tt.isNewlineBefore()) {
                    if (com.pullenti.ner.core.MiscHelper.canBeStartOfSentence(tt)) 
                        break;
                }
                if (tt.isChar(':') && tt.getWhitespacesAfterCount() > 0) {
                    res.setEndToken(tt);
                    break;
                }
                if (tt.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) {
                    com.pullenti.ner.decree.DecreeReferent dr = (com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreeReferent.class);
                    if (dr.getKind() == com.pullenti.ner.decree.DecreeKind.PUBLISHER) {
                        res.setEndToken(tt);
                        continue;
                    }
                    if (res.decree == null) {
                        if (dr.getKind() == com.pullenti.ner.decree.DecreeKind.PROJECT) 
                            return null;
                        res.decree = dr;
                    }
                    else {
                        if (res.addDecrees == null) 
                            res.addDecrees = new java.util.ArrayList<com.pullenti.ner.decree.DecreeReferent>();
                        res.addDecrees.add(dr);
                    }
                    res.setEndToken(tt);
                    res._skipDecreeDummy();
                    tt = res.getEndToken();
                    continue;
                }
                if (tt.isValue2("СОГЛАСНО", "ПРИЛОЖЕНИЕ")) {
                    res.appExtChanges = PartToken.tryAttach(tt.getNext(), null, false, false);
                    if (res.appExtChanges != null) {
                        if (res.appExtChanges.getEndToken().getNext() != null && res.appExtChanges.getEndToken().getNext().isValue("К", null)) {
                            com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(res.appExtChanges.getEndToken().getNext(), com.pullenti.ner.core.NounPhraseParseAttr.of((com.pullenti.ner.core.NounPhraseParseAttr.REFERENTCANBENOUN.value()) | (com.pullenti.ner.core.NounPhraseParseAttr.PARSEPREPOSITION.value())), 0, null);
                            if (npt != null) {
                                res.setEndToken((tt = npt.getEndToken()));
                                hasChange = true;
                                continue;
                            }
                        }
                        res.setEndToken((tt = res.appExtChanges.getEndToken()));
                        hasChange = true;
                        continue;
                    }
                }
                if ((tt.getReferent() instanceof com.pullenti.ner.decree.DecreePartReferent) && res.realPart == null) {
                    res.realPart = (com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreePartReferent.class);
                    res.setEndToken(tt);
                    continue;
                }
                java.util.ArrayList<PartToken> li = _tryParsePartList(tt);
                if (li != null && li.size() > 0) {
                    if (res.parts != null) 
                        break;
                    res.parts = li;
                    tt = res.setEndToken(li.get(li.size() - 1).getEndToken());
                    if (res.decree == null && li.get(li.size() - 1).decree != null) {
                        res.decree = li.get(li.size() - 1).decree;
                        res.setEndToken(li.get(li.size() - 1).getEndToken());
                        res._skipDecreeDummy();
                        tt = res.getEndToken();
                    }
                    continue;
                }
                if (tt.isChar('(')) {
                    com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(tt, com.pullenti.ner.core.BracketParseAttr.CANBEMANYLINES, 100);
                    if (br != null) {
                        tt = br.getEndToken();
                        continue;
                    }
                }
                if (tt.isNewlineBefore()) 
                    break;
                res.setEndToken(tt);
                if (tt.isCommaAnd() && tt.getNext() != null && (tt.getNext().getReferent() instanceof com.pullenti.ner.decree.DecreeReferent)) 
                    continue;
                if (tt.isChar(',') && hasChange) {
                    if (tt.getNext() == null) 
                        break;
                    tt = tt.getNext();
                    boolean ok = false;
                    for (com.pullenti.ner.Token ttt = tt; ttt != null; ttt = ttt.getNext()) {
                        if (tt.isValue("ИЗЛОЖИТЬ", null)) 
                            res.actKind = com.pullenti.ner.decree.DecreeChangeKind.NEW;
                        if (ttt.isValue2("СОГЛАСНО", "ПРИЛОЖЕНИЕ")) {
                            tt = ttt.getPrevious();
                            ok = true;
                            break;
                        }
                        if (ttt.isNewlineBefore()) 
                            break;
                    }
                    if (ok) 
                        continue;
                    res.typ = DecreeChangeTokenTyp.STARTSINGLE;
                    if (tt.isValue("ИЗЛОЖИТЬ", null)) {
                        if (tt.getNext() != null && tt.getNext().isValue("ОН", null)) 
                            tt = tt.getNext();
                        if (tt.isValue2("СОГЛАСНО", "ПРИЛОЖЕНИЕ")) {
                            tt = tt.getPrevious();
                            continue;
                        }
                        java.util.ArrayList<PartToken> li2 = _tryParsePartList(tt.getNext());
                        if (li2 != null && li2.size() == 1) {
                            if (res.parts != null) {
                                li2.get(0).setBeginToken(li2.get(0).setEndToken(res.parts.get(res.parts.size() - 1).getEndToken()));
                                res.parts.add(li2.get(0));
                            }
                            else {
                                res.parts = new java.util.ArrayList<PartToken>();
                                res.parts.add(li2.get(0));
                                tt = li2.get(0).getEndToken();
                            }
                        }
                    }
                    break;
                }
                if (tt.isValue("ИЗМЕНЕНИЕ", "ЗМІНА") || tt.isValue("ДОПОЛНЕНИЕ", "ДОДАТОК") || tt.isValue("ВНЕСТИ", null)) 
                    hasChange = true;
                else if (tt.isValue("СЛЕДУЮЩИЙ", "НАСТУПНИЙ")) {
                }
                else if (tt.isValue("ТАКОЙ", "ТАКИЙ")) {
                }
                else if (tt.isValue2("С", "ИЗМЕНЕНИЕ")) {
                    tt = tt.getNext();
                    if (tt.getNext() != null && tt.getNext().isComma()) 
                        tt = tt.getNext();
                }
            }
            if (!hasChange && !res.hasChangeKeyword) 
                return null;
            if (res.decree == null && res.parts == null && res.realPart == null) 
                return null;
            tt = res.getEndToken().getNext();
            res.hasChangeKeyword = true;
            if (res.typ == DecreeChangeTokenTyp.STARTSINGLE && res.parts == null && tt != null) {
                if ((tt.isValue("ИЗЛОЖИВ", "ВИКЛАВШИ") || tt.isValue("ДОПОЛНИВ", "ДОПОВНИВШИ") || tt.isValue("ИСКЛЮЧИВ", "ВИКЛЮЧИВШИ")) || tt.isValue("ЗАМЕНИВ", "ЗАМІНИВШИ")) {
                    tt = tt.getNext();
                    if (tt != null && tt.getMorph()._getClass().isPreposition()) 
                        tt = tt.getNext();
                    res.parts = _tryParsePartList(tt);
                    if (res.parts != null) {
                        tt = res.getEndToken().getNext();
                        if (tt.isValue("ДОПОЛНИВ", "ДОПОВНИВШИ")) 
                            res.actKind = com.pullenti.ner.decree.DecreeChangeKind.APPEND;
                        else if (tt.isValue("ИСКЛЮЧИВ", "ВИКЛЮЧИВШИ")) 
                            res.actKind = com.pullenti.ner.decree.DecreeChangeKind.REMOVE;
                        else if (tt.isValue("ИЗЛОЖИВ", "ВИКЛАВШИ")) 
                            res.actKind = com.pullenti.ner.decree.DecreeChangeKind.NEW;
                        else if (tt.isValue("ЗАМЕНИВ", "ЗАМІНИВШИ")) 
                            res.actKind = com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE;
                        res.setEndToken(res.parts.get(res.parts.size() - 1).getEndToken());
                        if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                            java.util.ArrayList<PartToken> pp = _tryParsePartList(res.getEndToken().getNext());
                            if (pp != null && pp.size() == 1) {
                                res.newParts = pp;
                                res.setEndToken(pp.get(0).getEndToken());
                            }
                        }
                    }
                }
            }
            return res;
        }
        com.pullenti.ner.Token ttExpire = null;
        boolean isSuspend = false;
        boolean isRollback = false;
        if (!ignoreNewlines && _isNewlineBefore) {
            for (com.pullenti.ner.Token tt2 = tt; tt2 != null; tt2 = tt2.getNext()) {
                if (tt2 != tt && tt2.isNewlineBefore()) 
                    break;
                if (tt2.getReferent() != null) 
                    continue;
                if (tt2.isChar('(')) {
                    com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(tt2, com.pullenti.ner.core.BracketParseAttr.NO, 100);
                    if (br != null) {
                        tt2 = br.getEndToken();
                        continue;
                    }
                }
                DecreeToken dt = DecreeToken.tryAttach(tt2, null, false);
                if (dt != null && dt.typ == DecreeToken.ItemType.TYP) {
                    tt2 = dt.getEndToken();
                    continue;
                }
                com.pullenti.morph.MorphClass mc = tt2.getMorphClassInDictionary();
                if (mc.isPreposition() || ((mc.isAdjective() && !mc.isVerb())) || mc.isPronoun()) 
                    continue;
                if (tt2.isCommaAnd()) 
                    continue;
                if (tt2.isValue("МОМЕНТ", null) || tt2.isValue("ДЕНЬ", null)) 
                    continue;
                if (tt2.isValue3("ВСТУПЛЕНИЕ", "В", "СИЛУ")) {
                    tt2 = tt2.getNext().getNext();
                    continue;
                }
                if ((tt2.isValue("ПРИЗНАТЬ", "ВИЗНАТИ") || tt2.isValue("ПРИЗНАВАЕМЫЙ", null) || tt2.isValue("СЧИТАТЬ", "ВВАЖАТИ")) || tt2.isValue("ПЕРЕЧЕНЬ", null)) {
                    com.pullenti.ner.Token tt3 = tt2.getNext();
                    if (tt3 != null && tt3.isComma()) 
                        tt3 = tt3.getNext();
                    if (tt3 == null) 
                        continue;
                    if (tt3.isValue("УТРАТИТЬ", "ВТРАТИТИ")) {
                        if (tt3.getNext() != null && tt3.getNext().isValue("СИЛА", "ЧИННІСТЬ")) {
                            ttExpire = tt3.getNext();
                            if (ttExpire.getNext() != null && ttExpire.getNext().isValue("ИЗМЕНЕНИЕ", null)) {
                                ttExpire = ttExpire.getNext();
                                isRollback = true;
                            }
                            break;
                        }
                    }
                }
                if (tt.isValue("ПРИОСТАНОВИТЬ", null) && tt.getNext() != null) {
                    if (tt.getNext().isValue("ДЕЙСТВИЕ", null) || tt.getNext().isValue("С", null)) {
                        ttExpire = tt.getNext();
                        isSuspend = true;
                        break;
                    }
                }
                break;
            }
        }
        if (ttExpire != null) {
            res = _new1064(tt, ttExpire, DecreeChangeTokenTyp.ACTION, (isRollback ? com.pullenti.ner.decree.DecreeChangeKind.EXPIRECHANGES : (isSuspend ? com.pullenti.ner.decree.DecreeChangeKind.SUSPEND : com.pullenti.ner.decree.DecreeChangeKind.EXPIRE)), _numBefore);
            boolean dayAfter = false;
            for (; tt != null; tt = tt.getNext()) {
                if (tt.isChar(':') && tt.getEndChar() > ttExpire.getEndChar()) {
                    res.typ = DecreeChangeTokenTyp.STARTMULTU;
                    if (tt.getEndChar() > res.getEndChar()) 
                        res.setEndToken(tt);
                    break;
                }
                if (tt.isValue2("ДЕНЬ", "ВВЕДЕНИЯ")) 
                    dayAfter = true;
                if (tt.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) {
                    if (!dayAfter) {
                        if (res.decree != null) {
                            if (!res.decree.canBeEquals(tt.getReferent(), com.pullenti.ner.core.ReferentsEqualType.WITHINONETEXT)) {
                                if (res.actKind != com.pullenti.ner.decree.DecreeChangeKind.EXPIRECHANGES) 
                                    break;
                            }
                        }
                        if (tt.getPrevious() != null && tt.getPrevious().isValue("СОГЛАСНО", null)) {
                        }
                        else {
                            res.typ = DecreeChangeTokenTyp.STARTSINGLE;
                            if (res.decree == null) 
                                res.decree = (com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreeReferent.class);
                        }
                    }
                    if (tt.getEndChar() > res.getEndChar()) 
                        res.setEndToken(tt);
                    res._skipDecreeDummy();
                    tt = res.getEndToken();
                    continue;
                }
                java.util.ArrayList<PartToken> li = _tryParsePartList(tt);
                if (li != null && li.size() > 0 && !tt.isValue("СИЛА", null)) {
                    if (!dayAfter) {
                        if (res.parts != null) 
                            break;
                        if (tt.getPrevious() != null && tt.getPrevious().isValue("СОГЛАСНО", null)) {
                        }
                        else if (tt.isValue("СОГЛАСНО", null)) {
                        }
                        else {
                            res.typ = DecreeChangeTokenTyp.STARTSINGLE;
                            res.parts = li;
                        }
                    }
                    tt = li.get(li.size() - 1).getEndToken();
                    if (tt.getEndChar() > res.getEndChar()) 
                        res.setEndToken(tt);
                    res._skipDecreeDummy();
                    continue;
                }
                if (tt.isValue2("В", "ЧАСТИ")) {
                    tt = tt.getNext();
                    continue;
                }
                if (tt.isChar(')')) {
                    res.setEndToken(tt);
                    continue;
                }
                if (tt.isComma() || tt.isValue("КАСАЮЩИЙСЯ", null)) 
                    continue;
                if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.EXPIRECHANGES) {
                    if (tt.isValue("КОТОРЫЙ", null) || tt.isValue("ВНОСИТЬСЯ", null) || tt.isValue("В", null)) 
                        continue;
                }
                if (tt.isChar('(')) {
                    if (tt.getNext() != null && tt.getNext().isValue2("В", "ЧАСТИ")) {
                        tt = tt.getNext().getNext();
                        continue;
                    }
                    com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(tt, com.pullenti.ner.core.BracketParseAttr.NO, 100);
                    if (br != null) {
                        tt = br.getEndToken();
                        continue;
                    }
                }
                com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt, com.pullenti.ner.core.NounPhraseParseAttr.NO, 0, null);
                if (npt != null) {
                    if (npt.getEndToken().isValue("АКТ", null) || npt.getEndToken().isValue("ПОЛОЖЕНИЕ", null)) {
                        tt = npt.getEndToken();
                        if (tt.getEndChar() > res.getEndChar()) 
                            res.setEndToken(tt);
                        continue;
                    }
                }
                com.pullenti.ner.Referent r = tt.getReferent();
                if (r != null && com.pullenti.unisharp.Utils.stringsEq(r.getTypeName(), "ORGANIZATION")) {
                    if (tt.getEndChar() > res.getEndChar()) 
                        res.setEndToken(tt);
                    continue;
                }
                if (tt.isNewlineBefore() && tt.getBeginChar() > ttExpire.getBeginChar()) {
                    res.typ = DecreeChangeTokenTyp.STARTMULTU;
                    break;
                }
                if (tt.isValue("ПОЗИЦИЯ", null) && tt.getNext() != null && tt.getNext().isChar(':')) {
                    DecreeChangeToken d = _tryParseText(tt.getNext().getNext(), false, false, null);
                    if (d != null) {
                        res.actKind = com.pullenti.ner.decree.DecreeChangeKind.REMOVE;
                        res.changeVal = d.changeVal;
                        res.typ = DecreeChangeTokenTyp.ACTION;
                        tt = res.setEndToken(d.getEndToken());
                        break;
                    }
                }
            }
            return res;
        }
        if ((!ignoreNewlines && ((_isNewlineBefore || tt == t)) && tt.isValue("УТРАТИТЬ", "ВТРАТИТИ")) && tt.getNext() != null && tt.getNext().isValue("СИЛА", "ЧИННІСТЬ")) {
            res = _new1048(tt, tt.getNext(), DecreeChangeTokenTyp.UNDEFINED);
            for (tt = tt.getNext(); tt != null; tt = tt.getNext()) {
                res.setEndToken(tt);
                if (tt.isNewlineAfter()) 
                    break;
            }
            return res;
        }
        if (!ignoreNewlines && _isNewlineBefore && !tt.isValue2("В", "КОНЦЕ")) {
            if (tt.isValue("СТРОКУ", null)) {
            }
            res = _new1066(tt, tt, DecreeChangeTokenTyp.STARTSINGLE, _numBefore);
            com.pullenti.ner.Token izlogit = null;
            boolean specRegime = false;
            boolean falseTableRow = false;
            boolean aboutChanges = false;
            for (; tt != null; tt = tt.getNext()) {
                if (tt != res.getBeginToken() && tt.isNewlineBefore()) {
                    if (res.decree == null && (tt.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent)) {
                    }
                    else 
                        break;
                }
                if (tt.isValue("В", null) || tt.isValue("B", null)) {
                    if (tt != res.getBeginToken() || !(tt instanceof com.pullenti.ner.TextToken)) 
                        continue;
                    if (tt.getNext() != null && tt.getNext().isValue("ТЕКСТ", null)) {
                        res.setEndToken((tt = tt.getNext()));
                        res.hasText = true;
                    }
                    if (tt.getNext() != null && tt.getNext().isValue("УКАЗАННЫЙ", null)) {
                        PartToken ppp = PartToken.tryAttach(tt.getNext().getNext(), null, false, false);
                        if (ppp != null) {
                            tt = tt.getNext();
                            continue;
                        }
                        ppp = PartToken.tryAttach(tt.getNext().getNext(), null, false, true);
                        if (ppp != null) {
                            res.setEndToken((tt = ppp.getEndToken()));
                            continue;
                        }
                    }
                    if (tt.getNext() != null && tt.getNext().isValue("СООТВЕТСТВИЕ", null)) 
                        return null;
                    PartToken prr = _tryParsePart(tt.getNext(), false);
                    if (prr != null) 
                        continue;
                    if (tt.getNext() != null && (tt.getNext().getReferent() instanceof com.pullenti.ner.decree.DecreePartReferent)) {
                        res.realPart = (com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(tt.getNext().getReferent(), com.pullenti.ner.decree.DecreePartReferent.class);
                        tt = tt.getNext();
                        res.setEndToken(tt);
                        continue;
                    }
                    boolean hasKeyword = DecreeToken.isKeyword(tt.getNext(), false) != null;
                    for (com.pullenti.ner.Token tt2 = tt.getNext(); tt2 != null; tt2 = tt2.getNext()) {
                        if (tt2.isCharOf(":;") || tt2.isNewlineBefore()) 
                            break;
                        com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(tt2, com.pullenti.ner.core.BracketParseAttr.NO, 100);
                        if (br != null) {
                            tt2 = br.getEndToken();
                            continue;
                        }
                        PartToken pt = PartToken.tryAttach(tt2, null, false, false);
                        if (pt != null && pt.typ == PartToken.ItemType.APPENDIX) {
                            if (res.parts == null) {
                                res.parts = new java.util.ArrayList<PartToken>();
                                res.parts.add(pt);
                                tt2 = pt.getEndToken();
                                continue;
                            }
                        }
                        if (tt2.isValue("УТВЕРЖДЕННЫЙ", null) && (tt2.getNext() instanceof com.pullenti.ner.ReferentToken) && (tt2.getNext().getReferent() instanceof com.pullenti.ner.decree.DecreeReferent)) {
                            tt = tt2;
                            break;
                        }
                        if ((tt2.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) && hasKeyword) {
                            tt = tt2.getPrevious();
                            break;
                        }
                    }
                    continue;
                }
                if (tt.isValue2("К", "ОН")) {
                    res.setEndToken((tt = tt.getNext()));
                    continue;
                }
                if (tt.isValue("К", null) || tt.isValue("K", null)) {
                    if (tt == res.getBeginToken() && tt.getPrevious() != null && tt.getPrevious().isValue("ПРИЛОЖЕНИЕ", null)) 
                        return null;
                    continue;
                }
                if (tt == t && t.isNewlineBefore() && t.isValue3("О", "ВНЕСЕНИЕ", "ИЗМЕНЕНИЙ")) {
                    aboutChanges = true;
                    tt = tt.getNext().getNext();
                    if (tt.getNext() != null && tt.getNext().isValue("В", null)) 
                        tt = tt.getNext();
                    continue;
                }
                if (tt.isValue("ИЗ", null)) 
                    continue;
                if (((tt.isValue("ПЕРЕЧЕНЬ", "ПЕРЕЛІК") || tt.isValue("СПИСОК", null))) && tt.getNext() != null && tt.getNext().isValue("ИЗМЕНЕНИЕ", "ЗМІНА")) {
                    if (tt == t) 
                        res.setEndToken(tt.getNext());
                    tt = tt.getNext().getNext();
                    res.typ = DecreeChangeTokenTyp.STARTMULTU;
                    for (; tt != null && tt.getNext() != null; tt = tt.getNext()) {
                        if ((tt.getNext().isComma() || tt.getNext().isValue("КОТОРЫЙ", null) || tt.getNext().isValue("ВНОСИТЬ", null)) || tt.getNext().isValue("ВНОСИМЫЙ", null)) 
                            res.setEndToken(tt);
                        else 
                            break;
                    }
                    if (tt.isNewlineBefore()) 
                        return res;
                    continue;
                }
                if (tt.isValue("ИЗМЕНЕНИЕ", null) && tt == t) {
                    res.typ = DecreeChangeTokenTyp.STARTMULTU;
                    res.hasChangeKeyword = true;
                    for (; tt != null && tt.getNext() != null; tt = tt.getNext()) {
                        if ((tt.getNext().isComma() || tt.getNext().isValue("КОТОРЫЙ", null) || tt.getNext().isValue("ВНОСИТЬ", null)) || tt.getNext().isValue("ВНОСИМЫЙ", null)) 
                            res.setEndToken(tt);
                        else 
                            break;
                    }
                    continue;
                }
                if (tt.isValue("ТЕКСТ", null)) {
                    PartToken pt = _tryParsePart(tt.getNext(), true);
                    if (pt != null && pt.getEndToken().getNext() != null && pt.getEndToken().getNext().isValue("СЧИТАТЬ", "ВВАЖАТИ")) {
                        res.setEndToken(pt.getEndToken());
                        if (changeStack != null && changeStack.size() > 0) 
                            res.realPart = changeStack.get(0);
                        res.actKind = com.pullenti.ner.decree.DecreeChangeKind.CONSIDER;
                        res.partTyp = pt.typ;
                        res.hasText = true;
                        return res;
                    }
                }
                if (tt.isValue2("И", "ТЕКСТ")) {
                    res.hasText = true;
                    res.setEndToken((tt = tt.getNext()));
                    continue;
                }
                if (tt.isValue3("ПО", "ВСЕМУ", "ТЕКСТУ")) {
                    res.hasText = true;
                    res.setEndToken((tt = tt.getNext().getNext()));
                    continue;
                }
                if (res.parts == null && tt.isValue("ДОПОЛНИТЬ", "ДОПОВНИТИ") && tt.getNext() != null) {
                    res.actKind = com.pullenti.ner.decree.DecreeChangeKind.APPEND;
                    if (tt.getNext().getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) 
                        continue;
                    tt = tt.getNext();
                    com.pullenti.ner.Token tt1 = DecreeToken.isKeyword(tt, false);
                    PartToken pp = _tryParsePart(tt, true);
                    if (tt1 == null || pp != null) {
                        tt1 = tt;
                        if (pp != null && !pp.getMorph().getCase().isInstrumental()) {
                            boolean ok = pp.values.size() > 0 || pp.name != null;
                            if (!ok) {
                                if (pp.typ == PartToken.ItemType.NAME || pp.typ == PartToken.ItemType.PREAMBLE || pp.typ == PartToken.ItemType.FREETEXT) 
                                    ok = true;
                            }
                            if (ok) {
                                if (res.parts == null) {
                                    res.parts = new java.util.ArrayList<PartToken>();
                                    res.parts.add(pp);
                                }
                            }
                            tt1 = pp.getEndToken().getNext();
                        }
                    }
                    else if (tt1.getMorph().getCase().isInstrumental()) 
                        tt1 = tt;
                    else 
                        tt1 = tt1.getNext();
                    if (tt1 != null && tt1.isValue("НОВЫЙ", "НОВИЙ")) 
                        tt1 = tt1.getNext();
                    if ((tt1 instanceof com.pullenti.ner.TextToken) && tt1.getMorph().getCase().isInstrumental() && com.pullenti.unisharp.Utils.stringsNe(((com.pullenti.ner.TextToken)com.pullenti.unisharp.Utils.cast(tt1, com.pullenti.ner.TextToken.class)).term, "СТАТЬЮ")) {
                        PartToken pt = _tryParsePart(tt1, true);
                        if (pt != null && pt.values.size() == 0 && tt1.isValue("СТРОКА", null)) {
                            if (com.pullenti.ner.core.BracketHelper.isBracket(tt1.getNext(), false)) {
                                pt = null;
                                falseTableRow = true;
                            }
                            else if (tt1.getNext() != null && tt1.getNext().isChar(':') && com.pullenti.ner.core.BracketHelper.isBracket(tt1.getNext().getNext(), false)) {
                                pt = null;
                                falseTableRow = true;
                            }
                        }
                        if (pt != null && pt.typ != PartToken.ItemType.PREFIX) {
                            res.partTyp = pt.typ;
                            tt = res.setEndToken(pt.getEndToken());
                            if (res.newParts == null) 
                                res.newParts = new java.util.ArrayList<PartToken>();
                            res.newParts.add(pt);
                            if (tt.getNext() != null && tt.getNext().isAnd()) {
                                pt = _tryParsePart(tt.getNext().getNext(), true);
                                if (pt != null) {
                                    res.newParts.add(pt);
                                    tt = res.setEndToken(pt.getEndToken());
                                }
                            }
                        }
                        if (!falseTableRow) 
                            continue;
                    }
                }
                if (tt.isValue("ДОПОЛНИТЬ", "ДОПОВНИТИ") && tt.getNext() != null && tt.getNext().isChar(':')) {
                    res.actKind2 = com.pullenti.ner.decree.DecreeChangeKind.APPEND;
                    res.setEndToken(tt.getNext());
                    return res;
                }
                if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED && tt.isValue("ИСКЛЮЧИТЬ", null) && !tt.getMorph().containsAttr("п.вр.", null)) {
                    res.setEndToken(tt);
                    res.actKind = com.pullenti.ner.decree.DecreeChangeKind.REMOVE;
                    continue;
                }
                if (tt.getReferent() instanceof com.pullenti.ner.decree.DecreePartReferent) {
                    if (res.realPart == null) 
                        res.realPart = (com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreePartReferent.class);
                    else {
                        if (res.addRealParts == null) 
                            res.addRealParts = new java.util.ArrayList<com.pullenti.ner.decree.DecreePartReferent>();
                        res.addRealParts.add((com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreePartReferent.class));
                    }
                    res.setEndToken(tt);
                    continue;
                }
                if (tt.isChar('(')) {
                    com.pullenti.ner.MetaToken ali = com.pullenti.ner.decree.DecreeAnalyzer._checkAliasAfter(tt);
                    if (ali != null) {
                        res.alias = ali;
                        res.setEndToken((tt = ali.getEndToken()));
                        continue;
                    }
                }
                java.util.ArrayList<PartToken> li = _tryParsePartList(tt);
                if (li != null && li.get(li.size() - 1).getEndToken().getNext() != null && li.get(li.size() - 1).getEndToken().getNext().isTableControlChar()) {
                    java.util.ArrayList<PartToken> li2 = _tryParsePartList(li.get(li.size() - 1).getEndToken().getNext().getNext());
                    if (li2 != null) 
                        com.pullenti.unisharp.Utils.addToArrayList(li, li2);
                }
                if (li == null && tt.isValue("ПРИМЕЧАНИЕ", "ПРИМІТКА")) {
                    li = new java.util.ArrayList<PartToken>();
                    li.add(PartToken._new1058(tt, tt, PartToken.ItemType.NOTICE));
                }
                if (li == null) {
                    if ((tt.isValue("ЧАСТЬ", null) || tt.isValue("ПУНКТ", null) || tt.isValue("ПОДПУНКТ", null)) || tt.isValue("АБЗАЦ", null)) {
                        li = _tryParsePartList(tt.getNext());
                        if (li != null) 
                            res.inPart = tt;
                    }
                }
                if (li != null && li.size() > 0) {
                    if (li.get(0).typ == PartToken.ItemType.PREFIX) 
                        li = null;
                    else if (li.get(0).typ == PartToken.ItemType.TABLE && li.get(0).values.size() == 0 && main == null) 
                        li = null;
                    else if (res.changeVal != null) 
                        li = null;
                }
                if (li != null && li.size() > 0) {
                    if (res.decree == null && li.get(li.size() - 1).decree != null) {
                        res.decree = li.get(li.size() - 1).decree;
                        res.setEndToken(li.get(li.size() - 1).getEndToken());
                        res._skipDecreeDummy();
                        tt = li.get(li.size() - 1).setEndToken(res.getEndToken());
                    }
                    if (li.get(li.size() - 1).isConfidential) 
                        res.actKind = com.pullenti.ner.decree.DecreeChangeKind.CONFIDENTIAL;
                    if (res.parts != null && res.parts.size() == 1) {
                        if (((res.parts.get(0).typ == PartToken.ItemType.NAME && res.hasText)) || res.parts.get(0).typ == PartToken.ItemType.FREETEXT) {
                            com.pullenti.unisharp.Utils.addToArrayList(res.parts, li);
                            res.setEndToken((tt = li.get(li.size() - 1).getEndToken()));
                            continue;
                        }
                    }
                    if ((li.size() == 1 && li.get(0).getMorph().getCase().isInstrumental() && !li.get(0).getMorph().getCase().isAccusative()) && res.newParts == null) {
                        res.newParts = new java.util.ArrayList<PartToken>();
                        res.newParts.add(li.get(0));
                        res.setEndToken((tt = li.get(0).getEndToken()));
                        continue;
                    }
                    if (li.size() == 1 && PartToken._getRank(li.get(0).typ) > 0 && tt == t) {
                        if (li.get(0).isNewlineAfter()) 
                            return null;
                        if (li.get(0).getEndToken().getNext() != null && li.get(0).getEndToken().getNext().isChar('.')) 
                            return null;
                    }
                    if (((li.get(li.size() - 1).typ == PartToken.ItemType.TABLE || li.get(li.size() - 1).typ == PartToken.ItemType.FORM)) && li.get(li.size() - 1).name == null) {
                        com.pullenti.ner.Token tt0 = li.get(li.size() - 1).getEndToken().getNext();
                        com.pullenti.ner.Token tt1 = null;
                        for (com.pullenti.ner.Token ttt2 = tt0; ttt2 != null; ttt2 = ttt2.getNext()) {
                            if (ttt2.isComma()) 
                                continue;
                            if (ttt2.isNewlineBefore() && ttt2 != tt0) {
                                if (ttt2.chars.isAllLower() && !_canBeChangeToken(ttt2, 0, false, false)) {
                                }
                                else 
                                    break;
                            }
                            if (ttt2.isCharOf(":;")) 
                                break;
                            if (ttt2 == tt0 && ttt2.isChar('(')) 
                                break;
                            if (ttt2.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) 
                                break;
                            if (M_TERMS.tryParse(ttt2, com.pullenti.ner.core.TerminParseAttr.NO) != null) {
                                if (ttt2.isValue("КОД", null)) {
                                }
                                else 
                                    break;
                            }
                            PartToken ptt = _tryParsePart(ttt2, false);
                            if (ptt != null && ptt.typ != PartToken.ItemType.PREFIX) 
                                break;
                            com.pullenti.morph.MorphClass mc = ttt2.getMorphClassInDictionary();
                            if (!mc.isPreposition()) 
                                tt1 = ttt2;
                        }
                        if (tt1 != null) {
                            li.get(li.size() - 1).setEndToken(tt1);
                            li.get(li.size() - 1).name = new com.pullenti.ner.MetaToken(tt0, tt1, null);
                            tt1 = tt1.getNext();
                            if (tt1 != null && tt1.isComma()) 
                                tt1 = tt1.getNext();
                            if (tt1 != null && tt1.isValue("В", null)) {
                                li.get(li.size() - 1).setEndToken(tt1);
                                tt1 = tt1.getNext();
                            }
                            if (tt1 == null) 
                                break;
                            java.util.ArrayList<PartToken> pp = _tryParsePartList(tt1);
                            if (pp != null && pp.size() > 0) 
                                com.pullenti.unisharp.Utils.addToArrayList(li, pp);
                        }
                    }
                    if (res.actKind != com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                        if (res.parts != null) {
                            if (res.parts.size() == 1 && ((res.parts.get(0).typ == PartToken.ItemType.APPENDIX || res.parts.get(0).typ == PartToken.ItemType.DOCPART))) {
                                if (li.size() > 1 && PartToken._getRank(li.get(0).typ) > PartToken._getRank(li.get(li.size() - 1).typ)) 
                                    com.pullenti.unisharp.Utils.insertToArrayList(res.parts, li, 0);
                                else 
                                    com.pullenti.unisharp.Utils.addToArrayList(res.parts, li);
                            }
                            else if (tt.getPrevious() == null) 
                                break;
                            else if (tt.getPrevious().isChar('(')) {
                                com.pullenti.unisharp.Utils.addToArrayList(res.parts, li);
                                res.setEndToken((tt = li.get(li.size() - 1).getEndToken()));
                                if (tt.getNext() != null && tt.getNext().isChar(')')) 
                                    res.setEndToken((tt = tt.getNext()));
                                continue;
                            }
                            else {
                                if (tt.getPrevious().isCommaAnd()) {
                                }
                                else if (tt.getPrevious().isValue("В", null) && tt.getPrevious().getPrevious() != null && tt.getPrevious().getPrevious().isCommaAnd()) {
                                }
                                else 
                                    break;
                                if (res.addParts == null) 
                                    res.addParts = new java.util.ArrayList<java.util.ArrayList<PartToken>>();
                                res.addParts.add(li);
                            }
                        }
                        else {
                            res.parts = li;
                            com.pullenti.ner.Token ttt1 = li.get(li.size() - 1).getEndToken();
                            if (ttt1.getNext() != null && ttt1.getNext().isValue("ПОСЛЕ", null)) {
                                PartToken sss = _tryParsePart(ttt1.getNext().getNext(), false);
                                if (sss != null) {
                                    li.add(sss);
                                    ttt1 = sss.getEndToken();
                                }
                            }
                            for (; ttt1 != null; ttt1 = ttt1.getNext()) {
                                if (ttt1.isNewlineBefore() || ttt1.isTableControlChar()) 
                                    break;
                                PartToken pp = _tryParsePart(ttt1, false);
                                if (pp != null && pp.typ != PartToken.ItemType.PREFIX) 
                                    break;
                                if (ttt1.isValue3("ВСТУПАТЬ", "В", "СИЛУ")) {
                                    res.ignorable = true;
                                    break;
                                }
                                if (((ttt1.isValue3("ИЗЛОЖИТЬ", "В", "СЛЕДУЮЩЕЙ") || ttt1.isValue3("ПРИНЯТЬ", "В", "СЛЕДУЮЩЕЙ") || ttt1.isValue3("ИЗЛОЖИТЬ", "В", "НОВОЙ")) || ttt1.isValue3("ИЗЛОЖИТЬ", "В", "РЕДАКЦИИ") || ttt1.isValue3("В", "СЛЕДУЮЩЕЙ", "РЕДАКЦИИ")) || ttt1.isValue3("В", "РЕДАКЦИИ", "ПРИЛОЖЕНИЯ")) {
                                    izlogit = ttt1.getPrevious();
                                    break;
                                }
                                if (M_TERMS.tryParse(ttt1, com.pullenti.ner.core.TerminParseAttr.NO) != null) 
                                    break;
                                if (ttt1.isChar('(') && res.decree == null) {
                                    PartToken app = PartToken.tryAttach(ttt1.getNext(), null, false, false);
                                    if (app != null && app.typ == PartToken.ItemType.APPENDIX) {
                                        if ((app.getEndToken().getNext() != null && app.getEndToken().getNext().isValue("К", null) && (app.getEndToken().getNext().getNext() instanceof com.pullenti.ner.ReferentToken)) && (app.getEndToken().getNext().getNext().getReferent() instanceof com.pullenti.ner.decree.DecreeReferent)) {
                                            app.name = new com.pullenti.ner.MetaToken(li.get(li.size() - 1).getEndToken().getNext(), ttt1.getPrevious(), null);
                                            res.parts.add(app);
                                            res.decree = (com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(app.getEndToken().getNext().getNext().getReferent(), com.pullenti.ner.decree.DecreeReferent.class);
                                            ttt1 = app.getEndToken().getNext().getNext();
                                            if (ttt1.getNext() != null && ttt1.getNext().isChar(')')) 
                                                ttt1 = ttt1.getNext();
                                            res.setEndToken((tt = ttt1));
                                        }
                                    }
                                }
                            }
                            if (res.decree != null) 
                                continue;
                        }
                    }
                    else if (li.size() == 1 && li.get(0).getMorph() != null && li.get(0).getMorph().getCase().isInstrumental()) {
                        if (res.newParts == null) 
                            res.newParts = new java.util.ArrayList<PartToken>();
                        res.newParts.add(li.get(0));
                    }
                    else if (res.parts == null) 
                        res.parts = li;
                    tt = res.setEndToken(li.get(li.size() - 1).getEndToken());
                    continue;
                }
                if (tt.getMorph()._getClass().isNoun() && changeStack != null && changeStack.size() > 0) {
                    PartToken pa = _tryParsePart(tt, true);
                    if (pa != null && pa.typ == PartToken.ItemType.TABLEROW && tt.getNext() != null) {
                        if (tt.getNext().isCharOf(":") || com.pullenti.ner.core.BracketHelper.isBracket(tt.getNext(), true)) 
                            pa = null;
                    }
                    if (pa != null) {
                        if (changeStack.get(0).getStringValue(PartToken._getAttrNameByTyp(pa.typ)) != null) {
                            res.realPart = changeStack.get(0);
                            res.setEndToken(tt);
                            continue;
                        }
                    }
                }
                if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                    PartToken pa = _tryParsePart(tt, true);
                    if (pa != null && tt.isValue("СТРОКА", null) && falseTableRow) 
                        pa = null;
                    if (pa != null && pa.typ != PartToken.ItemType.PREFIX) {
                        if (res.newParts == null) 
                            res.newParts = new java.util.ArrayList<PartToken>();
                        res.newParts.add(pa);
                        res.setEndToken(pa.getEndToken());
                        continue;
                    }
                }
                if (tt.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) {
                    com.pullenti.ner.decree.DecreeKind ki = ((com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreeReferent.class)).getKind();
                    if (ki == com.pullenti.ner.decree.DecreeKind.PUBLISHER) 
                        continue;
                    if (tt.getMorph().getCase().isInstrumental()) {
                        if (tt.isNewlineBefore()) 
                            return null;
                    }
                    if (res.decree == null) 
                        res.decree = (com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreeReferent.class);
                    else if (((com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreeReferent.class)) != res.decree) {
                        if (res.addDecrees == null) 
                            res.addDecrees = new java.util.ArrayList<com.pullenti.ner.decree.DecreeReferent>();
                        res.addDecrees.add((com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(tt.getReferent(), com.pullenti.ner.decree.DecreeReferent.class));
                    }
                    res.setEndToken(tt);
                    res._skipDecreeDummy();
                    tt = res.getEndToken();
                    if (tt.getWhitespacesAfterCount() < 3) {
                        li = _tryParsePartList(tt.getNext());
                        if (li != null && !li.get(0).getMorph().getCase().isInstrumental()) {
                            if (res.parts == null) 
                                res.parts = li;
                            else 
                                com.pullenti.unisharp.Utils.addToArrayList(res.parts, li);
                            PartToken.sort(res.parts);
                            tt = res.setEndToken(li.get(li.size() - 1).getEndToken());
                        }
                    }
                    continue;
                }
                PartToken pt0 = _tryParsePart(tt, true);
                if (pt0 != null && (pt0.typ == PartToken.ItemType.APPENDIX) && pt0.typ != PartToken.ItemType.PREFIX) {
                    if (res.getBeginToken() == tt && pt0.isNewlineAfter()) 
                        return null;
                    tt = res.setEndToken(pt0.getEndToken());
                    res.partTyp = pt0.typ;
                    if (pt0.typ == PartToken.ItemType.APPENDIX && res.parts == null) {
                        res.parts = new java.util.ArrayList<PartToken>();
                        res.parts.add(pt0);
                    }
                    continue;
                }
                if (res.changeVal == null && !isInEdition) {
                    DecreeChangeToken res1 = null;
                    if (tt.isChar(':') && !com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt.getNext(), true, false)) 
                        res1 = null;
                    else if (tt.kit.level <= 1 && !tt.isChar('<')) {
                        tt.kit.level++;
                        res1 = tryAttach(tt, main, true, null, false, false, (res.newParts != null && res.newParts.size() == 1 ? res.newParts.get(0) : null), false);
                        tt.kit.level--;
                    }
                    if (res1 != null && res1.typ == DecreeChangeTokenTyp.VALUE && res1.changeVal != null) {
                        res.changeVal = res1.changeVal;
                        res.inTheEnd = res1.inTheEnd;
                        if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                            res.actKind = res1.actKind;
                        tt = res.setEndToken(res1.getEndToken());
                        if (tt.getNext() != null && tt.getNext().isValue("К", null)) 
                            tt = tt.getNext();
                        continue;
                    }
                    if (res1 != null && res1.actKind == com.pullenti.ner.decree.DecreeChangeKind.CONSIDER) 
                        izlogit = null;
                    if (tt.isValue("ПОСЛЕ", "ПІСЛЯ")) {
                        java.util.ArrayList<PartToken> pts0 = _tryParsePartList(tt.getNext());
                        com.pullenti.ner.Token _inPart = null;
                        if (pts0 == null && tt.getNext() != null) {
                            if ((tt.getNext().isValue("ЧАСТЬ", null) || tt.getNext().isValue("ПУНКТ", null) || tt.getNext().isValue("ПОДПУНКТ", null)) || tt.getNext().isValue("АБЗАЦ", null)) {
                                pts0 = _tryParsePartList(tt.getNext().getNext());
                                if (pts0 != null) 
                                    _inPart = tt.getNext();
                            }
                        }
                        if (pts0 != null && pts0.size() > 0 && pts0.get(0).typ != PartToken.ItemType.PREFIX) {
                            com.pullenti.ner.Token tt2 = pts0.get(pts0.size() - 1).getEndToken().getNext();
                            while (tt2 != null && ((tt2.isValue("НОВЫЙ", null) || tt2.isValue("ДОПОЛНИТЬ", null)))) {
                                tt2 = tt2.getNext();
                            }
                            PartToken pt2 = _tryParsePart(tt2, true);
                            if (pt2 != null && pt2.typ == pts0.get(0).typ) {
                                if (pt2.values.size() > 0) {
                                    res.parts = pts0;
                                    res.newParts = new java.util.ArrayList<PartToken>();
                                    res.newParts.add(pt2);
                                    res.actKind = com.pullenti.ner.decree.DecreeChangeKind.APPEND;
                                    tt = res.setEndToken(pt2.getEndToken());
                                    continue;
                                }
                                java.util.ArrayList<PartToken> pts1 = PartToken.tryAttachList(tt.getNext(), false, 40);
                                if (pts1 != null && pts1.get(0).addValue(1)) {
                                    res.parts = pts0;
                                    res.newParts = pts1;
                                    res.actKind = com.pullenti.ner.decree.DecreeChangeKind.APPEND;
                                    tt = res.setEndToken(pt2.getEndToken());
                                    continue;
                                }
                            }
                            if (res.parts == null) {
                                res.parts = pts0;
                                res.inPart = _inPart;
                            }
                            tt = res.setEndToken(pts0.get(pts0.size() - 1).getEndToken());
                            continue;
                        }
                    }{
                            pt0 = _tryParsePart(tt, true);
                            if ((pt0 != null && pt0.typ != PartToken.ItemType.PREFIX && res.newParts == null) && pt0.getMorph().getCase().isInstrumental()) {
                                res.newParts = new java.util.ArrayList<PartToken>();
                                res.newParts.add(pt0);
                                tt = res.setEndToken(pt0.getEndToken());
                                continue;
                            }
                        }
                    if (tt.isValue("ТЕКСТ", null) && tt.getPrevious() != null && tt.getPrevious().isValue("В", "У")) 
                        continue;
                    if (tt.isValue2("ПО", "ТЕКСТУ")) {
                        tt = tt.getNext();
                        continue;
                    }
                    if (tt.isValue("ИЗМЕНЕНИЕ", "ЗМІНА")) {
                        res.setEndToken(tt);
                        continue;
                    }
                    if (tt.isValue("ВМЕСТО", null)) {
                        res.setEndToken(tt);
                        continue;
                    }
                    if (tt.isValue("УКАЗАННЫЙ", null) || tt.isValue("ВЫШЕУКАЗАННЫЙ", null)) {
                        com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt, com.pullenti.ner.core.NounPhraseParseAttr.NO, 0, null);
                        if (npt != null) {
                            res.setEndToken((tt = npt.getEndToken()));
                            continue;
                        }
                    }
                    if (tt.isChar(':') && tt.getNext() != null && tt.getNext().getNext() != null) {
                        if ((tt.getNext() instanceof com.pullenti.ner.NumberToken) || (tt.getNext().getLengthChar() == 1)) {
                            if (tt.getNext().getNext().isCharOf(".)")) 
                                break;
                        }
                    }
                }
                if (tt != t && (res.parts != null) && res.decree == null) {
                    java.util.ArrayList<DecreeToken> dts = DecreeToken.tryAttachList(tt, null, 10, false);
                    if (dts != null && dts.size() > 0 && dts.get(0).typ == DecreeToken.ItemType.TYP) {
                        tt = res.setEndToken(dts.get(dts.size() - 1).getEndToken());
                        if (main != null && res.decree == null && res.decreeTok == null) {
                            com.pullenti.ner.decree.DecreeReferent dec = null;
                            for (com.pullenti.ner.Referent v : main.getOwners()) {
                                if (v instanceof com.pullenti.ner.decree.DecreeReferent) {
                                    dec = (com.pullenti.ner.decree.DecreeReferent)com.pullenti.unisharp.Utils.cast(v, com.pullenti.ner.decree.DecreeReferent.class);
                                    break;
                                }
                                else if (v instanceof com.pullenti.ner.decree.DecreePartReferent) {
                                    dec = ((com.pullenti.ner.decree.DecreePartReferent)com.pullenti.unisharp.Utils.cast(v, com.pullenti.ner.decree.DecreePartReferent.class)).getOwner();
                                    if (dec != null) 
                                        break;
                                }
                            }
                            if (dec != null && com.pullenti.unisharp.Utils.stringsEq(dec.getTyp0(), dts.get(0).value)) {
                                res.decree = dec;
                                res.decreeTok = dts.get(0);
                            }
                        }
                        if (!tt.isNewlineAfter()) {
                            li = _tryParsePartList(tt.getNext());
                            if (li != null && !li.get(0).getMorph().getCase().isInstrumental()) {
                                if (res.parts == null) 
                                    res.parts = li;
                                else 
                                    com.pullenti.unisharp.Utils.addToArrayList(res.parts, li);
                                PartToken.sort(res.parts);
                                tt = res.setEndToken(li.get(li.size() - 1).getEndToken());
                            }
                        }
                        continue;
                    }
                }
                if (tt == res.getBeginToken() && main != null) {
                    com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt, com.pullenti.ner.core.NounPhraseParseAttr.NO, 0, null);
                    if (npt != null) {
                        com.pullenti.ner.Token tt1 = npt.getEndToken().getNext();
                        if ((tt1 != null && ((tt1.isValue("ИЗЛОЖИТЬ", "ВИКЛАСТИ") || tt1.isValue("ПРИНЯТЬ", null))) && tt1.getNext() != null) && tt1.getNext().isValue("В", null)) {
                            PartToken pt = PartToken._new1058(tt, npt.getEndToken(), PartToken.ItemType.APPENDIX);
                            pt.name = npt;
                            res.parts = new java.util.ArrayList<PartToken>();
                            res.parts.add(pt);
                            res.setEndToken(pt.getEndToken());
                            break;
                        }
                    }
                }
                com.pullenti.ner.Token ttt = DecreeToken.isKeyword(tt, false);
                if (ttt != null && res.parts == null) {
                    com.pullenti.ner.Token ttt0 = ttt;
                    for (; ttt != null; ttt = ttt.getNext()) {
                        if (com.pullenti.ner.core.MiscHelper.canBeStartOfSentence(ttt)) 
                            break;
                        if (ttt.isChar('(') && ttt.getNext() != null && ttt.getNext().isValue("ПРИЛОЖЕНИЕ", "ДОДАТОК")) {
                            if (ttt.isNewlineBefore()) 
                                break;
                            com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(ttt, com.pullenti.ner.core.BracketParseAttr.NO, 100);
                            if (br == null) 
                                break;
                            PartToken pt = _tryParsePart(ttt.getNext(), true);
                            if (pt != null) {
                                res.parts = new java.util.ArrayList<PartToken>();
                                res.parts.add(pt);
                                tt = res.setEndToken(br.getEndToken());
                                break;
                            }
                        }
                        if (ttt.isValue3("В", "СЛЕДУЮЩЕЙ", "РЕДАКЦИИ") || ttt.isValue3("В", "РЕДАКЦИИ", "ПРИЛОЖЕНИЕ")) {
                            PartToken pt = new PartToken(tt, ttt.getPrevious());
                            pt.typ = PartToken.ItemType.CHAPTER;
                            pt.name = new com.pullenti.ner.MetaToken(tt, ttt.getPrevious(), null);
                            res.parts = new java.util.ArrayList<PartToken>();
                            res.parts.add(pt);
                            tt = res.setEndToken(ttt.getPrevious());
                            break;
                        }
                    }
                    if (res.parts != null) 
                        continue;
                    if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                        tt = res.setEndToken(ttt0);
                        continue;
                    }
                    tt = ttt0;
                    if (tt.isValue("НОРМА", null)) {
                        com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt.getNext(), com.pullenti.ner.core.NounPhraseParseAttr.NO, 0, null);
                        if (npt != null && npt.getMorph().getCase().isGenitive()) {
                            res.setEndToken((tt = npt.getEndToken()));
                            continue;
                        }
                    }
                    continue;
                }
                if (specRegime) {
                    res.setEndToken(tt);
                    continue;
                }
                if (tt.isCharOf(".-") && !tt.isNewlineAfter()) {
                    res.setEndToken(tt);
                    continue;
                }
                if (tt.isComma() && res.decree != null) 
                    continue;
                if (tt.isValue("ИЗЛОЖИТЬ", null) || tt.isValue("ПРИНЯТЬ", null)) {
                    if (res.parts == null) {
                        res.actKind = com.pullenti.ner.decree.DecreeChangeKind.NEW;
                        if (tt.getNext() != null && tt.getNext().getMorphClassInDictionary().isPronoun()) {
                            tt = tt.getNext();
                            res.hasAnafor = true;
                        }
                        res.setEndToken(tt);
                        continue;
                    }
                }
                if (tt.getNext() != null) {
                    com.pullenti.ner.Token tt2 = tt.getNext();
                    if (tt.isValue("СОГЛАСНО", null)) 
                        tt2 = tt;
                    if (tt2 != null && tt2.isValue2("В", "РЕДАКЦИИ")) 
                        tt2 = tt2.getNext().getNext();
                    if (tt2 != null && tt2.isValue3("В", "НОВОЙ", "РЕДАКЦИИ")) 
                        tt2 = tt2.getNext().getNext().getNext();
                    if (tt2 != null && ((tt2.isValue2("СОГЛАСНО", "ПРИЛОЖЕНИЮ") || ((tt2.isValue("ПРИЛОЖЕНИЯ", null) && ((res.actKind == com.pullenti.ner.decree.DecreeChangeKind.NEW || tt.isValue("ИЗЛОЖИТЬ", null)))))))) {
                        PartToken ppp = _tryParsePart(tt2.getNext(), true);
                        if (ppp == null) 
                            ppp = _tryParsePart(tt2, true);
                        if (ppp != null && ppp.typ == PartToken.ItemType.APPENDIX) {
                            res.appExtChanges = ppp;
                            if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) 
                                res.actKind = com.pullenti.ner.decree.DecreeChangeKind.NEW;
                            res.setEndToken((tt = ppp.getEndToken()));
                            if (tt.getNext() != null && tt.getNext().isValue("К", null)) {
                                com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt.getNext().getNext(), com.pullenti.ner.core.NounPhraseParseAttr.NO, 0, null);
                                if (npt != null) 
                                    res.setEndToken((tt = npt.getEndToken()));
                            }
                            else if (tt.isValue("К", null)) {
                                com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt.getNext(), com.pullenti.ner.core.NounPhraseParseAttr.NO, 0, null);
                                if (npt != null) 
                                    res.setEndToken((tt = npt.getEndToken()));
                            }
                            continue;
                        }
                    }
                }
                if (izlogit != null && izlogit.getEndChar() > tt.getEndChar()) {
                    res.setEndToken((tt = izlogit));
                    izlogit = null;
                    continue;
                }
                if (tt.isCommaAnd() && res.parts != null) {
                    li = _tryParsePartList(tt.getNext());
                    if (li != null && li.size() > 0 && li.get(0).typ != PartToken.ItemType.PREFIX) {
                        com.pullenti.ner.Token tt2 = li.get(li.size() - 1).getEndToken().getNext();
                        if (tt2 != null && (tt2.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) && res.decree != null) {
                        }
                        else {
                            res.parts.get(res.parts.size() - 1).delimAfter = true;
                            com.pullenti.unisharp.Utils.addToArrayList(res.parts, li);
                            res.setEndToken((tt = li.get(li.size() - 1).getEndToken()));
                            continue;
                        }
                    }
                }
                if (tt.isCommaAnd()) 
                    continue;
                if (tt.getPrevious() != null && tt.getPrevious().isValue("К", null) && res.parts != null) {
                    com.pullenti.ner.Token tt2 = DecreeToken.isKeyword(tt, false);
                    if (tt2 != null && tt2.getNext() != null) {
                        li = _tryParsePartList(tt2.getNext());
                        if (li != null) {
                            com.pullenti.unisharp.Utils.addToArrayList(res.parts, li);
                            tt = res.setEndToken(li.get(li.size() - 1).getEndToken());
                            continue;
                        }
                    }
                }
                if (tt.isChar('<')) {
                }
                com.pullenti.ner.core.NounPhraseToken npt1 = com.pullenti.ner.core.NounPhraseHelper.tryParse(tt, com.pullenti.ner.core.NounPhraseParseAttr.PARSEPREPOSITION, 0, null);
                if (npt1 != null) {
                    if ((npt1.getEndToken().isValue("ПРИОРИТЕТ", null) || npt1.getEndToken().isValue("СФЕРА", null) || npt1.getEndToken().isValue("РЕАЛИЗАЦИЯ", null)) || npt1.getEndToken().isValue("СПИСОК", null) || npt1.getEndToken().isValue("ВОПРОС", null)) {
                        res.setEndToken((tt = npt1.getEndToken()));
                        if (tt.getNext() != null && (tt.getNext().getReferent() instanceof com.pullenti.ner.decree.DecreeReferent)) 
                            res.setEndToken((tt = tt.getNext()));
                        if (com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(tt.getNext(), false, null, false)) 
                            res.setEndToken((tt = tt.getNext()));
                        continue;
                    }
                }
                if (tt.isTableControlChar()) 
                    continue;
                break;
            }
            if (res.decree != null && aboutChanges && res.isNewlineAfter()) {
                com.pullenti.ner.Token tt2 = res.getEndToken().getNext();
                if (tt2 != null && tt2.isValue3("В", "СООТВЕТСТВИИ", "С")) {
                    for (tt2 = tt2.getNext().getNext().getNext(); tt2 != null; tt2 = tt2.getNext()) {
                        if (tt2.isCommaAnd()) 
                            continue;
                        if (tt2.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) 
                            continue;
                        java.util.ArrayList<PartToken> li = _tryParsePartList(tt2);
                        if (li != null && li.size() > 0) {
                            tt2 = li.get(li.size() - 1).getEndToken();
                            continue;
                        }
                        if (tt2.isValue("ПРИКАЗЫВАЮ", null)) {
                            res.setEndToken(tt2);
                            res.hasChangeKeyword = true;
                            return res;
                        }
                    }
                }
            }
            if (((res.ignorable || res.parts != null || res.decree != null) || res.realPart != null || res.actKind != com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) || res.changeVal != null) {
                if (res.getEndToken().getNext() != null && res.getEndToken().getNext().isChar(':')) {
                    boolean nl = res.getEndToken().getNext().isNewlineAfter();
                    if (!nl) {
                        PartToken pl = _tryParsePart(res.getEndToken().getNext().getNext(), false);
                        if (pl != null) 
                            nl = true;
                    }
                    if (nl) {
                        res.typ = DecreeChangeTokenTyp.SINGLE;
                        res.setEndToken(res.getEndToken().getNext());
                    }
                }
                return res;
            }
            if (res.getBeginToken() == tt) {
                com.pullenti.ner.core.TerminToken tok1 = M_TERMS.tryParse(tt, com.pullenti.ner.core.TerminParseAttr.NO);
                if (tok1 != null) {
                }
                else if (tt.isValue("ПОСЛЕ", null)) {
                }
                else 
                    return null;
            }
            else 
                return null;
        }
        for (; tt != null; tt = tt.getNext()) {
            if (tt.isValue("В", null) && tt.getNext() != null && tt.getNext().getMorphClassInDictionary().isPronoun()) 
                tt = tt.getNext();
            else if (tt.isValue("СЛЕДУЮЩИЙ", null)) {
            }
            else 
                break;
        }
        if (tt == null) 
            return null;
        com.pullenti.ner.core.TerminToken tok = M_TERMS.tryParse(tt, com.pullenti.ner.core.TerminParseAttr.NO);
        if (tt.getMorph()._getClass().isAdjective() && (((tt instanceof com.pullenti.ner.NumberToken) || tt.isValue("ПОСЛЕДНИЙ", "ОСТАННІЙ") || tt.isValue("ПРЕДПОСЛЕДНИЙ", "ПЕРЕДОСТАННІЙ")))) {
            com.pullenti.ner.Token tt2 = tt.getNext();
            for (; tt2 != null; tt2 = tt2.getNext()) {
                if ((tt2 instanceof com.pullenti.ner.NumberToken) || tt2.isCommaAnd()) {
                }
                else 
                    break;
            }
            tok = M_TERMS.tryParse(tt2, com.pullenti.ner.core.TerminParseAttr.NO);
            if (tok != null && (tok.termin.tag instanceof com.pullenti.ner.decree.DecreeChangeValueKind)) {
            }
            else 
                tok = null;
        }
        boolean afterValue = false;
        if (tok == null && tt.isValue("ПОСЛЕ", null) && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt.getNext(), true, false)) {
            tok = new com.pullenti.ner.core.TerminToken(tt, tt);
            tok.termin = com.pullenti.ner.core.Termin._new96("СЛОВО", com.pullenti.ner.decree.DecreeChangeValueKind.WORDS);
            afterValue = true;
        }
        if (tok == null && tt.isValue2("ПОСЛЕ", "АБЗАЦА") && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt.getNext().getNext(), true, false)) {
            tok = new com.pullenti.ner.core.TerminToken(tt, tt.getNext());
            tok.termin = com.pullenti.ner.core.Termin._new96("СЛОВО", com.pullenti.ner.decree.DecreeChangeValueKind.WORDS);
            afterValue = true;
        }
        if (tok == null && tt.isValue("ПРЕДЛОЖЕНИЕ", null) && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt.getNext(), true, false)) 
            tok = com.pullenti.ner.core.TerminToken._new568(tt, tt, m_Words);
        if (tok == null && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt, true, false) && tt.getPrevious() != null) {
            if ((tt.getPrevious().isValue("ПРЕДЛОЖЕНИЕ", null) || (tt.getPrevious().getReferent() instanceof com.pullenti.ner.decree.DecreePartReferent) || tt.isNewlineBefore()) || tt.getPrevious().isCharOf(".)")) 
                tok = com.pullenti.ner.core.TerminToken._new568(tt.getPrevious(), tt.getPrevious(), m_Words);
        }
        if ((tok == null && tt.isValue("ПРЕДЛОЖЕНИЕ", null) && tt.getNext() != null) && tt.getNext().isChar(':') && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt.getNext().getNext(), true, false)) 
            tok = com.pullenti.ner.core.TerminToken._new568(tt, tt.getNext(), m_Words);
        if (tok == null && tt.isValue3("РАЗДЕЛ", "СЛЕДУЮЩЕГО", "СОДЕРЖАНИЯ")) 
            tok = com.pullenti.ner.core.TerminToken._new568(tt, tt.getNext().getNext(), m_Words);
        if (tok == null && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt, true, false) && tt.getPrevious() != null) {
            if (tt.getPrevious().isValue("ДОПОЛНИТЬ", null) || tt.getPrevious().isValue("ЗАМЕНИТЬ", null) || tt.getPrevious().isValue("ИСКЮЧИТЬ", null)) 
                tok = com.pullenti.ner.core.TerminToken._new568(tt.getPrevious(), tt.getPrevious(), m_Words);
        }
        if (tok != null) {
            if (tok.termin.tag instanceof com.pullenti.ner.decree.DecreeChangeKind) {
                res = _new1076(tt, tok.getEndToken(), DecreeChangeTokenTyp.ACTION, (com.pullenti.ner.decree.DecreeChangeKind)tok.termin.tag);
                if (((res.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND || res.actKind == com.pullenti.ner.decree.DecreeChangeKind.CONSIDER)) && tok.getEndToken().getNext() != null && tok.getEndToken().getNext().getMorph().getCase().isInstrumental()) {
                    com.pullenti.ner.Token tt4 = tok.getEndToken().getNext();
                    while (tt4 != null && ((tt4.isValue("СЛЕДУЮЩИЙ", null) || tt4.isValue("НОВЫЙ", null)))) {
                        tt4 = tt4.getNext();
                    }
                    PartToken pt = _tryParsePart(tt4, true);
                    if (pt != null && pt.typ != PartToken.ItemType.PREFIX) {
                        if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                            res.partTyp = pt.typ;
                            if (res.newParts == null) 
                                res.newParts = new java.util.ArrayList<PartToken>();
                            res.newParts.add(pt);
                        }
                        else if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.CONSIDER) {
                            res.changeVal = new com.pullenti.ner.decree.DecreeChangeValueReferent();
                            res.changeVal.setValue(pt.getSourceText());
                            PartToken pt2 = _tryParsePart(pt.getEndToken().getNext(), false);
                            if (pt2 != null && pt2.getMorph().getCase().isGenitive()) {
                                res.changeVal.setValue((pt.getSourceText() + " " + pt2.getSourceText()));
                                pt = pt2;
                            }
                        }
                        tt = res.setEndToken(pt.getEndToken());
                        if (tt.getNext() != null && tt.getNext().isAnd() && res.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                            pt = _tryParsePart(tt.getNext().getNext(), true);
                            if (pt != null) {
                                res.newParts.add(pt);
                                tt = res.setEndToken(pt.getEndToken());
                            }
                        }
                    }
                }
                if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.CONSIDER && (tok.getEndToken().getNext() instanceof com.pullenti.ner.NumberToken) && (tok.getWhitespacesAfterCount() < 3)) {
                    for (com.pullenti.ner.Token tt3 = res.getEndToken().getNext(); tt3 != null; tt3 = tt3.getNext()) {
                        if (tt3 instanceof com.pullenti.ner.NumberToken) {
                            res.setEndToken(tt3);
                            continue;
                        }
                        if (tt3.isCommaAnd()) 
                            continue;
                        PartToken pp = _tryParsePart(tt3, true);
                        if (pp != null && pp.getEndToken() == tt3) {
                            res.setEndToken(tt3);
                            continue;
                        }
                        break;
                    }
                    res.changeVal = new com.pullenti.ner.decree.DecreeChangeValueReferent();
                    res.changeVal.setValue(com.pullenti.ner.core.MiscHelper.getTextValue(tok.getEndToken().getNext(), res.getEndToken(), com.pullenti.ner.core.GetTextAttr.KEEPREGISTER));
                }
                if (res.getEndToken().getNext() != null && res.getEndToken().getNext().isValue("СООТВЕТСТВЕННО", null)) 
                    res.setEndToken(res.getEndToken().getNext());
                if (res.actKind == com.pullenti.ner.decree.DecreeChangeKind.REMOVE && (res.getWhitespacesAfterCount() < 3)) {
                    PartToken pp = PartToken.tryAttach(res.getEndToken().getNext(), null, true, false);
                    if (pp != null && pp.typ == PartToken.ItemType.SENTENCE) {
                        res.parts = new java.util.ArrayList<PartToken>();
                        res.parts.add(pp);
                        res.setEndToken(pp.getEndToken());
                    }
                }
                return res;
            }
            if (tok.termin.tag instanceof com.pullenti.ner.decree.DecreeChangeValueKind) {
                res = _new1048(tt, (tok.getEndChar() > tt.getBeginChar() ? tok.getEndToken() : tt), DecreeChangeTokenTyp.VALUE);
                res.changeVal = new com.pullenti.ner.decree.DecreeChangeValueReferent();
                res.changeVal.setKind((com.pullenti.ner.decree.DecreeChangeValueKind)tok.termin.tag);
                if (tt.getPrevious() != null && tt.getPrevious().isValue("В", null)) 
                    res.changeVal.isContent = true;
                if (afterValue) 
                    res.typ = DecreeChangeTokenTyp.AFTERVALUE;
                if (res.changeVal.getKind() == com.pullenti.ner.decree.DecreeChangeValueKind.WORDS && (tok.termin.tag2 instanceof String)) {
                    res.changeVal.setValue((String)com.pullenti.unisharp.Utils.cast(tok.termin.tag2, String.class));
                    res.changeVal.setBeginChar(tok.getBeginChar());
                    res.changeVal.setEndChar(tok.getEndChar());
                    return res;
                }
                tt = tok.getEndToken().getNext();
                if (tt == null) 
                    return null;
                if (tt != null && ((tt.isValue("ИЗЛОЖИТЬ", "ВИКЛАСТИ") || tt.isValue("ПРИНЯТЬ", null))) && res.actKind == com.pullenti.ner.decree.DecreeChangeKind.UNDEFINED) {
                    res.actKind = com.pullenti.ner.decree.DecreeChangeKind.NEW;
                    tt = tt.getNext();
                    if (tt != null && tt.isValue("В", null)) 
                        tt = tt.getNext();
                }
                if ((tt != null && ((tt.isValue("СЛЕДУЮЩИЙ", "НАСТУПНИЙ") || tt.isValue("ТАКОЙ", "ТАКИЙ"))) && tt.getNext() != null) && ((tt.getNext().isValue("СОДЕРЖАНИЕ", "ЗМІСТ") || tt.getNext().isValue("СОДЕРЖИМОЕ", "ВМІСТ") || tt.getNext().isValue("РЕДАКЦИЯ", "РЕДАКЦІЯ")))) 
                    tt = tt.getNext().getNext();
                else if (tt != null && tt.isValue("РЕДАКЦИЯ", "РЕДАКЦІЯ")) 
                    tt = tt.getNext();
                if (tt != null && tt.isChar(':')) 
                    tt = tt.getNext();
                if (tt != null) 
                    res.changeVal.setBeginChar(tt.getBeginChar());
                if (res.getBeginToken().isValue("СЛОВО", null) && (tt instanceof com.pullenti.ner.TextToken) && tt.getLengthChar() > 1) {
                    DecreeChangeToken _next = tryAttach(tt.getNext(), null, true, null, false, false, null, false);
                    if (_next != null) {
                        if (_next.actKind == com.pullenti.ner.decree.DecreeChangeKind.REMOVE || _next.actKind == com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE || _next.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                            res.changeVal.setValue(tt.getSourceText());
                            res.setEndToken(tt);
                            res.changeVal.setBeginChar(tt.getBeginChar());
                            res.changeVal.setEndChar(tt.getEndChar());
                            return res;
                        }
                    }
                }
                if (tt.isChar('<') && (tt.getNext() instanceof com.pullenti.ner.TextToken)) {
                    if (tt.getNext().chars.isLatinLetter() || tt.getNext().isChar('/')) 
                        return null;
                }
                if (tt.isChar('«') && tt.getNext() != null && tt.getNext().isChar('»')) {
                    res.changeVal.setValue("");
                    res.setEndToken(tt.getNext());
                    res.changeVal.setBeginChar(tt.getEndChar() + 1);
                    res.changeVal.setEndChar(tt.getNext().getBeginChar() - 1);
                    return res;
                }
                boolean canBeStart = false;
                if (com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt, true, true)) 
                    canBeStart = true;
                else if (com.pullenti.ner.core.BracketHelper.isBracket(tt, true) && !tt.isWhitespaceAfter()) 
                    canBeStart = true;
                else if ((tt instanceof com.pullenti.ner.MetaToken) && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(tt, com.pullenti.ner.MetaToken.class)).getBeginToken(), true, false)) 
                    canBeStart = true;
                else if (tt != null && tt.isNewlineBefore() && tt.isValue("ПРИЛОЖЕНИЕ", "ДОДАТОК")) {
                    if ((tt.getPrevious() != null && tt.getPrevious().isChar(':') && tt.getPrevious().getPrevious() != null) && tt.getPrevious().getPrevious().isValue("РЕДАКЦИЯ", "РЕДАКЦІЯ")) 
                        canBeStart = true;
                }
                else if (t.getPrevious() != null && ((t.getPrevious().isValue("ДОПОЛНИТЬ", null) || t.getPrevious().isValue("ЗАМЕНИТЬ", null) || t.getPrevious().isValue("ПОСЛЕ", null)))) 
                    canBeStart = true;
                else if (tt.isChar((char)0x1E)) 
                    canBeStart = true;
                else if (tt.getNext() != null) {
                    int cou = 0;
                    for (com.pullenti.ner.Token tt2 = tt.getNext(); tt2 != null && (cou < 10); tt2 = tt2.getNext(),cou++) {
                        if (tt2.isChar('»')) {
                            res.changeVal.setValue((new com.pullenti.ner.MetaToken(tt, tt2.getPrevious(), null)).getSourceText());
                            res.setEndToken(tt2);
                            res.changeVal.setEndChar(tt2.getBeginChar() - 1);
                            return res;
                        }
                        else if ((tt2.isValue("ИСКЛЮЧИТЬ", null) || tt2.isValue("ДОПОЛНИТЬ", null) || tt2.isValue("ЗАМЕНИТЬ", null)) || tt2.isValue("УДАЛИТЬ", null)) 
                            canBeStart = true;
                    }
                }
                if (canBeStart) {
                    com.pullenti.ner.Token ttt = tt;
                    if (com.pullenti.ner.core.BracketHelper.isBracket(tt, true)) {
                        ttt = tt.getNext();
                        res.changeVal.setBeginChar(ttt.getBeginChar());
                        if (tt.isChar('<') && ttt.isChar('<') && ttt.getNext() != null) {
                            ttt = ttt.getNext();
                            res.changeVal.setBeginChar(ttt.getEndChar() + 1);
                        }
                    }
                    else if ((tt.isTableControlChar() && tt.getNext() != null && com.pullenti.ner.core.BracketHelper.isBracket(tt.getNext(), true)) && tt.getNext().getNext() != null) {
                        ttt = tt.getNext().getNext();
                        res.changeVal.setBeginChar(ttt.getBeginChar());
                    }
                    else {
                        com.pullenti.ner.Token img = com.pullenti.ner.core.MiscHelper.checkImage(tt);
                        if (img != null && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(img.getNext(), true, false) && img.getNext().getNext() != null) {
                            ttt = img.getNext().getNext();
                            res.changeVal.setBeginChar(ttt.getBeginChar());
                        }
                    }
                    com.pullenti.ner.Token ttt00 = ttt;
                    for (; ttt != null; ttt = ttt.getNext()) {
                        boolean stop = false;
                        if (ttt.isCharOf(".;") && !com.pullenti.ner.core.BracketHelper.isBracket(ttt.getNext(), true)) {
                            stop = ttt.isNewlineAfter();
                            if ((!stop && ttt.getNext() != null && ttt.getNext().isTableControlChar()) && ttt.getNext().isNewlineAfter()) 
                                stop = true;
                            if (!stop && com.pullenti.ner.core.BracketHelper.isBracket(ttt.getPrevious(), false)) {
                                com.pullenti.ner.core.ComplexNumToken num = com.pullenti.ner.core.ComplexNumToken.tryParse(ttt.getNext(), null, false, false);
                                if (num != null) 
                                    stop = true;
                            }
                            if (stop) 
                                ttt = ttt.getPrevious();
                        }
                        else if (ttt.isComma() && ttt.isNewlineAfter()) {
                            if (_canBeChangeToken(ttt.getNext(), 0, true, true)) 
                                stop = true;
                        }
                        if (ttt.tag instanceof com.pullenti.ner.NumberToken) {
                            if (((com.pullenti.ner.NumberToken)com.pullenti.unisharp.Utils.cast(ttt.tag, com.pullenti.ner.NumberToken.class)).getBeginChar() < res.getBeginChar()) 
                                stop = true;
                        }
                        if (ttt.isChar((char)0x1E) && !stop) {
                            java.util.ArrayList<com.pullenti.ner.core.TableRowToken> rows = com.pullenti.ner.core.TableHelper.tryParseRows(ttt, 0, true, false);
                            if (rows != null) {
                                for (com.pullenti.ner.Token tt3 = ttt.getNext(); tt3 != null && tt3.getEndChar() <= rows.get(rows.size() - 1).getEndChar(); tt3 = tt3.getNext()) {
                                    if (tt3.tag instanceof com.pullenti.ner.NumberToken) {
                                        if (((com.pullenti.ner.NumberToken)com.pullenti.unisharp.Utils.cast(tt3.tag, com.pullenti.ner.NumberToken.class)).getBeginChar() < res.getBeginChar()) {
                                            stop = true;
                                            ttt = tt3.getPrevious();
                                            if (ttt.isTableControlChar() && ttt.getPrevious() != null) 
                                                ttt = ttt.getPrevious();
                                            break;
                                        }
                                    }
                                }
                                if (!stop) {
                                    for (int jj = rows.size() - 1; jj > 0; jj--) {
                                        if (_canBeChangeToken(rows.get(jj).getBeginToken(), 0, false, false)) {
                                            for(int jjj = jj + rows.size() - jj - 1, mmm = jj; jjj >= mmm; jjj--) rows.remove(jjj);
                                            stop = true;
                                            break;
                                        }
                                    }
                                    ttt = rows.get(rows.size() - 1).getEndToken();
                                    if (ttt.isNewlineAfter() || stop) 
                                        stop = true;
                                    else 
                                        continue;
                                }
                            }
                        }
                        if (ttt.getNext() != null) {
                            if (ttt.getNext().isValue2("ДОПОЛНИТЬ", "СЛОВАМИ")) 
                                stop = true;
                            else if (ttt.getNext().isValue("УДАЛИТЬ", null) || ttt.getNext().isValue("ИСКЛЮЧИТЬ", null)) {
                                if (ttt.getNext().getNext() == null || tt.getNext().isNewlineAfter()) 
                                    stop = true;
                                else if (ttt.getNext().getNext().isCharOf(";")) 
                                    stop = true;
                                else if (ttt.getNext().getNext().isCharOf(".,") && tt.getNext().getNext().isNewlineAfter()) 
                                    stop = true;
                            }
                        }
                        com.pullenti.ner.Token img = com.pullenti.ner.core.MiscHelper.checkImage(ttt);
                        if (img != null) 
                            ttt = img;
                        if (!stop && ((ttt.isNewlineBefore() || ttt.getPrevious().isChar((char)0x1F)))) {
                            if (_canBeChangeToken(ttt, 0, true, true)) {
                                ttt = ttt.getPrevious();
                                stop = true;
                            }
                        }
                        if (!stop) {
                            java.util.ArrayList<PartToken> li = _tryParsePartList(ttt);
                            if (li != null) {
                                com.pullenti.ner.Token ttt11 = li.get(li.size() - 1).getEndToken();
                                if (_checkEndBracket(ttt11)) {
                                    if (ttt11.getPrevious().getBeginChar() > ttt.getBeginChar()) 
                                        ttt = ttt11.getPrevious();
                                }
                                else 
                                    ttt = ttt11;
                                continue;
                            }
                        }
                        if (ttt.isNewlineAfter()) {
                            img = com.pullenti.ner.core.MiscHelper.checkImage(ttt.getNext());
                            if (img != null) {
                                if (img.isNewlineAfter() || com.pullenti.ner.core.BracketHelper.isBracket(img.getNext(), true)) {
                                    ttt = img;
                                    continue;
                                }
                            }
                            if (_canBeChangeToken(ttt.getNext(), 0, true, true)) 
                                stop = true;
                        }
                        if (_checkEndBracket(ttt) || ttt.isChar(']')) {
                            if (_canBeChangeToken(ttt.getNext(), 0, false, false)) 
                                stop = true;
                        }
                        else if (!stop) 
                            continue;
                        if (ttt.getNext() == null || stop) {
                        }
                        else if (ttt.isNewlineAfter()) {
                            if (ttt.getNext().isCommaAnd() && ttt.getNext().getNext() != null) {
                                if (com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(ttt.getNext().getNext(), true, false) || (ttt.getNext().getNext().getReferent() instanceof com.pullenti.ner.decree.DecreeReferent)) 
                                    continue;
                            }
                            com.pullenti.ner.instrument.internal.InstrToken1 li = com.pullenti.ner.instrument.internal.InstrToken1.parse(ttt.getNext(), true, null, 0, null, false, 0, false, false);
                            if (li != null && li.getEndToken().isCharOf(";.,") && com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(li.getEndToken().getPrevious(), true, null, false)) 
                                continue;
                            if (li != null && com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(li.getEndToken(), true, null, false)) 
                                continue;
                        }
                        else if (ttt.getNext().isValue("СООТВЕТСТВЕННО", null) || ttt.getNext().isValue2("В", "СООТВЕТСТВУЮЩИЙ")) {
                        }
                        else if (ttt.getNext().isCharOf(".;") && ((ttt.getNext().isNewlineAfter() || tryAttach(ttt.getNext().getNext(), main, false, changeStack, true, false, null, false) != null || _tryParsePart(ttt.getNext().getNext(), false) != null))) {
                        }
                        else if (ttt.getNext().isCommaAnd() && tryAttach(ttt.getNext().getNext(), main, false, changeStack, true, false, null, false) != null) {
                        }
                        else if (ttt.getNext().isComma() && ttt.getNext().getNext() != null && ttt.getNext().getNext().isValue("А", null)) {
                            com.pullenti.ner.core.ConjunctionToken conj = com.pullenti.ner.core.ConjunctionHelper.tryParse(ttt.getNext().getNext());
                            if (conj != null && tryAttach(conj.getEndToken().getNext(), main, false, changeStack, true, false, null, false) != null) {
                            }
                            else 
                                continue;
                        }
                        else if (tryAttach(ttt.getNext(), main, false, changeStack, true, false, null, false) != null || M_TERMS.tryParse(ttt.getNext(), com.pullenti.ner.core.TerminParseAttr.NO) != null) {
                        }
                        else if ((ttt.getNext().isValue("ДОБАВИТЬ", null) || ttt.getNext().isValue("ДОПОЛНИТЬ", null) || ttt.getNext().isValue("ЗАМЕНИТЬ", null)) || ttt.getNext().isValue("УДАЛИТЬ", null)) {
                        }
                        else 
                            continue;
                        com.pullenti.ner.Token ttt1 = ttt;
                        if (com.pullenti.ner.core.BracketHelper.isBracket(ttt, true) && !ttt.isCharOf("]>")) {
                            if (_findPrevBracket(ttt, tt.getNext()) == null) 
                                ttt1 = ttt.getPrevious();
                        }
                        else if (ttt.isCharOf(";.") && com.pullenti.ner.core.BracketHelper.isBracket(ttt.getPrevious(), true) && !ttt.getPrevious().isCharOf("]>")) {
                            if (_findPrevBracket(ttt.getPrevious(), tt.getNext()) == null) 
                                ttt1 = ttt.getPrevious().getPrevious();
                        }
                        com.pullenti.ner.Token ttt0 = ttt00;
                        if (ttt0.getBeginChar() > ttt1.getBeginChar()) {
                        }
                        if (com.pullenti.ner.core.BracketHelper.isBracket(tt, true) && tt.getNext().getBeginChar() <= ttt1.getBeginChar()) {
                            ttt0 = tt.getNext();
                            if (ttt0 != null && tt.isChar('<')) {
                                if (ttt0.isChar('<')) 
                                    ttt0 = ttt0.getNext();
                                else if (!tt.isWhitespaceAfter() && (ttt0 instanceof com.pullenti.ner.TextToken) && ttt0.chars.isLatinLetter()) 
                                    continue;
                            }
                        }
                        else if ((tt.isTableControlChar() && tt.getNext() != null && com.pullenti.ner.core.BracketHelper.isBracket(tt.getNext(), true)) && tt.getNext().getNext() != null) 
                            ttt0 = tt.getNext().getNext();
                        if ((ttt1.isChar('>') && ttt1.getPrevious() != null && ttt1.getPrevious().isChar('>')) && ttt1.getPrevious().getPrevious() != null && ttt1.getPrevious().getPrevious().getBeginChar() >= ttt0.getBeginChar()) 
                            ttt1 = ttt1.getPrevious().getPrevious();
                        if (ttt0.getBeginChar() > ttt1.getBeginChar()) 
                            return null;
                        String val = (new com.pullenti.ner.MetaToken(ttt0, ttt1, null)).getSourceText();
                        res.setEndToken(ttt);
                        res.changeVal.setEndChar(ttt1.getEndChar());
                        if ((ttt == tt && (ttt instanceof com.pullenti.ner.MetaToken) && com.pullenti.ner.core.BracketHelper.isBracket(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(ttt, com.pullenti.ner.MetaToken.class)).getBeginToken(), true)) && com.pullenti.ner.core.BracketHelper.isBracket(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(ttt, com.pullenti.ner.MetaToken.class)).getEndToken(), true)) {
                            val = val.substring(1, 1 + val.length() - 2);
                            res.changeVal.setEndChar(res.changeVal.getEndChar() - 1);
                        }
                        else if ((tt instanceof com.pullenti.ner.MetaToken) && com.pullenti.ner.core.BracketHelper.isBracket(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(tt, com.pullenti.ner.MetaToken.class)).getBeginToken(), true)) 
                            val = val.substring(1, 1 + val.length() - 1);
                        res.changeVal.setValue(val);
                        if (com.pullenti.ner.core.BracketHelper.isBracket(res.getEndToken().getNext(), true)) {
                            if (res.getEndToken().getNext().isNewlineAfter() || res.getEndToken().getNext().getNext().isCharOf(";.")) 
                                res.setEndToken(res.getEndToken().getNext());
                        }
                        if (res.getEndToken().getNext() != null) {
                            if (res.getEndToken().getNext().isValue("СООТВЕТСТВЕННО", null)) 
                                res.setEndToken(res.getEndToken().getNext());
                        }
                        if (com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt, true, false) && com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(ttt, true, null, false)) {
                            java.util.ArrayList<String> vals = null;
                            java.util.HashMap<Integer, Integer> bes = null;
                            com.pullenti.ner.Token pp;
                            com.pullenti.ner.Token pp0 = tt.getNext();
                            for (pp = tt.getNext(); pp != null && pp.getEndChar() <= ttt.getEndChar(); pp = pp.getNext()) {
                                java.util.ArrayList<PartToken> li = _tryParsePartList(pp);
                                if (li != null) {
                                    pp = li.get(li.size() - 1).getEndToken();
                                    continue;
                                }
                                if (((com.pullenti.ner.core.BracketHelper.canBeEndOfSequence(pp, false, null, false) && pp.getNext() != null && pp.getNext().isCommaAnd()) && !pp.isChar('>') && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(pp.getNext().getNext(), true, false)) && (pp.getNext().getNext().getEndChar() < ttt.getBeginChar()) && !pp.getNext().getNext().isChar('<')) {
                                    if (vals == null) 
                                        vals = new java.util.ArrayList<String>();
                                    if (bes == null) 
                                        bes = new java.util.HashMap<Integer, Integer>();
                                    vals.add((new com.pullenti.ner.MetaToken(pp0, pp.getPrevious(), null)).getSourceText());
                                    bes.put(pp0.getBeginChar(), pp.getPrevious().getEndChar());
                                    pp = pp.getNext().getNext();
                                    pp0 = pp.getNext();
                                }
                            }
                            if (vals != null) {
                                if (pp0 != null && (pp0.getEndChar() < ttt.getBeginChar())) {
                                    vals.add((new com.pullenti.ner.MetaToken(pp0, ttt.getPrevious(), null)).getSourceText());
                                    bes.put(pp0.getBeginChar(), ttt.getPrevious().getEndChar());
                                }
                                com.pullenti.ner.decree.DecreeChangeValueKind ki = res.changeVal.getKind();
                                res.changeVal = new com.pullenti.ner.decree.DecreeChangeValueReferent();
                                res.changeVal.setKind(ki);
                                int i = 0;
                                for (java.util.Map.Entry<Integer, Integer> kp : bes.entrySet()) {
                                    res.changeVal.addSlot(com.pullenti.ner.decree.DecreeChangeReferent.ATTR_VALUE, vals.get(i), false, 0);
                                    i++;
                                    res.changeVal.addSlot("BEGIN", kp.getKey().toString(), false, 0);
                                    res.changeVal.addSlot("END", kp.getValue().toString(), false, 0);
                                }
                            }
                        }
                        break;
                    }
                    if (canBeStart) {
                        if (res.changeVal.getValue() == null) {
                            if (tt.kit.level <= 1 && !tt.isChar('<')) {
                                tt.kit.level++;
                                DecreeChangeToken txt = _tryParseText(tt, abzacRegime, false, null);
                                tt.kit.level--;
                                if (txt != null) {
                                    txt.setBeginToken(res.getBeginToken());
                                    txt.changeVal.isContent = res.changeVal.isContent;
                                    res = txt;
                                }
                            }
                        }
                        else if (res.isNewlineAfter() || ((res.getEndToken().getNext() != null && res.getEndToken().getNext().isCharOf(";,.") && res.getEndToken().getNext().isNewlineAfter()))) {
                            int crlf = 0;
                            for (com.pullenti.ner.Token t3 = tt; t3 != null && (t3.getEndChar() < res.getEndChar()); t3 = t3.getNext()) {
                                if (t3.isNewlineAfter()) 
                                    crlf++;
                            }
                            if (res.getLengthChar() > 200 || crlf > 1) {
                                if (tt.kit.level <= 1 && !tt.isChar('<')) {
                                    tt.kit.level++;
                                    DecreeChangeToken txt = _tryParseText(tt, abzacRegime, false, null);
                                    tt.kit.level--;
                                    if (txt != null && ((res.changeVal.getEndChar() + 3) < txt.getEndChar())) {
                                        txt.setBeginToken(res.getBeginToken());
                                        txt.changeVal.isContent = res.changeVal.isContent;
                                        res = txt;
                                    }
                                }
                            }
                        }
                    }
                    if (res.changeVal.getValue() == null) 
                        return null;
                    if (res.changeVal.getKind() == com.pullenti.ner.decree.DecreeChangeValueKind.WORDS) {
                        tok = M_TERMS.tryParse(res.getEndToken().getNext(), com.pullenti.ner.core.TerminParseAttr.NO);
                        if (tok != null && (tok.termin.tag instanceof com.pullenti.ner.decree.DecreeChangeValueKind) && ((com.pullenti.ner.decree.DecreeChangeValueKind)tok.termin.tag) == com.pullenti.ner.decree.DecreeChangeValueKind.ROBUSTWORDS) {
                            res.changeVal.setKind(com.pullenti.ner.decree.DecreeChangeValueKind.ROBUSTWORDS);
                            res.setEndToken(tok.getEndToken());
                            if (res.getEndToken().getNext() != null) {
                                if (res.getEndToken().getNext().isValue2("И", "ЧИСЛЕ") || res.getEndToken().getNext().isValue2("И", "ПАДЕЖЕ")) 
                                    res.setEndToken(res.getEndToken().getNext().getNext());
                            }
                        }
                    }
                }
                if (res.changeVal.getValue() == null) 
                    return null;
                return res;
            }
        }
        int isNexChange = 0;
        if (t != null && t.isValue("В", "У") && t.getNext() != null) {
            t = t.getNext();
            if (t.isValue("РЕДАКЦИЯ", "РЕДАКЦІЯ") && t.getNext() != null) {
                isNexChange = 1;
                t = t.getNext();
            }
        }
        if (((t.isValue("СЛЕДУЮЩИЙ", "НАСТУПНИЙ") || tt.isValue("ТАКОЙ", "ТАКИЙ"))) && t.getNext() != null && ((t.getNext().isValue("СОДЕРЖАНИЕ", "ЗМІСТ") || t.getNext().isValue("СОДЕРЖИМОЕ", "ВМІСТ") || t.getNext().isValue("РЕДАКЦИЯ", "РЕДАКЦІЯ")))) {
            isNexChange = 2;
            t = t.getNext().getNext();
        }
        if (t == null) 
            return null;
        if (t.getNext() != null && ((t.isChar(':') || ((t.isChar('.') && com.pullenti.ner.core.BracketHelper.isBracket(t.getNext(), true)))))) {
            if (t.getPrevious() != null && t.getPrevious().isValue("РЕДАКЦИЯ", "РЕДАКЦІЯ")) 
                isNexChange++;
            tt = (t = t.getNext());
            if (isNexChange > 0) 
                isNexChange++;
        }
        else if (t.getPrevious() != null && t.getPrevious().isValue("РЕДАКЦИЯ", null) && ((com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(t, true, false) || t.isNewlineBefore()))) 
            isNexChange++;
        if ((t == tt && t.getPrevious() != null && t.getPrevious().isChar(':')) && com.pullenti.ner.core.BracketHelper.isBracket(t, false) && !t.isChar('(')) 
            isNexChange = 1;
        com.pullenti.ner.Token xx1 = t;
        while (xx1 != null && xx1.isTableControlChar()) {
            xx1 = xx1.getNext();
        }
        if (((isNexChange > 0 && (((com.pullenti.ner.core.MiscHelper.checkImage(xx1) != null || com.pullenti.ner.core.BracketHelper.isBracket(xx1, true) || abzacRegime) || com.pullenti.ner.core.ComplexNumToken.tryParse(xx1, null, false, false) != null)))) || ((isNexChange > 1 && t.isValue("ПРИЛОЖЕНИЕ", "ДОДАТОК")))) {
            if (isInEdition) {
                res = _new1048(t, xx1, DecreeChangeTokenTyp.VALUE);
                res.changeVal = com.pullenti.ner.decree.DecreeChangeValueReferent._new1049(com.pullenti.ner.decree.DecreeChangeValueKind.TEXT);
                return res;
            }
            res = _tryParseText(xx1, abzacRegime, false, defPart);
            if (res == null) 
                return null;
            res.setBeginToken(t);
            return res;
        }
        if (tt.isValue("ПОСЛЕ", "ПІСЛЯ")) {
            java.util.ArrayList<PartToken> pt = _tryParsePartList(tt.getNext());
            if (pt != null && pt.size() > 0) {
                com.pullenti.ner.Token tt2 = pt.get(pt.size() - 1).getEndToken().getNext();
                while (tt2 != null && ((tt2.isValue("НОВЫЙ", null) || tt2.isValue("ДОПОЛНИТЬ", null)))) {
                    tt2 = tt2.getNext();
                }
                PartToken pt2 = _tryParsePart(tt2, true);
                if (pt2 != null && pt2.typ == pt.get(0).typ) {
                    if (pt2.values.size() > 0) {
                        res = new DecreeChangeToken(tt, pt2.getEndToken());
                        res.parts = pt;
                        res.actKind = com.pullenti.ner.decree.DecreeChangeKind.APPEND;
                        res.newParts = new java.util.ArrayList<PartToken>();
                        res.newParts.add(pt2);
                        return res;
                    }
                    java.util.ArrayList<PartToken> pt1 = _tryParsePartList(tt.getNext());
                    if (pt1.get(0).addValue(1)) {
                        res = new DecreeChangeToken(tt, pt2.getEndToken());
                        res.parts = pt;
                        res.actKind = com.pullenti.ner.decree.DecreeChangeKind.APPEND;
                        res.newParts = new java.util.ArrayList<PartToken>();
                        com.pullenti.unisharp.Utils.addToArrayList(res.newParts, pt1);
                        return res;
                    }
                }
            }
            res = tryAttach(tt.getNext(), null, false, null, false, false, null, false);
            if (res != null && res.typ == DecreeChangeTokenTyp.VALUE) {
                res.typ = DecreeChangeTokenTyp.AFTERVALUE;
                res.setBeginToken(tt);
                return res;
            }
        }
        if (tt.isValue2("В", "КОНЦЕ")) {
            java.util.ArrayList<PartToken> pts = _tryParsePartList(tt.getNext().getNext());
            if (pts != null && pts.size() > 0) {
                res = tryAttach(pts.get(pts.size() - 1).getEndToken().getNext(), null, false, null, false, false, null, false);
                if (res != null && res.parts == null) {
                    res.setBeginToken(tt);
                    res.inTheEnd = true;
                    if (res.changeVal != null) 
                        res.changeVal.addSlot("POSITION", "end", false, 0);
                    res.parts = pts;
                    return res;
                }
            }
        }
        return null;
    }

    public static boolean _canBeChangeToken(com.pullenti.ner.Token t, int lev, boolean strict, boolean inBrackets) {
        if (lev > 10) 
            return false;
        com.pullenti.ner.Token t0 = t;
        for (; t != null; t = t.getNext()) {
            com.pullenti.ner.Token tt = com.pullenti.ner.core.MiscHelper.checkImage(t);
            if (tt != null) {
                t = tt;
                continue;
            }
            if (!t.isCharOf(";.,") && !t.isTableControlChar()) {
                if (((t instanceof com.pullenti.ner.TextToken) && t.getLengthChar() == 1 && !t.chars.isLetter()) && !com.pullenti.ner.core.BracketHelper.isBracket(t, false)) 
                    continue;
                break;
            }
        }
        if (t == null) 
            return false;
        if (M_TERMS.tryParse(t, com.pullenti.ner.core.TerminParseAttr.NO) != null) {
            if ((t.isValue("СЧИТАТЬСЯ", null) || t.isValue("ПРИНЯТЬ", null) || t.isValue("ДАТА", null)) || t.isValue("КОД", null) || t.isValue("ЧИСЛО", null)) 
                return false;
            if (t.isValue("СЧИТАТЬ", null)) {
                if (PartToken.tryAttach(t.getNext(), null, false, false) != null) 
                    return true;
            }
            if (t.getMorphClassInDictionary().isAdjective()) 
                return false;
            com.pullenti.ner.core.TerminToken tok = M_TERMS.tryParse(t, com.pullenti.ner.core.TerminParseAttr.NO);
            if (strict) {
                if (M_TERMS.tryParse(tok.getEndToken().getNext(), com.pullenti.ner.core.TerminParseAttr.NO) != null) 
                    return true;
                if (_tryParsePart(tok.getEndToken().getNext(), true) != null) 
                    return true;
            }
            if (tok.termin.tag instanceof com.pullenti.ner.decree.DecreeChangeValueKind) {
                com.pullenti.ner.decree.DecreeChangeValueKind ki = (com.pullenti.ner.decree.DecreeChangeValueKind)tok.termin.tag;
                if (ki == com.pullenti.ner.decree.DecreeChangeValueKind.DEFINITION || ((((ki == com.pullenti.ner.decree.DecreeChangeValueKind.WORDS || ki == com.pullenti.ner.decree.DecreeChangeValueKind.NUMBERS)) && tok.termin.tag2 == null))) {
                    if (com.pullenti.ner.core.BracketHelper.isBracket(tok.getEndToken().getNext(), true)) 
                        return true;
                    if (tok.getEndToken().getNext() instanceof com.pullenti.ner.MetaToken) {
                        if (com.pullenti.ner.core.BracketHelper.isBracket(((com.pullenti.ner.MetaToken)com.pullenti.unisharp.Utils.cast(tok.getEndToken().getNext(), com.pullenti.ner.MetaToken.class)).getBeginToken(), true)) 
                            return true;
                    }
                    return false;
                }
            }
            if (tok.termin.tag instanceof com.pullenti.ner.decree.DecreeChangeKind) 
                return true;
            if (strict) 
                return false;
            return true;
        }
        if ((t instanceof com.pullenti.ner.TextToken) && com.pullenti.unisharp.Utils.stringsEq(((com.pullenti.ner.TextToken)com.pullenti.unisharp.Utils.cast(t, com.pullenti.ner.TextToken.class)).term, "СТ")) 
            return false;
        java.util.ArrayList<PartToken> ps = _tryParsePartList(t);
        com.pullenti.ner.Token tt1 = null;
        if (ps != null && ps.size() > 0) {
            if ((ps.size() == 1 && strict && ps.get(0).typ == PartToken.ItemType.FREETEXT) && ps.get(0).tag == null) 
                ps = null;
            else 
                tt1 = ps.get(ps.size() - 1).getEndToken().getNext();
        }
        if (tt1 != null) {
            int doubt = 0;
            for (; tt1 != null; tt1 = tt1.getNext()) {
                if (tt1.isTableControlChar() || tt1.isCharOf(".,")) 
                    continue;
                if (tt1.isChar('»') && inBrackets) 
                    break;
                if (tt1.isChar('«')) 
                    inBrackets = false;
                if (tt1.isChar(':') && tt1.isNewlineAfter()) {
                    if (_canBeChangeToken(tt1.getNext(), lev + 1, doubt > 0, false)) 
                        return true;
                }
                java.util.ArrayList<PartToken> ps2 = _tryParsePartList(tt1);
                if (ps2 != null && ps2.size() > 0) {
                    tt1 = ps2.get(ps2.size() - 1).getEndToken();
                    continue;
                }
                if (tt1.getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) {
                    doubt = 0;
                    continue;
                }
                if (tt1 != null && tt1.isChar('(')) {
                    com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(tt1, com.pullenti.ner.core.BracketParseAttr.NO, 100);
                    if (br != null) {
                        tt1 = br.getEndToken();
                        continue;
                    }
                }
                if (tt1 == null) 
                    return false;
                com.pullenti.ner.core.TerminToken tok = M_TERMS.tryParse(tt1, com.pullenti.ner.core.TerminParseAttr.NO);
                if (tok != null) {
                    if (tok.termin.tag instanceof com.pullenti.ner.decree.DecreeChangeKind) {
                        if (!tt1.getMorphClassInDictionary().isAdjective()) 
                            return true;
                    }
                    if (tt1.isValue("СЛОВО", null) && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(tt1.getNext(), true, false)) {
                        if (doubt == 0) 
                            return true;
                        com.pullenti.ner.core.BracketSequenceToken br = com.pullenti.ner.core.BracketHelper.tryParse(tt1.getNext(), com.pullenti.ner.core.BracketParseAttr.NO, 100);
                        if (br != null) {
                            tt1 = br.getEndToken();
                            continue;
                        }
                    }
                }
                if (tt1.isValue("ПОСЛЕ", null) && doubt == 0) 
                    return true;
                if (tt1.isNewlineBefore()) 
                    break;
                if (tt1.isValue("УТВЕРЖДЕННЫЙ", null)) 
                    break;
                if (tt1.getLengthChar() > 1) 
                    doubt++;
            }
            return false;
        }
        com.pullenti.ner.core.ComplexNumToken num = com.pullenti.ner.core.ComplexNumToken.tryParse(t, null, false, false);
        if (num != null) {
            if (num.getSuffix() == null) 
                return false;
            if (_canBeChangeToken(num.getEndToken().getNext(), lev + 1, false, false)) 
                return true;
            com.pullenti.ner.Token tt2 = num.getEndToken().getNext();
            boolean vv = false;
            if (tt2 != null && ((tt2.isValue("В", null) || tt2.isValue("B", null)))) {
                tt2 = tt2.getNext();
                vv = true;
            }
            if (DecreeToken.isKeyword(tt2, false) != null) {
                com.pullenti.ner.instrument.internal.InstrToken1 line = com.pullenti.ner.instrument.internal.InstrToken1.parse(t, true, null, 0, null, false, 0, false, false);
                if (line != null && line.getEndToken().isChar(':')) {
                    if (line.getEndToken().getPrevious().isValue("СОДЕРЖАНИЕ", null) || line.getEndToken().getPrevious().isValue("РЕДАКЦИЯ", null)) 
                        return true;
                    if (vv) {
                        if (line.getEndToken().getPrevious().getReferent() instanceof com.pullenti.ner.decree.DecreeReferent) 
                            return true;
                        DecreeToken dt = DecreeToken.tryAttach(line.getEndToken().getPrevious(), null, false);
                        if (dt != null && dt.typ == DecreeToken.ItemType.TYP) 
                            return true;
                    }
                }
            }
            if (((tt2 != null && tt2.isValue("УСТАНОВИТЬ", null) && tt2.getNext() != null) && tt2.getNext().isComma() && tt2.getNext().getNext() != null) && tt2.getNext().getNext().isValue("ЧТО", null)) 
                tt2 = tt2.getNext().getNext().getNext();
            if (tt2 == null) 
                return false;
            if (tt2.isValue2("КОНТРОЛЬ", "ЗА")) 
                return true;
            if (tt2.isValue("НАСТОЯЩИЙ", null)) {
                DecreeToken dt = DecreeToken.tryAttach(tt2.getNext(), null, false);
                if (dt != null && dt.typ == DecreeToken.ItemType.TYP) {
                    if (dt.getEndToken().getNext() != null && dt.getEndToken().getNext().isValue("ВСТУПАТЬ", null)) 
                        return true;
                }
            }
            if (strict) 
                return false;
        }
        else if (t.isValue("В", null) || t.isValue("B", null)) {
            if (strict && !t.isNewlineBefore()) 
                return false;
            if (_canBeChangeToken(t.getNext(), lev + 1, false, false)) 
                return true;
        }
        else if (t.isValue("ПОСЛЕ", null)) {
            if (_canBeChangeToken(t.getNext(), lev + 1, false, false)) 
                return true;
        }
        if (t0.isNewlineBefore() && num != null && lev == 0) {
            com.pullenti.ner.instrument.internal.InstrToken1 line = com.pullenti.ner.instrument.internal.InstrToken1.parse(t, true, null, 0, null, false, 0, false, false);
            if (line != null) 
                return _canBeChangeToken(line.getEndToken().getNext(), lev + 1, strict, false);
        }
        if (t.isValue("ВНЕСТИ", null) || t.isValue2("СЛЕДУЮЩИЕ", "ИЗМЕНЕНИЯ")) 
            return true;
        if (t.isValue("ИЗМЕНЕНИЕ", null)) {
            if (t.getPrevious() != null && t.getPrevious().isValue("ВНЕСЕНИЕ", null)) {
            }
            else if (t.getNext() != null && t.getNext().isValue("СОГЛАСНО", null)) 
                return true;
        }
        return false;
    }

    private static java.util.ArrayList<DecreeChangeToken> tryAttachList(com.pullenti.ner.Token t, boolean ignoreNewline, boolean abzacRegime) {
        if (t == null) 
            return null;
        if (t.isNewlineBefore() && !ignoreNewline) {
            if (com.pullenti.ner.core.ComplexNumToken.tryParse(t, null, false, false) != null || t.isValue("В", null) || t.isValue("B", null)) 
                return null;
            if (!_canBeChangeToken(t, 0, false, false)) 
                return null;
        }
        DecreeChangeToken d0 = tryAttach(t, null, false, null, false, abzacRegime, null, false);
        if (d0 == null && t.isTableControlChar()) {
            for (com.pullenti.ner.Token tt = t.getNext(); tt != null; tt = tt.getNext()) {
                if (!tt.isTableControlChar()) {
                    d0 = tryAttach(tt, null, false, null, false, abzacRegime, null, false);
                    break;
                }
            }
        }
        if ((d0 == null && t.getPrevious() != null && t.getPrevious().isChar(':')) && com.pullenti.ner.core.BracketHelper.isBracket(t, true)) 
            d0 = _tryParseText(t, abzacRegime, false, null);
        if (d0 == null || d0.typ == DecreeChangeTokenTyp.UNDEFINED) {
            int cou = 0;
            for (com.pullenti.ner.Token tt2 = t.getNext(); tt2 != null && (cou < 20); tt2 = tt2.getNext(),cou++) {
                if (tt2.isNewlineBefore() || com.pullenti.ner.core.MiscHelper.canBeStartOfSentence(tt2)) 
                    break;
                DecreeChangeToken d1 = tryAttach(tt2, null, false, null, false, false, null, false);
                if (d1 != null && d1.typ == DecreeChangeTokenTyp.ACTION && d1.actKind == com.pullenti.ner.decree.DecreeChangeKind.EXPIRE) {
                    d0 = d1;
                    break;
                }
            }
            if (d0 == null) 
                return null;
        }
        java.util.ArrayList<DecreeChangeToken> res = new java.util.ArrayList<DecreeChangeToken>();
        res.add(d0);
        t = d0.getEndToken().getNext();
        if (d0.getIndentRegime()) 
            abzacRegime = true;
        else if (d0.newParts != null) 
            abzacRegime = false;
        for (; t != null; t = t.getNext()) {
            DecreeChangeToken d = tryAttach(t, null, false, null, false, abzacRegime, null, false);
            if (t.isNewlineBefore()) {
                if ((t.isValue("ПРИЛОЖЕНИЕ", "ДОДАТОК") && t.getPrevious() != null && t.getPrevious().isChar(':')) && t.getPrevious().getPrevious() != null && t.getPrevious().getPrevious().isValue("РЕДАКЦИЯ", "РЕДАКЦІЯ")) {
                }
                else if (t.getPrevious() != null && ((t.getPrevious().isChar(':') || t.getPrevious().isValue("РЕДАКЦИЯ", "РЕДАКЦІЯ"))) && ((com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(t, true, false) || t.isChar((char)0x1E)))) 
                    d = null;
                else if (d0.actKind == com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE && t.isValue("НА", null)) {
                }
                else if (d != null && d.changeVal != null) {
                }
                else if ((d != null && d.typ == DecreeChangeTokenTyp.STARTSINGLE && d.changeVal != null) && ((t.getMorph().getCase().isInstrumental() || ((d.parts == null && d.decree == null))))) {
                    com.pullenti.ner.core.ComplexNumToken num = com.pullenti.ner.core.ComplexNumToken.tryParse(t, null, false, false);
                    if (num != null) 
                        break;
                    d.typ = DecreeChangeTokenTyp.VALUE;
                }
                else if (t.isAnd()) {
                }
                else 
                    break;
            }
            if (d == null && t.isChar('.') && !t.isNewlineAfter()) {
                if (res.get(res.size() - 1).changeVal != null) 
                    break;
                continue;
            }
            if (d == null && t.getPrevious().isValue("НА", null) && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(t, true, false)) 
                d = _tryParseText(t, abzacRegime, false, null);
            if (d == null && t.isValue("ПОЗИЦИЯ", null) && ((res.get(res.size() - 1).actKind == com.pullenti.ner.decree.DecreeChangeKind.EXPIRE || res.get(res.size() - 1).actKind == com.pullenti.ner.decree.DecreeChangeKind.REMOVE))) {
                com.pullenti.ner.Token tt2 = t.getNext();
                if (tt2 != null && tt2.isChar(':')) 
                    tt2 = tt2.getNext();
                d = _tryParseText(tt2, abzacRegime, false, null);
                if (d != null) 
                    res.get(res.size() - 1).actKind = com.pullenti.ner.decree.DecreeChangeKind.REMOVE;
            }
            if (d == null && t.isAnd()) {
                DecreeChangeToken dd = tryAttach(t.getNext(), null, false, null, false, abzacRegime, null, false);
                if (dd != null && dd.typ == DecreeChangeTokenTyp.AFTERVALUE && res.get(res.size() - 1).typ == dd.typ) 
                    d = dd;
                else if (dd == null && com.pullenti.ner.core.BracketHelper.isBracket(t.getNext(), true)) 
                    d = _tryParseText(t.getNext(), abzacRegime, false, null);
            }
            if (d == null) {
                if (t.isValue("НОВЫЙ", "НОВИЙ")) 
                    continue;
                if (t.isValue("НА", null)) 
                    continue;
                if (t.isValue2("ПО", "ТЕКСТУ")) {
                    t = t.getNext();
                    continue;
                }
                if (t.isValue2("К", "ОН")) {
                    t = t.getNext();
                    continue;
                }
                if (t.isValue("ЭТОТ", null)) {
                    com.pullenti.ner.core.NounPhraseToken npt = com.pullenti.ner.core.NounPhraseHelper.tryParse(t, com.pullenti.ner.core.NounPhraseParseAttr.PARSEPRONOUNS, 0, null);
                    if (npt != null) {
                        t = npt.getEndToken();
                        continue;
                    }
                }
                if (t.isChar(':') && ((!t.isNewlineAfter() || res.get(res.size() - 1).actKind == com.pullenti.ner.decree.DecreeChangeKind.NEW))) 
                    continue;
                if ((t instanceof com.pullenti.ner.TextToken) && com.pullenti.unisharp.Utils.stringsEq(((com.pullenti.ner.TextToken)com.pullenti.unisharp.Utils.cast(t, com.pullenti.ner.TextToken.class)).term, "ТЕКСТОМ")) 
                    continue;
                java.util.ArrayList<PartToken> pts = _tryParsePartList(t);
                if (pts != null) {
                    if (M_TERMS.tryParse(pts.get(pts.size() - 1).getEndToken().getNext(), com.pullenti.ner.core.TerminParseAttr.NO) != null) {
                    }
                    else {
                        d = _new1048(pts.get(0).getBeginToken(), pts.get(pts.size() - 1).getEndToken(), DecreeChangeTokenTyp.UNDEFINED);
                        if (t.getPrevious() != null && t.getPrevious().isValue("НОВЫЙ", "НОВИЙ")) 
                            d.newParts = pts;
                        else 
                            d.parts = pts;
                    }
                }
                else {
                    PartToken pt = _tryParsePart(t, true);
                    if (pt != null) {
                        d = new DecreeChangeToken(pt.getBeginToken(), pt.getEndToken());
                        if (t.getPrevious() != null && t.getPrevious().isValue("НОВЫЙ", "НОВИЙ")) {
                            d.newParts = new java.util.ArrayList<PartToken>();
                            d.newParts.add(pt);
                        }
                        else 
                            d.partTyp = pt.typ;
                    }
                }
            }
            if (d == null && res.get(res.size() - 1).actKind == com.pullenti.ner.decree.DecreeChangeKind.NEW) {
                if (com.pullenti.ner.core.BracketHelper.isBracket(t, true)) 
                    d = _tryParseText(t, abzacRegime, false, null);
                else if (((t.getPrevious().isChar(':') || t.getPrevious().isValue("РЕДАКЦИЯ", null))) && (t instanceof com.pullenti.ner.NumberToken)) {
                    com.pullenti.ner.core.ComplexNumToken nn = com.pullenti.ner.core.ComplexNumToken.tryParse(t, null, false, false);
                    if (nn != null && com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(nn.getEndToken().getNext(), true, false)) {
                        d = _tryParseText(nn.getEndToken().getNext(), abzacRegime, false, null);
                        if (d != null && d.changeVal != null) {
                            d.setBeginToken(t);
                            d.changeVal.setValue((nn.getSourceText() + " " + d.changeVal.getValue()));
                        }
                    }
                }
                else if (t.isChar((char)0x1E)) {
                    java.util.ArrayList<com.pullenti.ner.core.TableRowToken> rows = com.pullenti.ner.core.TableHelper.tryParseRows(t, 0, true, false);
                    if (rows != null) {
                        d = _new1048(t, rows.get(rows.size() - 1).getEndToken(), DecreeChangeTokenTyp.VALUE);
                        d.changeVal = com.pullenti.ner.decree.DecreeChangeValueReferent._new1049(com.pullenti.ner.decree.DecreeChangeValueKind.TEXT);
                        d.changeVal.setBeginChar(t.getBeginChar());
                        d.changeVal.setEndChar(d.getEndChar());
                        d.changeVal.setValue(d.getSourceText());
                        if (d.getEndToken().getNext() != null && com.pullenti.ner.core.BracketHelper.isBracket(d.getEndToken().getNext(), true)) {
                            if (d.getEndToken().getNext().isNewlineAfter()) 
                                d.setEndToken(d.getEndToken().getNext());
                            else if (d.getEndToken().getNext().getNext().isCharOf(".;")) 
                                d.setEndToken(d.getEndToken().getNext().getNext());
                        }
                    }
                }
            }
            if (d == null && res.get(res.size() - 1).actKind == com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE) {
                if (t.isValue("НА", null) && t.getNext() != null) 
                    t = t.getNext();
                if (com.pullenti.ner.core.BracketHelper.canBeStartOfSequence(t, true, false)) 
                    d = _tryParseText(t, abzacRegime, false, null);
            }
            if (d == null && t.isComma() && res.get(res.size() - 1).typ == DecreeChangeTokenTyp.AFTERVALUE) {
                d = tryAttach(t.getNext(), null, false, null, false, abzacRegime, null, false);
                if (d != null && d.actKind == com.pullenti.ner.decree.DecreeChangeKind.APPEND) {
                }
                else 
                    d = null;
            }
            if (d == null) 
                break;
            if (d.typ == DecreeChangeTokenTyp.STARTMULTU || d.typ == DecreeChangeTokenTyp.SINGLE) 
                break;
            if (d.typ == DecreeChangeTokenTyp.STARTSINGLE) {
                if (d.decree == null && d.changeVal != null && d.parts == null) 
                    d.typ = DecreeChangeTokenTyp.VALUE;
                else 
                    break;
            }
            res.add(d);
            t = d.getEndToken();
            if (d.getIndentRegime()) 
                abzacRegime = true;
            else if (d.newParts != null) 
                abzacRegime = false;
        }
        if ((res.size() == 1 && res.get(0).actKind == com.pullenti.ner.decree.DecreeChangeKind.CONSIDER && res.get(0).getEndToken().getNext() != null) && res.get(0).getEndToken().getNext().isCommaAnd() && res.get(0).changeVal == null) {
            java.util.ArrayList<DecreeChangeToken> _next = tryAttachList(res.get(0).getEndToken().getNext().getNext(), true, abzacRegime);
            if ((_next != null && _next.size() == 2 && _next.get(0).actKind == com.pullenti.ner.decree.DecreeChangeKind.NEW) && _next.get(1).typ == DecreeChangeTokenTyp.VALUE) 
                return _next;
        }
        return res;
    }

    public static com.pullenti.ner.core.TerminCollection M_TERMS;

    private static com.pullenti.ner.core.Termin m_Words;

    public static void initialize() {
        if (M_TERMS != null) 
            return;
        M_TERMS = new com.pullenti.ner.core.TerminCollection();
        com.pullenti.ner.core.Termin t;
        t = com.pullenti.ner.core.Termin._new96("ИЗЛОЖИТЬ В СЛЕДУЮЩЕЙ РЕДАКЦИИ", com.pullenti.ner.decree.DecreeChangeKind.NEW);
        t.addVariant("ПРИНЯТЬ В СЛЕДУЮЩЕЙ РЕДАКЦИИ", false);
        t.addVariant("ИЗЛОЖИВ ЕГО В СЛЕДУЮЩЕЙ РЕДАКЦИИ", false);
        t.addVariant("ИЗЛОЖИТЬ В РЕДАКЦИИ", false);
        t.addVariant("ИЗЛОЖИТЬ", false);
        t.addVariant("ПРИНЯТЬ", false);
        t.addVariant("ИЗЛОЖИТЬ В НОВОЙ РЕДАКЦИИ", false);
        t.addVariant("ЧИТАТЬ В СЛЕДУЮЩЕЙ РЕДАКЦИИ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new510("ВИКЛАСТИ В НАСТУПНІЙ РЕДАКЦІЇ", com.pullenti.morph.MorphLang.UA, com.pullenti.ner.decree.DecreeChangeKind.NEW);
        t.addVariant("ВИКЛАВШИ В ТАКІЙ РЕДАКЦІЇ", false);
        t.addVariant("ВИКЛАВШИ ЙОГО В НАСТУПНІЙ РЕДАКЦІЇ", false);
        t.addVariant("ВИКЛАСТИ В РЕДАКЦІЇ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("ПРИЗНАТЬ УТРАТИВШИМ СИЛУ", com.pullenti.ner.decree.DecreeChangeKind.EXPIRE);
        t.addVariant("СЧИТАТЬ УТРАТИВШИМ СИЛУ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new510("ВИЗНАТИ таким, що ВТРАТИВ ЧИННІСТЬ", com.pullenti.morph.MorphLang.UA, com.pullenti.ner.decree.DecreeChangeKind.EXPIRE);
        t.addVariant("ВВАЖАТИ таким, що ВТРАТИВ ЧИННІСТЬ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("ИСКЛЮЧИТЬ", com.pullenti.ner.decree.DecreeChangeKind.REMOVE);
        t.addVariant("ИСКЛЮЧИВ ИЗ НЕГО", false);
        t.addVariant("УДАЛИТЬ", false);
        t.addVariant("УДАЛИВ ИЗ НЕГО", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new510("ВИКЛЮЧИТИ", com.pullenti.morph.MorphLang.UA, com.pullenti.ner.decree.DecreeChangeKind.REMOVE);
        t.addVariant("ВИКЛЮЧИВШИ З НЬОГО", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("ПРИОСТАНОВИТЬ ДЕЙСТВИЕ", com.pullenti.ner.decree.DecreeChangeKind.SUSPEND);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("СЧИТАТЬ", com.pullenti.ner.decree.DecreeChangeKind.CONSIDER);
        t.addVariant("СЧИТАТЬ СООТВЕТСТВЕННО", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new510("ВВАЖАТИ", com.pullenti.morph.MorphLang.UA, com.pullenti.ner.decree.DecreeChangeKind.CONSIDER);
        t.addVariant("ВВАЖАТИ ВІДПОВІДНО", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("ЗАМЕНИТЬ", com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE);
        t.addVariant("ЗАМЕНИВ В НЕМ", false);
        t.addVariant("ИСКЛЮЧИТЬ ЗАМЕНИТЬ", false);
        t.addVariant("ИСКЛЮЧИТЬ И ЗАМЕНИТЬ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new510("ЗАМІНИТИ", com.pullenti.morph.MorphLang.UA, com.pullenti.ner.decree.DecreeChangeKind.EXCHANGE);
        t.addVariant("ЗАМІНИВШИ В НЬОМУ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("ДОПОЛНИТЬ", com.pullenti.ner.decree.DecreeChangeKind.APPEND);
        t.addVariant("ДОПОЛНИВ ЕГО", false);
        t.addVariant("ДОБАВИТЬ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new510("ДОПОВНИТИ", com.pullenti.morph.MorphLang.UA, com.pullenti.ner.decree.DecreeChangeKind.APPEND);
        t.addVariant("ДОПОВНИВШИ ЙОГО", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("СЛОВО", com.pullenti.ner.decree.DecreeChangeValueKind.WORDS);
        m_Words = t;
        t.addVariant("АББРЕВИАТУРА", false);
        t.addVariant("АБРЕВІАТУРА", false);
        t.addVariant("ЗНАК СНОСКИ", false);
        t.addVariant("ПЕРЕМЕННАЯ", false);
        t.addVariant("МНОЖИТЕЛЬ", false);
        t.addVariant("КОД", false);
        t.addVariant("СОЮЗ", false);
        t.addVariant("ТЕКСТ СЛЕДУЮЩЕГО СОДЕРЖАНИЯ", false);
        t.addVariant("ДАТА", false);
        t.addVariant("СТРОКА", false);
        t.addVariant("СЛЕДУЮЩЕГОСОДЕРЖАНИЯ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("ОПРЕДЕЛЕНИЕ", com.pullenti.ner.decree.DecreeChangeValueKind.DEFINITION);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new98("ТОЧКА С ЗАПЯТОЙ", com.pullenti.ner.decree.DecreeChangeValueKind.WORDS, ";");
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new98("ТОЧКА", com.pullenti.ner.decree.DecreeChangeValueKind.WORDS, ".");
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new98("ВОПРОСИТЕЛЬНЫЙ ЗНАК", com.pullenti.ner.decree.DecreeChangeValueKind.WORDS, "?");
        t.addVariant("ЗНАК ВОПРОСА", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new98("ВОСКЛИЦАТЕЛЬНЫЙ ЗНАК", com.pullenti.ner.decree.DecreeChangeValueKind.WORDS, "!");
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("ЦИФРА", com.pullenti.ner.decree.DecreeChangeValueKind.NUMBERS);
        t.addVariant("ЧИСЛО", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("БЛОК", com.pullenti.ner.decree.DecreeChangeValueKind.BLOCK);
        t.addVariant("БЛОК СО СЛОВАМИ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new510("БЛОК", com.pullenti.morph.MorphLang.UA, com.pullenti.ner.decree.DecreeChangeValueKind.BLOCK);
        t.addVariant("БЛОК ЗІ СЛОВАМИ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new96("В СООТВЕТСТВУЮЩИХ ЧИСЛЕ И ПАДЕЖЕ", com.pullenti.ner.decree.DecreeChangeValueKind.ROBUSTWORDS);
        t.addVariant("В СООТВЕТСТВУЮЩЕМ ПАДЕЖЕ", false);
        t.addVariant("В СООТВЕТСТВУЮЩЕМ ПАДЕЖЕ И ЧИСЛЕ", false);
        t.addVariant("В СООТВЕТСТВУЮЩЕМ ЧИСЛЕ", false);
        M_TERMS.add(t);
        t = com.pullenti.ner.core.Termin._new510("У ВІДПОВІДНОМУ ЧИСЛІ ТА ВІДМІНКУ", com.pullenti.morph.MorphLang.UA, com.pullenti.ner.decree.DecreeChangeValueKind.ROBUSTWORDS);
        t.addVariant("У ВІДПОВІДНОМУ ВІДМІНКУ", false);
        t.addVariant("У ВІДПОВІДНОМУ ЧИСЛІ", false);
        M_TERMS.add(t);
    }

    public static DecreeChangeToken _new1048(com.pullenti.ner.Token _arg1, com.pullenti.ner.Token _arg2, DecreeChangeTokenTyp _arg3) {
        DecreeChangeToken res = new DecreeChangeToken(_arg1, _arg2);
        res.typ = _arg3;
        return res;
    }

    public static DecreeChangeToken _new1063(com.pullenti.ner.Token _arg1, com.pullenti.ner.Token _arg2, DecreeChangeTokenTyp _arg3, boolean _arg4, com.pullenti.ner.core.ComplexNumToken _arg5) {
        DecreeChangeToken res = new DecreeChangeToken(_arg1, _arg2);
        res.typ = _arg3;
        res.hasChangeKeyword = _arg4;
        res.numBefore = _arg5;
        return res;
    }

    public static DecreeChangeToken _new1064(com.pullenti.ner.Token _arg1, com.pullenti.ner.Token _arg2, DecreeChangeTokenTyp _arg3, com.pullenti.ner.decree.DecreeChangeKind _arg4, com.pullenti.ner.core.ComplexNumToken _arg5) {
        DecreeChangeToken res = new DecreeChangeToken(_arg1, _arg2);
        res.typ = _arg3;
        res.actKind = _arg4;
        res.numBefore = _arg5;
        return res;
    }

    public static DecreeChangeToken _new1066(com.pullenti.ner.Token _arg1, com.pullenti.ner.Token _arg2, DecreeChangeTokenTyp _arg3, com.pullenti.ner.core.ComplexNumToken _arg4) {
        DecreeChangeToken res = new DecreeChangeToken(_arg1, _arg2);
        res.typ = _arg3;
        res.numBefore = _arg4;
        return res;
    }

    public static DecreeChangeToken _new1076(com.pullenti.ner.Token _arg1, com.pullenti.ner.Token _arg2, DecreeChangeTokenTyp _arg3, com.pullenti.ner.decree.DecreeChangeKind _arg4) {
        DecreeChangeToken res = new DecreeChangeToken(_arg1, _arg2);
        res.typ = _arg3;
        res.actKind = _arg4;
        return res;
    }
    public DecreeChangeToken() {
        super();
    }
}
