Skip to content

Replace string-based token references with Token enum in CodeGeneration #2006

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

Conversation

Matejkob
Copy link
Contributor

@Matejkob Matejkob commented Aug 5, 2023

The CodeGeneration module was previously referring to tokens using string-based references like IdentifierToken, which is not idiomatic Swift. To make the code more concise and in line with Swift's best practices, this commit introduces a Token enum in the TokenSpec.swift file.
Now, instead of string-based references, the new Token enum contains all the possible token kinds. It also includes a computed property that returns the corresponding TokenSpec for a given token, allowing for more concise and idiomatic references.
The code has been refactored to replace all string-based token references with members of the newly introduced Token enum. Associated tests have also been updated to reflect these changes.

Resolves #1978

@Matejkob Matejkob force-pushed the remove-string-based-reference-of-tokens branch from 7971c34 to 98be350 Compare August 5, 2023 05:53
@Matejkob Matejkob marked this pull request as ready for review August 5, 2023 06:00
@Matejkob Matejkob requested a review from ahoppen as a code owner August 5, 2023 06:00
@Matejkob Matejkob force-pushed the remove-string-based-reference-of-tokens branch from 98be350 to 7324a4c Compare August 5, 2023 06:05
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Wohooo. Looks very good, I love it. I’ve got a couple of minor comments but otherwise this looks ready to ship.

The CodeGeneration module was previously referring to tokens using string-based references like IdentifierToken, which is not idiomatic Swift. To make the code more concise and in line with Swift's best practices, this commit introduces a Token enum in the TokenSpec.swift file.
Now, instead of string-based references, the new Token enum contains all the possible token kinds. It also includes a computed property that returns the corresponding TokenSpec for a given token, allowing for more concise and idiomatic references.
The code has been refactored to replace all string-based token references with members of the newly introduced Token enum. Associated tests have also been updated to reflect these changes.
@Matejkob Matejkob force-pushed the remove-string-based-reference-of-tokens branch from 71fd968 to 8ebbac7 Compare August 7, 2023 16:37
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you

@ahoppen
Copy link
Member

ahoppen commented Aug 7, 2023

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge August 7, 2023 18:20
@ahoppen
Copy link
Member

ahoppen commented Aug 7, 2023

@swift-ci Please test

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.

Remove string-based reference of tokens in CodeGeneration
2 participants