public static IEnumerable<Token> Scan(string source) { var se = new SymbolsEnumerator(source); var result = new Scanner(se).Scan(); se.Dispose(); return result; }
public void ResetShouldSetPositionAsMinusOne() { var s = new SymbolsEnumerator("Elemar"); s.MoveNext(); s.Position.Should().Be(0); s.Reset(); s.Position.Should().Be(-1); }
//[ExpectedException(typeof(InvalidOperationException))] public void CurrentFromIEnumeratorShouldThowsInvalidOperationExceptionWhenMoveNextWasNotCalled() { var s = new SymbolsEnumerator("Elemar"); object c; Executing .This(() => c = ((IEnumerator)s).Current) .Should().Throw<InvalidOperationException>(); }
public void Initialization() { Assert.Throws<InvalidOperationException>(() => { var s = new SymbolsEnumerator("Elemar"); var c = s.Current; s.Dispose(); }); }
public Scanner(SymbolsEnumerator symbols) { _symbols = symbols; }
public void CanRecognizeIdentifier(string input, bool result) { var symbols = new SymbolsEnumerator(input); symbols.MoveNext(); symbols.CurrentPosCouldBeAnIdentifier().Should().Be(result); }
public void CurrentFromIEnumeratorShouldReturnSameAsRegularCurrent() { var s = new SymbolsEnumerator("Elemar"); s.MoveNext(); s.Current.Should().Be(((IEnumerator)s).Current); }