The first patch add a (?.<name>) syntax, where <name> designate a keyword, and is case sensitive. The ?. was chosen to match the idea of the #. reader macro. It includes the synonym parse tree from the corresponding keyword while the regex is parsed.
Thanks for this patch, but as you wrote in your email, I think this one is a little bit too hackish. It also breaks compatibility with Perl syntax.
Ok, then I've another suggestion. Let (:REGEX <string>) take optionally more symbols, and use place holders in <string> to insert corresponding syntax trees. For example:
(dpts tree1 (:regex "a{2,5}")) (dpts tree2 (:regex "b{1,3}")) (dpts tree3 (:regex "foo((?~)-bar-(?~)+)baz" tree1 tree2))
Where (?~) is the place holder. Or something else which doesn't break compatibility with Perl syntax.
Without such a feature, the last tree would have been:
(dpts tree3 (:sequence "foo" (:register (:sequence tree1 "-bar-" (:greedy-repetition 1 nil tree2))) "baz"))
(Where dpts = ppcre:define-parse-tree-synonym)
Is that a better alternative ?