I'm working in Guile Scheme. I'm making macros but I'm finding that I'm repeating a lot of boilerplate in my output. I'm fairly new to Scheme so if there's a better way to approach this than syntax-case I'm open to advice.
In this macro there's only one difference in the input, "set" vs. "setconst", and one difference in the output, "elementReference" vs. "stringValue". I've tried using #` with #, to unquote but I get error messages like " syntax: missing ellipsis in form (syntax set)". Ideally I'd like to put some scheme code inside my macro to distinguish between set and setconst, and change the output accordingly, but as I said this is new and if there's a better way to get my result I'm open.
Here's my code:
(define-syntax assign
(lambda (stx)
(syntax-case stx (then)
((assign aname then target (set to from) ...) #'(assignments (name aname)
(label aname)
(locationX 50)
(locationY 50)
((assignmentItems
(operator Assign)
(assignToReference to)
(value (elementReference from))) ...)
(connector (targetReference target))))
((assign aname then target (setconst to from) ...) #'(assignments (name aname)
(label aname)
(locationX 50)
(locationY 50)
((assignmentItems
(operator Assign)
(assignToReference to)
(value (stringValue from))) ...)
(connector (targetReference target))))
)))