当前位置: 首页>>代码示例>>C#>>正文


C# Lexer.NextToken方法代码示例

本文整理汇总了C#中Lexer.NextToken方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.NextToken方法的具体用法?C# Lexer.NextToken怎么用?C# Lexer.NextToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lexer的用法示例。


在下文中一共展示了Lexer.NextToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAsteriskAsArithmeticOperator

        public void GetAsteriskAsArithmeticOperator()
        {
            Lexer lexer = new Lexer("*");

            var token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual("*", token.Value);
            Assert.AreEqual(TokenType.Operator, token.Type);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:12,代码来源:LexerTests.cs

示例2: GetCommaAsDelimiter

        public void GetCommaAsDelimiter()
        {
            Lexer lexer = new Lexer(",");

            var token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual(",", token.Value);
            Assert.AreEqual(TokenType.Delimiter, token.Type);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:12,代码来源:LexerTests.cs

示例3: GetComparisonOperators

        public void GetComparisonOperators()
        {
            Lexer lexer = new Lexer("< > <= >= == /=");

            foreach (var value in new string[] { "<", ">", "<=", ">=", "==", "/=" })
            {
                var token = lexer.NextToken();

                Assert.IsNotNull(token);
                Assert.AreEqual(value, token.Value);
                Assert.AreEqual(TokenType.Operator, token.Type);
            }

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:15,代码来源:LexerTests.cs

示例4: GetArrowsAsOperators

        public void GetArrowsAsOperators()
        {
            Lexer lexer = new Lexer("-> <-");

            var token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual("->", token.Value);
            Assert.AreEqual(TokenType.Operator, token.Type);

            token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual("<-", token.Value);
            Assert.AreEqual(TokenType.Operator, token.Type);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:18,代码来源:LexerTests.cs

示例5: SkipMultiLineComment

        public void SkipMultiLineComment()
        {
            Lexer lexer = new Lexer("{- a comment\nin many lines -}");

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:6,代码来源:LexerTests.cs

示例6: SkipComment

        public void SkipComment()
        {
            Lexer lexer = new Lexer("-- a comment\n");

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:6,代码来源:LexerTests.cs

示例7: GetUnclosedString

        public void GetUnclosedString()
        {
            Lexer lexer = new Lexer("\"foo");

            try
            {
                lexer.NextToken();
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(LexerException));
                Assert.AreEqual("Unclosed string", ex.Message);
            }
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:15,代码来源:LexerTests.cs

示例8: TestParse

        private static void TestParse(string text, params string[] values)
        {
            Lexer lexer = new Lexer(text);

            Token token;

            for (int k = 0; k < values.Length; k++)
            {
                token = lexer.NextToken();
                Assert.IsNotNull(token);
                Assert.AreEqual(values[k], token.Value);
            }

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:AjBase,代码行数:15,代码来源:LexerTests.cs

示例9: GetIndexingOperator

        public void GetIndexingOperator()
        {
            Lexer lexer = new Lexer("!!");

            var token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual("!!", token.Value);
            Assert.AreEqual(TokenType.Operator, token.Type);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:12,代码来源:LexerTests.cs

示例10: GetParensAsDelimiters

        public void GetParensAsDelimiters()
        {
            Lexer lexer = new Lexer("()");

            var token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual("(", token.Value);
            Assert.AreEqual(TokenType.Delimiter, token.Type);

            token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual(")", token.Value);
            Assert.AreEqual(TokenType.Delimiter, token.Type);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:18,代码来源:LexerTests.cs

示例11: GetNullTokenFromNullText

        public void GetNullTokenFromNullText()
        {
            Lexer lexer = new Lexer(null);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:6,代码来源:LexerTests.cs

示例12: GetNullTokenFromEmptyText

        public void GetNullTokenFromEmptyText()
        {
            Lexer lexer = new Lexer(string.Empty);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:6,代码来源:LexerTests.cs

示例13: GetNameWithDigits

        public void GetNameWithDigits()
        {
            Lexer lexer = new Lexer("foo42");

            var token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual("foo42", token.Value);
            Assert.AreEqual(TokenType.Name, token.Type);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:12,代码来源:LexerTests.cs

示例14: GetInteger

        public void GetInteger()
        {
            Lexer lexer = new Lexer("42");

            var token = lexer.NextToken();

            Assert.IsNotNull(token);
            Assert.AreEqual("42", token.Value);
            Assert.AreEqual(TokenType.Integer, token.Type);

            Assert.IsNull(lexer.NextToken());
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:12,代码来源:LexerTests.cs

示例15: UnexpectedChar

        public void UnexpectedChar()
        {
            var lexer = new Lexer("@");

            try
            {
                lexer.NextToken();
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(LexerException));
                Assert.AreEqual("Unexpected '@'", ex.Message);
            }
        }
开发者ID:ajlopez,项目名称:Husky,代码行数:15,代码来源:LexerTests.cs


注:本文中的Lexer.NextToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。