Commit 45850f40 authored by yangguo's avatar yangguo Committed by Commit bot

[regexp] simplify unicode flag check.

It's sufficient to check for --harmony-unicode-regexps when parsing the
regexp flags from string.

R=neis@chromium.org

Review URL: https://codereview.chromium.org/1567413002

Cr-Commit-Position: refs/heads/master@{#33178}
parent 43d45493
......@@ -343,7 +343,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
// escaped,
// no other identity escapes are allowed. If the 'u' flag is not
// present, all identity escapes are allowed.
if (!FLAG_harmony_unicode_regexps || !unicode_) {
if (!unicode_) {
builder->AddCharacter(first_digit);
Advance(2);
} else {
......@@ -404,7 +404,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
uc32 value;
if (ParseHexEscape(2, &value)) {
builder->AddCharacter(value);
} else if (!FLAG_harmony_unicode_regexps || !unicode_) {
} else if (!unicode_) {
builder->AddCharacter('x');
} else {
// If the 'u' flag is present, invalid escapes are not treated as
......@@ -418,7 +418,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
uc32 value;
if (ParseUnicodeEscape(&value)) {
builder->AddCharacter(value);
} else if (!FLAG_harmony_unicode_regexps || !unicode_) {
} else if (!unicode_) {
builder->AddCharacter('u');
} else {
// If the 'u' flag is present, invalid escapes are not treated as
......@@ -434,8 +434,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
// other identity escapes are allowed. If the 'u' flag is not
// present,
// all identity escapes are allowed.
if (!FLAG_harmony_unicode_regexps || !unicode_ ||
IsSyntaxCharacter(current())) {
if (!unicode_ || IsSyntaxCharacter(current())) {
builder->AddCharacter(current());
Advance();
} else {
......@@ -736,7 +735,7 @@ bool RegExpParser::ParseUnicodeEscape(uc32* value) {
// Accept both \uxxxx and \u{xxxxxx} (if harmony unicode escapes are
// allowed). In the latter case, the number of hex digits between { } is
// arbitrary. \ and u have already been read.
if (current() == '{' && FLAG_harmony_unicode_regexps && unicode_) {
if (current() == '{' && unicode_) {
int start = position();
Advance();
if (ParseUnlimitedLengthHexNumber(0x10ffff, value)) {
......@@ -831,7 +830,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
if (ParseHexEscape(2, &value)) {
return value;
}
if (!FLAG_harmony_unicode_regexps || !unicode_) {
if (!unicode_) {
// If \x is not followed by a two-digit hexadecimal, treat it
// as an identity escape.
return 'x';
......@@ -847,7 +846,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
if (ParseUnicodeEscape(&value)) {
return value;
}
if (!FLAG_harmony_unicode_regexps || !unicode_) {
if (!unicode_) {
return 'u';
}
// If the 'u' flag is present, invalid escapes are not treated as
......@@ -860,8 +859,7 @@ uc32 RegExpParser::ParseClassCharacterEscape() {
// If the 'u' flag is present, only syntax characters can be escaped, no
// other identity escapes are allowed. If the 'u' flag is not present, all
// identity escapes are allowed.
if (!FLAG_harmony_unicode_regexps || !unicode_ ||
IsSyntaxCharacter(result)) {
if (!unicode_ || IsSyntaxCharacter(result)) {
Advance();
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment