First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / AstNode.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 /**
4  * It will be the mother of our own ast tree for php just like the ast tree of Eclipse.
5  * @author Matthieu Casanova
6  */
7 public abstract class AstNode {
8
9   /** Starting and ending position of the node in the sources. */
10   public int sourceStart, sourceEnd;
11
12   /**
13    * Create a node giving starting and ending offset
14    * @param sourceStart starting offset
15    * @param sourceEnd ending offset
16    */
17   public AstNode(int sourceStart, int sourceEnd) {
18     this.sourceStart = sourceStart;
19     this.sourceEnd = sourceEnd;
20   }
21
22   /**
23    * Add some tabulations.
24    * @param tab the number of tabulations
25    * @return a String containing some spaces
26    */
27   public static String tabString(int tab) {
28     StringBuffer s = new StringBuffer();
29     for (int i = tab; i > 0; i--)
30       s.append("  "); //$NON-NLS-1$
31     return s.toString();
32   }
33
34   /**
35    * Return the object into String.
36    * It should be overriden
37    * @return a String
38    */
39   public String toString() {
40     return "****" + super.toString() + "****";  //$NON-NLS-2$ //$NON-NLS-1$
41   }
42
43   /**
44    * Return the object into String.
45    * @param tab how many tabs (not used here
46    * @return a String
47    */
48   public abstract String toString(int tab);
49 }