00001 /* 00002 [The "BSD licence"] 00003 Copyright (c) 2005-2007 Kunle Odutola 00004 All rights reserved. 00005 00006 Redistribution and use in source and binary forms, with or without 00007 modification, are permitted provided that the following conditions 00008 are met: 00009 1. Redistributions of source code MUST RETAIN the above copyright 00010 notice, this list of conditions and the following disclaimer. 00011 2. Redistributions in binary form MUST REPRODUCE the above copyright 00012 notice, this list of conditions and the following disclaimer in 00013 the documentation and/or other materials provided with the 00014 distribution. 00015 3. The name of the author may not be used to endorse or promote products 00016 derived from this software without specific prior WRITTEN permission. 00017 4. Unless explicitly state otherwise, any contribution intentionally 00018 submitted for inclusion in this work to the copyright owner or licensor 00019 shall be under the terms and conditions of this license, without any 00020 additional terms or conditions. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00023 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00024 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00025 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00027 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00028 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00029 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00031 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 */ 00033 00034 00035 namespace Antlr.Runtime.Tree 00036 { 00037 using System; 00038 using Token = Antlr.Runtime.Token; 00039 00051 public interface ITree 00052 { 00053 int ChildCount 00054 { 00055 get; 00056 00057 } 00058 00059 // Tree tracks parent and child index now > 3.0 00060 00061 ITree Parent 00062 { 00063 get; 00064 set; 00065 } 00066 00068 int ChildIndex 00069 { 00070 get; 00071 set; 00072 } 00073 00075 void FreshenParentAndChildIndexes(); 00076 00081 bool IsNil 00082 { 00083 get; 00084 00085 } 00087 int Type 00088 { 00089 get; 00090 00091 } 00092 00093 string Text 00094 { 00095 get; 00096 00097 } 00098 00100 int Line 00101 { 00102 get; 00103 00104 } 00105 int CharPositionInLine 00106 { 00107 get; 00108 00109 } 00110 00111 ITree GetChild(int i); 00112 00118 void AddChild(ITree t); 00119 00121 void SetChild(int i, ITree t); 00122 00123 object DeleteChild(int i); 00124 00131 void ReplaceChildren(int startChildIndex, int stopChildIndex, object t); 00132 00137 int TokenStartIndex { get; set; } 00138 00143 int TokenStopIndex { get; set; } 00144 00145 ITree DupNode(); 00146 00147 string ToStringTree(); 00148 00149 string ToString(); 00150 } 00151 00152 public sealed class Tree 00153 { 00154 public readonly static ITree INVALID_NODE = new CommonTree(Token.INVALID_TOKEN); 00155 } 00156 }
1.5.5