X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java index 36adb95..83f8e87 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java @@ -156,12 +156,31 @@ public class Scanner implements IScanner, ITerminalSymbols { public static final int SquareBracket = 1; public static final int CurlyBracket = 2; public static final int BracketKinds = 3; + + public static final boolean DEBUG = false; public Scanner() { this(false, false); } public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace) { this(tokenizeComments, tokenizeWhiteSpace, false); } + + /** + * Determines if the specified character is + * permissible as the first character in a PHP identifier + */ + public static boolean isPHPIdentifierStart(char ch) { + return Character.isLetter(ch) || (ch == '_'); + } + + /** + * Determines if the specified character may be part of a PHP identifier as + * other than the first character + */ + public static boolean isPHPIdentifierPart(char ch) { + return Character.isLetterOrDigit(ch) || (ch == '_'); + } + public final boolean atEnd() { // This code is not relevant if source is // Only a part of the real stream input @@ -232,7 +251,7 @@ public class Scanner implements IScanner, ITerminalSymbols { } return result; } - + public final char[] getCurrentTokenSource(int startPos) { // Return the token REAL source (aka unicodes are precomputed) @@ -256,7 +275,7 @@ public class Scanner implements IScanner, ITerminalSymbols { } return result; } - + public final char[] getCurrentTokenSourceString() { //return the token REAL source (aka unicodes are precomputed). //REMOVE the two " that are at the beginning and the end. @@ -663,7 +682,7 @@ public class Scanner implements IScanner, ITerminalSymbols { } currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); - if (!Character.isJavaIdentifierPart(currentCharacter)) { + if (!isPHPIdentifierPart(currentCharacter)) { currentPosition = temp; return false; } @@ -684,7 +703,7 @@ public class Scanner implements IScanner, ITerminalSymbols { return true; } //-------------end unicode traitement-------------- else { - if (!Character.isJavaIdentifierPart(currentCharacter)) { + if (!isPHPIdentifierPart(currentCharacter)) { currentPosition = temp; return false; } @@ -700,9 +719,10 @@ public class Scanner implements IScanner, ITerminalSymbols { } public int getNextToken() throws InvalidInputException { + try { + int htmlPosition = currentPosition; while (!phpMode) { - startPosition = currentPosition; currentCharacter = source[currentPosition++]; if (currentCharacter == '<') { if (getNextChar('?')) { @@ -712,6 +732,12 @@ public class Scanner implements IScanner, ITerminalSymbols { //