[cl-ppcre-devel] Re: New version 1.2.15

Edi Weitz edi at agharta.de
Tue Jul 4 12:59:12 UTC 2006


On Mon, 03 Jul 2006 16:26:51 +0200, Frédéric Jolliton <cl-ppcre-devel at frederic.jolliton.com> wrote:

> 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.

(?~) is not special in Perl, so this /would/ break compatibility with
Perl syntax.  In fact, everything would break compatibility.

Apart from that, you'd have to change the parser accordingly, you'd
have to check if the number of occurrences of (?~) is equal to the
number of optional parameters, you'd have to check that (?~) is only
used within (:REGEX ...), and so on.

> 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 ?

I don't think it's worth the trouble.  My personal opinion is that for
complicated regular expressions you should use the S-expression syntax
anyway.  YMMV, of course.

Cheers,
Edi.



More information about the Cl-ppcre-devel mailing list