private int GetRestartStateIndex(ScannerState state, int stateIndex){ ScannerRestartState restartState = new ScannerRestartState(); this.scanner.InitializeRestartState(restartState); restartState.State = state; for (int i = stateIndex-1; i >= 0; i--){ ScannerRestartState rstate = (ScannerRestartState)this.stateList[i]; if (rstate == restartState) return i; } int n = this.stateList.Count; for (int i = stateIndex+1; i < n; i++){ ScannerRestartState rstate = (ScannerRestartState)this.stateList[i]; if (rstate == restartState) return i; } this.stateList.Add(restartState); return n; }
public void InitializeRestartState(ScannerRestartState restartState){ if (restartState == null){Debug.Assert(false); return;} restartState.DocCommentStart = this.docCommentStart; restartState.ElseCount = this.elseCount; restartState.EndIfCount = this.endIfCount; restartState.EndPos = this.endPos; restartState.IncludeCount = this.includeCount; restartState.NonExcludedEndifCount = this.nonExcludedEndIfCount; restartState.State = this.state; if (this.explicitlyInSpecSharp) restartState.State |= ScannerState.ExplicitlyInSpecSharp; if (this.inSpecSharpMultilineComment) restartState.State |= ScannerState.InSpecSharpMultilineComment; this.RestartStateHasChanged = false; }
private ScannerRestartState GetRestartStateFor(int stateIndex){ if (stateIndex < 0){Debug.Assert(false); stateIndex = 0;} if (this.stateList.Count <= stateIndex){ Debug.Assert(stateIndex == 0); ScannerRestartState restartState = new ScannerRestartState(); this.stateList.Add(restartState); this.scanner.InitializeRestartState(restartState); return restartState; } return (ScannerRestartState)this.stateList[stateIndex]; }
public void Restart(ScannerRestartState restartState){ if (restartState == null){Debug.Assert(false); return;} this.docCommentStart = restartState.DocCommentStart; this.elseCount = restartState.ElseCount; this.endIfCount = restartState.EndIfCount; this.endPos = restartState.EndPos; this.explicitlyInSpecSharp = (restartState.State & ScannerState.ExplicitlyInSpecSharp) != 0; this.includeCount = restartState.IncludeCount; this.inSpecSharpMultilineComment = (restartState.State & ScannerState.InSpecSharpMultilineComment) != 0; this.nonExcludedEndIfCount = restartState.NonExcludedEndifCount; this.state = restartState.State & ScannerState.StateMask; this.RestartStateHasChanged = false; }