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
Exp suffix naming convention used by FunctionCallExp, PropertyAccessExp, etc. - Maps to
MacroExpansionExprSyntax in 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)
Summary
SyntaxKit has no support for freestanding macro expressions (
MacroExpansionExprSyntax). A newMacroExptype should be added to cover#macroName(args...)syntax.Details
ExprCodeBlock(expression, not a declaration)Expsuffix naming convention used byFunctionCallExp,PropertyAccessExp, etc.MacroExpansionExprSyntaxin SwiftSyntax#stringify(x)#colorLiteral(red:green:blue:alpha:)#imageLiteral(resourceName:)#myMacro(arg:)defined via@freestanding(.expression)Example API