Ignore:
Timestamp:
Mar 3, 2016, 5:24:28 PM (9 years ago)
Author:
[email protected]
Message:

[ES6] Make Unicode RegExp pattern parsing conform to the spec
https://bugs.webkit.org/show_bug.cgi?id=154988

Reviewed by Benjamin Poulain.

Source/JavaScriptCore:

Updated RegExp pattern processing with 'u' (Unicode) flag to conform to the
spec (https://tc39.github.io/ecma262/2016/#sec-patterns). In the spec, the
grammar is annotated with [U] annotations. Productions that are prefixed with
[+U] are only available with the Unicode flags while productions prefixed with
[~U] are only available without the Unicode flag.

Added flags argument to Yarr::checkSyntax() so we can catch Unicode flag related
parsing errors at syntax checking time. Restricted what escapes are available for
non Unicode patterns. Most of this is defined in the IdentityEscape rule in the
pattern grammar.

Added \- as a CharacterClass only escape in Unicode patterns.

Updated the tests for these changes.

Made changes suggested in https://bugs.webkit.org/show_bug.cgi?id=154842#c22 after
change set r197426 was landed.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createRegExp):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parsePrimaryExpression):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createRegExp):

  • yarr/YarrInterpreter.cpp:

(JSC::Yarr::Interpreter::InputStream::readChecked):
(JSC::Yarr::Interpreter::InputStream::readSurrogatePairChecked):
(JSC::Yarr::Interpreter::InputStream::reread):
(JSC::Yarr::Interpreter::InputStream::uncheckInput):
(JSC::Yarr::Interpreter::InputStream::atStart):
(JSC::Yarr::Interpreter::InputStream::atEnd):
(JSC::Yarr::Interpreter::testCharacterClass):
(JSC::Yarr::Interpreter::backtrackPatternCharacter):
(JSC::Yarr::Interpreter::matchDisjunction):
(JSC::Yarr::ByteCompiler::atomPatternCharacter):

  • yarr/YarrParser.h:

(JSC::Yarr::Parser::Parser):
(JSC::Yarr::Parser::isIdentityEscapeAnError):
(JSC::Yarr::Parser::parseEscape):
(JSC::Yarr::Parser::parse):

  • yarr/YarrPattern.cpp:

(JSC::Yarr::CharacterClassConstructor::putChar):
(JSC::Yarr::CharacterClassConstructor::putRange):
(JSC::Yarr::CharacterClassConstructor::addSorted):
(JSC::Yarr::YarrPatternConstructor::setupAlternativeOffsets):

  • yarr/YarrSyntaxChecker.cpp:

(JSC::Yarr::SyntaxChecker::disjunction):
(JSC::Yarr::checkSyntax):

  • yarr/YarrSyntaxChecker.h:

LayoutTests:

Added tests cases.

  • js/regexp-unicode-expected.txt:
  • js/script-tests/regexp-unicode.js:

(shouldThrowInvalidEscape):

[ES6] Add support for Symbol.toPrimitive
https://bugs.webkit.org/show_bug.cgi?id=154877

Reviewed by Saam Barati.

Update test for Symbol.toPrimitive.

  • js/Object-getOwnPropertyNames-expected.txt:
  • js/script-tests/Object-getOwnPropertyNames.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/yarr/YarrSyntaxChecker.cpp

    r197426 r197534  
    5151};
    5252
    53 const char* checkSyntax(const String& pattern)
     53const char* checkSyntax(const String& pattern, const String& flags)
    5454{
    5555    SyntaxChecker syntaxChecker;
    56     return parse(syntaxChecker, pattern, false);
     56    return parse(syntaxChecker, pattern, flags.contains('u'));
    5757}
    5858
Note: See TracChangeset for help on using the changeset viewer.