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

Updated parser #85

Merged
merged 15 commits into from
Feb 7, 2022
Merged

Updated parser #85

merged 15 commits into from
Feb 7, 2022

Conversation

obycode
Copy link
Member

@obycode obycode commented Jan 27, 2022

I am still doing some testing, but it is in good enough shape to start a review.

@codecov-commenter
Copy link

codecov-commenter commented Jan 27, 2022

Codecov Report

Merging #85 (e6c9a96) into develop (b112962) will increase coverage by 4.94%.
The diff coverage is 82.73%.

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

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      hirosystems/clarity-repl#85      +/-   ##
===========================================
+ Coverage    49.01%   53.95%   +4.94%     
===========================================
  Files           90       96       +6     
  Lines        24194    28751    +4557     
===========================================
+ Hits         11858    15514    +3656     
- Misses       12336    13237     +901     
Flag Coverage Δ
unittests 53.95% <82.73%> (+4.94%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/repl/mod.rs 90.00% <ø> (ø)
src/repl/settings.rs 5.26% <ø> (ø)
src/repl/interpreter.rs 48.65% <47.00%> (-7.05%) ⬇️
src/repl/ast/mod.rs 52.38% <52.38%> (ø)
src/repl/ast/parser/lexer/error.rs 55.00% <55.00%> (ø)
src/repl/ast/parser/lexer/token.rs 60.00% <60.00%> (ø)
src/repl/ast/parser/error.rs 61.11% <61.11%> (ø)
src/clarity/diagnostic.rs 44.44% <62.50%> (+0.21%) ⬆️
src/repl/session.rs 38.50% <71.42%> (-5.62%) ⬇️
src/repl/ast/parser/mod.rs 83.74% <83.74%> (ø)
... and 11 more

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 b112962...f20e58c. Read the comment docs.

@obycode obycode force-pushed the feat/parser2 branch 2 times, most recently from 6b9a34e to c38d6b5 Compare February 2, 2022 01:51
Copy link
Member

@lgalabru lgalabru left a comment

Choose a reason for hiding this comment

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

This improvements are super exciting, and the implementation is really elegant, thank you @obycode!
I added a few feedbacks, curious to get your thoughts!

@obycode obycode force-pushed the feat/parser2 branch 2 times, most recently from e6c9a96 to f20e58c Compare February 3, 2022 19:33
lgalabru
lgalabru previously approved these changes Feb 4, 2022
Copy link
Member

@lgalabru lgalabru left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @obycode!

This parser should have better performance and generate better errors.

Resolves: #74
Some diagnostics do not have a proper column number set, leaving it as a
0. The code here subtracts one from the value to translate it to the
number of spaces to insert, but if it is 0, this will cause a panic,
`attempt to subtract with overflow`.
Comments are still not properly handled yet, but at least they are being
properly skipped like whitespace for now.
If there was a comment with no content before a newline, then the next
line was being sucked into the comment.
When there is a newline at the end of a file, and an error is reported
at the very end (for example, for a missing ')'), this would crash when
attempting to print out the line. This is fixed by only advancing the
line number when the next token is not the end of the file.
This will be useful during the transition period as we switch from the
old parser to the new parser.
While v2 is new, run both parsers and check that the ASTs are
equivalent. If not, report a warning and revert to v1.
To match the current implementation in the blockchain, identifiers
should be allowed to have special characters like `*`, `/`, `<`, etc. in
them, although, a future specification of the Clarity language may make
those illegal. Now, the parser will report a warning for those cases.

This change required some modified handling of the trait identifiers
(ex. `<my-trait>`), so the changes are more significant than might be
expected.
@obycode
Copy link
Member Author

obycode commented Feb 4, 2022

The only change in that last push was just rebasing on the latest develop branch (I guess that wasn't the right way to do it). Can you approve again? Thanks!

Copy link
Member

@lgalabru lgalabru left a comment

Choose a reason for hiding this comment

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

👍

@obycode obycode merged commit 2a0ea96 into develop Feb 7, 2022
@obycode obycode deleted the feat/parser2 branch February 7, 2022 14:36
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