import java.util.Iterator;
import java.util.List;
-import net.sourceforge.phpdt.core.compiler.*;
+import net.sourceforge.phpdt.core.compiler.IScanner;
+import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
+import net.sourceforge.phpdt.core.compiler.InvalidInputException;
import net.sourceforge.phpdt.internal.compiler.ast.StringLiteral;
public class Scanner implements IScanner, ITerminalSymbols {
public int getCurrentTokenEndPosition() {
return this.currentPosition - 1;
}
-
-
+
public final char[] getCurrentTokenSource() {
// Return the token REAL source (aka unicodes are precomputed)
public int getCurrentTokenStartPosition() {
return this.startPosition;
}
-
- public final char[] getCurrentStringLiteralSource() {
- // Return the token REAL source (aka unicodes are precomputed)
- char[] result;
+ public final char[] getCurrentStringLiteralSource() {
+ // Return the token REAL source (aka unicodes are precomputed)
+
+ char[] result;
- int length;
- System.arraycopy(source, startPosition+1, result = new char[length = currentPosition - startPosition - 2], 0, length);
- // }
- return result;
- }
+ int length;
+ System.arraycopy(source, startPosition + 1, result = new char[length = currentPosition - startPosition - 2], 0, length);
+ // }
+ return result;
+ }
/*
* Search the source position corresponding to the end of a given line number
return TokenNameTWIDDLE_EQUAL;
return TokenNameTWIDDLE;
case '!' :
- if (getNextChar('='))
+ if (getNextChar('=')) {
+ if (getNextChar('=')) {
+ return TokenNameNOT_EQUAL_EQUAL;
+ }
return TokenNameNOT_EQUAL;
+ }
return TokenNameNOT;
case '*' :
if (getNextChar('='))
return TokenNameGREATER;
}
case '=' :
- if (getNextChar('='))
+ if (getNextChar('=')) {
+ if (getNextChar('=')) {
+ return TokenNameEQUAL_EQUAL_EQUAL;
+ }
return TokenNameEQUAL_EQUAL;
+ }
if (getNextChar('>'))
return TokenNameEQUAL_GREATER;
return TokenNameEQUAL;
};
if (isVariable) {
+ if (new String(getCurrentTokenSource()).equals("$this")) {
+ return TokenNamethis;
+ }
return TokenNameVariable;
}
int index, length;
switch (act) {
case TokenNameERROR :
- return "ScannerError(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
+ return "ScannerError"; // + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$
case TokenNameStopPHP :
return "StopPHP(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case TokenNameIdentifier :
return "var"; //$NON-NLS-1$
case TokenNamewhile :
return "while"; //$NON-NLS-1$
+ case TokenNamethis :
+ return "$this"; //$NON-NLS-1$
case TokenNameIntegerLiteral :
return "Integer(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
case TokenNameDoubleLiteral :
return "--"; //$NON-NLS-1$
case TokenNameEQUAL_EQUAL :
return "=="; //$NON-NLS-1$
+ case TokenNameEQUAL_EQUAL_EQUAL :
+ return "==="; //$NON-NLS-1$
case TokenNameEQUAL_GREATER :
return "=>"; //$NON-NLS-1$
case TokenNameLESS_EQUAL :
return ">="; //$NON-NLS-1$
case TokenNameNOT_EQUAL :
return "!="; //$NON-NLS-1$
+ case TokenNameNOT_EQUAL_EQUAL :
+ return "!=="; //$NON-NLS-1$
case TokenNameLEFT_SHIFT :
return "<<"; //$NON-NLS-1$
case TokenNameRIGHT_SHIFT :