本文整理汇总了C#中Tokenizer.getNextToken方法的典型用法代码示例。如果您正苦于以下问题:C# Tokenizer.getNextToken方法的具体用法?C# Tokenizer.getNextToken怎么用?C# Tokenizer.getNextToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer.getNextToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperties
/// <summary>
/// Responsible for parsing the specified property string and returning a
/// HashMap representation of the properties specified in it.
/// </summary>
private Hashtable GetProperties(string propString)
{
bool uppercaseFlag = false;
Hashtable properties = new Hashtable();
Tokenizer tokenizer = new Tokenizer(propString);
string key = "";
int nestingLevel = 0;
State state = State.keyNeeded;
Stack stack = new Stack();
try
{
do
{
int token = tokenizer.getNextToken();
switch (token)
{
case Tokenizer.EOF:
if (state != State.keyNeeded)
{
throw new ConfigurationException("Invalid EOF");
}
if (nestingLevel > 0)
{
throw new ConfigurationException("Invalid property string, un-matched paranthesis");
}
return properties;
case Tokenizer.UNNEST:
if (state != State.keyNeeded)
{
throw new ConfigurationException("Invalid property string, ) misplaced");
}
if (nestingLevel < 1)
throw new ConfigurationException("Invalid property string, ) unexpected");
if (uppercaseFlag)
uppercaseFlag = false;
properties = stack.Pop() as Hashtable;
nestingLevel--;
break;
case Tokenizer.ID:
switch (state)
{
case State.keyNeeded:
if (key == "parameters")
uppercaseFlag = true;
key = tokenizer.TokenValue;
token = tokenizer.getNextToken();
if (token == Tokenizer.CONTINUE ||
token == Tokenizer.UNNEST ||
token == Tokenizer.ID ||
token == Tokenizer.EOF)
{
throw new ConfigurationException("Invalid property string, key following a bad token");
}
if (token == Tokenizer.ASSIGN)
{
state = State.valNeeded;
}
else if (token == Tokenizer.NEST)
{
stack.Push(properties);
properties[key.ToLower()] = new Hashtable();
properties = properties[key.ToLower()] as Hashtable;
state = State.keyNeeded;
nestingLevel++;
}
break;
case State.valNeeded:
string val = tokenizer.TokenValue;
token = tokenizer.getNextToken();
state = State.keyNeeded;
if (token == Tokenizer.ASSIGN || token == Tokenizer.ID || token == Tokenizer.EOF)
{
throw new ConfigurationException("Invalid property string, value following a bad token");
}
if (uppercaseFlag)
properties[key] = val;
else
properties[key.ToLower()] = val;
if (token == Tokenizer.NEST)
{
stack.Push(properties);
properties[key.ToLower()] = new Hashtable();
properties = properties[key.ToLower()] as Hashtable;
properties.Add("id", key);
//.........这里部分代码省略.........