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


C# Tree.CommonTree类代码示例

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


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

示例1: TestAddListToExistChildren

        public void TestAddListToExistChildren()
        {
            // Add child ^(nil 101 102 103) to root ^(5 6)
            // should add 101 102 103 to end of 5's child list
            CommonTree root = new CommonTree( new CommonToken( 5 ) );
            root.AddChild( new CommonTree( new CommonToken( 6 ) ) );

            // child tree
            CommonTree r0 = new CommonTree( (IToken)null );
            CommonTree c0, c1, c2;
            r0.AddChild( c0 = new CommonTree( new CommonToken( 101 ) ) );
            r0.AddChild( c1 = new CommonTree( new CommonToken( 102 ) ) );
            r0.AddChild( c2 = new CommonTree( new CommonToken( 103 ) ) );

            root.AddChild( r0 );

            assertNull( root.Parent );
            assertEquals( -1, root.ChildIndex );
            // check children of root all point at root
            assertEquals( root, c0.Parent );
            assertEquals( 1, c0.ChildIndex );
            assertEquals( root, c0.Parent );
            assertEquals( 2, c1.ChildIndex );
            assertEquals( root, c0.Parent );
            assertEquals( 3, c2.ChildIndex );
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:26,代码来源:TestTrees.cs

示例2: UserFunction

 // method xyt(param1, param2) {
 public UserFunction(String name, List<String> parameterNames, CommonTree functionBody, int definedLine)
 {
     this.parameterNames = parameterNames;
     this.functionBody = functionBody;
     this.name = name;
     this.definedLine = definedLine;
 }
开发者ID:brianex,项目名称:osu-sgl,代码行数:8,代码来源:UserFunction.cs

示例3: GetSpan

        private SnapshotSpan? GetSpan(CommonTree tree)
        {
            if (tree == null)
                return null;

            return GetSpan(tree.Token);
        }
开发者ID:sebandraos,项目名称:LangSvcV2,代码行数:7,代码来源:AlloyExpressionWalker.g3.cs

示例4: BindToAntlrNode

 public AstNode BindToAntlrNode(CommonTree node)
 {
     // horrible, but works for now
     if (AntlrNode == null)
         AntlrNode = node;
     return this;
 }
开发者ID:xeno-by,项目名称:elf4b,代码行数:7,代码来源:AstNode.cs

示例5: BlaiseInstrumentTreeWalker

        public BlaiseInstrumentTreeWalker(CommonTree tree, CommonTokenStream tokens, BlaiseImportOptions options, string agencyId, string mainLanguage)
        {
            this.tree = tree;
            this.tokens = tokens;
            this.options = options;
            this.MainLanguage = mainLanguage;
            this.AgencyId = agencyId;

            Result = new XDocument();

            DdiInstance = Ddi.Element(Ddi.DdiInstance);
            Ddi.AddNamespaces(DdiInstance);

            ResourcePackage = Ddi.Element(Ddi.ResourcePackage);

            // Required in DDI 3.1
            var purpose = Ddi.Element(Ddi.Purpose);
            purpose.Add(Ddi.XmlLang(MainLanguage));
            purpose.Add(new XElement(Ddi.Content, "Not Specified"));
            ResourcePackage.Add(purpose);

            Instrument = Ddi.Element(Ddi.Instrument);
            ControlConstructScheme = Ddi.Element(Ddi.ControlConstructScheme);

            XElement groupDataCollection = Ddi.Element(Ddi.GroupDataCollection, false);
            XElement dataCollection = Ddi.Element(Ddi.DataCollection);
            groupDataCollection.Add(dataCollection);
            dataCollection.Add(Instrument);
            ResourcePackage.Add(groupDataCollection);
            ResourcePackage.Add(ControlConstructScheme);
            DdiInstance.Add(ResourcePackage);
        }
开发者ID:Colectica,项目名称:MetadataConverters,代码行数:32,代码来源:BlaiseInstrumentTreeWalker.cs

示例6: CommonTree

		public CommonTree(CommonTree node) 
			: base(node)
		{
			this.token = node.token;
			this.startIndex = node.startIndex;
			this.stopIndex = node.stopIndex;
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:7,代码来源:CommonTree.cs

示例7: Add

        private object Add(CommonTree tree)
        {
            var lhs = LhsOperand(tree);
            var rhs = RhsOperand(tree);

            return Operator.Add(lhs, rhs);
        }
开发者ID:cstrahan,项目名称:chunky,代码行数:7,代码来源:ChunkyInterpreter.cs

示例8: TestSeek

        public void TestSeek()
        {
            // ^(101 ^(102 103 ^(106 107) ) 104 105)
            // stream has 7 real + 6 nav nodes
            // Sequence of types: 101 DN 102 DN 103 106 DN 107 UP UP 104 105 UP EOF
            ITree r0 = new CommonTree( new CommonToken( 101 ) );
            ITree r1 = new CommonTree( new CommonToken( 102 ) );
            r0.AddChild( r1 );
            r1.AddChild( new CommonTree( new CommonToken( 103 ) ) );
            ITree r2 = new CommonTree( new CommonToken( 106 ) );
            r2.AddChild( new CommonTree( new CommonToken( 107 ) ) );
            r1.AddChild( r2 );
            r0.AddChild( new CommonTree( new CommonToken( 104 ) ) );
            r0.AddChild( new CommonTree( new CommonToken( 105 ) ) );

            ITreeNodeStream stream = newStream( r0 );
            stream.Consume(); // consume 101
            stream.Consume(); // consume DN
            stream.Consume(); // consume 102
            stream.Seek( 7 );   // seek to 107
            Assert.AreEqual( 107, ( (ITree)stream.LT( 1 ) ).Type );
            stream.Consume(); // consume 107
            stream.Consume(); // consume UP
            stream.Consume(); // consume UP
            Assert.AreEqual( 104, ( (ITree)stream.LT( 1 ) ).Type );
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:26,代码来源:TestBufferedTreeNodeStream.cs

示例9: generateFile

 public void generateFile(CommonTree ast, string fileName)
 {
     using (XmlWriter writer = XmlWriter.Create(fileName))
     {
         generate(ast, writer);
     }
 }
开发者ID:perfoon,项目名称:JavaScript-analyser,代码行数:7,代码来源:XmlTranslatorActivity.cs

示例10: 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

示例11: WalkChildren

        protected void WalkChildren(CommonTree ast)
        {
            if (ast == null || ast.Children == null)
                return;

            foreach (CommonTree child in ast.Children)
                Walk(child);
        }
开发者ID:rhencke,项目名称:HiDPISteam,代码行数:8,代码来源:TreeWalker.cs

示例12: Extract

 public static List<Expression> Extract(CommonTree tree)
 {
     var list = new List<Expression>();
     if (tree.Children == null)
         return list;
     list.AddRange(tree.Children.Select(arg => new Expression(arg)));
     return list;
 }
开发者ID:jeffpanici75,项目名称:FastTemplate,代码行数:8,代码来源:FnArgs.cs

示例13: HandleSignature

        protected override void HandleSignature(CommonTree signature, IList<IToken> qualifiers, IList<CommonTree> names, CommonTree extendsSpec, CommonTree body, CommonTree block)
        {
            if (names == null)
                return;

            foreach (var name in names)
                HandleSignatureOrEnum(signature, name);
        }
开发者ID:sebandraos,项目名称:LangSvcV2,代码行数:8,代码来源:AlloyEditorNavigationSourceWalker.cs

示例14: CommonTree

        public CommonTree(CommonTree node)
            : base(node) {
            if (node == null)
                throw new ArgumentNullException("node");

            this.token = node.token;
            this.startIndex = node.startIndex;
            this.stopIndex = node.stopIndex;
        }
开发者ID:EightPillars,项目名称:PathwayEditor,代码行数:9,代码来源:CommonTree.cs

示例15: generateDocument

 public XmlDocument generateDocument(CommonTree ast)
 {
     XmlDocument doc = new XmlDocument();
     using (XmlWriter writer = doc.CreateNavigator().AppendChild())
     {
         generate(ast, writer);
     }
     return doc;
 }
开发者ID:perfoon,项目名称:JavaScript-analyser,代码行数:9,代码来源:XmlTranslatorActivity.cs


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