tonioo / sievelib

Client-side Sieve and Managesieve library written in Python.
MIT License
46 stars 24 forks source link

Save position (line/col) of parse error. #92

Closed derula closed 4 years ago

derula commented 4 years ago

Currently, the Lexer pos is at the end of the current token during yield. This means that the start position of the error cannot be reproduced. By updating the pos after the yield, we can determine the first broken byte.

Then, upon parse error, we can save error_pos = (line, col), which can be used to e.g. jump to the beginning of the error in a text editor. Otherwise, the best you could do is jump to the end of the error, which is counter-intuitive.

This also effects the error messages, which no longer claim that the error is at the end of the token, but its start.

derula commented 4 years ago

Currently checking unit tests. The failed script seems to test for unreleased features, as 1.1.1 fails to parse it as well.

codecov[bot] commented 4 years ago

Codecov Report

Merging #92 into master will decrease coverage by 0.02%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #92      +/-   ##
==========================================
- Coverage   85.21%   85.19%   -0.03%     
==========================================
  Files          10       10              
  Lines        1867     1871       +4     
==========================================
+ Hits         1591     1594       +3     
- Misses        276      277       +1     
Impacted Files Coverage Δ
sievelib/parser.py 86.23% <100.00%> (-0.19%) :arrow_down:

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 8855c3f...495ea62. Read the comment docs.

derula commented 4 years ago

I don't exactly understand how this is adding one miss in codecov. Seems to me like all the lines I touched are actually hit.

tonioo commented 4 years ago

@derula Indeed, all lines look covered. Codecov sometimes report strange results.