Lex() public method

public Lex ( ) : IEnumerable
return IEnumerable
Beispiel #1
0
 public void ItLexesMultpleCloseEndGroups()
 {
     var lexer = new Lexer(
     @"a
     b
     c
     d".ToStream());
     var stream = lexer.Lex().ToArray();
     AssertTokenStreamEquals(stream, new []
         {
             new Token() { Kind = TokenKind.Statement, Value = "a"},
             new Token() { Kind = TokenKind.EOL},
             new Token() { Kind = TokenKind.StartGroup },
             new Token() { Kind = TokenKind.Statement, Value = "b"},
             new Token() { Kind = TokenKind.EOL},
             new Token() { Kind = TokenKind.StartGroup },
             new Token() { Kind = TokenKind.Statement, Value = "c"},
             new Token() { Kind = TokenKind.EOL},
             new Token() { Kind = TokenKind.EndGroup },
             new Token() { Kind = TokenKind.EndGroup },
             new Token() { Kind = TokenKind.Statement, Value = "d"},
             new Token() { Kind = TokenKind.EOL},
             new Token() { Kind = TokenKind.EOF},
         });
 }
Beispiel #2
0
 public void ItLexesPrograms(string line, IEnumerable<Token> expected)
 {
     var lexer = new Lexer(line.ToStream());
     var tokens = lexer.Lex();
     AssertTokenStreamEquals(expected.ToArray(), tokens.ToArray());
 }
Beispiel #3
0
 public void ItDiesOnInconsistentWhitespace(string code)
 {
     var lexer = new Lexer(code.ToStream());
     Assert.Catch<InconsistentWhitespaceException>(() =>lexer.Lex().ToArray());
 }