Changeset 90265 in webkit for trunk/Source/JavaScriptCore/parser/Lexer.cpp
- Timestamp:
- Jul 1, 2011, 12:47:05 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/Lexer.cpp
r89257 r90265 234 234 m_keywordTable.deleteTable(); 235 235 } 236 237 UString Lexer::getInvalidCharMessage() 238 { 239 switch (m_current) { 240 case 0: 241 return "Invalid character: '\\0'"; 242 case 10: 243 return "Invalid character: '\\n'"; 244 case 11: 245 return "Invalid character: '\\v'"; 246 case 13: 247 return "Invalid character: '\\r'"; 248 case 35: 249 return "Invalid character: '#'"; 250 case 64: 251 return "Invalid character: '@'"; 252 case 96: 253 return "Invalid character: '`'"; 254 default: 255 return String::format("Invalid character '\\u%04u'", m_current).impl(); 256 } 257 } 236 258 237 259 ALWAYS_INLINE const UChar* Lexer::currentCharacter() const … … 262 284 m_error = false; 263 285 m_atLineStart = true; 286 m_lexErrorMessage = UString(); 264 287 265 288 m_buffer8.reserveInitialCapacity(initialReadBufferCapacity); … … 528 551 if (shouldBuildStrings) 529 552 record16('u'); 530 } else // Only stringQuoteCharacter allowed after \u 553 } else { 554 m_lexErrorMessage = "\\u can only be followed by a Unicode character sequence"; 531 555 return false; 556 } 532 557 } else if (strictMode && isASCIIDigit(m_current)) { 533 558 // The only valid numeric escape in strict mode is '\0', and this must not be followed by a decimal digit. 534 559 int character1 = m_current; 535 560 shift(); 536 if (character1 != '0' || isASCIIDigit(m_current)) 561 if (character1 != '0' || isASCIIDigit(m_current)) { 562 m_lexErrorMessage = "The only valid numeric escape in strict mode is '\\0'"; 537 563 return false; 564 } 538 565 if (shouldBuildStrings) 539 566 record16(0); … … 562 589 record16(m_current); 563 590 shift(); 564 } else 591 } else { 592 m_lexErrorMessage = "Unterminated string constant"; 565 593 return false; 594 } 566 595 567 596 stringStart = currentCharacter(); … … 573 602 if (UNLIKELY(((static_cast<unsigned>(m_current) - 0xE) & 0x2000))) { 574 603 // New-line or end of input is not allowed 575 if (UNLIKELY(isLineTerminator(m_current)) || UNLIKELY(m_current == -1)) 604 if (UNLIKELY(isLineTerminator(m_current)) || UNLIKELY(m_current == -1)) { 605 m_lexErrorMessage = "Unexpected EOF"; 576 606 return false; 607 } 577 608 // Anything else is just a normal character 578 609 } … … 924 955 if (parseMultilineComment()) 925 956 goto start; 957 m_lexErrorMessage = "Multiline comment was not closed properly"; 926 958 goto returnError; 927 959 } … … 1043 1075 if (isASCIIOctalDigit(m_current)) { 1044 1076 if (parseOctal(tokenData->doubleValue)) { 1045 if (strictMode) 1077 if (strictMode) { 1078 m_lexErrorMessage = "Octal escapes are forbidden in strict mode"; 1046 1079 goto returnError; 1080 } 1047 1081 token = NUMBER; 1048 1082 } … … 1059 1093 } 1060 1094 if ((m_current | 0x20) == 'e') 1061 if (!parseNumberAfterExponentIndicator()) 1095 if (!parseNumberAfterExponentIndicator()) { 1096 m_lexErrorMessage = "Non-number found after exponent indicator"; 1062 1097 goto returnError; 1098 } 1063 1099 // Null-terminate string for strtod. 1064 1100 m_buffer8.append('\0'); … … 1069 1105 1070 1106 // No identifiers allowed directly after numeric literal, e.g. "3in" is bad. 1071 if (UNLIKELY(isIdentStart(m_current))) 1107 if (UNLIKELY(isIdentStart(m_current))) { 1108 m_lexErrorMessage = "At least one digit must occur after a decimal point"; 1072 1109 goto returnError; 1110 } 1073 1111 m_buffer8.resize(0); 1074 1112 m_delimited = false; … … 1102 1140 goto start; 1103 1141 case CharacterInvalid: 1142 m_lexErrorMessage = getInvalidCharMessage(); 1104 1143 goto returnError; 1105 1144 default: 1106 1145 ASSERT_NOT_REACHED(); 1146 m_lexErrorMessage = "Internal Error"; 1107 1147 goto returnError; 1108 1148 }
Note:
See TracChangeset
for help on using the changeset viewer.