internal override void StartScopeForSuccesfulMatch(Scanner s, MatchResult match) { Scope newScope = this.BuildNewScope(s.TopScope); newScope.PosMatchedAt = match.PosMatchedAt; newScope.ExternalCaptures = match.ExternalCaptures; bool hasHighlightMode = match.Pattern.HasHighlightMode; if (0 == match.PosRegionStart) { match.PosRegionStart = hasHighlightMode ? match.PosAfterMatch : match.PosMatchStart; } if (0 == match.PosHighlightStart) { match.PosHighlightStart = match.PosMatchStart; } if (hasHighlightMode && match.PosHighlightStart < match.PosRegionStart) { s.SendMode(match.Pattern.HighlightMode, match.PosHighlightStart); } newScope.PosStart = hasHighlightMode ? match.PosRegionStart : match.PosMatchStart; newScope.PosHighlightStart = hasHighlightMode ? match.PosRegionStart : match.PosHighlightStart; newScope.PosEndSkippedUntil = hasHighlightMode ? match.PosRegionStart - 1 : match.PosAfterMatch - 1; newScope.EatNewLineInRegion = match.Pattern.EatNewLine; s.PushScope(newScope); }
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); }
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; }