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


C# CommonTree.GetChild方法代码示例

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


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

示例1: DebugTreeGrammar

 // Expected tree for function: ^(FUNC ID ( INT | ID ) expr)
 /** Set up a local evaluator for a nested function call. The evaluator gets the definition
  *  tree of the function; the set of all defined functions (to find locally called ones); a
  *  pointer to the global variable memory; and the value of the function parameter to be
  *  added to the local memory.
  */
 private DebugTreeGrammar(CommonTree function,
              List<CommonTree> functionDefinitions,
              IDictionary<string, BigInteger> globalMemory,
              BigInteger paramValue)
     : this(new CommonTreeNodeStream(function.GetChild(2)), functionDefinitions)
 {
     this.globalMemory = globalMemory;
     localMemory[function.GetChild(1).Text] = paramValue;
 }
开发者ID:jjchaverra,项目名称:antlr3,代码行数:15,代码来源:DebugTreeGrammarHelper.cs

示例2: ProfileTreeGrammar

 /** Set up a local evaluator for a nested function call. The evaluator gets the definition
  *  tree of the function; the set of all defined functions (to find locally called ones); a
  *  pointer to the global variable memory; and the value of the function parameter to be
  *  added to the local memory.
  */
 private ProfileTreeGrammar(CommonTree function,
              List<CommonTree> functionDefinitions,
              IDictionary<string, BigInteger> globalMemory,
              BigInteger paramValue)
     // Expected tree for function: ^(FUNC ID ( INT | ID ) expr)
     : this(new CommonTreeNodeStream(function.GetChild(2)), functionDefinitions)
 {
     this.globalMemory = globalMemory;
     localMemory[function.GetChild(1).Text] = paramValue;
 }
开发者ID:jjchaverra,项目名称:antlr3,代码行数:15,代码来源:ProfileTreeGrammarHelper.cs

示例3: FunctionalTreeParser

 /// <summary>
 /// Set up a local evaluator for a nested function call. The evaluator gets the definition
 ///  tree of the function; the set of all defined functions (to find locally called ones); a
 /// pointer to the global variable memory; and the value of the function parameter to be
 /// added to the local memory.
 /// </summary>
 /// <param name="function"></param>
 /// <param name="functionDefinitions"></param>
 /// <param name="globalMemory"></param>
 /// <param name="paramValue"></param>
 private FunctionalTreeParser(
     CommonTree function,
     IList<CommonTree> functionDefinitions,
     IDictionary<string, BigInteger> globalMemory,
     BigInteger paramValue)
     : this(// Expected tree for function: ^(FUNC ID ( INT | ID ) expr)
         new CommonTreeNodeStream(function.GetChild(2)), functionDefinitions)
 {
     //this.globalMemory = globalMemory;
     this.localMemory.Add(function.GetChild(1).Text, paramValue);
 }
开发者ID:DamianReeves,项目名称:Functional,代码行数:21,代码来源:FunctionalTreeParser.g3.cs

示例4: Test4Nodes

        public void Test4Nodes()
        {
            // ^(101 ^(102 103) 104)
            CommonTree r0 = new CommonTree( new CommonToken( 101 ) );
            r0.AddChild( new CommonTree( new CommonToken( 102 ) ) );
            r0.GetChild( 0 ).AddChild( new CommonTree( new CommonToken( 103 ) ) );
            r0.AddChild( new CommonTree( new CommonToken( 104 ) ) );

            assertNull( r0.Parent );
            assertEquals( -1, r0.ChildIndex );
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:11,代码来源:TestTrees.cs

示例5: Test4Nodes

        public void Test4Nodes()
        {
            // ^(101 ^(102 103) 104)
            ITree t = new CommonTree( new CommonToken( 101 ) );
            t.AddChild( new CommonTree( new CommonToken( 102 ) ) );
            t.GetChild( 0 ).AddChild( new CommonTree( new CommonToken( 103 ) ) );
            t.AddChild( new CommonTree( new CommonToken( 104 ) ) );

            ITreeNodeStream stream = newStream( t );
            string expecting = " 101 102 103 104";
            string found = ToNodesOnlyString( stream );
            Assert.AreEqual( expecting, found );

            expecting = " 101 2 102 2 103 3 104 3";
            found = ToTokenTypeString( stream );
            Assert.AreEqual( expecting, found );
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:17,代码来源:TestTreeNodeStream.cs

示例6: ToList

        private List<String> ToList(CommonTree tree, int childNum)
        {
            List<String> ids = new List<String>();

            // convert the tree to a List of Strings
            Console.WriteLine("1: " + childNum);
            if (tree.ChildCount > 0)
            {
                Console.WriteLine("2: " + childNum);
                for (int i = 0; i < tree.GetChild(childNum).ChildCount; i++)
                {
                    Console.WriteLine("3: " + childNum);
                    CommonTree child = (CommonTree)tree.GetChild(childNum).GetChild(i);
                    ids.Add(child.Text);
                    Console.WriteLine("add to List (" + childNum + "): " + child.Text);
                }
                Console.WriteLine("4: " + childNum);
            }
            return ids;
        }
开发者ID:peppy,项目名称:sgl4cs,代码行数:20,代码来源:Method.cs

示例7: Visit

 public void Visit(InsertOverwriteStatement statement, CommonTree tree)
 {
     Parent(tree).Children.Add(statement);
     SetLine(statement, tree);
     Visit(tree.GetChild(0));
     Visit(tree.GetChild(1));
 }
开发者ID:bitsummation,项目名称:pickaxe,代码行数:7,代码来源:BridgeVisitor.cs

示例8: ParseArg

 internal KeyValuePair<string, StoreType> ParseArg(CommonTree node)
 {
   StoreType st = new StoreType();
   int i = 0;
   st.Name = node.GetChild(i).Text;
   st.VarKind = VarKindEnum.Argument;
   i++;
   if (Cmp(node.GetChild(i).Text, "data_type") == 0)
   {
     ParseDataType(st, (CommonTree)node.GetChild(i));
     i++;
   }
   if (i < node.ChildCount)
   {
     string s = node.GetChild(i).Text;
     if ((Cmp("in", s) == 0) || (Cmp("out", s) == 0) || (Cmp("inout", s) == 0))
     {
       st.ArgType = (ArgTypeEnum)Enum.Parse(typeof(ArgTypeEnum), s, true);
     }
   }
   return new KeyValuePair<string, StoreType>(st.Name, st);
 }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:22,代码来源:Debugger.cs

示例9: GetTypeText

        private static string GetTypeText(CommonTree tree)
        {
            if (tree.Type == Java2Lexer.ARRAY_TYPE)
                return GetTypeText((CommonTree)tree.GetChild(0)) + "[]";

            // this covers primitiveType
            if (tree.ChildCount == 0)
                return tree.Text;

            if (tree.Type == Java2Lexer.DOT)
                return GetTypeText((CommonTree)tree.GetChild(0)) + "." + GetTypeText((CommonTree)tree.GetChild(1));

            // if we get here, we know the tree is ^(IDENTIFIER typeArguments)
            string name = tree.Text;
            IEnumerable<string> typeArguments = ((CommonTree)tree.GetChild(0)).Children.Select(GetTypeArgumentText);
            return string.Format("{0}<{1}>", name, string.Join(", ", typeArguments));
        }
开发者ID:Kav2018,项目名称:JavaForVS,代码行数:17,代码来源:JavaEditorNavigationSource.cs

示例10: ParseDeclares

 /// <summary>
 /// Parses begin/end block gathering info in all declared local variables.
 /// TODO: how to take care of session & globals? same as in emulation: by providing a watches facility.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="vars"></param>
 private void ParseDeclares(CommonTree node, Dictionary<string, StoreType> vars)
 {
   if (( Cmp(node.Text, "declare") == 0 ) && 
       ( Cmp(node.GetChild(0).Text, "condition") != 0 ) &&
       ( Cmp( node.GetChild( 0 ).Text, "cursor") != 0 ))
   {
     // Register vars...
     StoreType[] stVars = ParseDeclare(node);
     StoreType st2;
     foreach (StoreType st in stVars)
     {
       // variables with same name, are hidden by already declared ones.
       if (!vars.TryGetValue(st.Name, out st2))
       {
         vars.Add(st.Name, st);
       }
     }        
   }
   else
   {
     if (node.Children == null) return;
     foreach (ITree ct in node.Children)
     {
       ParseDeclares((CommonTree)ct, vars);
     }
   }
 }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:33,代码来源:Debugger.cs

示例11: PreinstrumentStatement

 /// <summary>
 /// For a given statement, instruments all triggers & functions that will be invoked
 /// at its execution.
 /// </summary>
 /// <param name="stmt"></param>
 private void PreinstrumentStatement(CommonTree stmt)
 {
   // Identify all current dependencies and instrument them:
   if ( (Cmp( stmt.Text, "begin_end" ) == 0) ||
     ( Cmp( stmt.Text, "loop" ) == 0 ))
   {
     // Nothing to preinstrument, body has already being instrumented.
     return;
   }
   if (Cmp(stmt.Text, "while") == 0)
   {
     stmt = ( CommonTree )stmt.GetChild(0);
   }
   else if (Cmp(stmt.Text, "repeat") == 0)
   {
     stmt = (CommonTree)stmt.GetChild(stmt.ChildCount - 1);
   }
   // TODO: if, etc.
   else if (Cmp(stmt.Text, "call") == 0)
   {
     // Get dependencies from args (like functions)
     RoutineInfo ri = GetRoutineInfo(((CommonTree)stmt).GetChild(0).Text);
     if (string.IsNullOrEmpty(ri.InstrumentedSourceCode))
       InstrumentRoutine(ri);
   }
   DoPreinstrumentStatement(stmt);
 }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:32,代码来源:Debugger.cs

示例12: TestLT

        public void TestLT()
        {
            // ^(101 ^(102 103) 104)
            ITree t = new CommonTree( new CommonToken( 101 ) );
            t.AddChild( new CommonTree( new CommonToken( 102 ) ) );
            t.GetChild( 0 ).AddChild( new CommonTree( new CommonToken( 103 ) ) );
            t.AddChild( new CommonTree( new CommonToken( 104 ) ) );

            ITreeNodeStream stream = newStream( t );
            Assert.AreEqual( 101, ( (ITree)stream.LT( 1 ) ).Type );
            Assert.AreEqual( TokenTypes.Down, ( (ITree)stream.LT( 2 ) ).Type );
            Assert.AreEqual( 102, ( (ITree)stream.LT( 3 ) ).Type );
            Assert.AreEqual( TokenTypes.Down, ( (ITree)stream.LT( 4 ) ).Type );
            Assert.AreEqual( 103, ( (ITree)stream.LT( 5 ) ).Type );
            Assert.AreEqual( TokenTypes.Up, ( (ITree)stream.LT( 6 ) ).Type );
            Assert.AreEqual( 104, ( (ITree)stream.LT( 7 ) ).Type );
            Assert.AreEqual( TokenTypes.Up, ( (ITree)stream.LT( 8 ) ).Type );
            Assert.AreEqual( TokenTypes.EndOfFile, ( (ITree)stream.LT( 9 ) ).Type );
            // check way ahead
            Assert.AreEqual( TokenTypes.EndOfFile, ( (ITree)stream.LT( 100 ) ).Type );
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:21,代码来源:TestTreeNodeStream.cs

示例13: Visit

        public IAspectElement Visit(
            CommonTree root, int depth, IAspectElement element)
        {
            if (root.Token == null)
                return element;

            var token = root.Token.Text;
            switch (token) {
            case "ASPECT":
                foreach (var child in root.Children) {
                    element = Visit((CommonTree)child, depth + 1, element);
                }
                return element;

            case "ASPECT_BODY":
                foreach (var child in root.Children) {
                    element = Visit((CommonTree)child, depth + 1, element);
                }
                return element;

            case "ELEMENTS":
                foreach (var child in root.Children) {
                    element = Visit((CommonTree)child, depth + 1, element);
                }
                return element;

            case "ELEMENT":
                foreach (var child in root.Children) {
                    element = Visit((CommonTree)child, depth + 1, element);
                }
                return element;

            case "INTERTYPE_DECLARATION":
                element = new Intertype();
                foreach (var child in root.Children) {
                    element = Visit((CommonTree)child, depth + 1, element);
                }
                Intertypes.Add((Intertype)element);
                return element;

            case "POINTCUT_DECLARATION":
                element = new Pointcut();
                foreach (var child in root.Children) {
                    element = Visit((CommonTree)child, depth + 1, element);
                }
                Pointcuts.Add((Pointcut)element);
                return element;

            case "ADVICE_DECLARATION":
                element = new Advice();
                foreach (var child in root.Children) {
                    element = Visit((CommonTree)child, depth + 1, element);
                }
                Advices.Add((Advice)element);
                return element;

            case "TYPE":
                element.SetType(root.GetChild(0).Text);
                return element;

            case "TARGET_CLASS":
                element.SetTarget(root.GetChild(0).Text);
                return element;

            case "POINTCUT_NAME":
                element.SetName(root.GetChild(0).Text);
                return element;

            case "IDENTIFIER_WITH_CLASS_NAME":
                foreach (var child in root.Children) {
                    element.SetTarget(((CommonTree)child).Text);
                }
                return element;

            case "PARAMETERS":
                if (root.ChildCount > 0) {
                    foreach (var child in root.Children) {
                        element = Visit((CommonTree)child, depth + 1, element);
                    }
                }
                return element;

            case "PARAMETER":
                element = Visit((CommonTree)root.Children[0], depth + 1, element);
                element.SetParameter(((CommonTree)root.Children[1]).Text);
                return element;

            case "PARAMETER_TYPE":
                element.SetParameterType(root.GetChild(0).Text);
                return element;

            case "ARGUMENTS":
                WriteIndent(depth);
                Console.WriteLine("<" + token + ">");
                foreach (var child in root.Children) {
                    Visit((CommonTree)child, depth + 1, element);
                }
                WriteIndent(depth);
                Console.WriteLine("</ " + token + ">");
                return element;
//.........这里部分代码省略.........
开发者ID:UnicoenProject,项目名称:UniAspect,代码行数:101,代码来源:AstVisitor.cs

示例14: Children

 /// <summary>
 /// Children will enumerate children of node t.
 /// </summary>
 /// <param name="t">node for which children are to be identified.</param>
 /// <returns>returns one child at a time.</returns>
 public IEnumerable<CommonTree> Children(CommonTree t)
 {
     for (int i = 0; i < t.ChildCount; i++)
         yield return (CommonTree)t.GetChild(i);
 }
开发者ID:neilmayhew,项目名称:pathway,代码行数:10,代码来源:CssTreeParser.cs

示例15: ParseColor

        /// <summary>
        /// Parses an ARGB color from the MapCSS definition.
        /// </summary>
        /// <param name="colorTree"></param>
        /// <returns></returns>
        private static int ParseColor(CommonTree colorTree)
        {
            if (colorTree == null)
            {
                throw new ArgumentNullException("colorTree");
            }

            int valueInt;
            KnownColor namedColor;

            if (colorTree.Text == "VALUE_RGB")
            { // a pre-defined RGB value.
                string rString = colorTree.GetChild(0).Text;
                string gString = colorTree.GetChild(1).Text;
                string bString = colorTree.GetChild(2).Text;

                int r = int.Parse(rString);
                int g = int.Parse(gString);
                int b = int.Parse(bString);

                return SimpleColor.FromArgb(r, g, b).Value;
            }
            else if (int.TryParse(colorTree.Text, NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out valueInt))
            { // the color is defined as an integer? this cannot happen??
                return valueInt;
            }
#if!WINDOWS_PHONE
            else if (Enum.TryParse<KnownColor>(colorTree.Text, true, out namedColor))
#else
            else if (EnumHelper.TryParse<KnownColor>(colorTree.Text, true, out namedColor))
#endif
            { // the color was named.
                return SimpleColor.FromKnownColor(namedColor).Value;
            }
            else
            { // value could not be parsed.
                throw new MapCSSDomainParserException(colorTree,
                                                            string.Format("Color value cannot be parsed!"));
            }
        }
开发者ID:JoeCooper,项目名称:ui,代码行数:45,代码来源:MapCSSDomainParser.cs


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