-
Notifications
You must be signed in to change notification settings - Fork 683
Change '{' regex parsing to work similarly to other engines (#2134) #2169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change '{' regex parsing to work similarly to other engines (#2134) #2169
Conversation
…ipt-project#2134) Changed regex parsing to be able to handle opening braces as other engines do, and also added a compile flag which can disable this behaviour. JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
ad7702a
to
02cf035
Compare
case LIT_CHAR_LEFT_BRACE: | ||
{ | ||
#ifdef ENABLE_REGEXP_STRICT_MODE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we switch around the logic and do something like this?
case LIT_CHAR_PLUS:
case LIT_CHAR_LEFT_BRACE:
{
#ifndef ENABLE_REGEXP_STRICT_MODE
const lit_utf8_byte_t *input_curr_p = parser_ctx_p->input_curr_p;
lit_utf8_decr (&parser_ctx_p->input_curr_p);
if (!ecma_is_value_empty (re_parse_iterator (parser_ctx_p, out_token_p)))
{
parser_ctx_p->input_curr_p = input_curr_p;
out_token_p->type = RE_TOK_CHAR;
out_token_p->value = ch;
ret_value = re_parse_iterator (parser_ctx_p, out_token_p);
if (!ecma_is_value_empty (ret_value))
{
parser_ctx_p->input_curr_p = input_curr_p;
ret_value = ECMA_VALUE_EMPTY;
}
break;
}
#else /* ENABLE_REGEXP_STRICT_MODE */
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid RegExp token."));
#endif /* !ENABLE_REGEXP_STRICT_MODE */
so we can remove the 884-886 line additions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can't remove these lines, because this patch handles only the {
braces issue and doesn't catch other iterator characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh yeah! I was to eager to simplify.
set(FEATURE_MEM_STRESS_TEST OFF CACHE BOOL "Enable mem-stress test?") | ||
set(FEATURE_PARSER_DUMP OFF CACHE BOOL "Enable parser byte-code dumps?") | ||
set(FEATURE_PROFILE "es5.1" CACHE STRING "Use default or other profile?") | ||
set(FEATURE_REGEXP_STRICT_MODE OFF CACHE BOOL "Enable regexp strict mode?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we change the current behaviour here? Personally I would prefer FEATURE_REGEXP_COMPATIBILITY_MODE, and keep it OFF by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, now the compatibility mode is the default, so the regexp engine accepts this /{}/
regex pattern while the strict mode does not.
Shall I set the strict mode as default?
(Personally I would prefer the extended behaviour as default, like other engines.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to hear others opinion (kind of voting). I usually prefer to keep the current behaviour but I am not that strict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong preferences. I think the average user won't notice the compatibility features only if they dig into the build system. So enable compatibility mode by default sounds reasonable for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @szledan and @LaszloLango, the compatibility features should be enabled by default, but I would change the name also. So my vote is to set the FEATURE_REGEXP_COMPATIBILITY_MODE
to ON
instead of setting the FEATURE_REGEXP_STRICT_MODE
to OFF
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I rethought it, the FEATURE_REGEXP_STRICT_MODE
with OFF
is fine. The other version may cause problems/different behaviors if somebody want to compile without CMake and forget to define the appropriate macro. LGTM (informally)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It is a followup fix after jerryscript-project#2169. Fixes jerryscript-project#2204. It also fixes a memory leak. JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
It is a followup fix after jerryscript-project#2169. Fixes jerryscript-project#2204. It also fixes a memory leak. JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
It is a followup fix after jerryscript-project#2169. It also fixes a memory leak. This fixes jerryscript-project#2198 and fixes jerryscript-project#2204 JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
It is a followup fix after #2169. It also fixes a memory leak. This fixes #2198 and fixes #2204 JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
It is a followup fix after jerryscript-project#2169. It also fixes a memory leak. This fixes jerryscript-project#2198 and fixes jerryscript-project#2204 JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
Changed regex parsing to be able to handle opening braces
as other engines do, and also added a compile flag which
can disable this behaviour.
JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]