本文整理汇总了C++中Lexer::Parse方法的典型用法代码示例。如果您正苦于以下问题:C++ Lexer::Parse方法的具体用法?C++ Lexer::Parse怎么用?C++ Lexer::Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer::Parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
Schedule Parse(String source, String _fileName)
{
this->fileName = _fileName;
Schedule schedule;
Lexer lex;
tokens = lex.Parse(fileName, source, errors);
pos = 0;
try
{
while (pos < tokens.Count())
{
if (LookAheadToken(L"attrib"))
{
EnumerableDictionary<String, String> additionalAttributes;
ReadToken(L"attrib");
String choiceName = ReadToken(TokenType::Identifier).Content;
while (LookAheadToken(L"."))
{
choiceName = choiceName + L".";
ReadToken(TokenType::Dot);
choiceName = choiceName + ReadToken(TokenType::Identifier).Content;
}
ReadToken(TokenType::OpAssign);
while (pos < tokens.Count())
{
auto name = ReadToken(TokenType::Identifier).Content;
String value;
if (LookAheadToken(L":"))
{
ReadToken(L":");
value = ReadToken(TokenType::StringLiterial).Content;
}
additionalAttributes[name] = value;
if (LookAheadToken(L","))
ReadToken(TokenType::Comma);
else
break;
}
schedule.AddtionalAttributes[choiceName] = additionalAttributes;
}
else
{
String choiceName = ReadToken(TokenType::Identifier).Content;
while (LookAheadToken(L"."))
{
choiceName = choiceName + L".";
ReadToken(TokenType::Dot);
choiceName = choiceName + ReadToken(TokenType::Identifier).Content;
}
ReadToken(TokenType::OpAssign);
List<RefPtr<ChoiceValueSyntaxNode>> worlds;
while (pos < tokens.Count())
{
auto & token = ReadToken(TokenType::StringLiterial);
RefPtr<ChoiceValueSyntaxNode> choiceValue = new ChoiceValueSyntaxNode();
choiceValue->Position = token.Position;
int splitterPos = token.Content.IndexOf(L':');
if (splitterPos != -1)
{
choiceValue->WorldName = token.Content.SubString(0, splitterPos);
choiceValue->AlternateName = token.Content.SubString(splitterPos + 1, token.Content.Length() - splitterPos - 1);
}
else
{
choiceValue->WorldName = token.Content;
}
worlds.Add(choiceValue);
if (LookAheadToken(L","))
ReadToken(TokenType::Comma);
else
break;
}
schedule.Choices[choiceName] = worlds;
}
ReadToken(TokenType::Semicolon);
}
}
catch (...)
{
}
return schedule;
}