本文整理汇总了C#中Antlr4.Tool.Ast.GrammarAST.FreshenParentAndChildIndexesDeeply方法的典型用法代码示例。如果您正苦于以下问题:C# GrammarAST.FreshenParentAndChildIndexesDeeply方法的具体用法?C# GrammarAST.FreshenParentAndChildIndexesDeeply怎么用?C# GrammarAST.FreshenParentAndChildIndexesDeeply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr4.Tool.Ast.GrammarAST
的用法示例。
在下文中一共展示了GrammarAST.FreshenParentAndChildIndexesDeeply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandOptionalQuantifiersForBlock
protected virtual bool ExpandOptionalQuantifiersForBlock(GrammarAST block, bool variant)
{
IList<GrammarAST> children = new List<GrammarAST>();
for (int i = 0; i < block.ChildCount; i++)
{
GrammarAST child = (GrammarAST)block.GetChild(i);
if (child.Type != ANTLRParser.ALT)
{
children.Add(child);
continue;
}
GrammarAST expandedAlt = ExpandOptionalQuantifiersForAlt(child);
if (expandedAlt == null)
{
return false;
}
children.Add(expandedAlt);
}
GrammarAST newChildren = (GrammarAST)adaptor.Nil();
newChildren.AddChildren(children);
block.ReplaceChildren(0, block.ChildCount - 1, newChildren);
block.FreshenParentAndChildIndexesDeeply();
if (!variant && block.Parent is RuleAST)
{
RuleAST ruleAST = (RuleAST)block.Parent;
string ruleName = ruleAST.GetChild(0).Text;
Rule r = _rules[ruleName];
IList<GrammarAST> blockAlts = block.GetAllChildrenWithType(ANTLRParser.ALT);
r.numberOfAlts = blockAlts.Count;
r.alt = new Alternative[blockAlts.Count + 1];
for (int i = 0; i < blockAlts.Count; i++)
{
r.alt[i + 1] = new Alternative(r, i + 1);
r.alt[i + 1].ast = (AltAST)blockAlts[i];
}
}
return true;
}