private bool MatchEndSequence(CharacterScanner scanner) { bool flag = false; while (!scanner.IsEndOfScan) { char currentCharacter = scanner.CurrentCharacter; if (this.skipString == null || flag || !scanner.MatchString(this.skipString)) { if ((int)currentCharacter == (int)this.endSequence[0] && !flag && scanner.MatchString(this.endSequence)) { return(true); } int num1; if (this.escapeCharacter.HasValue) { char?nullable = this.escapeCharacter; int num2 = (int)currentCharacter; num1 = (int)nullable.GetValueOrDefault() != num2 ? 0 : (nullable.HasValue ? 1 : 0); } else { num1 = 0; } flag = num1 != 0; scanner.MoveNext(); if (this.finishesOnEOL && (int)currentCharacter == 10) { return(true); } } } return(false); }
public IList <ClassificationSpan> GetClassificationSpans(SnapshotSpan span, RuleScannerState currentState, out RuleScannerState endState) { CharacterScanner scanner = new CharacterScanner(span); List <ClassificationSpan> list = new List <ClassificationSpan>(); int currentRule = currentState.CurrentRule; RuleState endState1 = currentState.RuleState; while (!scanner.IsEndOfScan) { bool flag = false; int cursor = scanner.Cursor; if (!endState1.IsResuming) { currentRule = 0; } for (; currentRule < this.rules.Count; ++currentRule) { IClassificationType classification = this.rules[currentRule].Run(scanner, endState1, out endState1); if (classification != null) { list.Add(new ClassificationSpan(new SnapshotSpan(scanner.Snapshot, cursor, scanner.Cursor - cursor), classification)); flag = true; break; } } if (!flag) { scanner.MoveNext(); } } endState = new RuleScannerState(currentRule, endState1); return((IList <ClassificationSpan>)list); }
public IClassificationType Run(CharacterScanner scanner, RuleState startState, out RuleState endState) { RuleState ruleState = startState; int cursor = scanner.Cursor; if (!ruleState.IsResuming && !string.IsNullOrEmpty(this.startSequence)) { if ((int)scanner.CurrentCharacter != (int)this.startSequence[0]) { endState = new RuleState(); return((IClassificationType)null); } if (!scanner.MatchString(this.startSequence)) { endState = new RuleState(); return((IClassificationType)null); } } bool flag = false; if (string.IsNullOrEmpty(this.endSequence)) { while (!scanner.IsEndOfScan) { if (this.finishesOnEOL && (int)scanner.CurrentCharacter == 10) { flag = true; break; } scanner.MoveNext(); } } else { flag = this.MatchEndSequence(scanner) || scanner.IsEndOfFile; } endState = new RuleState(!flag); return(this.classification); }