Here is 2 patches (attached, if mailman doesn't drop them) for
CL-PPCRE for mixing parse trees and regex strings.
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.
The second patch add the (:REGEX <regex>) construct to use regex
string into parse tree. It's the opposite idea of the former patch.
The rationale is that sometimes it's preferable to use regex strings
(for compactness), while sometimes it's better to use parse tree (when
programmatically computed), but to my knowledge it was impossible to
mix them easily.
I hope that these patches are not too "hackish". In particular, the
reference to a synonym must be a keyword, it's not possible to specify
symbols in other packages. Also, since cl-ppcre use symbol property,
it's worst to use keywords (unless one take cares to avoid name
clashes.) I'm not sure how to fix that.
These patches are more to describe what I've in mind rather than
providing production quality patches.
What do you think about these suggestions ?
Examples of use:
-=-=-
CL> (define-parse-tree-synonym :foo
(:sequence #\a (:greedy-repetition 1 3 (:alternation #\b #\c))))
CL> (scan-to-strings "b(ar(?.FOO))a" "baracca")
"baracca"
#("aracc")
-=-=-
Mixing the other way:
-=-=-
CL> (scan-to-strings '(:sequence "b"
(:register (:sequence "ar"
(:regex "a(?:b|c){1,3}")))
"a")
"baracca")
"baracca"
#("aracc")
CL>
-=-=-
--
Frédéric Jolliton