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

feat: prepare public API for alpha release #391

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

OmarTawfik
Copy link
Collaborator

@OmarTawfik OmarTawfik commented Mar 29, 2023

  • created a slang_solidity::syntax module, with sub-modules nodes, parser, and visitors.
  • renamed codegen_parser to codegen_syntax accourdingly.
  • renamed Visitable::visit() to Visitable::accept_visitor().
  • made Visitable::accept_visitor_with_path() private, since it accepts a &mut path, and we expect/pop nodes in a certain order that external callers can violate.
  • renamed ParserOutput to ParseOutput to match parse().
  • changed a few internal helpers/constructors to pub(crate) instead.

Tested using cargo rustdoc.

@OmarTawfik OmarTawfik enabled auto-merge March 29, 2023 22:03
@OmarTawfik OmarTawfik requested a review from AntonyBlakey March 29, 2023 22:04
@OmarTawfik OmarTawfik force-pushed the OmarTawfik/prepare-public-api branch from 2e3296a to 5a69f34 Compare March 29, 2023 22:12
Copy link
Contributor

@AntonyBlakey AntonyBlakey left a comment

Choose a reason for hiding this comment

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

I have some general issues with the semantics of the renamings in this PR.

created a slang_solidity::syntax module, with sub-modules nodes, parsing, and visitors

nodes and visitors are nouns, but parsing is a verb.

renamed codegen_parser to codegen_syntax accourdingly

Note sure about this for the same reason. It does generate the parser. I know we discussed this, but now that I see it, I'm not convinced. I think it makes it less semantically clear.

renamed Visitable::visit() to Receiver::receive() for correctness

IMO Visitable is much more descriptive than Receiver because it ties it to the Visitor. I understand the linguistic relationship of receiving a visitor, but Receiver seems too generic (Sender/Receiver), and the -able suffix is better linguistically for me. The only other alternative that seems right is ReceiveVisitor::receive_visitor, but I strongly prefer -able for the name of this role in these kind of patterns.

renamed ParserOutput to ParseResult to match

I see ...Result and I think Result<T>, with the corresponding type semantics. Which ParserOutput is not.

@OmarTawfik
Copy link
Collaborator Author

OmarTawfik commented Mar 31, 2023

created a slang_solidity::syntax module, with sub-modules nodes, parsing, and visitors*

nodes and visitors are nouns, but parsing is a verb.

f2f: let's use nodes, parser, and visitors for now.

renamed codegen_parser to codegen_syntax accourdingly

Note sure about this for the same reason. It does generate the parser. I know we discussed this, but now that I see it, I'm not convinced. I think it makes it less semantically clear.

f2f: let's use codegen_syntax for now.

renamed Visitable::visit() to Receiver::receive() for correctness

IMO Visitable is much more descriptive than Receiver because it ties it to the Visitor. I understand the linguistic relationship of receiving a visitor, but Receiver seems too generic (Sender/Receiver), and the -able suffix is better linguistically for me. The only other alternative that seems right is ReceiveVisitor::receive_visitor, but I strongly prefer -able for the name of this role in these kind of patterns.

f2f: let's use Visitable::accept_visitor()

renamed ParserOutput to ParseResult to match

I see ...Result and I think Result<T>, with the corresponding type semantics. Which ParserOutput is not.

f2f: let's use ParseOutput, as it is returned from a parse() method.

@OmarTawfik
Copy link
Collaborator Author

Should also add rust-lang/cargo#1982 to the dummy module comment.

- created a `slang_solidity::syntax` module, with sub-modules `nodes`, `parser`, and `visitors`.
- renamed `codegen_parser` to `codegen_syntax` accourdingly.
- renamed `Visitable::visit()` to `Visitable::accept_visitor()`.
- made `Visitable::accept_visitor_with_path()` private, since it accepts a `&mut path`, and we expect/pop nodes in a certain order that external callers can violate.
- renamed `ParserOutput` to `ParseOutput` to match `parse()`.
- changed a few internal helpers/constructors to `pub(crate)` instead.

Tested using `cargo rustdoc`.
@OmarTawfik OmarTawfik force-pushed the OmarTawfik/prepare-public-api branch from 5a69f34 to a8f7cc8 Compare March 31, 2023 06:23
@OmarTawfik OmarTawfik requested a review from a team as a code owner March 31, 2023 06:23
@OmarTawfik
Copy link
Collaborator Author

Comments addressed, and PR description updated with changes.

@OmarTawfik OmarTawfik added this pull request to the merge queue Mar 31, 2023
Merged via the queue into main with commit df880b7 Mar 31, 2023
@OmarTawfik OmarTawfik deleted the OmarTawfik/prepare-public-api branch March 31, 2023 06: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.

2 participants