public PeekToken Peek(PeekToken peekToken) { int oldIndex = _index; _index = peekToken.TokenIndex; if (_index >= _inputString.Length) { _index = oldIndex; return(null); } foreach (KeyValuePair <Tokens, string> pair in _tokens) { var r = new Regex(pair.Value); Match m = r.Match(_inputString, _index); if (m.Success && m.Index == _index) { _index += m.Length; var pt = new PeekToken(_index, new Token(pair.Key, m.Value)); _index = oldIndex; return(pt); } } var pt2 = new PeekToken(_index + 1, new Token(Tokens.Undefined, string.Empty)); _index = oldIndex; return(pt2); }
public PeekToken Peek(PeekToken peekToken) { int oldIndex = _index; _index = peekToken.TokenIndex; if (_index >= _inputString.Length) { _index = oldIndex; return null; } foreach (KeyValuePair<Tokens, string> pair in _tokens) { var r = new Regex(pair.Value); Match m = r.Match(_inputString, _index); if (m.Success && m.Index == _index) { _index += m.Length; var pt = new PeekToken(_index, new Token(pair.Key, m.Value)); _index = oldIndex; return pt; } } var pt2 = new PeekToken(_index + 1, new Token(Tokens.Undefined, string.Empty)); _index = oldIndex; return pt2; }