-
Notifications
You must be signed in to change notification settings - Fork 687
Support ES6 based octal literals #3338
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
Support ES6 based octal literals #3338
Conversation
dcebf1a to
99ab518
Compare
jerry-core/parser/js/js-lexer.c
Outdated
| const uint8_t *src_end_p = src_p + length - 1; | ||
|
|
||
| #if ENABLED (JERRY_ES2015) | ||
| if (src_p[1] == LIT_CHAR_LOWERCASE_O) |
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.
This should be LEXER_TO_ASCII_LOWERCASE (src_p[1) == LIT_CHAR_LOWERCASE_O
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.
Good catch! You are right :)
6641aa9 to
ea863dd
Compare
ea863dd to
5abafb5
Compare
ossy-szeged
left a comment
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.
It's great to support octal literals. But I think we should make Number(...) too to be able to parse octal numbers too. Of course, it can be done in a follow-up PR.
jerry-core/parser/js/js-lexer.c
Outdated
|
|
||
| if (*source_p < context_p->source_end_p | ||
| && *source_p[0] >= LIT_CHAR_8 | ||
| && *source_p[0] <= LIT_CHAR_9) |
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.
Are you sure if this check is correct? Maybe I'm wrong, but I can't see what is it for.
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.
This part of code checks if an octal literal contains 8 or 9 digits (that is not allowed). (A simple copy paste from the original code.) But it can be simplified :)
tests/jerry/es2015/octal.js
Outdated
| // limitations under the License. | ||
|
|
||
| assert (0o10 === 8); | ||
| assert (0O10 === 0o10); |
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.
Can we add more tests, maybe invalid tests too to check corner cases of the parser.
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.
Of course.
aa9e5af to
5cd750f
Compare
jerry-core/parser/js/js-lexer.c
Outdated
| if (*source_p < context_p->source_end_p | ||
| && (*source_p[0] == LIT_CHAR_8 || *source_p[0] == LIT_CHAR_9)) | ||
| { | ||
| parser_raise_error (context_p, PARSER_ERR_INVALID_NUMBER); |
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.
Shouldn't we use the PARSER_ERR_INVALID_OCTAL_DIGIT error here as well?
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, that is more precise error message. I've modified the PR.
5cd750f to
41d297c
Compare
dbatyai
left a comment
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
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs [email protected]
41d297c to
221a11a
Compare
rerobika
left a comment
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
No description provided.