Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Completing for "find" and _regex_arguments (Re: PATCH: Re: sudo completion problem)



In article <1000504151422.ZM22851@xxxxxxxxxxxxxxxxxxxxxxx>,
  "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx> writes:

> Is there any chance that it could now be rewritten using extendedglob
> patterns, rather than parsing its own RE syntax?

Hm.  _regex_arguments handles two kind of RE.  Inner RE is just
extendedglob pattern: /RE/.  Outer RE is RE which contains elements as
inner REs instead of characters.  Outer RE has also lookaheads, guards,
and actions and they are corresponds to inner REs.  A lookahead is
also just extendedglob pattern but it doesn't consume arguments
string.  This corresponds to a zero-width positive look-ahead
assertion in perl5: `(?=pattern)'.  A guard is zsh code to test
something which cannot represent as RE.  This corresponds to (??{
(code) ? "[^\000-\377]" : "" }) in perl5.6.  However, currently I
don't use this as real test.  I used this as recording option use
etc. and always report a test is succeed.  So (?{ code }) in perl5.6
is enough to implement my use.  A action is zsh code for completion.
They are evaluated when whole outer RE is failed to match.  When it is
failed, actions corresponding to inner REs which are last candidates
to match.  There is no direct correspondences in RE constructs.  But I
think this can be implemented as (?{ code }) which set some variables.

Note that outer RE of _regex_arguments is not real RE because it
doesn't backtrack.  But if it is implemented by real RE engine, it can
backtrack...

So, if extendedglob patterns have enough RE constructs in perl5.6, 
it can be used to unify inner and outer RE in _regex_arguments.
Maybe.
-- 
Tanaka Akira



Messages sorted by: Reverse Date, Date, Thread, Author