Changeset 73594 in webkit for trunk/JavaScriptCore/yarr/RegexParser.h
- Timestamp:
- Dec 8, 2010, 9:40:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/yarr/RegexParser.h
r72999 r73594 59 59 ParenthesesTypeInvalid, 60 60 CharacterClassUnmatched, 61 CharacterClassInvalidRange,62 61 CharacterClassOutOfOrder, 63 62 EscapeUnterminated, … … 143 142 return; 144 143 144 // See coment in atomBuiltInCharacterClass below. 145 // This too is technically an error, per ECMA-262, and again we 146 // we chose to allow this. Note a subtlely here that while we 147 // diverge from the spec's definition of CharacterRange we do 148 // remain in compliance with the grammar. For example, consider 149 // the expression /[\d-a-z]/. We comply with the grammar in 150 // this case by not allowing a-z to be matched as a range. 145 151 case AfterCharacterClassHyphen: 146 // Error! We have something like /[\d-x]/.147 m_ err = CharacterClassInvalidRange;152 m_delegate.atomCharacterClassAtom(ch); 153 m_state = Empty; 148 154 return; 149 155 } … … 168 174 return; 169 175 176 // If we hit either of these cases, we have an invalid range that 177 // looks something like /[x-\d]/ or /[\d-\d]/. 178 // According to ECMA-262 this should be a syntax error, but 179 // empirical testing shows this to break teh webz. Instead we 180 // comply with to the ECMA-262 grammar, and assume the grammar to 181 // have matched the range correctly, but tweak our interpretation 182 // of CharacterRange. Effectively we implicitly handle the hyphen 183 // as if it were escaped, e.g. /[\w-_]/ is treated as /[\w\-_]/. 170 184 case CachedCharacterHyphen: 185 m_delegate.atomCharacterClassAtom(m_character); 186 m_delegate.atomCharacterClassAtom('-'); 187 // fall through 171 188 case AfterCharacterClassHyphen: 172 // Error! If we hit either of these cases, we have an 173 // invalid range that looks something like /[x-\d]/ 174 // or /[\d-\d]/. 175 m_err = CharacterClassInvalidRange; 189 m_delegate.atomCharacterClassBuiltIn(classID, invert); 190 m_state = Empty; 176 191 return; 177 192 } … … 682 697 "unrecognized character after (?", 683 698 "missing terminating ] for character class", 684 "invalid range in character class",685 699 "range out of order in character class", 686 700 "\\ at end of pattern"
Note:
See TracChangeset
for help on using the changeset viewer.