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

Re: [svn:parrot] r12294 - trunk/languages/perl6/lib

4 views
Skip to first unread message

Nicholas Clark

unread,
Apr 17, 2006, 2:25:27 PM4/17/06
to perl6-c...@perl.org
On Mon, Apr 17, 2006 at 10:15:40AM -0700, autr...@cvs.perl.org wrote:

> * grammar_rules.pge - support for POD sections.
>
> Modified: trunk/languages/perl6/lib/grammar_rules.pge
> ==============================================================================
> --- trunk/languages/perl6/lib/grammar_rules.pge (original)
> +++ trunk/languages/perl6/lib/grammar_rules.pge Mon Apr 17 10:15:39 2006
> @@ -15,9 +15,15 @@
>
>
> ## This rule handles whitespace and comments between tokens.
> -## XXX: Add pod directive handling
>
> -rule ws { [ \# \N+ | \s+ ]* ::: }
> +rule ws {
> + [ \# \N+
> + | \s+
> + | ^^ =cut \s* $$
> + | ^^ =for \s* \N+ .*? ^^$$
> + | ^^ =\w\N* .*? ^^ =cut $$
> + ]* :::
> +}

[People not reading the commit list should note that this wasn't the final
form]

I see you've taken out the XXX. However, isn't the plan for Perl 6 that all
the POD is going to be available as <DATA>-like streams? Whereas whitespace
does get eaten. So surely they should be 2 different rules?

(Or does whitespace get eaten? Is Larry planning a MAD-like mode for Perl 6
where it can regurgitate the entire program source code in byte-for-byte
perfection?)

Nicholas Clark

Patrick R. Michaud

unread,
Apr 17, 2006, 8:44:02 PM4/17/06
to Nicholas Clark, perl6-c...@perl.org
On Mon, Apr 17, 2006 at 07:25:27PM +0100, Nicholas Clark wrote:
> On Mon, Apr 17, 2006 at 10:15:40AM -0700, autr...@cvs.perl.org wrote:
> > * grammar_rules.pge - support for POD sections.
> > ## This rule handles whitespace and comments between tokens.
> > -## XXX: Add pod directive handling
> >
> > -rule ws { [ \# \N+ | \s+ ]* ::: }
> > +rule ws {
> > + [ \# \N+
> > + | \s+
> > + | ^^ =cut \s* $$
> > + | ^^ =for \s* \N+ .*? ^^$$
> > + | ^^ =\w\N* .*? ^^ =cut $$
> > + ]* :::
> > +}
>
> [People not reading the commit list should note that this wasn't the final
> form]
>
> I see you've taken out the XXX. However, isn't the plan for Perl 6 that all
> the POD is going to be available as <DATA>-like streams? Whereas whitespace
> does get eaten. So surely they should be 2 different rules?

Since we can embed closures and subroutines in rules, we can capture
the POD as we eat it. :-) In the long-run it will likely end up as:

rule ws {
[ \# \N+
| \s+
| \. \# <PGE::Text::bracketed: <({[>
| ^^ <pod>
]* :::

where the <pod> subrule can keep track of the appropriate things
to make the <DATA>-like streams.

Audrey originally had some of the pod elements separated out
into subrules, but I decided to switch to the single <ws> rule
for the time being since I'm starting to re-use this particular
pattern in a few other tools.

Pm

0 new messages