当前位置: 首页>>代码示例>>C#>>正文


C# AstNode.GetAll方法代码示例

本文整理汇总了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
 }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:8,代码来源:AstProcessor.cs

示例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());
                        }
                    }


                }
            }
        }
开发者ID:TheByte,项目名称:sones,代码行数:86,代码来源:GraphCLI.cs


注:本文中的AstNode.GetAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。