Exemplo n.º 1
0
        private void Parse(State state, Range rng)
        {
            Console.WriteLine($"Start parse from {rng.Start}");
            var lss = 0;

            contextChar = '\0';
            var len = Editor.Buffer.Document.Lines.Count;

            for (var i = rng.Start.Line; i < len; i++)
            {
                var line = Lines[i];
                Editor.AffinityManager.ClearAssociations(i);
                var grm = App.Ext.Grammars().GetGrammar(state.GrammarKey);
                Styles.ClearStyles(i);
                var col  = 0;
                var sect = grm.Sections[lss];
                sect.Sections.ResetSelective();
                state = ParseLine(sect, ref col, i);
                grm   = App.Ext.Grammars().GetGrammar(state.GrammarKey);
                var st = (sect.Id != 0 || sect.GrammarKey != Editor.Buffer.GrammarKey) && sect.Multiline ? 2 : StateToBit(state);

                while (col <= line.Length)
                {
                    grm  = App.Ext.Grammars().GetGrammar(state.GrammarKey);
                    sect = grm.Sections[state.SectionId];
                    sect.Sections.ResetSelective();
                    state = ParseLine(sect, ref col, i);
                    st    = st == 2 ? 1 : StateToBit(state);
                }

                line.State = st > 1 ? 1 : st;
                lss        = state.SectionId;

                if (i >= rng.End.Line && st == 0 && (i == len - 1 || Lines[i + 1].State == 0))
                {
                    break;
                }
            }
        }