Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #75668] [BUG] whitespace before ^ in rule

2 views
Skip to first unread message

rirans @ comcast . net

unread,
Jun 11, 2010, 12:11:43 AM6/11/10
to bugs-bi...@rt.perl.org
# New Ticket Created by rir...@comcast.net
# Please include the string: [perl #75668]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=75668 >


In
commit a5467733bdab87210a4eae6d3af309a0c3041c87
I think it is a bug that these differ

rule TOP { ^ <tok> }
rule TOP {^ <tok> }

If I'm far from right, let me know so I
won't waste folks time.

Thank you for rakudo.

Be well,
rir

rir

unread,
Jun 12, 2010, 12:15:13 AM6/12/10
to Moritz Lenz via RT
On Fri, Jun 11, 2010 at 02:16:28PM -0700, Moritz Lenz via RT wrote:

> On Thu Jun 10 21:11:42 2010, rir...@comcast.net wrote:

> > I think it is a bug that these differ

> > rule TOP { ^ <tok> }
> > rule TOP {^ <tok> }

> It actually conforms the current spec. Each consecutive run of
> whitespace is replaced by a call to <.ws>. So the first rule is
> equivalent to

> token TOP { <.ws> ^ <.ws> <tok> <.ws> }
>
> When there is leading whitespace in the string, the first <.ws> matches,
> and ^ fails. Since there's no backtracking in a token, the match fails.

> I agree that that it's not obvious or intuitive, but rakudo should only
> special-case it if the spec says so.

Thanks for the reply, I'll be slower to submit bugs.

I get your point. I think the spec may be open to other interpretations
though:

^ and $ now always match the start/end of a string,

How can even a zero-width atom ever match before the start of a string?
What are we matching against?

I think whitespace before a leading/trailing ^/$ needs to be discounted.
Dwimmery and elegance demand.

It is foul if the "formalization" of matching leads us to

rule TOP {
: my $dog = "Magic";
^ <matchme>
}

needing to be

rule TOP {
: my $dog = "Magic";^
<matchme>
}

Either way, the spec needs to be clarified.

Moritz, I appreciate the time you have taken with me. I'm more or less
at 5.005 regarding regexes, so some of the Perl5 refs in the synopses are
not so helpful to me. I'm am excited by grammars; they change
the mentation of matching.

On Perlmonks, I have found your answers satisfying but was disappointed
that we seem to be a party of two (at least there is an audience). I feel
that I could wear you out with my questions. I like Perlmonks, but could
move to another site.

Be well,
rir

yary

unread,
Jun 12, 2010, 3:26:25 PM6/12/10
to rirans, perl6-bugs-followup
>...

> On Perlmonks, I have found your answers satisfying but was disappointed
> that we seem to be a party of two (at least there is an audience).  I feel
> that I could wear you out with my questions.  I like Perlmonks, but could
> move to another site.

A good thing about perlmonks is that your audience is likely to grow,
and those posts will be referenced by future perl6-ers.

Bruce Keeler

unread,
Jun 14, 2010, 2:34:08 PM6/14/10
to rir...@comcast.net, Moritz Lenz via RT

> I think whitespace before a leading/trailing ^/$ needs to be discounted.
> Dwimmery and elegance demand.
>
>
+1
0 new messages