Ignore:
Timestamp:
Dec 9, 2008, 8:59:06 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-12-09 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.

In preparation for compiling WREC without PCRE:


Further relaxed WREC's parsing to be more web-compatible. Fixed PCRE to
match in cases where it didn't already.


Changed JavaScriptCore to report syntax errors detected by WREC, rather
than falling back on PCRE any time WREC sees an error.


  • pcre/pcre_compile.cpp: (checkEscape): Relaxed parsing of \c and \N escapes to be more web-compatible.


  • runtime/RegExp.cpp: (JSC::RegExp::RegExp): Only fall back on PCRE if WREC has not reported a syntax error.
  • wrec/WREC.cpp: (JSC::WREC::Generator::compileRegExp): Fixed some error reporting to match PCRE.
  • wrec/WRECParser.cpp: Added error messages that match PCRE.

(JSC::WREC::Parser::consumeGreedyQuantifier):
(JSC::WREC::Parser::parseParentheses):
(JSC::WREC::Parser::parseCharacterClass):
(JSC::WREC::Parser::parseNonCharacterEscape): Updated the above functions to
use the new setError API.

(JSC::WREC::Parser::consumeEscape): Relaxed parsing of \c \N \u \x \B
to be more web-compatible.

(JSC::WREC::Parser::parseAlternative): Distinguish between a malformed
quantifier and a quantifier with no prefix, like PCRE does.

(JSC::WREC::Parser::consumeParenthesesType): Updated to use the new setError API.

  • wrec/WRECParser.h: (JSC::WREC::Parser::error): (JSC::WREC::Parser::syntaxError): (JSC::WREC::Parser::parsePattern): (JSC::WREC::Parser::reset): (JSC::WREC::Parser::setError): Store error messages instead of error codes, to provide for exception messages. Use a setter for reporting errors, so errors detected early are not overwritten by errors detected later.

LayoutTests:

2008-12-09 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.

Updated regular expression layout tests to be agnostic between WREC
and PCRE quirks. Also, updated results to match new, more web-compatible
regular expression parsing.

  • fast/js/regexp-charclass-crash-expected.txt:
  • fast/js/regexp-charclass-crash.html:
  • fast/js/regexp-no-extensions-expected.txt:
  • fast/js/resources/regexp-no-extensions.js:
  • fast/regex/test1-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/pcre/pcre_compile.cpp

    r34858 r39162  
    237237                 this is not octal. */
    238238               
    239                 if ((c = *ptr) >= '8')
     239                if ((c = *ptr) >= '8') {
     240                    c = '\\';
     241                    ptr -= 1;
    240242                    break;
     243                }
    241244
    242245            /* \0 always starts an octal number, but we may drop through to here with a
     
    299302                    return 0;
    300303                }
     304               
    301305                c = *ptr;
    302                
     306                if (!isASCIIAlpha(c)) {
     307                    c = '\\';
     308                    ptr -= 2;
     309                    break;
     310                }
     311
    303312                /* A letter is upper-cased; then the 0x40 bit is flipped. This coding
    304313                 is ASCII-specific, but then the whole concept of \cx is ASCII-specific. */
Note: See TracChangeset for help on using the changeset viewer.