Skip to content

Improve parser #1237

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
merged 35 commits into from
Mar 29, 2023
Merged

Improve parser #1237

merged 35 commits into from
Mar 29, 2023

Conversation

DaniPopes
Copy link
Contributor

@DaniPopes DaniPopes commented Mar 24, 2023

This PR does 3 main things to the solang-parser crate:

  1. adds documentation to all items
  2. improves some logic in the parsing functions, like less allocations and some minor refactoring
  3. most importantly, adds parse tree helpers (moving existing implementations):
  • fmt: implements std::fmt::Display for all parse tree types
  • loc, expanding on the CodeLocation traits:
    • implementations for all possible parse tree types
    • generic implementations for Vec, Option etc
    • renames the loc method to loc_opt on OptionalCodeLocation to avoid name collision
    • previously there were some standalone (not with the traits) methods on structs, these were moved to the trait implementations
  • ord: implements std::cmp::{Ord, PartialOrd}
  • helper methods on parse tree types; you can view them by looking for the impl blocks in pt

The massive diff in the lexer tests is just whitespace and renaming the fully qualified collect::<Vec<...>> to just Vec<_>

Some of these changes have been upstreamed from foundry-rs/foundry's forge-doc and forge-fmt.

BREAKING CHANGES:

  • pt::OptionalCodeLocation::loc renamed to loc_opt
  • pt::Level::to_string renamed to as_str
  • lexer::Spanned<Token, Loc, Error> split into Spanned<'a> and Result<'a, T = Spanned<'a>, E = LexicalError>
  • pt::UsingList's Error variant changed from tuple to unit (no more () at the end)

DaniPopes and others added 24 commits March 24, 2023 22:16
Signed-off-by: DaniPopes <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
…edger-solang#1222)

* remove conflicting contract names

Signed-off-by: salaheldinsoliman <[email protected]>
Co-authored-by: Sean Young <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
@seanyoung
Copy link
Contributor

The new files need:

// SPDX-License-Identifier: Apache-2.0

on the first line, else CI will fail. Also note the clippy errors.

Signed-off-by: DaniPopes <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
Signed-off-by: DaniPopes <[email protected]>
Copy link
Contributor

@xermicus xermicus left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Copy link
Contributor

@seanyoung seanyoung left a comment

Choose a reason for hiding this comment

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

There is a lot of good stuff in this - very large - pull request, it is great, thank you very much!

So I only have one comment, please us let know what you think. Thanks for some quality code changes. 🙏

@seanyoung seanyoung merged commit 5a928a3 into hyperledger-solang:main Mar 29, 2023
@seanyoung
Copy link
Contributor

@DaniPopes thank you very much, great stuff! 🙏

@DaniPopes DaniPopes deleted the improve-parser branch March 29, 2023 16:56
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.

5 participants