I'm working on a macro tweening system whereby a user can specify a set of fields and values for them to tween to, avoiding the use of dynamics and reflection. At present this set is represented by a Map<ExprOf<FieldAccess>, Expr>.
e.g.
Tween.tween([p.x => 100, p.scale => [x => 50, y => 50]]);
This works, but ideally I would prefer a slightly more compact syntax that closer resembles object notation.
e.g.
Tween.tween({p.x: 100, p.scale: {x: 50, y: 50}});
Unfortunately the parser doesn't expect field expressions on the left hand side of an object assignment. If ":" were a BinOp then I could have an array of binop expressions, but sadly it is not. Is it possible to create custom syntax that doesn't just exploit existing syntax? If not, is there some other way around this?
It's not a huge issue so this is mostly academic. I know macro processing comes after parsing, but in theory it seems like it might be possible to leave cues for the parser to parse something differently, or perhaps see an Expr and hold off on parsing it by turning it into a string to be later parsed by Context.parse. It's a long shot, I know. :P