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

[ASTGen] Generate MagicIdentifierLiteralExpr #79353

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Feb 13, 2025

E.g. #file. These are parsed as MacroExpansionExprSyntax in SwiftParser.

Also while I'm here, eliminate SYNTAX_KIND from MagicIdentifierKinds.def because nothing is using it anymore.

@rintaro
Copy link
Member Author

rintaro commented Feb 13, 2025

@swift-ci Please smoke test

@rintaro rintaro force-pushed the astgen-magic-ident-literal branch from 3e674a8 to 2edc31e Compare February 13, 2025 07:16
@rintaro rintaro force-pushed the astgen-magic-ident-literal branch from 2edc31e to 563ddc4 Compare February 13, 2025 07:19
@rintaro
Copy link
Member Author

rintaro commented Feb 13, 2025

@swift-ci Please smoke test

Comment on lines +830 to +831
default:
// Fallback to MacroExpansionExpr.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also need to handle things like #error, #warning, #assert, #fileLiteral, #colorLiteral, and #imageLiteral, right? Would it be worth bridging an enum for POUND_KEYWORD such that we make sure we don't miss any cases here?

Copy link
Member Author

@rintaro rintaro Feb 13, 2025

Choose a reason for hiding this comment

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

Huh, I thought #fileLiteral et al were removed from the language, yeah we might want a bridging enum for POUND_OBJECT_LITERAL (i.e. ObjectLiteralExpr::LiteralKind).

As for #error, #warning, and #assert, they are not expressions so we can't handle it here.
#assert is a statement, #warrning and #error are decl, considering how to handle them in ASTGen and POUND_KEYWORD would include some noise (i.e. #if, #sourceLocation etc.), I'm not sure POUND_KEYWORD bridging enum would be beneficial. I will think about it.

Anyway, thank you for reminding me!

Copy link
Contributor

Choose a reason for hiding this comment

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

As for #error, #warning, and #assert, they are not expressions so we can't handle it here.

We'd want to diagnose them though, right? AFAIK swift-syntax won't reject them

@rintaro rintaro merged commit 73164a0 into swiftlang:main Feb 13, 2025
3 checks passed
@rintaro rintaro deleted the astgen-magic-ident-literal branch February 13, 2025 14:25
@rintaro rintaro restored the astgen-magic-ident-literal branch February 13, 2025 14:34
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