本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}