reworked the Console write() method
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / phpparser / PHPParser.java
index ad5173d..c5a29c0 100644 (file)
@@ -19,6 +19,7 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
 import net.sourceforge.phpeclipse.phpeditor.PHPString;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPKeywords;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.runtime.CoreException;
@@ -34,6 +35,7 @@ public class PHPParser extends PHPKeywords {
   public static final int ERROR = 2;
   public static final int WARNING = 1;
   public static final int INFO = 0;
+  
   private IFile fileToParse;
   private ArrayList phpList;
 
@@ -196,6 +198,12 @@ public class PHPParser extends PHPKeywords {
     }
   }
 
+  /**
+   * This method will throw the SyntaxError.
+   * It will add the good lines and columns to the Error
+   * @param error the error message
+   * @throws SyntaxError the error raised
+   */
   private void throwSyntaxError(String error) {
 
     if (str.length() < chIndx) {
@@ -213,8 +221,13 @@ public class PHPParser extends PHPKeywords {
     throw new SyntaxError(rowCount, chIndx - columnCount + 1, str.substring(columnCount, eol), error);
   }
 
+  /**
+   * This method will throw the SyntaxError.
+   * It will add the good lines and columns to the Error
+   * @param error the error message
+   * @throws SyntaxError the error raised
+   */
   private void throwSyntaxError(String error, int startRow) {
-
     throw new SyntaxError(startRow, 0, " ", error);
   }
 
@@ -1263,11 +1276,13 @@ public class PHPParser extends PHPKeywords {
     //    }
   }
 
-
+  /**
+   * Get an identifier.
+   */
   private void getIdentifier() {
-    StringBuffer ident = new StringBuffer();
-
-    ident.append(ch);
+  //  StringBuffer ident = new StringBuffer();
+    int startPosition = chIndx - 1;
+//    ident.append(ch);
     if (ch == '$') {
       getChar();
       // attention recursive call:
@@ -1279,13 +1294,18 @@ public class PHPParser extends PHPKeywords {
     }
 
     getChar();
+
+    //this will read the buffer until the next character is a forbidden character for identifier
     while ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch == '_')) {
-      ident.append(ch);
+  //    ident.append(ch);
       getChar();
     }
-    identifier = ident.toString();
-    chIndx--;
+    int endPosition = chIndx--;
+    int length = (--endPosition) - startPosition;
 
+    identifier = str.substring(startPosition, endPosition);
+    // System.out.println(identifier);
+    
     // determine if this identitfer is a keyword
     // @todo improve this in future version
     Integer i = (Integer) keywordMap.get(identifier.toLowerCase());
@@ -1294,6 +1314,13 @@ public class PHPParser extends PHPKeywords {
     }
   }
 
+  /**
+   * Get a number.
+   * if it's a <code>double</code> the number will be stored in <code>doubleNumber</code> and the token will have the
+   * value {@link PHPParser#TT_DOUBLE_NUMBER}<br />
+   * if it's a <code>double</code> the number will be stored in <code>longNumber</code> and the token will have the
+   * value {@link PHPParser#TT_INT_NUMBER}
+   */
   private void getNumber() {
     StringBuffer inum = new StringBuffer();
     char dFlag = ' ';
@@ -3294,6 +3321,10 @@ public class PHPParser extends PHPKeywords {
     }
   }
 
+  /**
+   * It will look for a value (after a '=' for example)
+   * @throws CoreException
+   */
   private void constant() throws CoreException {
     String ident;
     switch (token) {
@@ -3377,9 +3408,9 @@ public class PHPParser extends PHPKeywords {
     MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_PARSER_PREF));
     String command = form.format(arguments);
 
-    String parserResult = PHPStartApacheAction.execute(command, "External parser: ");
+    String parserResult = PHPStartApacheAction.getParserOutput(command, "External parser: ");
 
-    try {
+    try { 
       // parse the buffer to find the errors and warnings
       createMarkers(parserResult, file);
     } catch (CoreException e) {