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


C# CommonTree.GetFirstChildWithType方法代码示例

本文整理汇总了C#中Antlr.Runtime.Tree.CommonTree.GetFirstChildWithType方法的典型用法代码示例。如果您正苦于以下问题:C# CommonTree.GetFirstChildWithType方法的具体用法?C# CommonTree.GetFirstChildWithType怎么用?C# CommonTree.GetFirstChildWithType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Antlr.Runtime.Tree.CommonTree的用法示例。


在下文中一共展示了CommonTree.GetFirstChildWithType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CountAltsForRule

        public int CountAltsForRule( CommonTree t )
        {
            CommonTree block = (CommonTree)t.GetFirstChildWithType(BLOCK);
            if (block == null || block.ChildCount == 0)
                return 0;

            return block.Children.Count(i => i.Type == ALT);
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:8,代码来源:DefineGrammarItemsWalkerHelper.cs

示例2: GetPageId

        private string GetPageId(CommonTree node)
        {
            if (node.Type == FlashTeaseScriptLexer.RANGE)
            {
                var fromNode = node.GetChild(0) as CommonTree;
                var toNode = node.GetChild(1) as CommonTree;
                if (fromNode != null && toNode != null)
                {
                    var fromText = String.Concat(fromNode.Children.Select(child => child.Text).ToArray());
                    var toText = String.Concat(toNode.Children.Select(child => child.Text).ToArray());

                    var prefix = node.GetFirstChildWithType(FlashTeaseScriptLexer.PREFIX) as CommonTree;

                    string prefixText = (prefix != null) ? prefix.GetChild(0).Text.Trim('\'', '"') : null;

                    return String.Format("{0}({1}..{2})", prefixText, fromText, toText);
                }
            }
            return String.Concat(node.Children.Select(child => child.Text).ToArray());
        }
开发者ID:TakenagaT,项目名称:TeaseMe,代码行数:20,代码来源:FlashTeaseConverter.cs

示例3: ProcessFunctionParameters

        private IEnumerable<string> ProcessFunctionParameters(CommonTree child)
        {
            CommonTree parameterTree = child.GetFirstChildWithType(GoLexer.LPAREN) as CommonTree;
            if (parameterTree == null)
                yield break;

            foreach (CommonTree parameter in parameterTree.Children)
            {
                if (parameter.Type == GoLexer.RPAREN)
                    continue;

                if (parameter.ChildCount == 0)
                {
                    yield return parameter.Text;
                }
                else if (parameter.ChildCount == 1)
                {
                    yield return string.Format("{0} {1}", parameter.Text, GetTypeString((CommonTree)parameter.GetChild(0)));
                }
                else
                {
                    yield return "<unknown parameter>";
                }
            }
        }
开发者ID:sebandraos,项目名称:LangSvcV2,代码行数:25,代码来源:GoEditorNavigationSource.cs

示例4: GetDelay

        private TeaseDelay GetDelay(CommonTree delayNode)
        {
            if (delayNode == null)
            {
                return null;
            }

            var result = new TeaseDelay();

            var timeNode = delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.TIME) as CommonTree;
            if (timeNode != null)
            {
                var minNode = (CommonTree)timeNode.GetFirstChildWithType(FlashTeaseScriptLexer.MIN);
                int minSecs = Convert.ToInt32(minNode.GetChild(0).Text);
                if (minNode.ChildCount > 1)
                {
                    var minUnit = minNode.GetChild(1).Text;
                    switch (minUnit)
                    {
                        case "hrs": { minSecs = minSecs * 60 * 60; break; }
                        case "min": { minSecs = minSecs * 60; break; }
                        default: break;
                    }
                }

                var maxNode = timeNode.GetFirstChildWithType(FlashTeaseScriptLexer.MAX) as CommonTree;
                int maxSecs = -1;
                if (maxNode != null)
                {
                    maxSecs = Convert.ToInt32(maxNode.GetChild(0).Text);
                    if (maxNode.ChildCount > 1)
                    {
                        var maxUnit = maxNode.GetChild(1).Text;
                        switch (maxUnit)
                        {
                            case "hrs": { maxSecs = maxSecs * 60 * 60; break; }
                            case "min": { maxSecs = maxSecs * 60; break; }
                            default: break;
                        }
                    }
                }

                result.Seconds = (maxSecs > minSecs) ? String.Format("({0}..{1})", minSecs, maxSecs) : String.Format("{0}", minSecs);
            }

            result.Target = GetPageId(delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.TARGET).GetChild(0) as CommonTree);

            var styleNode = delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.STYLE) as CommonTree;
            if (styleNode != null && styleNode.ChildCount > 0)
            {
                switch (styleNode.GetChild(0).Text.ToLowerInvariant())
                {
                    case "hidden": result.Style = DelayStyle.Hidden; break;
                    case "secret": result.Style = DelayStyle.Secret; break;
                    default: result.Style = DelayStyle.Normal; break;
                }
            }

            return result;
        }
开发者ID:TakenagaT,项目名称:TeaseMe,代码行数:60,代码来源:FlashTeaseConverter.cs

示例5: GetButtons

        private IEnumerable<TeaseButton> GetButtons(CommonTree propertiesNode)
        {
            var result = new List<TeaseButton>();

            var goNode = propertiesNode.GetFirstChildWithType(FlashTeaseScriptLexer.GO) as CommonTree;
            if (goNode != null)
            {
                result.Add(new TeaseButton { Text = "Continue", Target = GetPageId(goNode.GetChild(0) as CommonTree) });
            }
            var ynNode = propertiesNode.GetFirstChildWithType(FlashTeaseScriptLexer.YN) as CommonTree;
            if (ynNode != null)
            {
                result.Add(new TeaseButton { Text = "Yes", Target = GetPageId(ynNode.GetFirstChildWithType(FlashTeaseScriptLexer.YES).GetChild(0) as CommonTree) });
                result.Add(new TeaseButton { Text = "No", Target = GetPageId(ynNode.GetFirstChildWithType(FlashTeaseScriptLexer.NO).GetChild(0) as CommonTree) });
            }
            var buttonsNode = propertiesNode.GetFirstChildWithType(FlashTeaseScriptLexer.BUTTONS) as CommonTree;
            if (buttonsNode != null)
            {
                foreach (CommonTree buttonNode in buttonsNode.Children.Where(x => x.Type == FlashTeaseScriptLexer.BUTTON))
                {
                    result.Add(new TeaseButton
                    {
                        Text = buttonNode.GetFirstChildWithType(FlashTeaseScriptLexer.CAP).GetChild(0).Text.Trim('\'', '"'),
                        Target = GetPageId(buttonNode.GetFirstChildWithType(FlashTeaseScriptLexer.TARGET).GetChild(0) as CommonTree)
                    });
                }
            }

            result.Reverse();
            return result;
        }
开发者ID:TakenagaT,项目名称:TeaseMe,代码行数:31,代码来源:FlashTeaseConverter.cs

示例6: GetAudio

        private TeaseMedia GetAudio(CommonTree soundNode)
        {
            if (soundNode == null)
            {
                return null;
            }

            var result = new  TeaseMedia();

            var idNode = soundNode.GetFirstChildWithType(FlashTeaseScriptLexer.ID) as CommonTree;
            if (idNode != null)
            {
                result.Id = idNode.GetChild(0).Text.Trim('\'', '"');
            }

            var loopsNode = soundNode.GetFirstChildWithType(FlashTeaseScriptLexer.LOOPS) as CommonTree;
            if (loopsNode != null && loopsNode.ChildCount > 0)
            {
                result.Repeat = loopsNode.GetChild(0).Text;
            }
            return result;
        }
开发者ID:TakenagaT,项目名称:TeaseMe,代码行数:22,代码来源:FlashTeaseConverter.cs

示例7: GetParameterType

        private static string GetParameterType(CommonTree tree)
        {
            int index = 0;

            while (index < tree.ChildCount)
            {
                switch (tree.GetChild(index).Type)
                {
                case Java2Lexer.MONKEYS_AT:
                case Java2Lexer.FINAL:
                    index++;
                    continue;

                default:
                    break;
                }

                break;
            }

            string typeText = GetTypeText((CommonTree)tree.GetChild(index));

            if (tree.GetFirstChildWithType(Java2Lexer.ELLIPSIS) != null)
                typeText = typeText + "...";

            return typeText;
        }
开发者ID:Kav2018,项目名称:JavaForVS,代码行数:27,代码来源:JavaEditorNavigationSource.cs

示例8: GetDelay

        private TeaseDelay GetDelay(CommonTree delayNode)
        {
            if (delayNode == null)
            {
                return null;
            }

            var result = new TeaseDelay();

            var timeNode = delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.TIME) as CommonTree;
            if (timeNode != null)
            {
                int secs = System.Convert.ToInt32(timeNode.GetChild(0).Text);
                if (timeNode.GetChild(1).Text == "min")
                {
                    secs = secs * 60;
                }
                result.Seconds = secs.ToString();
            }

            result.Target = GetPageId(delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.TARGET).GetChild(0) as CommonTree);

            var styleNode = delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.STYLE) as CommonTree;
            if (styleNode != null && styleNode.ChildCount > 0)
            {
                switch (styleNode.GetChild(0).Text)
                {
                    case "hidden": result.Style = DelayStyle.Hidden; break;
                    case "secret": result.Style = DelayStyle.Secret; break;
                    default: result.Style = DelayStyle.Normal; break;
                }
            }

            return result;
        }
开发者ID:d3vi0n,项目名称:TeaseMe,代码行数:35,代码来源:FlashTeaseConverter.cs


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