On Mon, Feb 07, 2005 at 01:21:00PM +0100, Juerd wrote:
> Nicholas Clark skribis 2005-02-07 12:10 (+0000):
> > Will the relative precedence of grouping versus anchors for beginning and
> > end of line remain the same in Perl6 rules?
>
> There currently is no such thing as precedence in regexes. Changing this
> would make understanding regexes a lot harder, I think.
A clarification:
P6rules currently has precedence. Alternatives is one
of the looser bindings. I suspect the original question is really
asking about the "relative precedence of [alternatives] versus
anchors for beginning and end of [string]", since the question arises
even in the absence of (?:...) constructs.
Here's a brief stab at a p6 rule expression "precedence table", at least
for what I've been working with in the grammar engine:
terms a . \s \b ^ $ ^^ $$ (...) [...] <...> :: :::
quantifiers * + ? *? +? ?? **{...} **{...}?
backtracking :
concatenation
conjunctive &
alternative |
Thus Nicholas' question is really asking if we can give ^ and $ a
looser binding than alternatives, such that
/ ^ abc | def | ghi $ /
binds as
/ ^ [ abc | def | ghi ] $/
and not
/ [^abc] | def | [ghi$] /
It's certainly technically possible to do this, but I'd then wonder what
to do about ^^ and $$, and if it would then be more confusing that
^ and $ (and possibly ^^ and $$) bind much more loosely than the
other assertions. Personally, I'll let you guys hash out those things
and then set the grammar engine to match. :-)
Pm