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

Add CST labels to EBNF #976

Merged

Conversation

ggiraldez
Copy link
Contributor

@ggiraldez ggiraldez commented May 22, 2024

Closes #916
Closes #917

The changes add the corresponding CST labels to the generated EBNF grammar representation, via the use of a leading comment before the appropriate references (which represent the nodes in the CST).

This PR also adds the PrecedenceExpression visible in the generated EBNF, fixing #917. Since they are not direct children of the Topics they were being omitted from the language specification.

A couple of questions/items I have doubts on:

  • I copied the BuiltInLabels enum from the grammar generator crate because it was private and not directly accessible from the ebnf crate. But I think it may make sense to move the enum into the language_definition crate? It may make it possible to remove all the duplication.

  • A minor concern is the readability of the resulting EBNF, for sequences in particular. Adding the labels introduces noise to the spec document already. But for separated sequences, the resulting lines almost never fit into the enclosing box in the HTML, which forces horizontal scrolling.

Copy link

changeset-bot bot commented May 22, 2024

⚠️ No Changeset found

Latest commit: 4ca53ee

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

@ggiraldez ggiraldez marked this pull request as ready for review May 23, 2024 18:29
@ggiraldez ggiraldez requested a review from a team as a code owner May 23, 2024 18:29
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.

Great work. LGTM!

@ggiraldez ggiraldez force-pushed the feat/916-add-cst-labels-to-ebnf branch 2 times, most recently from 52fcc10 to 8ab4b58 Compare May 28, 2024 15:48
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.

Thanks for the refactoring. Only one tiny suggestion left.

@ggiraldez ggiraldez force-pushed the feat/916-add-cst-labels-to-ebnf branch from a2fb1b7 to e6a72c0 Compare May 29, 2024 14:33
ggiraldez and others added 7 commits May 29, 2024 14:15
Missing some built-in labels, such as those internal to operators and items and
separators.
Because they are not direct children of Topic, they were being omitted from the
output when building the language spec.
This allows labelling Separated, which was the remaining grammar Item that
needed it.
@ggiraldez ggiraldez force-pushed the feat/916-add-cst-labels-to-ebnf branch from e6a72c0 to 4ca53ee Compare May 29, 2024 18:16
@OmarTawfik OmarTawfik enabled auto-merge May 30, 2024 06:11
@OmarTawfik OmarTawfik added this pull request to the merge queue May 30, 2024
Merged via the queue into NomicFoundation:main with commit c9c57b2 May 30, 2024
1 check passed
github-merge-queue bot pushed a commit that referenced this pull request Jun 5, 2024
Spin off of #976 

Moves the `BuiltInLabel` enum from the parser generator into the
language definition and remove duplication in the `kinds` template.
@ggiraldez ggiraldez deleted the feat/916-add-cst-labels-to-ebnf branch June 20, 2024 14:27
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
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.

ebnf links broken for precedence expressions add CST labels to EBNF snippets/docs
3 participants