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..c897fdb 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,35 @@ 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 == '_') + || (0x7F <= ch && ch <= 0xFF); + } + + /** + * 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 == '_') + || (0x7F <= ch && ch <= 0xFF); + } + public final boolean atEnd() { // This code is not relevant if source is // Only a part of the real stream input @@ -232,7 +255,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 +279,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 +686,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 +707,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 +723,9 @@ public class Scanner implements IScanner, ITerminalSymbols { } public int getNextToken() throws InvalidInputException { + int htmlPosition = currentPosition; try { while (!phpMode) { - startPosition = currentPosition; currentCharacter = source[currentPosition++]; if (currentCharacter == '<') { if (getNextChar('?')) { @@ -712,6 +735,12 @@ public class Scanner implements IScanner, ITerminalSymbols { //