1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Rook
.Compiler
.AST
18 using Castle
.Rook
.Compiler
.Visitors
;
21 public abstract class ASTNode
: IASTNode
23 private IASTNode parent
;
24 private LexicalPosition position
;
25 private ISymbolTable symTable
;
31 public ASTNode(ISymbolTable symTable
)
33 this.symTable
= symTable
;
36 public IASTNode Parent
38 get { return parent; }
39 set { parent = value; }
42 public LexicalPosition Position
44 get { return position; }
45 set { position = value; }
48 public ISymbolTable DefiningSymbolTable
50 get { return symTable; }
51 set { symTable = value; }
54 public virtual void ReplaceBy(IASTNode node
)
58 throw new ApplicationException("Couldn't find a parent node to delegate");
61 Parent
.ReplaceChild(this, node
);
64 public virtual void ReplaceChild(IASTNode oldNode
, IASTNode newNode
)
66 throw new NotImplementedException( this.GetType().FullName
+ " must implement ReplaceChild" );
69 public virtual void RemoveChild(IASTNode node
)
71 throw new NotImplementedException( this.GetType().FullName
+ " must implement RemoveChild" );
74 public virtual bool Accept(IASTVisitor visitor
)
76 throw new NotImplementedException( this.GetType().FullName
+ " must implement Accept" );