本文整理汇总了C#中Irony.Parsing.ParsingContext.ComputeStackRangeSpan方法的典型用法代码示例。如果您正苦于以下问题:C# ParsingContext.ComputeStackRangeSpan方法的具体用法?C# ParsingContext.ComputeStackRangeSpan怎么用?C# ParsingContext.ComputeStackRangeSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Irony.Parsing.ParsingContext
的用法示例。
在下文中一共展示了ParsingContext.ComputeStackRangeSpan方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResultNode
protected override ParseTreeNode GetResultNode(ParsingContext context)
{
int childCount = Production.RValues.Count;
int firstChildIndex = context.ParserStack.Count - childCount;
var span = context.ComputeStackRangeSpan(childCount);
var newNode = new ParseTreeNode(Production.LValue, span);
if (childCount > 0) { //if it is not empty production - might happen for MakeStarRule
var listNode = context.ParserStack[firstChildIndex]; //get the transient list with all members - it is the first child node
newNode.ChildNodes.AddRange(listNode.ChildNodes); //copy all list members
}
return newNode;
}
示例2: GetResultNode
protected virtual ParseTreeNode GetResultNode(ParsingContext context) {
var childCount = Production.RValues.Count;
int firstChildIndex = context.ParserStack.Count - childCount;
var span = context.ComputeStackRangeSpan(childCount);
var newNode = new ParseTreeNode(Production.LValue, span);
for (int i = 0; i < childCount; i++) {
var childNode = context.ParserStack[firstChildIndex + i];
if (childNode.IsPunctuationOrEmptyTransient()) continue; //skip punctuation or empty transient nodes
newNode.ChildNodes.Add(childNode);
}//for i
return newNode;
}