fixed some parser bugs
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Scanner.java
index c1098d5..0997cb7 100644 (file)
@@ -871,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)) {
@@ -967,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)) {
@@ -1063,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)) {
@@ -1185,7 +1191,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
               case '{' :
                 if (encapsedChar == '$') {
                   if (getNextChar('$'))
-                    return TokenNameCURLY_OPEN;
+                    return TokenNameLBRACE_DOLLAR;
                 }
                 return TokenNameLBRACE;
               case '}' :
@@ -1704,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;
@@ -2259,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
@@ -3849,6 +3860,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
         return "$";
       case TokenNameDOLLAR_LBRACE :
         return "${";
+      case TokenNameLBRACE_DOLLAR :
+        return "{$";
       case TokenNameEOF :
         return "EOF"; //$NON-NLS-1$
       case TokenNameWHITESPACE :