本文整理汇总了C#中NodeList.Get方法的典型用法代码示例。如果您正苦于以下问题:C# NodeList.Get方法的具体用法?C# NodeList.Get怎么用?C# NodeList.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeList
的用法示例。
在下文中一共展示了NodeList.Get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseEmbed
/// <summary>
/// Parser for Embed
/// </summary>
/// <returns>Parsed Embed</returns>
public Embed ParseEmbed()
{
Embed embed = null;
NodeList markupList = new NodeList();
//Set up MarkupParser
markupParser = new MarkupParser(EmbeddingTokenStream);
//Parse Markup*
//EmbeddingTokenStream.HasNext(2) && !(EmbeddingTokenStream.Peek(2).GetValue().ToString() == ">"
while(NextTokenIsMarkup())
{
markupList.Add(markupParser.ParseMarkup());
}
//Check if an expression is remaining, otherwise embed is MarkupEmbedding
if (IsExpressionRemaining())
{ //ExpressionEmbedding
ExpressionEmbed expressionEmbed = new ExpressionEmbed();
//Add already parsed markups to expressionEmbed
expressionEmbed.SetMarkups(markupList);
//Set up expressionparser
expressionParser = new ExpressionParser(EmbeddingTokenStream);
//Parse expression
expressionEmbed.SetExpression(expressionParser.ParseExpression());
embed = expressionEmbed;
}
else
{ //MarkupEmbedding
//Get last item from markupList and add it as Markup
if (markupList.Count != 0)
{
Markup markup = (Markup)markupList.Get(markupList.Count - 1);
markupList.Remove(markupList.Count - 1);
MarkupEmbed markupEmbed = new MarkupEmbed();
markupEmbed.SetMarkups(markupList);
markupEmbed.SetMarkup(markup);
embed = markupEmbed;
}
else
{ //Markup* Markup must contain at least one markup element
throw new UnexpectedToken("Markup expected, but found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
}
}
/*//Determine if remaining embed is Markup or Expression
if (NextTokenIsMarkup())
{ //MarkupEmbedding
MarkupEmbed markupEmbed = new MarkupEmbed();
//Add already parsed markups to markupEmbed
markupEmbed.SetMarkups(markupList);
//Parse latest markup
markupEmbed.SetMarkup(markupParser.ParseMarkup());
embed = markupEmbed;
}
else
{ //ExpressionEmbedding
ExpressionEmbed expressionEmbed = new ExpressionEmbed();
//Add already parsed markups to expressionEmbed
expressionEmbed.SetMarkups(markupList);
//Set up expressionparser
expressionParser = new ExpressionParser(EmbeddingTokenStream);
//Parse expression
expressionEmbed.SetExpression(expressionParser.ParseExpression());
embed = expressionEmbed;
} */
return embed;
}
示例2: ParseMarkupStatement
/// <summary>
/// Parser for MarkupStatement types
/// </summary>
/// <returns>Parsed Statement</returns>
public Statement ParseMarkupStatement()
{
//Start parsing first markup part
Markup firstMarkup = markupParser.ParseMarkup();
if (TokenStream.HasNext() && TokenStream.Peek(1).GetType() == TokenType.SYMBOL && TokenStream.Peek(1).GetValue().ToString() == ";")
{ //Just a single markup statement
MarkupStatement markupStatement = new MarkupStatement();
markupStatement.SetMarkup(firstMarkup);
//Skip ; token
NextToken(";", "markup;", ';');
return markupStatement;
}
else
{
//Get other markups
NodeList markups = new NodeList();
markups.Add(firstMarkup);
while(DetectNextIsMarkup())
{
markups.Add(markupParser.ParseMarkup());
}
//Determine statement type
if (TokenStream.HasNext())
{
if (TokenStream.Peek(1).GetType() == TokenType.EMBEDDING)
{ //Markup Embedding Statement
MarkupEmbeddingStatement markupEmbedding = new MarkupEmbeddingStatement();
markupEmbedding.SetMarkups(markups);
markupEmbedding.SetEmbedding(embeddingParser.ParseEmbedding());
//Skip ; token
NextToken(";", "Markup+ Embedding;", ';');
return markupEmbedding;
}
else if(TokenStream.Peek(1).GetValue().ToString() == ";")
{ //MarkupStatement
MarkupMarkupStatement markupStatement = new MarkupMarkupStatement();
//Get last parsed markup from list and remove it from list
Markup last = (Markup) markups.Get(markups.Count - 1);
markups.Remove(markups.Count-1);
markupStatement.SetMarkup(last);
markupStatement.SetMarkups(markups);
//Skip ; token
NextToken(";", "Markup+ Markup;", ';');
return markupStatement;
}
else if (IsMarkupStatStatement())
{ //MarkupStatStatement
MarkupStatStatement markupStatStatement = new MarkupStatStatement();
markupStatStatement.SetMarkups(markups);
markupStatStatement.SetStatement(ParseStatement());
return markupStatStatement;
}
else if (IsMarkupExpressionStatement())
{ //MarkupExpressionStatement
MarkupExpressionStatement markupExpressionStatement = new MarkupExpressionStatement();
//Parse MarkupExpressionStatement
markupExpressionStatement.SetMarkups(markups);
markupExpressionStatement.SetExpression(expressionParser.ParseExpression());
//Skip ; token
NextToken(";", "Markup+ Expression;", ';');
return markupExpressionStatement;
}
else
{ //Unexpected token
throw new UnexpectedToken("Markup Statement expected, but found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
}
}
else
{
throw new UnexpectedToken("Expected MarkupStatement type, but found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
}
}
}