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

refactor: Move grammar parser constructor to codegen_grammar #746

Conversation

Xanewok
Copy link
Contributor

@Xanewok Xanewok commented Jan 15, 2024

Follow-up to #650

Nothing ground-breaking, just cleaning up the language definition crate and moving the grammar construction to be a part of the crate responsible for the codegen/parser logic itself.

This is an overdue cleanup; rather than shipping the constructor with
the language definition, it should be a part of the crate responsible
for the codegen/parser logic itself.
@Xanewok Xanewok requested a review from a team as a code owner January 15, 2024 20:06
Copy link

changeset-bot bot commented Jan 15, 2024

⚠️ No Changeset found

Latest commit: 199bd95

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -3,8 +3,6 @@ pub use solidity::SolidityDefinition;
codegen_language_macros::compile!(Language(
name = Solidity,
root_item = SourceUnit,
// TODO(#638): For now this is on par with the DSL v1 definition to minimize the fallout.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided against virtual EndOfInput tokens, so not bringing that trivia parser back from the original DSLv2. Also, the trivia has to require something, i.e. we shouldn't create empty rules. Will be unnested anyway to sibling tokens with #737

The new definition was also wrong, as in, we need to find an ergomonic way to accept MultilineComment as part of the leading trivia but only if it doesn't have newline in it; I'd consider this a separate work item (new "feature") and it's not of urgent priority - we should probably stick to single-line comments and revisit this at some point.

Copy link
Contributor

@OmarTawfik OmarTawfik Jan 16, 2024

Choose a reason for hiding this comment

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

Also, the trivia has to require something, i.e. we shouldn't create empty rules

Not sure I'm following. Since they are siblings, we should be using the original ZeroOrMore, as it should always be possible to have no leading trivia, right?
We will run that parser (that adds all its results to the "current" parent rule node), and possibly adding nothing.

-> Same concern for the removed TODO comment in model/terminals/trivia.rs

accept MultilineComment as part of the leading trivia but only if it doesn't have newline in it

Not sure I'm following either? newlines is legal/valid in leading trivia.

Copy link
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

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

Left one concern about the removed TODO comments, which I don't think are related. If you don't mind, let's keep them as-is until we discuss this further.

Otherwise, LGTM.

@OmarTawfik
Copy link
Contributor

Replaced by #747

@OmarTawfik OmarTawfik closed this Jan 16, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jan 19, 2024
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