the current implementation almost supports this

the problem is that the ~(...) forms use an internal subexpression parser that 
nests
\(...\) for BREs and SREs and (...) for all others except FREs (literal)
so switching out of an re-type where ')' is not special is undefined in the 
grammar
e.g.,
        ~(F)...
F is (almost) literal -- the only terminating characters are \n and \0
so once ~(F) is hit ~(...) is no longer special so you can't get out

same problem for ~(B) and ~(S)

the ~(<type>:...)scoped forms have similar problems
in fact currently this fails
        ~(F:...)
because the parse eats the ')'

\ escaping is already inconsistent between RE types (e.g., what does \ mean 
inside [...]?)
so figuring this out at the regcomp() level will take some thought

simple () counting won't do because the meaning of () is context *and* re-type 
sensitive
e.g., ( vs \( vs [(]

the more you think about it the messier it gets
I think the roach motel model (you get in but can't get out) will apply here:

you can catenate re types by
        ~(t1:scopedpat1)pat1~(t2:scopedpat2)pat2...~(tn:scopedpatn)patn
for ti != B (basic) or F (fgrep/literal) or S (sh)
where :scopedpati and/or pati are optional
and the last re-type switch can include the non-scoped forms
        ~(B) or ~(F) or ~(S)

for ksh this means you can switch between
        K (ksh) and P (perl) and E (extended) and A (augmented)

if ksh you can use '...' or "..." to force any part of a pattern to be literal

On Sat, 14 Apr 2012 00:16:28 +0200 =?KOI8-R?B?z8zYx8Egy9LZ1sHOz9fTy8HR?= wrote:
> RFE: Add a new AST regex mode ~(C) which allows to concatenate
> patterns of different pattern systems into one. Each element of a ~C
> string starts with a bracket open and ends with a bracket close, e.g.
> (~(F)he)(~(E)..)(~(Ei)o) to match "hello" or "hellO".

> Example:
> ~(C)(~(E)hello.*world)(~(F)*fish) would match the string "hello world*fish"

> The idea is that shell, perl and egrep pattern can be concatenated or
> converted into other patterns using ksh's printf %P/%R formats.

> What do you think about this idea?

> Olga
> -- 
>       ,   _                                    _   ,
>      { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
> .----'-/`-/     [email protected]   \-`\-'----.
>  `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
>       /\/\     Solaris/BSD//C/C++ programmer   /\/\
>       `--`                                      `--`

_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to