Enable the creation of syntax nodes from a string interpolation #782
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make the main categories of syntax nodes (
DeclSyntax
,ExprSyntax
,StmtSyntax
,TypeSyntax
, andPatternSyntax
) conform toExpressiblyByStringInterpolation
. The string literal portions are source text, and one can interpolate both additional source text and syntax nodes into that source text. The result will be parsed by the parser to produce a node of the given kind. For example, we can produce aTypeSyntax
like this:And then use that in another production, for example to create a function declaration:
This approach is intended to simplify code generation, by allowing code to generate Swift syntax trees in the most natural way possible---by writing the Swift code that generates them.