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

Add numeric separator lexing #995

Merged
merged 2 commits into from
Dec 28, 2020
Merged

Add numeric separator lexing #995

merged 2 commits into from
Dec 28, 2020

Conversation

tofpie
Copy link
Contributor

@tofpie tofpie commented Dec 26, 2020

This Pull Request fixes #994

It changes the following:

  • Lexing of numbers

@codecov
Copy link

codecov bot commented Dec 26, 2020

Codecov Report

Merging #995 (0e7bbad) into master (015c11e) will increase coverage by 0.07%.
The diff coverage is 70.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #995      +/-   ##
==========================================
+ Coverage   59.97%   60.04%   +0.07%     
==========================================
  Files         166      166              
  Lines       10851    10881      +30     
==========================================
+ Hits         6508     6534      +26     
- Misses       4343     4347       +4     
Impacted Files Coverage Δ
boa/src/syntax/lexer/mod.rs 66.66% <50.00%> (-1.81%) ⬇️
boa/src/syntax/lexer/number.rs 68.45% <72.22%> (+5.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 015c11e...0e7bbad. Read the comment docs.

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 good!

Check my comments :)

R: Read,
{
let mut prev_is_underscore = false;
let mut pos = cursor.pos();
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the pos variable, cant we call cursor.pos() where we need the position?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to have the correct position when the separator is at the end of the number. If we take cursor.pos(), then the position is after the separator, on not on the separator.

boa/src/syntax/lexer/number.rs Outdated Show resolved Hide resolved
cursor.take_while_ascii_pred(&mut buf, &|c: char| c.is_digit(kind.base()))?;
if cursor.peek()? == Some(b'_') {
return Err(Error::syntax(
"numeric separator not allowed after .",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"numeric separator not allowed after .",
"numeric separator not allowed after '.'",

same here.

boa/src/syntax/lexer/number.rs Outdated Show resolved Hide resolved
@HalidOdat HalidOdat added enhancement New feature or request lexer Issues surrounding the lexer labels Dec 26, 2020
@HalidOdat HalidOdat added this to the v0.11.0 milestone Dec 26, 2020
@HalidOdat
Copy link
Member

Test result master count PR count difference
Total 78,493 78,493 0
Passed 19,596 19,735 +139
Ignored 15,585 15,585 0
Failed 43,312 43,173 -139
Panics 447 447 0
Conformance 24.97 25.14 +0.18%

Copy link
Member

@RageKnify RageKnify left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I'd preffer if one of the "parser people" had a look since I still don't fully grasp it.

Copy link

@Lan2u Lan2u left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@Lan2u Lan2u merged commit 6f3641d into boa-dev:master Dec 28, 2020
@tofpie tofpie deleted the numeric branch December 28, 2020 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lexer Issues surrounding the lexer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numeric separators are not supported
4 participants