-
Notifications
You must be signed in to change notification settings - Fork 1
Add MacroExp for freestanding macro expressions #141
Copy link
Copy link
Open
Description
Summary
SyntaxKit has no support for freestanding macro expressions (MacroExpansionExprSyntax). A new MacroExp type should be added to cover #macroName(args...) syntax.
Details
- Conforms to
ExprCodeBlock(expression, not a declaration) - Follows the
Expsuffix naming convention used byFunctionCallExp,PropertyAccessExp, etc. - Maps to
MacroExpansionExprSyntaxin SwiftSyntax - Covers both built-in macros and custom user-defined macros:
#stringify(x)#colorLiteral(red:green:blue:alpha:)#imageLiteral(resourceName:)- Any custom
#myMacro(arg:)defined via@freestanding(.expression)
Example API
MacroExp("stringify", ReferenceExp("x"))
// → #stringify(x)
MacroExp("colorLiteral") {
Argument("red", Literal.float(0.5))
Argument("green", Literal.float(0.2))
Argument("blue", Literal.float(0.8))
Argument("alpha", Literal.float(1.0))
}
// → #colorLiteral(red: 0.5, green: 0.2, blue: 0.8, alpha: 1.0)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels