> * 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
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