Skip to content
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

[Merged by Bors] - Reduced boilerplate code in the parser #2410

Closed
wants to merge 1 commit into from

Conversation

Razican
Copy link
Member

@Razican Razican commented Nov 5, 2022

This PR adds an OrAbrupt trait, with the or_abrupt() function. This function is equivalent to the previous ?.ok_or(ParseError::AbruptEnd), but it's cleaner. It's implemented for the parser cursor results types.

It also adds an advance() function to the parser cursor (which might be possible to optimize further), that just advances the cursor without returning any token. This shows a clearer intent in many places where it's being used.

I also used ParseResult in more places, since we were not using it in many places.

@Razican Razican added parser Issues surrounding the parser Internal Category for changelog labels Nov 5, 2022
@Razican Razican added this to the v0.17.0 milestone Nov 5, 2022
@github-actions
Copy link

github-actions bot commented Nov 5, 2022

Test262 conformance changes

Test result main count PR count difference
Total 93,789 93,789 0
Passed 69,500 69,500 0
Ignored 18,422 18,422 0
Failed 5,867 5,867 0
Panics 0 0 0
Conformance 74.10% 74.10% 0.00%

@codecov
Copy link

codecov bot commented Nov 5, 2022

Codecov Report

Merging #2410 (5438162) into main (8e14d76) will increase coverage by 0.31%.
The diff coverage is 61.07%.

❗ Current head 5438162 differs from pull request most recent head 4e78079. Consider uploading reports for the commit 4e78079 to get more accurate results

@@            Coverage Diff             @@
##             main    #2410      +/-   ##
==========================================
+ Coverage   38.41%   38.72%   +0.31%     
==========================================
  Files         313      313              
  Lines       23974    23874     -100     
==========================================
+ Hits         9210     9246      +36     
+ Misses      14764    14628     -136     
Impacted Files Coverage Δ
boa_engine/src/syntax/parser/error.rs 44.44% <ø> (ø)
...rser/expression/assignment/async_arrow_function.rs 0.00% <0.00%> (ø)
...syntax/parser/expression/assignment/conditional.rs 50.00% <0.00%> (-3.85%) ⬇️
...src/syntax/parser/expression/left_hand_side/mod.rs 62.50% <0.00%> (ø)
boa_engine/src/syntax/parser/expression/mod.rs 40.21% <0.00%> (-2.12%) ⬇️
.../parser/expression/primary/class_expression/mod.rs 0.00% <0.00%> (ø)
...oa_engine/src/syntax/parser/statement/block/mod.rs 41.46% <0.00%> (-0.21%) ⬇️
...ngine/src/syntax/parser/statement/break_stm/mod.rs 58.82% <0.00%> (-5.89%) ⬇️
...ne/src/syntax/parser/statement/continue_stm/mod.rs 60.00% <0.00%> (-5.00%) ⬇️
...gine/src/syntax/parser/statement/return_stm/mod.rs 62.50% <0.00%> (-6.25%) ⬇️
... and 108 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Razican Razican changed the title Added OrAbrupt trait to reduce some boilerplate code in the parser Reduced boilerplate code in the parser Nov 5, 2022
Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changes!

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect to me!

@HalidOdat
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Nov 6, 2022
This PR adds an `OrAbrupt` trait, with the `or_abrupt()` function. This function is equivalent to the previous `?.ok_or(ParseError::AbruptEnd)`, but it's cleaner. It's implemented for the parser cursor results types.

It also adds an `advance()` function to the parser cursor (which might be possible to optimize further), that just advances the cursor without returning any token. This shows a clearer intent in many places where it's being used.

I also used `ParseResult` in more places, since we were not using it in many places.
@bors
Copy link

bors bot commented Nov 6, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Reduced boilerplate code in the parser [Merged by Bors] - Reduced boilerplate code in the parser Nov 6, 2022
@bors bors bot closed this Nov 6, 2022
@bors bors bot deleted the or_abrupt branch November 6, 2022 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Category for changelog parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants