-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
Added check to ignore semicolon in parser #913
Added check to ignore semicolon in parser #913
Conversation
Codecov Report
@@ Coverage Diff @@
## master #913 +/- ##
==========================================
+ Coverage 59.18% 59.21% +0.03%
==========================================
Files 166 166
Lines 10515 10554 +39
==========================================
+ Hits 6223 6250 +27
- Misses 4292 4304 +12
Continue to review full report at Codecov.
|
1e67661
to
6f8663b
Compare
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.
Looks really good! Just a couple of minor things which might be nice to include :)
Some tests showing the empty statement parsing etc. would also be nice - if the code is going to change later I'd argue they are even more valuable
I suggested on Discord to split this into two PRs. This one with a parse method refactor. And the new one with the EmptyStatement correct parsing solution. For the second one the idea is not to skip the semicolon but to parse it into EmptyStatement node, as does esprima.org parser: So I would move the following https://github.com/boa-dev/boa/pull/913/files#diff-42cd36e93bb156b2ab7a6277865a1b01d012dbc15af014ef25492f43b1343227R281-R284 down to the |
I will review this as soon as I have time, hopefully today.
This makes sense from a Parser-only perspective, but the issue with this is that adds extra allocations in the The current version just ignores In my opinion we shouldn't add an |
We will then not conform to the parsing and evaluation described in the ES, which possibly introduces errors and makes it harder to follow. |
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 like this new implementation, should solve the issue we are having with empty statements :) Just check my comments to see if we can improve it further.
boa/src/syntax/parser/mod.rs
Outdated
@@ -139,6 +139,9 @@ where | |||
} | |||
} | |||
|
|||
/// The possible TokenKind which indicate the end of a case statement. | |||
const SCRIPT_BREAK_TOKENS: [TokenKind; 1] = [TokenKind::Punctuator(Punctuator::CloseBlock)]; |
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.
Is this defined somewhere? I believe a script will never end with a }
, right? I think this list should be empty, and in that case, we should add the exception to the parser so that it doesn't fail with an AbruptEnd
error.
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.
No, I just added it cause I thought I needed to. I'm going to reassess each one and see what it's proper closing should be.
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.
Ok, I think this should be resolved. I'm not sure I understand what an exception should be, I ran the tests and I'm getting the same percentage. Can you give me an example of where this might occur?
After some discussion on discord, it seems that EmptyStatements are indeed important, and they will be implemented fully in the future, as @croraf mentions. For now, I would merge this as soon as the review comments are solved. |
Can we merge just the refactor part (which is the majority of this PR), without the semicolon part? (after resolving the comments ofc) |
Sorry @croraf I'll be working through the comments today, just got hit with a ton of work this week 😅 |
@AngelOnFira No hurry, we were just discussing. |
baae916
to
d59e1bc
Compare
d59e1bc
to
544e194
Compare
Cool. After this bigger addressing you can make a new PR for the semicolon changes if you wish, it should be very easy to solve that. |
Oops still have to make the tests :P |
Actually I think the tests don't apply here since this is just a refactor. |
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.
Looks good, thanks!
Test262 conformance changes:
Test result | master count | PR count | difference |
---|---|---|---|
Total | 78,415 | 78,415 | 0 |
Passed | 18,945 | 18,945 | 0 |
Ignored | 15,547 | 15,547 | 0 |
Failed | 43,923 | 43,923 | 0 |
Panics | 1,127 | 1,127 | 0 |
Conformance | 24.16 | 24.16 | 0.00% |
@AngelOnFira Gj. Are you willing to make another PR with the semicolon issue fix? |
@croraf ya, I'll try to do that now that this is merged. |
This Pull Request closes #892.
It changes the following:
In the original issue, it was mentioned that there might be a problem with empty
StatementLists
as well. I couldn't find a case where it didn't work as is, but I still brought the semicolon skip up a little higher.I'm not sure if any specific tests should be written for this, but if so I can add them.
This PR improves conformance by 0.07% 😄