X-Git-Url: http://git.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 bfbb4d7..e313f23 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 @@ -18,7 +18,9 @@ import net.sourceforge.phpdt.core.compiler.CharOperation; 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; +import net.sourceforge.phpeclipse.internal.compiler.ast.StringLiteral; + + public class Scanner implements IScanner, ITerminalSymbols { /* * APIs ares - getNextToken() which return the current type of the token @@ -869,6 +871,8 @@ public class Scanner implements IScanner, ITerminalSymbols { // } } } catch (IndexOutOfBoundsException e) { +// reset end position for error reporting + currentPosition-=2; throw new InvalidInputException(UNTERMINATED_STRING); } catch (InvalidInputException e) { if (e.getMessage().equals(INVALID_ESCAPE)) { @@ -965,6 +969,8 @@ public class Scanner implements IScanner, ITerminalSymbols { // } } } catch (IndexOutOfBoundsException e) { + // reset end position for error reporting + currentPosition-=2; throw new InvalidInputException(UNTERMINATED_STRING); } catch (InvalidInputException e) { if (e.getMessage().equals(INVALID_ESCAPE)) { @@ -1061,6 +1067,8 @@ public class Scanner implements IScanner, ITerminalSymbols { // } } } catch (IndexOutOfBoundsException e) { +// reset end position for error reporting + currentPosition-=2; throw new InvalidInputException(UNTERMINATED_STRING); } catch (InvalidInputException e) { if (e.getMessage().equals(INVALID_ESCAPE)) { @@ -1195,7 +1203,7 @@ public class Scanner implements IScanner, ITerminalSymbols { case '\'' : if (tokenizeStrings) { consumeStringConstant(); - return TokenNameStringConstant; + return TokenNameStringSingleQuote; } return TokenNameEncapsedString1; case '"' : @@ -1460,11 +1468,11 @@ public class Scanner implements IScanner, ITerminalSymbols { return TokenNameAT; case '\'' : consumeStringConstant(); - return TokenNameStringConstant; + return TokenNameStringSingleQuote; case '"' : if (tokenizeStrings) { consumeStringLiteral(); - return TokenNameStringLiteral; + return TokenNameStringDoubleQuote; } return TokenNameEncapsedString2; case '`' : @@ -1702,6 +1710,8 @@ public class Scanner implements IScanner, ITerminalSymbols { return TokenNameCOMMENT_BLOCK; } } catch (IndexOutOfBoundsException e) { +// reset end position for error reporting + currentPosition-=2; throw new InvalidInputException(UNTERMINATED_COMMENT); } break; @@ -2257,6 +2267,9 @@ public class Scanner implements IScanner, ITerminalSymbols { public char[] getSource() { return this.source; } + public static boolean isIdentifierOrKeyword(int token) { + return (token == TokenNameIdentifier) || (token > TokenNameKEYWORD); + } final char[] optimizedCurrentTokenSource1() { //return always the same char[] build only once //optimization at no speed cost of 99.5 % of the singleCharIdentifier @@ -3724,9 +3737,9 @@ public class Scanner implements IScanner, ITerminalSymbols { return "Integer(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ case TokenNameDoubleLiteral : return "Double(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - case TokenNameStringLiteral : + case TokenNameStringDoubleQuote : return "StringLiteral(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - case TokenNameStringConstant : + case TokenNameStringSingleQuote : return "StringConstant(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ case TokenNameStringInterpolated : return "StringInterpolated(" + new String(getCurrentTokenSource())