本文整理汇总了C#中AstNode.GetAll方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.GetAll方法的具体用法?C# AstNode.GetAll怎么用?C# AstNode.GetAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.GetAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunPhases
public void RunPhases(AstNode astRoot, CompilerContext context, params AstProcessingPhase[] phases)
{
IEnumerable<AstNode> allNodes = astRoot.GetAll();
foreach (AstProcessingPhase phase in phases) {
foreach (AstNode node in allNodes)
node.OnAstProcessing(context, phase);
}//foreach phase
}
示例2: ExtractOptionsFromTree
//#region (private) GetCurrentCommandCategory(CurrentCommand)
//private CLICommandCategory GetCurrentCommandCategory(string CurrentCommand)
//{
// byte CommandSign;
// CommandSign = (byte)Commands[CurrentCommand].aCategory;
// if ((CommandSign & (byte)CLICommandCategory.FSCommand).CompareTo(1) >=0)
// return CLICommandCategory.FSCommand;
// else
// if ((CommandSign & (byte)CLICommandCategory.DBCommand).CompareTo(1) >= 0)
// return CLICommandCategory.DBCommand;
// else
// return CLICommandCategory.CLIStandardCommand;
//}//method
//#endregion
#region (private) ExtractOptionsFromTree(_ExecutionTree)
private void ExtractOptionsFromTree(AstNode _ExecutionTree)
{
List<AstNode> AllNodes = (List<AstNode>)_ExecutionTree.GetAll();
//get the command
CurrentCommand = AllNodes[0].GetContent().Clone().ToString();
//get the category of the command
//CommandCategory = GetCurrentCommandCategory(CurrentCommand);
List<AstNode> ToBeDeleted = new List<AstNode>();
foreach (AstNode aAstNOde in AllNodes)
{
if (aAstNOde.Term.GraphOptions.Contains(GraphOption.IsStructuralObject) || aAstNOde.Term.GraphOptions.Contains(GraphOption.IsCommandRoot))
{
ToBeDeleted.Add(aAstNOde);
}
}
foreach (AstNode aElement in ToBeDeleted)
{
AllNodes.Remove(aElement);
}
//finally, remove first Element (the command)
AddOptionToParameters(CreateNewOption(AllNodes[0].GetContent(), AllNodes[0].Span));
AllNodes.RemoveAt(0);
bool _IsNewOption = false;
bool _DidIEverDetectAnOption = false;
foreach (AstNode aAstNOde in AllNodes)
{
if (aAstNOde.Term.GraphOptions.Contains(GraphOption.IsOption))
{
//wohoo, new Option
_IsNewOption = true;
_DidIEverDetectAnOption = true;
}
else
{
if (_IsNewOption)
{
AddOptionToParameters(CreateNewOption(aAstNOde.GetContent(), aAstNOde.Span));
_IsNewOption = false;
}
else
{
if (!_DidIEverDetectAnOption)
{
//for one-line bnf-rules
AddOptionToParameters(CreateNewOption(aAstNOde.GetContent(), aAstNOde.Span));
}
else
{
int _ActualCountOfOptions = Parameters[CurrentOption.Option].Count;
Parameters[CurrentOption.Option][_ActualCountOfOptions - 1].AddParameter(aAstNOde.GetContent());
}
}
}
}
}