src/jdk/nashorn/internal/parser/Lexer.java
Print this page
*** 646,656 ****
* @param ch Character to convert.
* @param base Numeric base.
*
* @return The converted digit or -1 if invalid.
*/
! private static int convertDigit(final char ch, final int base) {
int digit;
if ('0' <= ch && ch <= '9') {
digit = ch - '0';
} else if ('A' <= ch && ch <= 'Z') {
--- 646,656 ----
* @param ch Character to convert.
* @param base Numeric base.
*
* @return The converted digit or -1 if invalid.
*/
! protected static int convertDigit(final char ch, final int base) {
int digit;
if ('0' <= ch && ch <= '9') {
digit = ch - '0';
} else if ('A' <= ch && ch <= 'Z') {
*** 906,916 ****
}
/**
* Scan over a string literal.
*/
! private void scanString(final boolean add) {
// Type of string.
TokenType type = STRING;
// Record starting quote.
final char quote = ch0;
// Skip over quote.
--- 906,916 ----
}
/**
* Scan over a string literal.
*/
! protected void scanString(final boolean add) {
// Type of string.
TokenType type = STRING;
// Record starting quote.
final char quote = ch0;
// Skip over quote.
*** 923,932 ****
--- 923,935 ----
while (!atEOF() && ch0 != quote && !isEOL(ch0)) {
// Skip over escaped character.
if (ch0 == '\\') {
type = ESCSTRING;
skip(1);
+ if (! isEscapeCharacter(ch0)) {
+ error(Lexer.message("invalid.escape.char"), STRING, position, limit);
+ }
if (isEOL(ch0)) {
// Multiline string literal
skipEOL(false);
continue;
}
*** 977,986 ****
--- 980,999 ----
}
}
}
/**
+ * Is the given character a valid escape char after "\" ?
+ *
+ * @param ch character to be checked
+ * @return if the given character is valid after "\"
+ */
+ protected boolean isEscapeCharacter(final char ch) {
+ return true;
+ }
+
+ /**
* Convert string to number.
*
* @param valueString String to convert.
* @param radix Numeric base.
* @return Converted number.
*** 1022,1032 ****
}
/**
* Scan a number.
*/
! private void scanNumber() {
// Record beginning of number.
final int start = position;
// Assume value is a decimal.
TokenType type = DECIMAL;
--- 1035,1045 ----
}
/**
* Scan a number.
*/
! protected void scanNumber() {
// Record beginning of number.
final int start = position;
// Assume value is a decimal.
TokenType type = DECIMAL;
*** 1581,1591 ****
}
return null;
}
! private static String message(final String msgId, final String... args) {
return ECMAErrors.getMessage("lexer.error." + msgId, args);
}
/**
* Generate a runtime exception
--- 1594,1604 ----
}
return null;
}
! protected static String message(final String msgId, final String... args) {
return ECMAErrors.getMessage("lexer.error." + msgId, args);
}
/**
* Generate a runtime exception