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: Use collect_breaking_versions from v2 directly in PG #1002

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

Xanewok
Copy link
Member

@Xanewok Xanewok commented Jun 4, 2024

Part of #638

Follow-up to #991

Pretty straightforward: instead of visiting the previously built v1 definition structure, we defer to Language::collect_breaking_changes as the definitions overlap - the breaking changes are defined as versions in which the syntax items may be evaluated differently, which means that these are exactly the versions that will be referenced for the conditional syntax item evaluation in the parser/lexer.

@Xanewok Xanewok requested a review from a team as a code owner June 4, 2024 10:25
Copy link

changeset-bot bot commented Jun 4, 2024

⚠️ No Changeset found

Latest commit: 3acf212

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

@@ -30,7 +30,10 @@ use crate::parser_support::{
#[cfg_attr(feature = "slang_napi_interfaces", napi(namespace = "language"))]
pub struct Language {
{%- if not rendering_in_stubs -%}
{%- for version in model.parser.referenced_versions -%}
{%- for version in model.breaking_versions -%}
{% if loop.first %} {# The first supported version may not be referenced by the items #}
Copy link
Member Author

Choose a reason for hiding this comment

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

For more context, it's possible right now to have enabled = From(THE_FIRST_VERSION) in the DSL v2, which is what testlang does but what solidity does not.

I don't have a preference whether we should disallow it or not (it probably should be a warning at best if they were supported by proc macros) but I figured that it's not in scope for this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should disallow it if it doesn't have additinal semantics/provide a benefit to us. If for any reason, it is to avoid special casing it in various places in codegen (exactly like this here).
But there are definetely more important validation rules we can implement if we decide to spend more time there.

@Xanewok
Copy link
Member Author

Xanewok commented Jun 5, 2024

Thanks @OmarTawfik for the review!

@Xanewok Xanewok added this pull request to the merge queue Jun 5, 2024
Merged via the queue into NomicFoundation:main with commit a318014 Jun 5, 2024
1 check passed
@Xanewok Xanewok deleted the pg-breaking-versions branch June 5, 2024 12:35
github-merge-queue bot pushed a commit that referenced this pull request Jun 20, 2024
Based on #1002
Part of #638

The DSL v2's `model::Scanner` is almost 1:1 usable with our current
parser codegen, with the exception of versioned scanners. In short we:
- introduce a helper type `VersionedScanner` that is used in place of
the old `ScannerDefinitionNode::Versioned`
- introduce a `ScannerExt` trait implemented for both `VersionedScanner`
and the `model::Scanner`, which is responsible for generating the main
scanning logic
- Repurposes `ScannerDefinition` slightly to surface more of the
scanner-related logic for trivia/fragment/token
- implements this directly for
`model::{TriviaItem,FragmentItem,TokenItem}` and stores it in the v1
Grammar struct
- similarly, uses `model::KeywordItem` directly in place of v1's
`KeywordScannerDefinition` as they shared the same functionality
OmarTawfik pushed a commit to OmarTawfik-forks/slang that referenced this pull request Aug 4, 2024
…Foundation#1002)

Part of NomicFoundation#638

Follow-up to NomicFoundation#991

Pretty straightforward: instead of visiting the previously built v1
definition structure, we defer to `Language::collect_breaking_changes`
as the definitions overlap - the breaking changes are defined as
versions in which the syntax items may be evaluated differently, which
means that these are exactly the versions that will be referenced for
the conditional syntax item evaluation in the parser/lexer.

Refactor `BuiltInLabel` to avoid duplication (NomicFoundation#992)

Spin off of NomicFoundation#976

Moves the `BuiltInLabel` enum from the parser generator into the
language definition and remove duplication in the `kinds` template.

add wit

generating wit and glue

stub adaptors, wit feature flag

glue macros

remove wit_bindgen

fix wit gen paths

add wit-bindgen

export the kinds

pub export macro for wit

improve export macro

world => slang

fully implement glue

convert query matches

refactor ffi glue macros

refactor wit

variant rather than enum

back to enum
OmarTawfik added a commit to OmarTawfik-forks/slang that referenced this pull request Aug 5, 2024
…Foundation#1002)

Part of NomicFoundation#638

Follow-up to NomicFoundation#991

Pretty straightforward: instead of visiting the previously built v1
definition structure, we defer to `Language::collect_breaking_changes`
as the definitions overlap - the breaking changes are defined as
versions in which the syntax items may be evaluated differently, which
means that these are exactly the versions that will be referenced for
the conditional syntax item evaluation in the parser/lexer.

Refactor `BuiltInLabel` to avoid duplication (NomicFoundation#992)

Spin off of NomicFoundation#976

Moves the `BuiltInLabel` enum from the parser generator into the
language definition and remove duplication in the `kinds` template.

add wit

generating wit and glue

stub adaptors, wit feature flag

glue macros

remove wit_bindgen

fix wit gen paths

add wit-bindgen

export the kinds

pub export macro for wit

improve export macro

world => slang

fully implement glue

convert query matches

refactor ffi glue macros

refactor wit

variant rather than enum

back to enum
OmarTawfik pushed a commit to OmarTawfik-forks/slang that referenced this pull request Aug 5, 2024
…Foundation#1002)

Part of NomicFoundation#638 

Follow-up to NomicFoundation#991

Pretty straightforward: instead of visiting the previously built v1
definition structure, we defer to `Language::collect_breaking_changes`
as the definitions overlap - the breaking changes are defined as
versions in which the syntax items may be evaluated differently, which
means that these are exactly the versions that will be referenced for
the conditional syntax item evaluation in the parser/lexer.
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