better error messages for unterminated strings and comments
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Scanner.java
index 0544363..e313f23 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)) {
@@ -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;