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

Ensure Char doesn't match provided delim before marking OK #153

Merged
merged 9 commits into from
Dec 14, 2022
Merged

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Dec 13, 2022

In the switch to making Char non-greedy in the 2.5 release, I failed to account for the fact that the parsed Char may in fact be the delimiter provided, in which case we want to match the delim instead of treating it as a successfully parsed Char (Char is greedy in this way like Strings).

Luckily we can still do this pretty efficiently by checking our parsed Char against the delimiter, if there is one.

In the switch to making Char non-greedy in the 2.5 release, I
failed to account for the fact that the parsed Char may in fact
be the delimiter provided, in which case we want to match the delim
instead of treating it as a successfully parsed Char (Char is greedy
in this way like Strings).

Luckily we can still do this pretty efficiently by checking our parsed
Char against the delimiter, if there is one.
@codecov
Copy link

codecov bot commented Dec 13, 2022

Codecov Report

Base: 91.03% // Head: 88.36% // Decreases project coverage by -2.67% ⚠️

Coverage data is based on head (4db2386) compared to base (f994915).
Patch coverage: 92.85% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #153      +/-   ##
==========================================
- Coverage   91.03%   88.36%   -2.68%     
==========================================
  Files           9        8       -1     
  Lines        1607     1530      -77     
==========================================
- Hits         1463     1352     -111     
- Misses        144      178      +34     
Impacted Files Coverage Δ
src/utils.jl 80.88% <80.00%> (-7.52%) ⬇️
src/strings.jl 94.11% <100.00%> (+2.59%) ⬆️
src/dates.jl 76.17% <0.00%> (-2.92%) ⬇️
src/Parsers.jl 94.73% <0.00%> (-2.02%) ⬇️
src/floats.jl 93.69% <0.00%> (-1.60%) ⬇️
src/components.jl 98.34% <0.00%> (-0.83%) ⬇️
src/bools.jl 97.50% <0.00%> (-0.12%) ⬇️
src/precompile.jl

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

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Drvi
Copy link
Collaborator

Drvi commented Dec 13, 2022

I think the interaction with EOF is still not quite right, compared to String, for example:

julia> Parsers.xparse(String, ",,", 1, 2, Parsers.Options(sentinel=missing, delim=','))
Parsers.Result{Parsers.PosLen}(code=`SUCCESS: SENTINEL | DELIMITED `, tlen=1, val=PosLen(pos=1, len=0, missingvalue=false, escapedvalue=false))

julia> Parsers.xparse(String, ",,", 2, 2, Parsers.Options(sentinel=missing, delim=','))
Parsers.Result{Parsers.PosLen}(code=`SUCCESS: SENTINEL | DELIMITED `, tlen=1, val=PosLen(pos=2, len=0, missingvalue=false, escapedvalue=false))

julia> Parsers.xparse(String, ",,", 3, 2, Parsers.Options(sentinel=missing, delim=','))
Parsers.Result{Parsers.PosLen}(code=`SUCCESS: SENTINEL | EOF `, tlen=0, val=PosLen(pos=3, len=0, missingvalue=false, escapedvalue=false))
julia> Parsers.xparse(Char, ",,", 1, 2, Parsers.Options(sentinel=missing, delim=','))
Parsers.Result{Char}(code=`SUCCESS: SENTINEL | DELIMITED `, tlen=1, val=����)

julia> Parsers.xparse(Char, ",,", 2, 2, Parsers.Options(sentinel=missing, delim=','))
Parsers.Result{Char}(code=`SUCCESS: SENTINEL | DELIMITED | EOF `, tlen=1, val=����)

julia> Parsers.xparse(Char, ",,", 3, 2, Parsers.Options(sentinel=missing, delim=','))
Parsers.Result{Char}(code=`SUCCESS: OK | EOF `, tlen=1, val=)

@quinnj
Copy link
Member Author

quinnj commented Dec 13, 2022

@Drvi, I think the JET failures are unrelated? Would you mind taking a look? Otherwise, I think this is ready to merge and tag.

test/runtests.jl Outdated Show resolved Hide resolved
Copy link
Collaborator

@nickrobinson251 nickrobinson251 left a comment

Choose a reason for hiding this comment

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

LGTM

some thoughts on tests but whatever you decide is fine

test/runtests.jl Outdated Show resolved Hide resolved
test/runtests.jl Outdated Show resolved Hide resolved
@Drvi Drvi mentioned this pull request Dec 14, 2022
@Drvi Drvi merged commit 8eca7df into main Dec 14, 2022
@Drvi Drvi deleted the jq-greedy-char branch December 14, 2022 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants