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


C# Scanner.RemoveTokenFromBeginning方法代码示例

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


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

示例1: AnalyzeAssignString_Test

        public void AnalyzeAssignString_Test()
        {
            _testScanner = new Scanner();

            List<Token> expectedList = new List<Token>();
            expectedList.Add(new Token("(", TokenType.LeftParen));
            expectedList.Add(new Token("assign", TokenType.Keyword));
            expectedList.Add(new Token("thisInt", TokenType.Identifier));
            expectedList.Add(new Token("1", TokenType.Integer));
            expectedList.Add(new Token(")", TokenType.RightParen));

            string s = "(assign thisInt 1)";

            List<Token> actualList = new List<Token>();

            while (s.Any())
            {
                var token = _testScanner.GetNextToken(ref s);
                actualList.Add(token);
                _testScanner.RemoveTokenFromBeginning(ref s, token);
            }

            ValidateExpectedVsActualTokens(expectedList, actualList);
        }
开发者ID:koswesley,项目名称:cs480,代码行数:24,代码来源:LexicalAnalyzerTest.cs

示例2: AnalyzeWhileLoopString_Test

        public void AnalyzeWhileLoopString_Test()
        {
            _testScanner = new Scanner();

            List<Token> expectedList = new List<Token>();
            expectedList.Add(new Token("(", TokenType.LeftParen));
            expectedList.Add(new Token("while", TokenType.Keyword));
            expectedList.Add(new Token("thisBool", TokenType.Identifier));
            expectedList.Add(new Token("(", TokenType.LeftParen));
            expectedList.Add(new Token("if", TokenType.Keyword));
            expectedList.Add(new Token("thisBool", TokenType.Identifier));
            expectedList.Add(new Token("false", TokenType.Boolean));
            expectedList.Add(new Token(")", TokenType.RightParen));
            expectedList.Add(new Token(")", TokenType.RightParen));

            string s = "(while thisBool (if thisBool false))";

            List<Token> actualList = new List<Token>();

            while (s.Any())
            {
                var token = _testScanner.GetNextToken(ref s);
                actualList.Add(token);
                _testScanner.RemoveTokenFromBeginning(ref s, token);
            }

            ValidateExpectedVsActualTokens(expectedList, actualList);
        }
开发者ID:koswesley,项目名称:cs480,代码行数:28,代码来源:LexicalAnalyzerTest.cs

示例3: AnalyzeEscapeQuoteCharacterString_Test

        public void AnalyzeEscapeQuoteCharacterString_Test()
        {
            _testScanner = new Scanner();
            List<Token> expectedTokens = new List<Token>() {
                new Token("(", TokenType.LeftParen),
                new Token("assign", TokenType.Keyword),
                new Token("thisInt", TokenType.Identifier),
                new Token("\"BOS test \\\" string \\\" EOS\"", TokenType.String),
                new Token(")", TokenType.RightParen)
            };

            List<Token> actualTokens = new List<Token>();

            string inputString = "(assign thisInt \"BOS test \\\" string \\\" EOS\")";
            while (inputString.Any()) {
                var token = _testScanner.GetNextToken(ref inputString);
                actualTokens.Add(token);
                _testScanner.RemoveTokenFromBeginning(ref inputString, token);
            }

            ValidateExpectedVsActualTokens(expectedTokens, actualTokens);
        }
开发者ID:koswesley,项目名称:cs480,代码行数:22,代码来源:LexicalAnalyzerTest.cs

示例4: AnalyzePowerString_Test

        public void AnalyzePowerString_Test()
        {
            _testScanner = new Scanner();

            List<Token> expectedList = new List<Token>();
            expectedList.Add(new Token("(", TokenType.LeftParen));
            expectedList.Add(new Token("^", TokenType.Operator));
            expectedList.Add(new Token("1", TokenType.Integer));
            expectedList.Add(new Token("2", TokenType.Integer));
            expectedList.Add(new Token(")", TokenType.RightParen));

            string s = "(^ 1 2)";

            List<Token> actualList = new List<Token>();

            while (s.Any())
            {
                var token = _testScanner.GetNextToken(ref s);
                actualList.Add(token);
                _testScanner.RemoveTokenFromBeginning(ref s, token);
            }

            ValidateExpectedVsActualTokens(expectedList, actualList);
        }
开发者ID:koswesley,项目名称:cs480,代码行数:24,代码来源:LexicalAnalyzerTest.cs

示例5: AnalyzeCrazyEscapeCharacterString_Test

        public void AnalyzeCrazyEscapeCharacterString_Test()
        {
            _testScanner = new Scanner();
            List<Token> expectedTokens = new List<Token>() {
                new Token("(", TokenType.LeftParen),
                new Token("assign", TokenType.Keyword),
                new Token("thisVar", TokenType.Identifier),
                new Token("\"This is \\\"suppose\\\" to be \\\"something\\\" \\n ormal.\\; \"", TokenType.String),
                new Token(")", TokenType.RightParen)
            };

            List<Token> actualTokens = new List<Token>();

            string inputString = "(assign thisVar \"This is \\\"suppose\\\" to be \\\"something\\\" \\n ormal.\\; \")";
            while (inputString.Any()) {
                var token = _testScanner.GetNextToken(ref inputString);
                actualTokens.Add(token);
                _testScanner.RemoveTokenFromBeginning(ref inputString, token);
            }

            ValidateExpectedVsActualTokens(expectedTokens, actualTokens);
        }
开发者ID:koswesley,项目名称:cs480,代码行数:22,代码来源:LexicalAnalyzerTest.cs


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