From 5450e645a52543fc29123e780ad3ff09501004a0 Mon Sep 17 00:00:00 2001 From: khartlage Date: Sun, 11 Jul 2004 20:49:26 +0000 Subject: [PATCH] better error messages for unterminated strings and comments --- .../phpdt/internal/compiler/parser/Parser.java | 7 +++++++ .../phpdt/internal/compiler/parser/Scanner.java | 8 ++++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index 264b0ad..137bf14 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -208,6 +208,13 @@ public class Parser //extends PHPParserSuperclass } } catch (InvalidInputException e) { token = TokenNameERROR; + String detailedMessage = e.getMessage(); + + if (detailedMessage==Scanner.UNTERMINATED_STRING) { + throwSyntaxError("Unterminated string."); + } else if (detailedMessage==Scanner.UNTERMINATED_COMMENT) { + throwSyntaxError("Unterminated commment."); + } } return; } 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 0544363..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 @@ -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; -- 1.7.1