예제 #1
0
        private void TestReservedWord(string expression, object value, TokenKind expectedTokenKind) {
            var lexer = new Tokenizer(expression);
            var token1 = lexer.NextToken();
            Assert.That(token1.Kind, Is.EqualTo(expectedTokenKind));
            Assert.That(token1.Value, Is.EqualTo(value));

            var token2 = lexer.NextToken();
            Assert.That(token2.Kind, Is.EqualTo(TokenKind.Eof));
        }
예제 #2
0
        private void TestStringLiteral(string value, string expected, TokenKind expectedTokenKind) {
            var lexer = new Tokenizer(value);
            var token1 = lexer.NextToken();
            Assert.That(token1.Kind, Is.EqualTo(expectedTokenKind));
            Assert.That(token1.Value, Is.EqualTo(expected));

            var token2 = lexer.NextToken();
            Assert.That(token2.Kind, Is.EqualTo(TokenKind.Eof));
        }
예제 #3
0
        private void CheckTokenSequence(string expression, params TokenKind[] tokenKinds) {
            var lexer = new Tokenizer(expression);
            foreach (var kind in tokenKinds) {
                var token = lexer.NextToken();
                Assert.That(token.Kind, Is.EqualTo(kind));
            }

            var token2 = lexer.NextToken();
            Assert.That(token2.Kind, Is.EqualTo(TokenKind.Eof));
        }
예제 #4
0
파일: Lexer.cs 프로젝트: anycall/Orchard
 public Lexer(Tokenizer tokenizer) {
     _tokenizer = tokenizer;
 }