I am creating a DSL for an extensible card game engine I'm working on using boo.
I have a card macro that creates a class for a new card type and initializes some properties in the constructor. This macro has several sub-macros to configure other things. Basically, I want this to work out like this:
card 'A new card':
type TypeA
ability EffectA:
// effect definition
in it:
class ANewCard (Card):
def constructor():
Name = "A new card"
Type = Types.TypeA
AddEffect(EffectA())
class EffectA (Effect):
// effectdefintion
An effect should definitely be a class because it will be passed (this is a strategy template).
So far I have had this simple skeleton:
macro card:
yield [|
class $(ReferenceExpression(card.Arguments[0])) (Card):
def constructor():
Name = $(card.Arguments[0])
|]
Now I don’t know what to do with card.Body to make the macro able to add code to the constructor and also create a nested class. Any suggestions? Can this be done using current language features?