X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPParser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPParser.java index 981cd7f..bcc7ba9 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPParser.java @@ -14,16 +14,19 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; +import java.util.Stack; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; import net.sourceforge.phpeclipse.phpeditor.PHPString; +import net.sourceforge.phpeclipse.phpeditor.PHPParserAction; 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; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.action.IAction; import org.eclipse.ui.texteditor.MarkerUtilities; public class PHPParser extends PHPKeywords { @@ -171,22 +174,23 @@ public class PHPParser extends PHPKeywords { } public static void setMarker(IFile file, String message, int lineNumber, int errorLevel) throws CoreException { - - Hashtable attributes = new Hashtable(); - MarkerUtilities.setMessage(attributes, message); - switch (errorLevel) { - case ERROR : - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); - break; - case WARNING : - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); - break; - case INFO : - attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); - break; + if (file != null) { + Hashtable attributes = new Hashtable(); + MarkerUtilities.setMessage(attributes, message); + switch (errorLevel) { + case ERROR : + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); + break; + case WARNING : + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING)); + break; + case INFO : + attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO)); + break; + } + MarkerUtilities.setLineNumber(attributes, lineNumber); + MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); } - MarkerUtilities.setLineNumber(attributes, lineNumber); - MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM); } private void throwSyntaxError(String error) { @@ -361,7 +365,6 @@ public class PHPParser extends PHPKeywords { if (openString) { throwSyntaxError("Open string character \"`\" at end of file.", startRow); } - setMarker("Other string delimiters prefered (found \"`\").", rowCount, PHPParser.INFO); token = TT_STRING_CONSTANT; return; } @@ -751,7 +754,7 @@ public class PHPParser extends PHPKeywords { if (ch2 == '?') { ch2 = str.charAt(chIndx++); if (Character.isWhitespace(ch2)) { - // php start + // php start phpMode = true; phpFound = true; break; @@ -1333,10 +1336,15 @@ public class PHPParser extends PHPKeywords { ident.append(ch); if (ch == '$') { + getChar(); + // attention recursive call: + getIdentifier(); token = TT_VARIABLE; + return; } else { token = TT_IDENTIFIER; } + getChar(); while ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch == '_')) { ident.append(ch); @@ -1345,6 +1353,8 @@ public class PHPParser extends PHPKeywords { identifier = ident.toString(); chIndx--; + // determine if this identitfer is a keyword + // @todo improve this in future version Integer i = (Integer) keywordMap.get(identifier.toLowerCase()); if (i != null) { token = i.intValue(); @@ -1460,7 +1470,7 @@ public class PHPParser extends PHPKeywords { if (ch2 == '?') { ch2 = input.charAt(i++); if (Character.isWhitespace(ch2)) { - // php start + // php start phpMode = true; phpFound = true; startIndex = i; @@ -1609,7 +1619,7 @@ public class PHPParser extends PHPKeywords { // String temp = ((PHPString)phpList.get(j)).getPHPString(); // int startIndx = temp.length()-10; // if (startIndx<0) { - // startIndx = 0; + // startIndx = 0; // } // System.out.println(temp.substring(startIndx)+"?>"); // } @@ -1618,7 +1628,7 @@ public class PHPParser extends PHPKeywords { // for(int j=0;j