コード例 #1
0
ファイル: Scope.cs プロジェクト: svermeulen/iris
        internal static Scope BuildBackgroundScope(SetOfSyntaxItems topItems)
        {
            Scope backgroundScope = new Scope();

            backgroundScope.SyntaxItem = BackgroundItem.Instance;
            backgroundScope.ActiveSyntaxItems = topItems;

            backgroundScope.PosStart = 0;
            backgroundScope.PosAfter = int.MaxValue;
            backgroundScope.PosHighlightStart = 0;
            backgroundScope.PosAfterHighlight = int.MaxValue;

            return backgroundScope;
        }
コード例 #2
0
ファイル: Scanner.cs プロジェクト: svermeulen/iris
 internal void StartNextGroup(Scope nextGroupScope)
 {
     this.m_scopeStack.Add(nextGroupScope);
 }
コード例 #3
0
ファイル: Scanner.cs プロジェクト: svermeulen/iris
        internal void PushScope(Scope newScope)
        {
            SyntaxItem newTopItem = newScope.SyntaxItem;

            bool previouslyExtending = this.TopScope.Extend;
            bool previouslyWithinKeepEnd = this.TopScope.IsWithinKeepEnd;

            if (this.TopScope.SyntaxItem is NextGroup) {
                this.m_scopeStack[this.m_scopeStack.Count - 1] = newScope;
            } else {
                this.m_scopeStack.Add(newScope);
            }

            this.TopScope.Extend |= previouslyExtending && !previouslyWithinKeepEnd;
            this.TopScope.IsWithinKeepEnd |= !this.TopScope.Extend && previouslyWithinKeepEnd;

            if (!newTopItem.IsTransparent || newScope.IsRegionWithMatchGroupEnd) {
                this.BuildHighlightModes(newScope.PosHighlightStart);
            }
        }
コード例 #4
0
ファイル: Region.cs プロジェクト: svermeulen/iris
        private Scope BuildNewScope(Scope currentTopScope)
        {
            Scope scope = new Scope();

            scope.PosAfter = int.MaxValue;
            scope.PosAfterHighlight = int.MaxValue;

            scope.SyntaxItem = this;
            scope.AsRegion = this;
            scope.Extend = this.Extend;
            scope.IsWithinKeepEnd = this.KeepEnd;

            scope.ActiveSyntaxItems = this.GetMatchableItems(currentTopScope);

            scope.IsRegion = true;
            scope.AsRegion = this;
            scope.IsRegionWithMatchGroupEnd = false;

            for (int i = 0; i < this.m_endPatterns.Count; i++) {
                if (this.m_endPatterns[i].HasHighlightMode) {
                    scope.IsRegionWithMatchGroupEnd = true;
                    break;
                }
            }

            return scope;
        }
コード例 #5
0
ファイル: Region.cs プロジェクト: svermeulen/iris
        internal bool TrySkips(Scanner s, Scope scope, int posMatchAt)
        {
            if (posMatchAt <= scope.PosEndSkippedUntil || scope.PosAfter != int.MaxValue) {
                return false;
            }

            MatchResult result = new MatchResult();
            result.MatchType = MatchType.RegionSkip;

            for (int i = 0; i < this.m_skipPatterns.Count; i++) {
                this.m_skipPatterns[i].Match(s, posMatchAt, scope.ExternalCaptures, ref result);

                if (result.Success) {
                    if (result.PosAfterMatch <= s.PosWindowEnd) {
                        if ('\n' == s[result.PosAfterMatch]) {
                            result.PosAfterMatch++;
                        }
                    }

                    scope.PosEndSkippedUntil = result.PosAfterMatch - 1;
                    return true;
                }
            }

            return false;
        }
コード例 #6
0
ファイル: Region.cs プロジェクト: svermeulen/iris
        internal bool TryEnding(Scanner s, Scope scope)
        {
            int posMatchAt = s.Reader.PosCurrent;

            if (posMatchAt <= scope.PosEndSkippedUntil || scope.PosAfter != int.MaxValue) {
                return false;
            }

            if (this.TrySkips(s, scope, posMatchAt)) {
                return false;
            }

            MatchResult result = new MatchResult();
            result.MatchType = MatchType.RegionEnd;

            for (int i = 0; i < this.m_endPatterns.Count; i++) {
                this.m_endPatterns[i].Match(s, posMatchAt, scope.ExternalCaptures, ref result);

                if (result.Success) {
                    scope.PosAfter = result.PosAfterMatch;

                    bool hasHighlightMode = this.m_endPatterns[i].HasHighlightMode;

                    if (0 == result.PosAfterRegion && hasHighlightMode) {
                        result.PosAfterRegion = result.PosMatchStart;
                    }

                    if (0 == result.PosAfterHighlight) {
                        result.PosAfterHighlight = result.PosAfterMatch;
                    }

                    if (hasHighlightMode && result.PosAfterRegion < result.PosAfterHighlight) {
                        s.SendMode(this.m_endPatterns[i].HighlightMode, result.PosAfterRegion);
                    }

                    if (result.PosAfterHighlight < result.PosAfterMatch) {
                        s.BuildHighlightModes(result.PosAfterHighlight);
                    }

                    return true;
                }
            }

            return false;
        }
コード例 #7
0
ファイル: ContainerItem.cs プロジェクト: svermeulen/iris
        internal SetOfSyntaxItems GetMatchableItems(Scope currentTopScope)
        {
            if (this.m_inheritActiveItemsFromTopScope) {
                return currentTopScope.ActiveSyntaxItems;
            }

            return this.m_containedItems;
        }
コード例 #8
0
ファイル: VimMatch.cs プロジェクト: svermeulen/iris
        private Scope BuildNewScope(MatchResult result, Scope currentTopScope)
        {
            Scope scope = new Scope();

            scope.PosMatchedAt = result.PosMatchedAt;
            scope.PosStart = result.PosMatchStart;
            scope.PosAfter = result.PosAfterMatch;

            scope.PosHighlightStart = result.PosHighlightStart;
            scope.PosAfterHighlight = result.PosAfterHighlight;

            scope.SyntaxItem = this;
            scope.Extend = this.Extend;
            scope.EatNewLineInRegion = this.Pattern.EatNewLine;

            scope.ActiveSyntaxItems = this.GetMatchableItems(currentTopScope);

            return scope;
        }